Do not manage VG with > 1 volume in Kaminario driver
Currently, if we want to manage a volume in the K2 array, we rename the volume and associated VG in K2 according to cv-CinderVolumeId for volume and cvg-CinderVolumeId for VG. So, if K2 volume is managed by cinder, then for any future reference for the managed volume, cv-CinderVolumeId and cvg-CinderVolumeId must exist on K2 array. But if a VG in K2 have more than one volume and we try to manage another volume in the same VG, then it will rename the VG and any future reference for another managed volume will result in error. Change-Id: I0db48d11d812ea802d11165a959ff5b46a4d6af3 Closes-Bug: #1646766 Co-Authored-By: Nikesh Mahalka <Nikesh.Mahalka.ctr@kaminario.com> Co-Authored-By: Ido Benda<Ido.Benda@kaminario.com>
This commit is contained in:
parent
8e5912cb51
commit
6d7125bdbc
@ -313,6 +313,12 @@ class TestKaminarioISCSI(test.TestCase):
|
||||
self.driver.manage_existing, self.vol,
|
||||
{'source-name': 'test'})
|
||||
|
||||
def test_manage_vg_volumes(self):
|
||||
self.driver.nvol = 2
|
||||
self.assertRaises(exception.ManageExistingInvalidReference,
|
||||
self.driver.manage_existing, self.vol,
|
||||
{'source-name': 'test'})
|
||||
|
||||
def test_manage_existing_get_size(self):
|
||||
"""Test manage_existing_get_size."""
|
||||
self.driver.client.search().hits[0].size = units.Mi
|
||||
|
@ -1026,18 +1026,28 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||
vg_new_name = self.get_volume_group_name(volume.id)
|
||||
vg_name = None
|
||||
is_dedup = self._get_is_dedup(volume.get('volume_type'))
|
||||
reason = None
|
||||
try:
|
||||
LOG.debug("Searching volume: %s in K2.", vol_name)
|
||||
vol = self.client.search("volumes", name=vol_name).hits[0]
|
||||
vg = vol.volume_group
|
||||
nvol = self.client.search("volumes", volume_group=vg).total
|
||||
vg_replica = self._get_replica_status(vg.name)
|
||||
vol_map = False
|
||||
if self.client.search("mappings", volume=vol).total != 0:
|
||||
vol_map = True
|
||||
if is_dedup != vg.is_dedup or vg_replica or vol_map:
|
||||
if is_dedup != vg.is_dedup:
|
||||
reason = 'dedup type mismatch for K2 volume group.'
|
||||
elif vg_replica:
|
||||
reason = 'replication enabled K2 volume group.'
|
||||
elif vol_map:
|
||||
reason = 'attached K2 volume.'
|
||||
elif nvol != 1:
|
||||
reason = 'multiple volumes in K2 volume group.'
|
||||
if reason:
|
||||
raise exception.ManageExistingInvalidReference(
|
||||
existing_ref=existing_ref,
|
||||
reason=_('Manage volume type invalid.'))
|
||||
reason=_('Unable to manage K2 volume due to: %s') % reason)
|
||||
vol.name = new_name
|
||||
vg_name = vg.name
|
||||
LOG.debug("Manage new volume name: %s", new_name)
|
||||
@ -1046,7 +1056,11 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||
vg.save()
|
||||
LOG.debug("Manage volume: %s in K2.", vol_name)
|
||||
vol.save()
|
||||
except Exception as ex:
|
||||
except exception.ManageExistingInvalidReference:
|
||||
LOG.exception(_LE("manage volume: %s failed."), vol_name)
|
||||
raise
|
||||
except Exception:
|
||||
LOG.exception(_LE("manage volume: %s failed."), vol_name)
|
||||
vg_rs = self.client.search("volume_groups", name=vg_new_name)
|
||||
if hasattr(vg_rs, 'hits') and vg_rs.total != 0:
|
||||
vg = vg_rs.hits[0]
|
||||
@ -1054,10 +1068,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
||||
vg.name = vg_name
|
||||
LOG.debug("Updating vg new name to old name: %s ", vg_name)
|
||||
vg.save()
|
||||
LOG.exception(_LE("manage volume: %s failed."), vol_name)
|
||||
raise exception.ManageExistingInvalidReference(
|
||||
existing_ref=existing_ref,
|
||||
reason=six.text_type(ex.message))
|
||||
raise
|
||||
|
||||
@kaminario_logger
|
||||
def manage_existing_get_size(self, volume, existing_ref):
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- Fixed issue of managing a VG with more than one
|
||||
volume in Kaminario FC and iSCSI Cinder drivers.
|
||||
|
Loading…
Reference in New Issue
Block a user