From 987352d6cbcc6ead3c1e5c4ad9948b59b71c57fb Mon Sep 17 00:00:00 2001 From: silvacarloss Date: Fri, 8 Mar 2024 15:47:05 -0300 Subject: [PATCH] Change admin metadata config option name This change is a follow-up to a change that merged recently [1]. We are changing the name of the config option to make it similar to the policy we have defined for updating some metadata that should only be manipulated by administrators. [1] https://review.opendev.org/c/openstack/manila/+/909175 Related-Bug: #2050010 Change-Id: I9a8a27f1181b92291f2d4ad5fd9d4483e2dacc50 --- manila/api/v1/share_metadata.py | 8 +++++--- manila/api/v2/shares.py | 8 ++++---- manila/common/config.py | 2 +- ...guring-admin-and-driver-metadata-b0ede7d7cf057b5b.yaml | 6 ++++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manila/api/v1/share_metadata.py b/manila/api/v1/share_metadata.py index e307c281f0..5976c75959 100644 --- a/manila/api/v1/share_metadata.py +++ b/manila/api/v1/share_metadata.py @@ -109,7 +109,7 @@ class ShareMetadataController(object): def _update_share_metadata(self, context, share_id, metadata, delete=False): - ignore_keys = getattr(CONF, 'admin_metadata_keys', []) + ignore_keys = getattr(CONF, 'admin_only_metadata', []) try: share = self.share_api.get(context, share_id) if set(metadata).intersection(set(ignore_keys)): @@ -178,8 +178,10 @@ class ShareMetadataController(object): try: share = self.share_api.get(context, share_id) - admin_metadata_keys = getattr(CONF, 'admin_metadata_keys', set()) - if id in admin_metadata_keys: + admin_only_metadata_keys = ( + getattr(CONF, 'admin_only_metadata', set()) + ) + if id in admin_only_metadata_keys: policy.check_policy(context, 'share', 'update_admin_only_metadata') db.share_metadata_delete(context, share['id'], id) diff --git a/manila/api/v2/shares.py b/manila/api/v2/shares.py index ed04204efa..4d4b9ca0bd 100644 --- a/manila/api/v2/shares.py +++ b/manila/api/v2/shares.py @@ -59,8 +59,8 @@ class ShareController(wsgi.Controller, self.resource_locks_api = resource_locks.API() self._access_view_builder = share_access_views.ViewBuilder() self._migration_view_builder = share_migration_views.ViewBuilder() - self._conf_admin_metadata_keys = getattr( - CONF, 'admin_metadata_keys', [] + self._conf_admin_only_metadata_keys = getattr( + CONF, 'admin_only_metadata', [] ) @wsgi.Controller.authorize('revert_to_snapshot') @@ -627,7 +627,7 @@ class ShareController(wsgi.Controller, def _validate_metadata_for_update(self, req, share_id, metadata, delete=True): - admin_metadata_ignore_keys = set(self._conf_admin_metadata_keys) + admin_metadata_ignore_keys = set(self._conf_admin_only_metadata_keys) context = req.environ['manila.context'] if set(metadata).intersection(admin_metadata_ignore_keys): try: @@ -705,7 +705,7 @@ class ShareController(wsgi.Controller, @wsgi.Controller.authorize("delete_share_metadata") def delete_metadata(self, req, resource_id, key): context = req.environ['manila.context'] - if key in self._conf_admin_metadata_keys: + if key in self._conf_admin_only_metadata_keys: policy.check_policy(context, 'share', 'update_admin_only_metadata') return self._delete_metadata(req, resource_id, key) diff --git a/manila/common/config.py b/manila/common/config.py index a05e1b29a5..a52bfd07da 100644 --- a/manila/common/config.py +++ b/manila/common/config.py @@ -137,7 +137,7 @@ global_opts = [ help='Maximum time (in seconds) to keep a share in ' 'awaiting_transfer state, after timeout, the share will ' 'automatically be rolled back to the available state'), - cfg.ListOpt('admin_metadata_keys', + cfg.ListOpt('admin_only_metadata', default=constants.AdminOnlyMetadata.SCHEDULER_FILTERS, help='Metadata keys that should only be manipulated by ' 'administrators.'), diff --git a/releasenotes/notes/bug-2050010-allow-configuring-admin-and-driver-metadata-b0ede7d7cf057b5b.yaml b/releasenotes/notes/bug-2050010-allow-configuring-admin-and-driver-metadata-b0ede7d7cf057b5b.yaml index e3fa250261..019fcad5c6 100644 --- a/releasenotes/notes/bug-2050010-allow-configuring-admin-and-driver-metadata-b0ede7d7cf057b5b.yaml +++ b/releasenotes/notes/bug-2050010-allow-configuring-admin-and-driver-metadata-b0ede7d7cf057b5b.yaml @@ -1,6 +1,8 @@ --- upgrades: - | - A new configuration option called ``admin_metadata_keys`` has been + A new configuration option called ``admin_only_metadata`` has been introduced to assist cloud administrators while defining share - metadata that should only be modified by administrators. + metadata that should only be modified by administrators. This + configuration option defaults to the existing admin only metadata + keys, i.e., scheduler hints to preserve backwards compatibility.