Allow Passing of Jitter Values in TimerDriver
For periodic pipelines to not all trigger at the same moment and thus potentially bear a lot of load on a system, we could spread the trigger times by a jitter value. The APScheduler library Zuul uses for timer triggers supports such jitter values. This change allows one to pass that jitter value within the cron-like 'time' parameter of the timer trigger. The optional Jitter parameter can be passed as the last parameter after the optional 'seconds'. Change-Id: I58e756dff6251b49a972b26f7a3a49a8ee5aa70e
This commit is contained in:
@@ -61,7 +61,7 @@ class TimerDriver(Driver, TriggerInterface):
|
||||
continue
|
||||
for timespec in ef.timespecs:
|
||||
parts = timespec.split()
|
||||
if len(parts) < 5 or len(parts) > 6:
|
||||
if len(parts) < 5 or len(parts) > 7:
|
||||
self.log.error(
|
||||
"Unable to parse time value '%s' "
|
||||
"defined in pipeline %s" % (
|
||||
@@ -69,15 +69,21 @@ class TimerDriver(Driver, TriggerInterface):
|
||||
pipeline.name))
|
||||
continue
|
||||
minute, hour, dom, month, dow = parts[:5]
|
||||
# default values
|
||||
second = None
|
||||
jitter = None
|
||||
|
||||
if len(parts) > 5:
|
||||
second = parts[5]
|
||||
else:
|
||||
second = None
|
||||
if len(parts) > 6:
|
||||
jitter = parts[6]
|
||||
|
||||
try:
|
||||
jitter = int(jitter) if jitter is not None else None
|
||||
|
||||
trigger = CronTrigger(day=dom, day_of_week=dow,
|
||||
hour=hour, minute=minute,
|
||||
second=second)
|
||||
second=second, jitter=jitter)
|
||||
except ValueError:
|
||||
self.log.exception(
|
||||
"Unable to create CronTrigger "
|
||||
|
||||
Reference in New Issue
Block a user