Skip to content

Commit

Permalink
fix: handle optional steps (#5922)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 authored Oct 14, 2024
1 parent f303b6e commit 9b92457
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions pkg/api/v1/testkube/model_test_workflow_result_extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,16 @@ func (r *TestWorkflowResult) HealMissingPauseStatuses() {
}
}

func (r *TestWorkflowResult) healPredictedStatus() {
func isStepOptional(sigSequence []TestWorkflowSignature, ref string) bool {
for i := range sigSequence {
if sigSequence[i].Ref == ref {
return sigSequence[i].Optional
}
}
return false
}

func (r *TestWorkflowResult) healPredictedStatus(sigSequence []TestWorkflowSignature) {
// Mark as aborted, when any step is aborted
if r.IsAnyStepAborted() || r.Initialization.Status.AnyError() {
r.PredictedStatus = common.Ptr(ABORTED_TestWorkflowStatus)
Expand All @@ -343,7 +352,7 @@ func (r *TestWorkflowResult) healPredictedStatus() {

// Determine if there are some steps failed
for ref := range r.Steps {
if r.Steps[ref].Status != nil && r.Steps[ref].Status.AnyError() {
if r.Steps[ref].Status.Aborted() || (r.Steps[ref].Status.AnyError() && !isStepOptional(sigSequence, ref)) {
r.PredictedStatus = common.Ptr(FAILED_TestWorkflowStatus)
return
}
Expand All @@ -361,8 +370,8 @@ func (r *TestWorkflowResult) healStatus() {
}
}

func (r *TestWorkflowResult) HealStatus() {
r.healPredictedStatus()
func (r *TestWorkflowResult) HealStatus(sigSequence []TestWorkflowSignature) {
r.healPredictedStatus(sigSequence)
r.healStatus()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/testworkflows/testworkflowcontroller/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (n *notifier) reconcile() {
n.result.HealTimestamps(n.sigSequence, n.scheduledAt, containerStartTs, completionTs, n.ended)
n.result.HealDuration()
n.result.HealMissingPauseStatuses()
n.result.HealStatus()
n.result.HealStatus(n.sigSequence)
}

// TODO: Optimize memory
Expand Down

0 comments on commit 9b92457

Please sign in to comment.