Attachment lost after migrating in-use volume
Without proper refresh, attachment info are lost after migrating in-use volumes. This is to fix the problem. Change-Id: I31012a1871b85e038e6595097ad25224488d72a1 Closes-bug: #1614371
This commit is contained in:
parent
78e75c5648
commit
7a8daa5c61
|
@ -463,6 +463,7 @@ class Volume(base.CinderPersistentObject, base.CinderObject,
|
|||
setattr(self, key, value)
|
||||
setattr(dest_volume, key, value_to_dst)
|
||||
|
||||
self.save()
|
||||
dest_volume.save()
|
||||
return dest_volume
|
||||
|
||||
|
|
|
@ -380,6 +380,9 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
|||
updated_dest_volume.display_description)
|
||||
self.assertEqual(src_volume.id, updated_dest_volume._name_id)
|
||||
self.assertTrue(volume_update.called)
|
||||
volume_update.assert_has_calls([
|
||||
mock.call(self.context, src_volume.id, mock.ANY),
|
||||
mock.call(self.context, dest_volume.id, mock.ANY)])
|
||||
ctxt, vol_id, updates = volume_update.call_args[0]
|
||||
self.assertNotIn('volume_type', updates)
|
||||
|
||||
|
|
|
@ -1793,11 +1793,15 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||
volume.save()
|
||||
|
||||
# Detach the source volume (if it fails, don't fail the migration)
|
||||
# As after detach and refresh, volume_attchments will be None.
|
||||
# We keep volume_attachment for later attach.
|
||||
if orig_volume_status == 'in-use':
|
||||
attachments = volume.volume_attachment
|
||||
else:
|
||||
attachments = None
|
||||
try:
|
||||
if orig_volume_status == 'in-use':
|
||||
attachments = volume.volume_attachment
|
||||
for attachment in attachments:
|
||||
self.detach_volume(ctxt, volume.id, attachment['id'])
|
||||
for attachment in attachments:
|
||||
self.detach_volume(ctxt, volume.id, attachment['id'])
|
||||
except Exception as ex:
|
||||
LOG.error(_LE("Detach migration source volume failed: %(err)s"),
|
||||
{'err': ex}, resource=volume)
|
||||
|
@ -1819,7 +1823,6 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||
'migration_status': 'success'}
|
||||
|
||||
if orig_volume_status == 'in-use':
|
||||
attachments = volume.volume_attachment
|
||||
for attachment in attachments:
|
||||
rpcapi.attach_volume(ctxt, volume,
|
||||
attachment['instance_uuid'],
|
||||
|
|
Loading…
Reference in New Issue