From 3471ec993c42530ec951991765b8736726dd7e51 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Tue, 8 Mar 2016 14:04:17 +0100 Subject: [PATCH] Officially deprecate rollback for introspection rules This was designed to clean up action effects, but proved too confusing. We should recommend using explicit clean up action instead. Change-Id: Ia414979956cc0cbd5ed040831c49dba18671f86d --- CONTRIBUTING.rst | 4 ---- doc/source/usage.rst | 2 -- ironic_inspector/plugins/base.py | 10 +++++++++- ironic_inspector/plugins/example.py | 3 --- .../notes/deprecate-rollback-dea95ac515d3189b.yaml | 4 ++++ 5 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/deprecate-rollback-dea95ac515d3189b.yaml diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 8ffb57304..3d2cc3bad 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -268,10 +268,6 @@ Writing a Plugin The following methods and attributes may also be overridden: - ``rollback(node_info,params,**)`` - called to clean up when conditions were not met. - Default implementation does nothing. - ``validate(params,**)`` called to validate parameters provided during actions creating. Default implementation requires keys listed in ``REQUIRED_PARAMS`` (and diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 887ce3dcd..cfdd6b949 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -49,8 +49,6 @@ them automatically after running all processing hooks. A rule consists of conditions to check, and actions to run. If conditions evaluate to true on the introspection data, then actions are run on a node. -All actions have "rollback actions" associated with them, which are run when -conditions evaluate to false. This way we can safely rerun introspection. Available conditions and actions are defined by plugins, and can be extended, see :ref:`contributing_link` for details. See :ref:`api` for specific calls diff --git a/ironic_inspector/plugins/base.py b/ironic_inspector/plugins/base.py index c7834c52c..218f7f45b 100644 --- a/ironic_inspector/plugins/base.py +++ b/ironic_inspector/plugins/base.py @@ -16,13 +16,15 @@ import abc from oslo_config import cfg +from oslo_log import log import six import stevedore -from ironic_inspector.common.i18n import _ +from ironic_inspector.common.i18n import _, _LW CONF = cfg.CONF +LOG = log.getLogger(__name__) @six.add_metaclass(abc.ABCMeta) @@ -195,4 +197,10 @@ def rule_actions_manager(): _ACTIONS_MGR = stevedore.ExtensionManager( 'ironic_inspector.rules.actions', invoke_on_load=True) + for act in _ACTIONS_MGR: + # a trick to detect if function was overriden + if "rollback" in act.obj.__class__.__dict__: + LOG.warning(_LW('Defining "rollback" for introspection rules ' + 'actions is deprecated (action "%s")'), + act.name) return _ACTIONS_MGR diff --git a/ironic_inspector/plugins/example.py b/ironic_inspector/plugins/example.py index 45d741575..e4f749619 100644 --- a/ironic_inspector/plugins/example.py +++ b/ironic_inspector/plugins/example.py @@ -37,6 +37,3 @@ def example_not_found_hook(introspection_data, **kwargs): class ExampleRuleAction(base.RuleActionPlugin): # pragma: no cover def apply(self, node_info, params, **kwargs): LOG.debug('apply action to %s: %s', node_info.uuid, params) - - def rollback(self, node_info, params, **kwargs): - LOG.debug('rollback action to %s: %s', node_info.uuid, params) diff --git a/releasenotes/notes/deprecate-rollback-dea95ac515d3189b.yaml b/releasenotes/notes/deprecate-rollback-dea95ac515d3189b.yaml new file mode 100644 index 000000000..9cbedf95c --- /dev/null +++ b/releasenotes/notes/deprecate-rollback-dea95ac515d3189b.yaml @@ -0,0 +1,4 @@ +--- +deprecations: + - The rollback actions for introspection rules are deprecated. No in-tree + actions are using them, 3rdpart should stop using them as soon as possible.