Skip to content

Commit fe52b6c

Browse files
author
Alexandre Arents
committed
Update image_base_image_ref during rebuild.
In different location we assume system_metadata.image_base_image_ref exists, because it is set during instance creation in method _populate_instance_for_create But once instance is rebuild, all system_metadata image property a dropped and replace by new image property and without setting back image_base_image_ref. This change propose to set image_base_image_ref during rebuild. In specific case of shelve/unshelve in Qcow2 backend, image_base_image_ref is used to rebase disk image, so we ensure this property is set as instance may have been rebuild before the fix was apply. Related-Bug: #1732428 Closes-Bug: #1893618 Change-Id: Ia3031ea1f7db8b398f02d2080ca603ded8970200
1 parent b5d4804 commit fe52b6c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

nova/compute/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,6 +3534,8 @@ def _reset_image_metadata():
35343534
new_sys_metadata = utils.get_system_metadata_from_image(
35353535
image, flavor)
35363536

3537+
new_sys_metadata.update({'image_base_image_ref': image_id})
3538+
35373539
instance.system_metadata.update(new_sys_metadata)
35383540
instance.save()
35393541
return orig_sys_metadata
@@ -4170,6 +4172,14 @@ def shelve(self, context, instance, clean_shutdown=True):
41704172
hypervisor.
41714173
"""
41724174
instance.task_state = task_states.SHELVING
4175+
4176+
# NOTE(aarents): Ensure image_base_image_ref is present as it will be
4177+
# needed during unshelve and instance rebuild done before Bug/1893618
4178+
# Fix dropped it.
4179+
instance.system_metadata.update(
4180+
{'image_base_image_ref': instance.image_ref}
4181+
)
4182+
41734183
instance.save(expected_task_state=[None])
41744184

41754185
self._record_action_start(context, instance, instance_actions.SHELVE)

nova/tests/unit/compute/test_compute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9045,6 +9045,7 @@ def fake_rpc_rebuild(context, **kwargs):
90459045
'image_ramdisk_id': uuids.ramdisk_id,
90469046
'image_something_else': 'meow',
90479047
'preserved': 'preserve this!',
9048+
'image_base_image_ref': image_ref,
90489049
'boot_roles': ''},
90499050
sys_meta)
90509051

0 commit comments

Comments
 (0)