placement: ignore policy scope check failures if not enforcing scope
Rather than spam the placement API logs with scope check
warnings from oslo.policy when placement isn't configured
for scope type enforcement, ignore those warnings.
Note that the same warnings filter in the placement WarningsFixture
is left intact because the configuration defaults setting code in
wsgi.py which allows the warning filter to be set in deploy.py,
is not run by the functional tests. In future changes this will
be resolved by unifying configuration handling.
Closes-Bug: #1786498
Related-Bug: #1784663
Change-Id: I34e4e550c9c31a654308e555210588156418f9e3
(cherry picked from commit 94617a7176
)
This commit is contained in:
parent
afd1c1e6e1
commit
97e7087ac3
|
@ -81,6 +81,13 @@ def deploy(conf):
|
|||
if middleware:
|
||||
application = middleware(application)
|
||||
|
||||
# NOTE(mriedem): Ignore scope check UserWarnings from oslo.policy.
|
||||
if not conf.oslo_policy.enforce_scope:
|
||||
import warnings
|
||||
warnings.filterwarnings('ignore',
|
||||
message="Policy .* failed scope check",
|
||||
category=UserWarning)
|
||||
|
||||
return application
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import os.path
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_middleware import cors
|
||||
from oslo_policy import opts as policy_opts
|
||||
from oslo_utils import importutils
|
||||
import pbr.version
|
||||
|
||||
|
@ -65,6 +66,10 @@ def _parse_args(argv, default_config_files):
|
|||
|
||||
_set_middleware_defaults()
|
||||
|
||||
# This is needed so we can check [oslo_policy]/enforce_scope in the
|
||||
# deploy module.
|
||||
policy_opts.set_defaults(conf.CONF)
|
||||
|
||||
conf.CONF(argv[1:], project='nova', version=version_info.version_string(),
|
||||
default_config_files=default_config_files)
|
||||
|
||||
|
|
Loading…
Reference in New Issue