From 8c132193923168150fdc7f62a20e2d887cde723b Mon Sep 17 00:00:00 2001 From: Brian Rosmaita Date: Wed, 5 Dec 2018 22:12:13 -0500 Subject: [PATCH] Correct default policy_file in the sample config When the sample config is generated, the policy_file default value specified by oslo.policy is showing up, not the default value that Cinder is using. Correct this by enhancing the function specified for cinder in the oslo.config.opts.defaults entry point. This patch exposed Bug #1807184 in oslo.policy. The requirements and lower-constraints changes on this patch bump the minimum version of oslo.policy we use to include the fix (1.44.1). This version was already included in upper-constraints by Change I50bb9d48106376f5baaafae372492c0744182da2. Change-Id: Ic28d660a9d876139f47f98cf1024a30b005cd0e0 Closes-bug: #1807071 --- cinder/common/config.py | 14 ++++++++++++++ cinder/policy.py | 3 ++- lower-constraints.txt | 2 +- requirements.txt | 2 +- setup.cfg | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cinder/common/config.py b/cinder/common/config.py index 731cb1febbb..812f3b1ffc1 100644 --- a/cinder/common/config.py +++ b/cinder/common/config.py @@ -30,8 +30,11 @@ import socket from oslo_config import cfg from oslo_log import log as logging from oslo_middleware import cors +from oslo_policy import opts as policy_opts from oslo_utils import netutils +from cinder.policy import DEFAULT_POLICY_FILENAME + CONF = cfg.CONF logging.register_options(CONF) @@ -210,3 +213,14 @@ def set_middleware_defaults(): 'PATCH', 'HEAD'] ) + + +def set_external_library_defaults(): + """Set default configuration options for external openstack libraries.""" + # This function is required so that our settings will override the defaults + # set by the libraries when the Cinder config files are generated. This + # function is declared as an entry point for oslo.config.opts.defaults in + # setup.cfg. + + set_middleware_defaults() + policy_opts.set_defaults(CONF, policy_file=DEFAULT_POLICY_FILENAME) diff --git a/cinder/policy.py b/cinder/policy.py index 4d8c179c229..7d399ef43f6 100644 --- a/cinder/policy.py +++ b/cinder/policy.py @@ -28,7 +28,8 @@ from cinder import policies CONF = cfg.CONF LOG = logging.getLogger(__name__) -policy_opts.set_defaults(cfg.CONF, 'policy.yaml') +DEFAULT_POLICY_FILENAME = 'policy.yaml' +policy_opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILENAME) _ENFORCER = None diff --git a/lower-constraints.txt b/lower-constraints.txt index 7b1f81b9d66..9ae0cbf71bd 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -76,7 +76,7 @@ oslo.i18n==3.15.3 oslo.log==3.36.0 oslo.messaging==6.4.0 oslo.middleware==3.31.0 -oslo.policy==1.30.0 +oslo.policy==1.44.1 oslo.privsep==1.23.0 oslo.reports==1.18.0 oslo.rootwrap==5.8.0 diff --git a/requirements.txt b/requirements.txt index 70ae0b03bea..0347debe52e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ oslo.db>=4.27.0 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0 oslo.messaging>=6.4.0 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0 -oslo.policy>=1.30.0 # Apache-2.0 +oslo.policy>=1.44.1 # Apache-2.0 oslo.privsep>=1.23.0 # Apache-2.0 oslo.reports>=1.18.0 # Apache-2.0 oslo.rootwrap>=5.8.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index df02db14c14..42b184ab808 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ cinder.scheduler.weights = oslo.config.opts = cinder = cinder.opts:list_opts oslo.config.opts.defaults = - cinder = cinder.common.config:set_middleware_defaults + cinder = cinder.common.config:set_external_library_defaults oslo.policy.enforcer = cinder = cinder.policy:get_enforcer oslo.policy.policies =