Run periodic_task in a with a dynamic timer

In ironic.common.service, Ironic was running the periodic task loop
every periodic_interval (60s by default) seconds. This means that any
periodic task configured with an interval shorter than periodic_interval
was only getting run every periodic_interval seconds.

I reconfigured periodic tasks to run in a dynamic loop, where
now the periodic task loop will run every min(periodic_interval,
next_run) seconds.

Change-Id: I17a270ecbb5fd53149a89816f4be1c9a0c27b541
Closes-Bug: 1295874
This commit is contained in:
Jay Faulkner 2014-03-24 14:31:10 -07:00 committed by Devananda van der Veen
parent d1293ba400
commit 026d71b4d5

View File

@ -48,9 +48,10 @@ class PeriodicService(rpc_service.Service, periodic_task.PeriodicTasks):
def start(self):
super(PeriodicService, self).start()
admin_context = context.RequestContext('admin', 'admin', is_admin=True)
self.tg.add_timer(cfg.CONF.periodic_interval,
self.manager.periodic_tasks,
context=admin_context)
self.tg.add_dynamic_timer(
self.manager.periodic_tasks,
periodic_interval_max=cfg.CONF.periodic_interval,
context=admin_context)
def prepare_service(argv=[]):