Add deprecation warning to periodic tasks with parallel=False

This setting never made much sense, and with move to Futurist it is
likely to become noop.

Change-Id: Id6341e2cefcd74e0ebfe5a0a8fb32432159743fa
This commit is contained in:
Dmitry Tantsur 2015-08-25 10:29:54 +02:00
parent cd93da0437
commit 55e655a01e
2 changed files with 15 additions and 16 deletions

View File

@ -93,20 +93,18 @@ driver itself or on any interface with driver_periodic_task_ decorator, e.g.
def task2(self, manager, context): def task2(self, manager, context):
pass # do something pass # do something
@base.driver_periodic_task(parallel=False)
def blocking_task(self, manager, context):
pass # do something fast, this blocks other tasks from starting!
Here the ``spacing`` argument is a period in seconds for a given periodic task. Here the ``spacing`` argument is a period in seconds for a given periodic task.
For example 'spacing=5' means every 5 seconds. For example 'spacing=5' means every 5 seconds.
The ``parallel`` argument may be passed to driver_periodic_task_ and defaults .. note::
to True. If False, this task will be run in the periodic task loop, rather The ``parallel`` argument may be passed to driver_periodic_task_.
than a separate greenthread. This should be used with caution, as it will If it's set to False, this task will be run in the periodic task loop,
cause all other periodic tasks to be blocked from starting while the rather than a separate greenthread.
non-parallel task is running. Long running tasks, especially any tasks that
make a remote call (to a BMC, HTTP, etc.) **must** be parallelized. This is deprecated as of Liberty release, and the parallel argument will be
ignored starting in the Mitaka cycle, as such task would prevent all other
periodic tasks from starting while it is is running.
.. note:: .. note::
By default periodic task names are derived from method names, By default periodic task names are derived from method names,

View File

@ -32,7 +32,7 @@ from oslo_utils import excutils
import six import six
from ironic.common import exception from ironic.common import exception
from ironic.common.i18n import _LE from ironic.common.i18n import _LE, _LW
from ironic.common import raid from ironic.common import raid
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -1021,11 +1021,8 @@ def driver_periodic_task(parallel=True, **other):
:param parallel: If True (default), this task is run in a separate thread. :param parallel: If True (default), this task is run in a separate thread.
If False, this task will be run in the conductor's periodic task If False, this task will be run in the conductor's periodic task
loop, rather than a separate greenthread. False should be used with loop, rather than a separate greenthread. This parameter is
caution, as it will cause all other periodic tasks to be blocked deprecated and will be ignored starting with Mitaka cycle.
from starting while the non-parallel task is running. Long running
tasks, especially any tasks that make a remote call (to a BMC,
HTTP, etc.) must be parallelized.
:param other: arguments to pass to @periodic_task.periodic_task :param other: arguments to pass to @periodic_task.periodic_task
""" """
# TODO(dtantsur): drop all this magic once # TODO(dtantsur): drop all this magic once
@ -1042,6 +1039,10 @@ def driver_periodic_task(parallel=True, **other):
eventlet.greenthread.spawn_n(_internal) eventlet.greenthread.spawn_n(_internal)
else: else:
LOG.warn(_LW(
'Using periodic tasks with parallel=False is deprecated, '
'"parallel" argument will be ignored starting with '
'the Mitaka release'))
func(*args, **kwargs) func(*args, **kwargs)
# NOTE(dtantsur): name should be unique # NOTE(dtantsur): name should be unique