From 7eb5e2948cf6674e5627bbf4a91b52ee4e6942d5 Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Sun, 10 Nov 2024 21:37:59 -0800 Subject: [PATCH] Remove default override for config options policy_file olso.policy 4.5.0[1] changed the config options policy_file default value to 'policy.yaml', which means it is changed for all the OpenStack services and they do not need to override the default anymore. NOTE: There is no change in behaviour here, oslo.policy provides the same configuration that services have overridden till now. [1] https://review.opendev.org/c/openstack/releases/+/934012 [2] https://review.opendev.org/c/openstack/requirements/+/934295 Change-Id: Ia48842d0e0254bc2185716a3199ec7f810374f5d --- glance/api/policy.py | 10 ---------- glance/common/config.py | 7 ------- glance/tests/utils.py | 2 ++ requirements.txt | 2 +- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/glance/api/policy.py b/glance/api/policy.py index b10c235c72..62a94d0866 100644 --- a/glance/api/policy.py +++ b/glance/api/policy.py @@ -20,7 +20,6 @@ from collections import abc from oslo_config import cfg from oslo_log import log as logging -from oslo_policy import opts from oslo_policy import policy from glance.common import exception @@ -33,15 +32,6 @@ CONF = cfg.CONF _ENFORCER = None -# TODO(gmann): Remove overriding the default value of config options -# 'policy_file' once oslo_policy changes its default value to what -# is overridden here. -DEFAULT_POLICY_FILE = 'policy.yaml' -opts.set_defaults( - cfg.CONF, - DEFAULT_POLICY_FILE) - - class Enforcer(policy.Enforcer): """Responsible for loading and enforcing rules""" diff --git a/glance/common/config.py b/glance/common/config.py index 406bcbfe64..98f26b3b4e 100644 --- a/glance/common/config.py +++ b/glance/common/config.py @@ -22,7 +22,6 @@ import os from oslo_config import cfg from oslo_middleware import cors -from oslo_policy import opts from paste import deploy from glance.i18n import _ @@ -745,12 +744,6 @@ def set_config_defaults(): """This method updates all configuration default values.""" set_cors_middleware_defaults() - # TODO(gmann): Remove setting the default value of config policy_file - # once oslo_policy change the default value to 'policy.yaml'. - # https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49 - DEFAULT_POLICY_FILE = 'policy.yaml' - opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE) - def set_cors_middleware_defaults(): """Update default configuration options for oslo.middleware.""" diff --git a/glance/tests/utils.py b/glance/tests/utils.py index 2717c62b10..72845b44f1 100644 --- a/glance/tests/utils.py +++ b/glance/tests/utils.py @@ -37,6 +37,7 @@ from oslo_config import cfg from oslo_config import fixture as cfg_fixture from oslo_log.fixture import logging_error as log_fixture from oslo_log import log +from oslo_policy import opts as opts from oslo_utils import timeutils from oslo_utils import units import testtools @@ -104,6 +105,7 @@ class BaseTestCase(testtools.TestCase): cached_images.WORKER = None def set_policy(self): + opts.set_defaults(CONF) conf_file = "policy.yaml" self.policy_file = self._copy_data_file(conf_file, self.conf_dir) self.config(policy_file=self.policy_file, group='oslo_policy') diff --git a/requirements.txt b/requirements.txt index 0a1c77fb27..04a0183267 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ oslo.log>=4.5.0 # Apache-2.0 oslo.messaging>=5.29.0,!=9.0.0 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0 oslo.reports>=1.18.0 # Apache-2.0 -oslo.policy>=4.4.0 # Apache-2.0 +oslo.policy>=4.5.0 # Apache-2.0 retrying!=1.3.0,>=1.2.3 # Apache-2.0 osprofiler>=1.4.0 # Apache-2.0