Fix logic in retype check for encryption changes

The check was looking for not None to decide if it can
call the driver.retype(..). Turns out the diff has an
empty dictionary when it didn't find any encryption diff.

We now just look at the converted boolean value of whatever
was in there so the empty dict is interpreted the right way.

Change-Id: Ic1ae3c6596f2a390b8f8a41495d1a58ee58eacdf
Closes-Bug: #1622762
This commit is contained in:
Patrick East 2016-09-12 15:08:53 -07:00
parent 109241db58
commit 83bfa87e23
2 changed files with 6 additions and 2 deletions
cinder
tests/unit
volume

@ -5302,7 +5302,11 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
mock.patch.object(db.sqlalchemy.api, 'volume_get') as mock_get:
mock_get.return_value = volume
_retype.return_value = driver
returned_diff = {}
returned_diff = {
'encryption': {},
'qos_specs': {},
'extra_specs': {},
}
if encryption_changed:
returned_diff = {'encryption': 'fake'}
_diff.return_value = (returned_diff, diff_equal)

@ -2287,7 +2287,7 @@ class VolumeManager(manager.SchedulerDependentManager):
# We assume that those that support pools do this internally
# so we strip off the pools designation
if (not retyped and
diff.get('encryption') is None and
not diff.get('encryption') and
vol_utils.hosts_are_equivalent(self.driver.host,
host['host'])):
try: