From 67ff5ff2b4ad4a12965142ffb1ff7fb11c07d337 Mon Sep 17 00:00:00 2001 From: melanie witt Date: Thu, 1 Jul 2021 22:01:14 +0000 Subject: [PATCH] Suppress policy deprecation and default change warnings As part of the policy defaults refresh work, all of the defaults for policies were changed and warnings about it are being emitted constantly in the logs. We can suppress these for now until we are enforcing new defaults [1]. This also suppresses policy deprecation warnings during tests to avoid filling the console with warning messages. Related to blueprint policy-defaults-refresh [1]https://docs.openstack.org/nova/latest/configuration/config.html#oslo_policy.enforce_new_defaults Change-Id: I4a169b42d516a7ae2adcee9b69d71723fdefcd95 --- ironic/common/policy.py | 7 +++++++ ironic/tests/unit/policy_fixture.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ironic/common/policy.py b/ironic/common/policy.py index 1f5d9050c8..2e493e9af0 100644 --- a/ironic/common/policy.py +++ b/ironic/common/policy.py @@ -1797,6 +1797,13 @@ def init_enforcer(policy_file=None, rules=None, rules=rules, default_rule=default_rule, use_conf=use_conf) + # NOTE(melwitt): 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 _ENFORCER.register_defaults(list_policies()) diff --git a/ironic/tests/unit/policy_fixture.py b/ironic/tests/unit/policy_fixture.py index 4e07c25542..973c1e75ee 100644 --- a/ironic/tests/unit/policy_fixture.py +++ b/ironic/tests/unit/policy_fixture.py @@ -44,3 +44,7 @@ class PolicyFixture(fixtures.Fixture): CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy') ironic_policy._ENFORCER = None self.addCleanup(ironic_policy.get_enforcer().clear) + # NOTE(melwitt): Logging all the deprecation warning for every unit + # test will overflow the log files. Suppress the deprecation warnings + # for tests. + ironic_policy._ENFORCER.suppress_deprecation_warnings = True