[goal] Deprecate the JSON formatted policy file

As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also replace policy.json to policy.yaml ref from doc and tests.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Change-Id: Ibb26169656785330e7d86a362fd110222fb63a07
This commit is contained in:
Ghanshyam Mann 2020-12-20 18:08:59 -06:00 committed by Martin Chacon Piza
parent 99f6cf2b1c
commit c491b34888
5 changed files with 38 additions and 10 deletions

View File

@ -24,12 +24,12 @@ netaddr==0.7.20
netifaces==0.10.4
os-client-config==1.28.0
os-testr==1.0.0
oslo.config==5.2.0
oslo.context==2.19.2
oslo.config==6.8.0
oslo.context==2.22.0
oslo.i18n==3.15.3
oslo.policy==1.30.0
oslo.policy==3.6.0
oslo.serialization==2.18.0
oslo.utils==3.33.0
oslo.utils==4.5.0
oslotest==3.2.0
pbr==2.0.0
PyMySQL==0.8.0
@ -37,11 +37,11 @@ pyparsing==2.1.0
python-mimeparse==1.6.0
python-subunit==1.0.0
pytz==2013.6
PyYAML==3.13
requests==2.14.2
PyYAML==5.1
requests==2.20.0
requests-mock==1.2.0
requestsexceptions==1.2.0
rfc3986==0.3.1
rfc3986==1.2.0
simplejson==3.13.2
smmap==0.9.0
stestr==1.0.0

View File

@ -22,6 +22,7 @@ import sys
import logging
from oslo_config import cfg
from oslo_policy import opts
from oslo_policy import policy
from monasca_common.policy.i18n import _LW
@ -41,6 +42,13 @@ _ENFORCER = None
saved_file_rules = []
# TODO(gmann): Remove setting the default value of config policy_file
# once oslo_policy change the default value to 'policy.yaml'.
# https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49
DEFAULT_POLICY_FILE = 'policy.yaml'
opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE)
def reset():
"""Reset Enforcer class."""
global _ENFORCER

View File

@ -0,0 +1,20 @@
---
upgrade:
- |
The default value of ``[oslo_policy] policy_file`` config option has
been changed from ``policy.json`` to ``policy.yaml``.
Operators who are utilizing customized or previously generated
static policy JSON files (which are not needed by default), should
generate new policy files or convert them in YAML format. Use the
`oslopolicy-convert-json-to-yaml
<https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html>`_
tool to convert a JSON to YAML formatted policy file in
backward compatible way.
deprecations:
- |
Use of JSON policy files was deprecated by the ``oslo.policy`` library
during the Victoria development cycle. As a result, this deprecation is
being noted in the Wallaby cycle with an anticipated future removal of support
by ``oslo.policy``. As such operators will need to convert to YAML policy
files. Please see the upgrade notes for details on migration of any
custom policy files.

View File

@ -3,8 +3,8 @@
# process, which may cause wedges in the gate later.
kazoo>=2.8.0 # Apache-2.0
PyMySQL>=0.8.0 # MIT License
oslo.config>=5.2.0 # Apache-2.0
oslo.policy>=1.30.0 # Apache-2.0
oslo.config>=6.8.0 # Apache-2.0
oslo.policy>=3.6.0 # Apache-2.0
pbr!=2.1.0,>=2.0.0 # Apache-2.0
pyparsing>=2.1.0 # MIT
simplejson>=3.13.2 # MIT

View File

@ -8,7 +8,7 @@ Babel!=2.4.0,>=2.3.4 # BSD
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
httplib2>=0.9.1 # MIT
oslo.context>=2.19.2 # Apache-2.0
oslo.context>=2.22.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0
stestr>=1.0.0 # Apache-2.0
requests-mock>=1.2.0 # Apache-2.0