From 026d71b4d599edd756ba925e99c7e13aff4551cd Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Mon, 24 Mar 2014 14:31:10 -0700 Subject: [PATCH] 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 --- ironic/common/service.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ironic/common/service.py b/ironic/common/service.py index b8a83c7dd6..14e019a06e 100644 --- a/ironic/common/service.py +++ b/ironic/common/service.py @@ -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=[]):