Skip to content

Commit

Permalink
fix(step): Prevented step's conditions from being evaluated when the …
Browse files Browse the repository at this point in the history
…step isn't in a final state

Signed-off-by: Ruben Tordjman <[email protected]>
  • Loading branch information
Ruben Tordjman authored and rclsilver committed Jan 24, 2024
1 parent f9892e1 commit 3cde7b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion engine/step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -65,6 +66,7 @@ var (
stepConditionValidStates = []string{StateDone, StatePrune, StateToRetry, StateRetryNow, StateFatalError, StateClientError}
runnableStates = []string{StateTODO, StateServerError, StateClientError, StateFatalError, StateCrashed, StateToRetry, StateRetryNow, StateAfterrunError, StateExpanded, StateWaiting} // everything but RUNNING, DONE, PRUNE
retriableStates = []string{StateServerError, StateToRetry, StateAfterrunError}
validAfterRunStates = []string{StateDone, StateClientError, StateAfterrunError}
)

// Step describes one unit of work within a task, and its dependency to other steps
Expand Down Expand Up @@ -531,7 +533,8 @@ func PreRun(st *Step, values *values.Values, ss StateSetter, executedSteps map[s
// AfterRun evaluates a step's "check" conditions after the Step's action has been performed
// and impacts the entire task's execution flow through the provided StateSetter
func AfterRun(st *Step, values *values.Values, ss StateSetter) {
if st.skipped || st.State == StateServerError || st.State == StateFatalError || st.ForEach != "" {
// Not all steps' states should trigger evaluation of AfterRun conditions
if st.skipped || st.ForEach != "" || !slices.Contains(validAfterRunStates, st.State) {
return
}

Expand Down

0 comments on commit 3cde7b6

Please sign in to comment.