@@ -206,12 +206,12 @@ func (jm *JobManager) createDescriptorSourceAndgRPCMethod(
206206}
207207
208208// createJobFunction returns a function that the job scheduler puts on its queue.
209- func (jm * JobManager ) createJobFunction (jc config.JobConfig ) func () error {
209+ func (jm * JobManager ) createJobFunction (jc config.JobConfig ) func (ctx context. Context ) error {
210210 jobLogger := jm .logger .Sublogger (jc .Name )
211211 // To support logging for quick jobs (~ on the seconds schedule), we disable log
212212 // deduplication for job loggers.
213213 jobLogger .NeverDeduplicate ()
214- return func () error {
214+ return func (ctx context. Context ) error {
215215 res , err := jm .getResource (jc .Resource )
216216 if err != nil {
217217 jobLogger .CWarnw (jm .ctx , "Could not get resource" , "error" , err .Error ())
@@ -362,6 +362,7 @@ func (jm *JobManager) scheduleJob(jc config.JobConfig, verbose bool) {
362362 // queued on the job scheduler, while CRON jobs are tied to the physical clock.
363363 gocron .WithSingletonMode (jobLimitMode ),
364364 gocron .WithName (jc .Name ),
365+ gocron .WithContext (jm .ctx ),
365366 gocron .WithEventListeners (
366367 // May be slightly more accurate to use j.LastRun(), but we don't have direct reference to it here, and we don't want the job to
367368 // complete before we can store the returned Job.
0 commit comments