Fix retype with migrate
When a retype requires migrating a volume the check on the volume manager will always consider that there's no need to migrate so it will not try to migrate the volume but retype it instead, so in drivers that implement `retype` (like LVM) it will falsely report success. This patch fixes the check to detect if the volume is in our own backend. Closes-bug: #1652802 Change-Id: I5e977ed412cf4a1614d7728ffe7898435291fcc3
This commit is contained in:
parent
02389a1d2a
commit
dafd68eadd
|
@ -5589,6 +5589,8 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
|
|||
migration_policy=policy,
|
||||
reservations=reservations,
|
||||
old_reservations=old_reservations)
|
||||
if host_obj['host'] != CONF.host:
|
||||
_retype.assert_not_called()
|
||||
|
||||
# get volume/quota properties
|
||||
volume = objects.Volume.get_by_id(elevated, volume.id)
|
||||
|
|
|
@ -2212,6 +2212,13 @@ class VolumeManager(manager.CleanableManager,
|
|||
LOG.info(_LI("Extend volume completed successfully."),
|
||||
resource=volume)
|
||||
|
||||
def _is_our_backend(self, host, cluster_name):
|
||||
return ((not cluster_name and
|
||||
vol_utils.hosts_are_equivalent(self.driver.host, host)) or
|
||||
(cluster_name and
|
||||
vol_utils.hosts_are_equivalent(self.driver.cluster_name,
|
||||
cluster_name)))
|
||||
|
||||
def retype(self, context, volume, new_type_id, host,
|
||||
migration_policy='never', reservations=None,
|
||||
old_reservations=None):
|
||||
|
@ -2295,11 +2302,7 @@ class VolumeManager(manager.CleanableManager,
|
|||
|
||||
if (not retyped and
|
||||
not diff.get('encryption') and
|
||||
((not host.get('cluster_name') and
|
||||
vol_utils.hosts_are_equivalent(self.driver.host,
|
||||
host['host'])) or
|
||||
(vol_utils.hosts_are_equivalent(self.driver.cluster_name,
|
||||
host.get('cluster_name'))))):
|
||||
self._is_our_backend(host['host'], host.get('cluster_name'))):
|
||||
try:
|
||||
new_type = volume_types.get_volume_type(context, new_type_id)
|
||||
ret = self.driver.retype(context,
|
||||
|
|
Loading…
Reference in New Issue