compute: Retain instance metadata for 'evacuate' on shared storage
When performing instance evacuation (which is essentially "rebuild an instance elsewhere"), image metadata is not persistent -- this manifests only when instances are on shared storage. So, supply the original instance metadata to 'image_meta' parameter, instead of an empty dict. Change-Id: Ibea4954c149b9dcb162c5962ab8e9a4f17e51a1d Co-Authored-By: Diana Clarke <diana.joan.clarke@gmail.com> Closes-Bug: 1562681
This commit is contained in:
parent
40196d34db
commit
82098d06db
@ -2721,7 +2721,7 @@ class ComputeManager(manager.Manager):
|
||||
image_meta = objects.ImageMeta.from_image_ref(
|
||||
context, self.image_api, image_ref)
|
||||
else:
|
||||
image_meta = objects.ImageMeta.from_dict({})
|
||||
image_meta = instance.image_meta
|
||||
|
||||
# This instance.exists message should contain the original
|
||||
# image_ref, not the new one. Since the DB has been updated
|
||||
|
@ -11682,11 +11682,14 @@ class EvacuateHostTestCase(BaseTestCase):
|
||||
self.assertRaises(exception.InstanceRecreateNotSupported,
|
||||
lambda: self._rebuild(on_shared_storage=True))
|
||||
|
||||
def test_on_shared_storage_not_provided_host_without_shared_storage(self):
|
||||
@mock.patch('nova.objects.ImageMeta.from_image_ref')
|
||||
def test_on_shared_storage_not_provided_host_without_shared_storage(self,
|
||||
mock_image_meta):
|
||||
# 'spawn' should be called with the image_meta from the image_ref
|
||||
self.mox.StubOutWithMock(self.compute.driver, 'spawn')
|
||||
self.compute.driver.spawn(mox.IsA(self.context),
|
||||
mox.IsA(objects.Instance),
|
||||
mox.IsA(objects.ImageMeta),
|
||||
mock_image_meta.return_value,
|
||||
mox.IgnoreArg(), mox.IsA('newpass'),
|
||||
network_info=mox.IgnoreArg(),
|
||||
block_device_info=mox.IgnoreArg())
|
||||
@ -11697,11 +11700,15 @@ class EvacuateHostTestCase(BaseTestCase):
|
||||
|
||||
self._rebuild(on_shared_storage=None)
|
||||
|
||||
def test_on_shared_storage_not_provided_host_with_shared_storage(self):
|
||||
@mock.patch('nova.objects.Instance.image_meta',
|
||||
new_callable=mock.PropertyMock)
|
||||
def test_on_shared_storage_not_provided_host_with_shared_storage(self,
|
||||
mock_image_meta):
|
||||
# 'spawn' should be called with the image_meta from the instance
|
||||
self.mox.StubOutWithMock(self.compute.driver, 'spawn')
|
||||
self.compute.driver.spawn(mox.IsA(self.context),
|
||||
mox.IsA(objects.Instance),
|
||||
mox.IsA(objects.ImageMeta),
|
||||
mock_image_meta.return_value,
|
||||
mox.IgnoreArg(), 'newpass',
|
||||
network_info=mox.IgnoreArg(),
|
||||
block_device_info=mox.IgnoreArg())
|
||||
|
Loading…
x
Reference in New Issue
Block a user