Make periodic task spacing configurable
Change-Id: I1e35b3538e8656756588e2b94a02756704ccf76b Closes-Bug: #1745077
This commit is contained in:
parent
6270eb3615
commit
e012c0122a
|
@ -26,8 +26,24 @@ periodic_opts = [
|
|||
default=180,
|
||||
help='Max interval size between periodic tasks execution in '
|
||||
'seconds.'),
|
||||
cfg.IntOpt('sync_container_state_interval',
|
||||
default=60,
|
||||
help="""
|
||||
Interval to sync container states between the database and the docker.
|
||||
|
||||
The interval that Zun checks the actual container state and
|
||||
the state that Zun has recorded in its database. If they are inconsistent,
|
||||
Zun will update the database according to the actual container state.
|
||||
|
||||
Possible values:
|
||||
* 0: Will run at the default periodic interval.
|
||||
* Any value < 0: Disables the option.
|
||||
* Any positive integer in seconds.
|
||||
|
||||
"""),
|
||||
]
|
||||
|
||||
|
||||
ALL_OPTS = (periodic_opts)
|
||||
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@ from oslo_log import log
|
|||
from oslo_service import periodic_task
|
||||
|
||||
from zun.common import context
|
||||
import zun.conf
|
||||
from zun.container import driver
|
||||
from zun import objects
|
||||
|
||||
CONF = zun.conf.CONF
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -39,7 +42,8 @@ class ContainerStateSyncPeriodicJob(periodic_task.PeriodicTasks):
|
|||
conf.container_driver)
|
||||
super(ContainerStateSyncPeriodicJob, self).__init__(conf)
|
||||
|
||||
@periodic_task.periodic_task(run_immediately=True)
|
||||
@periodic_task.periodic_task(spacing=CONF.sync_container_state_interval,
|
||||
run_immediately=True)
|
||||
@set_context
|
||||
def sync_container_state(self, ctx):
|
||||
LOG.debug('Start syncing container states.')
|
||||
|
|
Loading…
Reference in New Issue