Use oslo policy flag to disable default change warning instead of all

oslo has new flag to disable the warning for default check_str
change and keep logging warning if policy name is changed or it is
marked for removal.

Policy defaults refresh BP work changed the defaults for all the
policy so logging their warning is dangerousa and fill up the log file.
Once we switch to new defaults then we can enable them if needed.

Logging warning for name change and marked for removal make sense
when old rules are override by operator so the new flag does not control
those. For policy defaults refresh BP work, we do not have many policies
in this category so logging their warning is ok.

This commits reset the testing flag 'suppress_deprecation_warnings'
default value back to False. Test policy fixture sets that to True to
avoid any warnig during tests run.

Bumping the oslo policy version where this new flag is present
- https://review.opendev.org/#/c/719547/

Partial implement blueprint policy-defaults-refresh

Change-Id: Iaa6baf6877890babb6205bdb3ee2e1a2b28ebd9c
This commit is contained in:
Ghanshyam Mann 2020-04-06 14:09:11 -05:00
parent 86655fe07f
commit a2d25f42c0
3 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,7 @@ oslo.i18n==3.15.3
oslo.log==3.36.0
oslo.messaging==10.3.0
oslo.middleware==3.31.0
oslo.policy==2.3.0
oslo.policy==3.1.0
oslo.privsep==1.33.2
oslo.reports==1.18.0
oslo.rootwrap==5.8.0

View File

@ -49,10 +49,8 @@ def reset():
_ENFORCER = None
# TODO(gmann): Make suppress_deprecation_warnings default to False, once
# we find the way to disable warning for default change on oslo side.
def init(policy_file=None, rules=None, default_rule=None, use_conf=True,
suppress_deprecation_warnings=True):
suppress_deprecation_warnings=False):
"""Init an Enforcer class.
:param policy_file: Custom policy file to use, if none is specified,
@ -75,6 +73,13 @@ def init(policy_file=None, rules=None, default_rule=None, use_conf=True,
rules=rules,
default_rule=default_rule,
use_conf=use_conf)
# NOTE(gmann): Explictly disable the warnings for policies
# changing their default check_str. During policy-defaults-refresh
# work, all the policy defaults have been changed and warning for
# each policy started filling the logs limit for various tool.
# Once we move to new defaults only world then we can enable these
# warning again.
_ENFORCER.suppress_default_change_warnings = True
if suppress_deprecation_warnings:
_ENFORCER.suppress_deprecation_warnings = True
register_rules(_ENFORCER)

View File

@ -45,7 +45,7 @@ oslo.utils>=4.1.0 # Apache-2.0
oslo.db>=4.44.0 # Apache-2.0
oslo.rootwrap>=5.8.0 # Apache-2.0
oslo.messaging>=10.3.0 # Apache-2.0
oslo.policy>=2.3.0 # Apache-2.0
oslo.policy>=3.1.0 # Apache-2.0
oslo.privsep>=1.33.2 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.service>=1.40.1 # Apache-2.0