Skip to content

Commit

Permalink
chore: handle canary cron entry mgmt
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Jul 1, 2023
1 parent 590de90 commit ee1410e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/jobs/canary/canary_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,20 @@ func SyncCanaryJob(canary v1.Canary) error {
}

// Schedule canary for the first time
_, err = CanaryScheduler.AddJob(canary.Spec.GetSchedule(), job)
entryID, err := CanaryScheduler.AddJob(canary.Spec.GetSchedule(), job)
if err != nil {
return fmt.Errorf("failed to schedule canary %s/%s: %v", canary.Namespace, canary.Name, err)
}
entryPtr := CanaryScheduler.Entry(entryID)
entry = &entryPtr
logger.Infof("Scheduled %s: %s", canary, canary.Spec.GetSchedule())

canaryUpdateTimeCache[dbCanary.ID.String()] = dbCanary.UpdatedAt
}

//Run all regularly scheduled canaries on startup (<1h) and not daily/weekly schedules
// Run all regularly scheduled canaries on startup (<1h) and not daily/weekly schedules
if entry != nil && time.Until(entry.Next) < 1*time.Hour && !exists {
job = entry.Job.(CanaryJob)
go job.Run()
go entry.Job.Run()
}

return nil
Expand Down

0 comments on commit ee1410e

Please sign in to comment.