From 0fc7629865f4eddb702f6bede162441776296619 Mon Sep 17 00:00:00 2001 From: Steven Zou Date: Tue, 7 Apr 2020 17:10:19 +0800 Subject: [PATCH] fix[jobservice]:enqueue job with UTC - schedule the periodical jobs following the UTC timezone - e.g: 5 10 10 * * * means run jobs at UTC time 10:10:05 everyday - fix issue #11466 Signed-off-by: Steven Zou --- src/jobservice/period/enqueuer.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/jobservice/period/enqueuer.go b/src/jobservice/period/enqueuer.go index 9fc40c0c2..256aafb17 100644 --- a/src/jobservice/period/enqueuer.go +++ b/src/jobservice/period/enqueuer.go @@ -33,7 +33,6 @@ import ( const ( enqueuerSleep = 2 * time.Minute enqueuerHorizon = 4 * time.Minute - neverExecuted = 365 * 24 * time.Hour // PeriodicExecutionMark marks the scheduled job to a periodic execution PeriodicExecutionMark = "_job_kind_periodic_" @@ -89,9 +88,6 @@ func (e *enqueuer) loop() { case <-e.context.Done(): return // exit case <-timer.C: - // Pause the timer for completing the processing this time - timer.Reset(neverExecuted) - // Check and enqueue. // Set next turn with lower priority to balance workload with long // round time if it hits. @@ -158,7 +154,8 @@ func (e *enqueuer) enqueue() { // scheduleNextJobs schedules job for next time slots based on the policy func (e *enqueuer) scheduleNextJobs(p *Policy, conn redis.Conn) { - nowTime := time.Unix(time.Now().Unix(), 0) + // Follow UTC time spec + nowTime := time.Unix(time.Now().UTC().Unix(), 0).UTC() horizon := nowTime.Add(enqueuerHorizon) schedule, err := cron.Parse(p.CronSpec)