Deprecate CONF.monkey_patch

This option, along with monkey_patch_modules, is
arguably worse than hooks since it doesn't even
rely on having in-tree code. It's super legacy,
not tested, not supported and is a barrier to
interoperability, so we should deprecate it for
removal.

This also allows us to deprecate the default_publisher_id
option which is used for the legacy notify_decorator
which is only used if specified with the monkey_patch_modules
option, which is also deprecated here.

Also removed the nova.api.ec2.cloud mention from the
config option help text for monkey_patch_modules
since that isn't valid in nova anymore.

Change-Id: Id793ac2c5cdc5dc473f95eac53b77617a1e389da
This commit is contained in:
Matt Riedemann 2017-08-25 18:21:57 -04:00
parent 1080506f16
commit a3bc1b067b
5 changed files with 42 additions and 2 deletions

View File

@ -63,6 +63,12 @@ entry.
cfg.BoolOpt(
'monkey_patch',
default=False,
deprecated_for_removal=True,
deprecated_since='17.0.0',
deprecated_reason="""
Monkey patching nova is not tested, not supported, and is a barrier
for interoperability.
""",
help="""
Determine if monkey patching should be applied.
@ -74,6 +80,12 @@ Related options:
cfg.ListOpt(
'monkey_patch_modules',
default=['nova.compute.api:nova.notifications.notify_decorator'],
deprecated_for_removal=True,
deprecated_since='17.0.0',
deprecated_reason="""
Monkey patching nova is not tested, not supported, and is a barrier
for interoperability.
""",
help="""
List of modules/decorators to monkey patch.
@ -83,7 +95,6 @@ modules.
Possible values:
* nova.compute.api:nova.notifications.notify_decorator
* nova.api.ec2.cloud:nova.notifications.notify_decorator
* [...]
Related options:

View File

@ -67,6 +67,14 @@ API service.
'default_publisher_id',
default='$my_ip',
deprecated_group='DEFAULT',
deprecated_for_removal=True,
deprecated_since='17.0.0',
deprecated_reason="""
This option is only used when ``monkey_patch=True`` and
``monkey_patch_modules`` is configured to specify the legacy notify_decorator.
Since the monkey_patch and monkey_patch_modules options are deprecated, this
option is also deprecated.
""",
help="""
Default publisher_id for outgoing notifications. If you consider routing
notifications using different publisher, change this value accordingly.

View File

@ -46,6 +46,8 @@ LOG = log.getLogger(__name__)
CONF = nova.conf.CONF
# TODO(mriedem): Remove this when CONF.monkey_patch, CONF.monkey_patch_modules
# and CONF.default_publisher_id are removed in Rocky.
def notify_decorator(name, fn):
"""Decorator for notify which is used from utils.monkey_patch().

View File

@ -498,8 +498,9 @@ def format_remote_path(host, path):
return "%s:%s" % (safe_ip_format(host), path)
# TODO(mriedem): Remove this in Rocky.
def monkey_patch():
"""If the CONF.monkey_patch set as True,
"""DEPRECATED: If the CONF.monkey_patch set as True,
this function patches a decorator
for all functions in specified modules.
You can set decorators for each modules
@ -517,6 +518,7 @@ def monkey_patch():
# If CONF.monkey_patch is not True, this function do nothing.
if not CONF.monkey_patch:
return
LOG.warning('Monkey patching nova is deprecated for removal.')
if six.PY2:
is_method = inspect.ismethod
else:

View File

@ -0,0 +1,17 @@
---
deprecations:
- |
The following configuration options are deprecated for removal:
- ``[DEFAULT]/monkey_patch``
- ``[DEFAULT]/monkey_patch_modules``
Monkey patching nova is not tested, not supported, and is a barrier to
interoperability. If you have code which relies on monkey patching
decorators, for example, for notifications, please propose those changes
upstream.
As a result, the following option is also deprecated for removal since it
is only used when specified with ``[DEFAULT]/monkey_patch_modules``:
- ``[notifications]/default_publisher_id``