Merge "Remove allow_additional_image_properties"

This commit is contained in:
Zuul 2024-04-30 13:25:35 +00:00 committed by Gerrit Code Review
commit 4c9aec7349
7 changed files with 8 additions and 118 deletions

View File

@ -21,10 +21,6 @@ Using image properties
Some important points to keep in mind:
* In order to allow custom image properties, Glance must be configured with
the ``glance-api.conf`` setting ``allow_additional_image_properties`` set
to True. (This is the default setting.)
* The ``glance-api.conf`` setting ``image_property_quota`` should be
sufficiently high to allow any additional desired properties. (The default
is 128.)

View File

@ -1896,10 +1896,7 @@ def _get_base_links():
def get_schema(custom_properties=None):
properties = get_base_properties()
links = _get_base_links()
if CONF.allow_additional_image_properties:
schema = glance.schema.PermissiveSchema('image', properties, links)
else:
schema = glance.schema.Schema('image', properties)
schema = glance.schema.PermissiveSchema('image', properties, links)
if custom_properties:
for property_value in custom_properties.values():

View File

@ -173,36 +173,6 @@ Related Options:
]
common_opts = [
cfg.BoolOpt('allow_additional_image_properties', default=True,
deprecated_for_removal=True,
deprecated_since="Ussuri",
deprecated_reason=_("""
This option is redundant. Control custom image property usage via the
'image_property_quota' configuration option. This option is scheduled
to be removed during the Victoria development cycle.
"""),
help=_("""
Allow users to add additional/custom properties to images.
Glance defines a standard set of properties (in its schema) that
appear on every image. These properties are also known as
``base properties``. In addition to these properties, Glance
allows users to add custom properties to images. These are known
as ``additional properties``.
By default, this configuration option is set to ``True`` and users
are allowed to add additional properties. The number of additional
properties that can be added to an image can be controlled via
``image_property_quota`` configuration option.
Possible values:
* True
* False
Related options:
* image_property_quota
""")),
cfg.StrOpt('hashing_algorithm',
default='sha512',
help=_("""
@ -255,12 +225,6 @@ Maximum number of properties allowed on an image.
This enforces an upper limit on the number of additional properties an image
can have. Any negative value is interpreted as unlimited.
NOTE: This won't have any impact if additional properties are disabled. Please
refer to ``allow_additional_image_properties``.
Related options:
* ``allow_additional_image_properties``
""")),
cfg.IntOpt('image_tag_quota', default=128,
help=_("""

View File

@ -446,7 +446,6 @@ image_property_quota=%(image_property_quota)s
image_tag_quota=%(image_tag_quota)s
image_location_quota=%(image_location_quota)s
location_strategy=%(location_strategy)s
allow_additional_image_properties = True
node_staging_uri=%(node_staging_uri)s
[database]
connection = %(sql_connection)s
@ -633,7 +632,6 @@ image_property_quota=%(image_property_quota)s
image_tag_quota=%(image_tag_quota)s
image_location_quota=%(image_location_quota)s
location_strategy=%(location_strategy)s
allow_additional_image_properties = True
enabled_backends=file1:file,file2:file,file3:file
[database]
connection = %(sql_connection)s

View File

@ -114,7 +114,7 @@ class TestPermissiveSchema(test_utils.BaseTestCase):
}
self.schema = glance.schema.PermissiveSchema('permissive', properties)
def test_validate_with_additional_properties_allowed(self):
def test_validate_with_additional_properties(self):
obj = {'ham': 'virginia', 'eggs': 'scrambled', 'bacon': 'crispy'}
self.schema.validate(obj) # No exception raised

View File

@ -4252,11 +4252,6 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
'checksum': CHKSUM,
'bogus_key': 'bogus_value',
}
request.body = jsonutils.dump_as_bytes(changes)
self.assertRaisesRegex(
webob.exc.HTTPBadRequest,
'Additional properties are not allowed',
self.deserializer.update, request)
changes[0]['value']['validation_data'] = {
'checksum': CHKSUM,
@ -4971,7 +4966,6 @@ class TestImagesDeserializerWithExtendedSchema(test_utils.BaseTestCase):
def setUp(self):
super(TestImagesDeserializerWithExtendedSchema, self).setUp()
self.config(allow_additional_image_properties=False)
custom_image_properties = {
'pants': {
'type': 'string',
@ -5030,7 +5024,6 @@ class TestImagesDeserializerWithAdditionalProperties(test_utils.BaseTestCase):
def setUp(self):
super(TestImagesDeserializerWithAdditionalProperties, self).setUp()
self.config(allow_additional_image_properties=True)
self.deserializer = glance.api.v2.images.RequestDeserializer()
def test_create(self):
@ -5083,36 +5076,6 @@ class TestImagesDeserializerWithAdditionalProperties(test_utils.BaseTestCase):
self.assertEqual({'changes': [change]}, output)
class TestImagesDeserializerNoAdditionalProperties(test_utils.BaseTestCase):
def setUp(self):
super(TestImagesDeserializerNoAdditionalProperties, self).setUp()
self.config(allow_additional_image_properties=False)
self.deserializer = glance.api.v2.images.RequestDeserializer()
def test_create_with_additional_properties_disallowed(self):
self.config(allow_additional_image_properties=False)
request = unit_test_utils.get_fake_request()
request.body = jsonutils.dump_as_bytes({'foo': 'bar'})
self.assertRaises(webob.exc.HTTPBadRequest,
self.deserializer.create, request)
def test_neg_create_with_stores(self):
self.config(allow_additional_image_properties=True)
request = unit_test_utils.get_fake_request()
request.body = jsonutils.dump_as_bytes({'stores': 'test'})
self.assertRaises(webob.exc.HTTPForbidden,
self.deserializer.create, request)
def test_update(self):
request = unit_test_utils.get_fake_request()
request.content_type = 'application/openstack-images-v2.1-json-patch'
doc = [{'op': 'add', 'path': '/foo', 'value': 'bar'}]
request.body = jsonutils.dump_as_bytes(doc)
self.assertRaises(webob.exc.HTTPBadRequest,
self.deserializer.update, request)
class TestImagesSerializer(test_utils.BaseTestCase):
def setUp(self):
@ -5608,7 +5571,6 @@ class TestImagesSerializerWithExtendedSchema(test_utils.BaseTestCase):
def setUp(self):
super(TestImagesSerializerWithExtendedSchema, self).setUp()
self.config(allow_additional_image_properties=False)
custom_image_properties = {
'color': {
'type': 'string',
@ -5651,6 +5613,7 @@ class TestImagesSerializerWithExtendedSchema(test_utils.BaseTestCase):
'min_disk': None,
'disk_format': None,
'container_format': None,
'mood': 'grouchy',
}
response = webob.Response()
self.serializer.show(response, self.fixture)
@ -5682,6 +5645,7 @@ class TestImagesSerializerWithExtendedSchema(test_utils.BaseTestCase):
'min_disk': None,
'disk_format': None,
'container_format': None,
'mood': 'grouchy',
}
response = webob.Response()
self.serializer.show(response, self.fixture)
@ -5692,7 +5656,6 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
def setUp(self):
super(TestImagesSerializerWithAdditionalProperties, self).setUp()
self.config(allow_additional_image_properties=True)
self.fixture = _domain_fixture(
UUID2, name='image-2', owner=TENANT2,
checksum='ca425b88f047ce8ec45ee90e813ada91',
@ -5768,37 +5731,6 @@ class TestImagesSerializerWithAdditionalProperties(test_utils.BaseTestCase):
serializer.show(response, self.fixture)
self.assertEqual(expected, jsonutils.loads(response.body))
def test_show_with_additional_properties_disabled(self):
self.config(allow_additional_image_properties=False)
serializer = glance.api.v2.images.ResponseSerializer()
expected = {
'id': UUID2,
'name': 'image-2',
'status': 'queued',
'visibility': 'private',
'protected': False,
'os_hidden': False,
'checksum': 'ca425b88f047ce8ec45ee90e813ada91',
'os_hash_algo': FAKEHASHALGO,
'os_hash_value': MULTIHASH1,
'tags': [],
'size': 1024,
'virtual_size': 3072,
'owner': '2c014f32-55eb-467d-8fcb-4bd706012f81',
'created_at': ISOTIME,
'updated_at': ISOTIME,
'self': '/v2/images/%s' % UUID2,
'file': '/v2/images/%s/file' % UUID2,
'schema': '/v2/schemas/image',
'min_ram': None,
'min_disk': None,
'disk_format': None,
'container_format': None,
}
response = webob.Response()
serializer.show(response, self.fixture)
self.assertEqual(expected, jsonutils.loads(response.body))
class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
@ -5920,7 +5852,6 @@ class TestImageSchemaFormatConfiguration(test_utils.BaseTestCase):
class TestImageSchemaDeterminePropertyBasis(test_utils.BaseTestCase):
def test_custom_property_marked_as_non_base(self):
self.config(allow_additional_image_properties=False)
custom_image_properties = {
'pants': {
'type': 'string',

View File

@ -0,0 +1,4 @@
---
upgrade:
- The ``allow_additional_image_properties`` configuration option, which
was deprecated in Ussuri, has been removed in this release.