Skip to content

Commit 68cfb15

Browse files
miltalexteo
authored andcommitted
[executor] set timeout to 15s for OCC transition
1 parent f9fbbd4 commit 68cfb15

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

executor/executable/controllabletask.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -392,35 +392,32 @@ func (t *ControllableTask) Kill() error {
392392
"targetList": cmd.TargetList,
393393
}).
394394
Debug("state DONE not reached, about to commit transition")
395-
395+
396396
// Call cmd.Commit() asynchronous
397397
commitDone := make(chan *CommitResponse)
398-
go func() {
398+
go func() {
399399
var cr CommitResponse
400400
cr.newState, cr.transitionError = cmd.Commit()
401401
commitDone <- &cr
402402
}()
403403

404-
// Set timeout cause OCC is locking up so killing is not possible. The following approach
405-
// help us to bypass the OCC transition, so we can kill the tasks on force destroy env.
406-
// Currently this will run for every Kill message receive (force or not).
407-
// TODO: Find a better way to distinguish force from plain Kill message.
408-
var _cr *CommitResponse
404+
// Set timeout cause OCC is locking up so killing is not possible.
405+
var commitResponse *CommitResponse
409406
select {
410-
case _cr = <- commitDone:
411-
case <-time.After(45 * time.Second):
407+
case commitResponse = <- commitDone:
408+
case <-time.After(15 * time.Second):
412409
log.Error("deadline exceeded")
413410
break
414-
}
411+
}
415412

416-
log.WithField("newState", _cr.newState).
417-
WithError(_cr.transitionError).
413+
log.WithField("newState", commitResponse.newState).
414+
WithError(commitResponse.transitionError).
418415
Debug("transition committed")
419-
if _cr.transitionError != nil || len(cmd.Event) == 0 {
420-
log.WithError(_cr.transitionError).Error("cannot gracefully end task")
416+
if commitResponse.transitionError != nil || len(cmd.Event) == 0 {
417+
log.WithError(commitResponse.transitionError).Error("cannot gracefully end task")
421418
break
422419
}
423-
reachedState = _cr.newState
420+
reachedState = commitResponse.newState
424421
}
425422

426423
log.Debug("end transition loop done")

0 commit comments

Comments
 (0)