From a034d2d8f55a8bf7e96e7d6b79a2c948a7df265c Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 21 Nov 2017 17:37:49 +0100 Subject: polling: run polling tasks immediately on start When Ceilometer polling agent start, one has to wait N seconds for the first polling to happen. This makes testing extremely difficult. I can't see any good reason to not poll at (re)start. Since the last run time is lost anyway, the interval will never be perfect. So at least let's make it convenient by polling on startup. Also set a default random 0-10 seconds delay before the first poll so if a lot of daemons are started at the same time they don't all hit the same endpoint at the same time. Change-Id: I0741a586cec499c259f0e90977f185c4e68a99d3 --- ceilometer/polling/manager.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ceilometer/polling') diff --git a/ceilometer/polling/manager.py b/ceilometer/polling/manager.py index 89e983a5..93d16d12 100644 --- a/ceilometer/polling/manager.py +++ b/ceilometer/polling/manager.py @@ -50,7 +50,7 @@ OPTS = [ 'throughput at the cost of load set this to False.'), cfg.FloatOpt('shuffle_time_before_polling_task', min=0, - default=0, + default=10, help='To reduce large requests at same time to Nova or other ' 'components from different compute agents, shuffle ' 'start time of polling task.'), @@ -379,13 +379,12 @@ class AgentManager(cotyledon.Service): futures.ThreadPoolExecutor(max_workers=len(data))) for interval, polling_task in data.items(): - delay_time = interval + delay_polling_time - @periodics.periodic(spacing=interval, run_immediately=False) + @periodics.periodic(spacing=interval, run_immediately=True) def task(running_task): self.interval_task(running_task) - utils.spawn_thread(utils.delayed, delay_time, + utils.spawn_thread(utils.delayed, delay_polling_time, self.polling_periodics.add, task, polling_task) utils.spawn_thread(self.polling_periodics.start, allow_empty=True) -- cgit v1.2.1