From a3bc1b067b4434a894288410201dc9c03aa7a50b Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Fri, 25 Aug 2017 18:21:57 -0400 Subject: [PATCH] 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 --- nova/conf/base.py | 13 ++++++++++++- nova/conf/notifications.py | 8 ++++++++ nova/notifications/base.py | 2 ++ nova/utils.py | 4 +++- ...deprecate-monkey-patch-5cd654924694b9ae.yaml | 17 +++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/deprecate-monkey-patch-5cd654924694b9ae.yaml diff --git a/nova/conf/base.py b/nova/conf/base.py index 98dd21c8c2..d8ca1f56d6 100644 --- a/nova/conf/base.py +++ b/nova/conf/base.py @@ -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: diff --git a/nova/conf/notifications.py b/nova/conf/notifications.py index 42fae1a85f..a1381c16fb 100644 --- a/nova/conf/notifications.py +++ b/nova/conf/notifications.py @@ -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. diff --git a/nova/notifications/base.py b/nova/notifications/base.py index 8396b63779..1421e74592 100644 --- a/nova/notifications/base.py +++ b/nova/notifications/base.py @@ -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(). diff --git a/nova/utils.py b/nova/utils.py index c55cdabc94..6ee945b035 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -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: diff --git a/releasenotes/notes/deprecate-monkey-patch-5cd654924694b9ae.yaml b/releasenotes/notes/deprecate-monkey-patch-5cd654924694b9ae.yaml new file mode 100644 index 0000000000..3b46a235e2 --- /dev/null +++ b/releasenotes/notes/deprecate-monkey-patch-5cd654924694b9ae.yaml @@ -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``