Fix oslo policy DeprecatedRule warnings

Since 3.7.0, oslo policy started the DeprecationWarning[1] if
deprecated_reason and deprecated_since param are not passed
in DeprecatedRule or they are passed in RuleDefault object.

These warnings are logged for every test which increase the
log size and sometime can full the log buffer and fail the
job.
- https://zuul.opendev.org/t/openstack/build/ddb517bc792b49b9a8cf508eb3e361b0/log/job-output.txt#918

[1] https://github.com/openstack/oslo.policy/blob/3.7.0/oslo_policy/policy.py#L1538

Change-Id: Iae5d4c06c736e9cb24037f32cbe369fdfee9c2ab
This commit is contained in:
Ghanshyam Mann 2021-07-03 18:43:21 -05:00
parent da771fce25
commit 2dc1084fcd
3 changed files with 66 additions and 83 deletions

View File

@ -72,16 +72,17 @@ rules = [
'policy in the supplied policy.json file.',
deprecated_rule=policy.DeprecatedRule(
name='default',
check_str='role:admin'),
deprecated_reason='In order to allow operators to '
'accept the default policies from code by not defining '
'them in the policy file, while still working with old '
'policy files that rely on the ``default`` rule for '
'policies that are not specified in the policy file, '
'the ``default`` rule must now be explicitly set to '
'``"role:admin"`` when that is the desired default for '
'unspecified rules.',
deprecated_since='Ussuri'),
check_str='role:admin',
deprecated_reason='In order to allow operators to '
'accept the default policies from code by not '
'defining them in the policy file, while still '
'working with old policy files that rely on the '
'``default`` rule for policies that are '
'not specified in the policy file, the ``default`` '
'rule must now be explicitly set to '
'``"role:admin"`` when that is the desired default '
'for unspecified rules.',
deprecated_since='Ussuri')),
policy.RuleDefault(name='context_is_admin', check_str='role:admin',
description='Defines the rule for the is_admin:True '
'check.'),

View File

@ -31,10 +31,9 @@ image_policies = [
'method': 'POST'}
],
deprecated_rule=policy.DeprecatedRule(
name="add_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="add_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY)
),
policy.DocumentedRuleDefault(
name="delete_image",
@ -46,10 +45,9 @@ image_policies = [
'method': 'DELETE'}
],
deprecated_rule=policy.DeprecatedRule(
name="delete_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="delete_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="get_image",
@ -61,10 +59,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="get_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="get_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="get_images",
@ -76,10 +73,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="get_images", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="get_images", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="modify_image",
@ -91,10 +87,9 @@ image_policies = [
'method': 'PATCH'}
],
deprecated_rule=policy.DeprecatedRule(
name="modify_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="modify_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="publicize_image",
@ -116,10 +111,9 @@ image_policies = [
'method': 'PATCH'}
],
deprecated_rule=policy.DeprecatedRule(
name="communitize_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="communitize_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
@ -132,10 +126,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="download_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="download_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="upload_image",
@ -147,10 +140,9 @@ image_policies = [
'method': 'PUT'}
],
deprecated_rule=policy.DeprecatedRule(
name="upload_image", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="upload_image", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
@ -163,10 +155,9 @@ image_policies = [
'method': 'PATCH'}
],
deprecated_rule=policy.DeprecatedRule(
name="delete_image_location", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="delete_image_location", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="get_image_location",
@ -178,10 +169,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="get_image_location", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="get_image_location", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="set_image_location",
@ -193,10 +183,9 @@ image_policies = [
'method': 'PATCH'}
],
deprecated_rule=policy.DeprecatedRule(
name="set_image_location", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="set_image_location", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
@ -209,10 +198,9 @@ image_policies = [
'method': 'POST'}
],
deprecated_rule=policy.DeprecatedRule(
name="add_member", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="add_member", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="delete_member",
@ -224,10 +212,9 @@ image_policies = [
'method': 'DELETE'}
],
deprecated_rule=policy.DeprecatedRule(
name="delete_member", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="delete_member", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="get_member",
@ -239,10 +226,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="get_member", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="get_member", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="get_members",
@ -254,10 +240,9 @@ image_policies = [
'method': 'GET'}
],
deprecated_rule=policy.DeprecatedRule(
name="get_members", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="get_members", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="modify_member",
@ -269,10 +254,9 @@ image_policies = [
'method': 'PUT'}
],
deprecated_rule=policy.DeprecatedRule(
name="modify_member", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="modify_member", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.RuleDefault(
@ -295,10 +279,9 @@ image_policies = [
'method': 'POST'}
],
deprecated_rule=policy.DeprecatedRule(
name="deactivate", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="deactivate", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(
name="reactivate",
@ -310,10 +293,9 @@ image_policies = [
'method': 'POST'}
],
deprecated_rule=policy.DeprecatedRule(
name="reactivate", check_str="rule:default"
),
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
name="reactivate", check_str="rule:default",
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY),
),
policy.DocumentedRuleDefault(

View File

@ -43,7 +43,7 @@ oslo.log>=4.3.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>=3.6.2 # Apache-2.0
oslo.policy>=3.7.0 # Apache-2.0
retrying!=1.3.0,>=1.2.3 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0