Skip to content

Commit

Permalink
fix: try to resolve waiting steps at the end of the main loop
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Bétrancourt <thomas@betrancourt.net>
  • Loading branch information
rclsilver committed Jul 31, 2023
1 parent 4ce3e42 commit 6042fc2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ func resolve(dbp zesty.DBProvider, res *resolution.Resolution, t *task.Task, sm
stepChan := make(chan *step.Step)

expectedMessages := runAvailableSteps(dbp, map[string]bool{}, res, t, stepChan, executedSteps, []string{}, wg, debugLogger)
recheckWaiting := true

forLoop:
for expectedMessages > 0 {
Expand Down Expand Up @@ -521,6 +522,21 @@ forLoop:
// from candidate resolution states, choose a resolution state by priority
for _, status := range []string{resolution.StateCrashed, resolution.StateBlockedFatal, resolution.StateBlockedBadRequest, resolution.StateError, resolution.StateWaiting, resolution.StateBlockedDeadlock, resolution.StateToAutorunDelayed} {
if mapStatus[status] {
if status == resolution.StateWaiting && recheckWaiting {
for name, s := range res.Steps {
if s.State == step.StateWaiting {
delete(executedSteps, name)
}
}

expectedMessages = runAvailableSteps(dbp, map[string]bool{}, res, t, stepChan, executedSteps, []string{}, wg, debugLogger)
recheckWaiting = false

debugLogger.Debugf("Engine: resolve() %s loop, try to resolve %d waiting step(s)", res.PublicID, expectedMessages)

goto forLoop
}

res.SetState(status)
break
}
Expand Down

0 comments on commit 6042fc2

Please sign in to comment.