Skip to content

Commit

Permalink
Do not inherit os_glance properties on snapshot
Browse files Browse the repository at this point in the history
Glance uses properties like os_glance_importing_to_stores for internal
purposes. These should never be copied to a snapshot by nova. Further,
Glance would like to disallow setting these properties by namespace
entirely in the future.

This patch adds namespace support to our existing list of static
properties which are non-inheritable.

Change-Id: Ib5d9da46b1a0e467b968e3ec3e61125e06f99bfc
  • Loading branch information
kk7ds committed Jan 18, 2021
1 parent 5b65812 commit dda179d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nova/compute/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
'img_signature_key_type',
'img_signature_certificate_uuid'])

# Properties starting with these namespaces are reserved for internal
# use by other services. It does not make sense (and may cause a request
# fail) if we include them in a snapshot.
NON_INHERITABLE_IMAGE_NAMESPACES = frozenset([
'os_glance',
])


def exception_to_dict(fault, message=None):
"""Converts exceptions to a dict for use in notifications.
Expand Down Expand Up @@ -1268,6 +1275,9 @@ def initialize_instance_snapshot_metadata(context, instance, name,
properties = image_meta['properties']
keys_to_pop = set(CONF.non_inheritable_image_properties).union(
NON_INHERITABLE_IMAGE_PROPERTIES)
for ns in NON_INHERITABLE_IMAGE_NAMESPACES:
keys_to_pop |= {key for key in properties
if key.startswith(ns)}
for key in keys_to_pop:
properties.pop(key, None)

Expand Down
2 changes: 2 additions & 0 deletions nova/tests/unit/compute/test_compute_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@ def test_initialize_instance_snapshot_metadata_removed_metadata(self):
'deeeeeac-d75e-11e2-8271-1234567897d6',
'image_some_key': 'some_value',
'image_fred': 'barney',
'image_os_glance_importing_to_stores': '',
'image_cache_in_nova': 'true'
}
image_meta = compute_utils.initialize_instance_snapshot_metadata(
Expand All @@ -1548,6 +1549,7 @@ def test_initialize_instance_snapshot_metadata_removed_metadata(self):
self.assertNotIn(p, properties)
for p in CONF.non_inheritable_image_properties:
self.assertNotIn(p, properties)
self.assertNotIn('os_glance_importing_to_stores', properties)


class PciRequestUpdateTestCase(test.NoDBTestCase):
Expand Down

0 comments on commit dda179d

Please sign in to comment.