File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -230,16 +230,18 @@ func (p *Server) runJob(ctx context.Context, job *proto.AcquiredJob) {
230
230
go func () {
231
231
ticker := time .NewTicker (p .opts .UpdateInterval )
232
232
defer ticker .Stop ()
233
- select {
234
- case <- p .closed :
235
- return
236
- case <- ctx .Done ():
237
- return
238
- case <- p .shutdown :
239
- p .opts .Logger .Info (ctx , "attempting graceful cancelation" )
240
- shutdownCancel ()
241
- return
242
- case <- ticker .C :
233
+ for {
234
+ select {
235
+ case <- p .closed :
236
+ return
237
+ case <- ctx .Done ():
238
+ return
239
+ case <- p .shutdown :
240
+ p .opts .Logger .Info (ctx , "attempting graceful cancelation" )
241
+ shutdownCancel ()
242
+ return
243
+ case <- ticker .C :
244
+ }
243
245
resp , err := p .client .UpdateJob (ctx , & proto.UpdateJobRequest {
244
246
JobId : job .JobId ,
245
247
})
@@ -248,18 +250,18 @@ func (p *Server) runJob(ctx context.Context, job *proto.AcquiredJob) {
248
250
return
249
251
}
250
252
if ! resp .Canceled {
251
- return
253
+ continue
252
254
}
253
255
p .opts .Logger .Info (ctx , "attempting graceful cancelation" )
254
256
shutdownCancel ()
255
257
// Hard-cancel the job after a minute of pending cancelation.
256
258
timer := time .NewTimer (p .opts .ForceCancelInterval )
257
- defer timer .Stop ()
258
259
select {
259
260
case <- timer .C :
260
261
p .failActiveJobf ("cancelation timed out" )
261
262
return
262
263
case <- ctx .Done ():
264
+ timer .Stop ()
263
265
return
264
266
}
265
267
}
You can’t perform that action at this time.
0 commit comments