Skip to content

Commit

Permalink
fix: handle optional steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Oct 11, 2024
1 parent df7575b commit fb3dd1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions pkg/api/v1/testkube/model_test_workflow_result_extended.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,27 @@ func (r *TestWorkflowResult) HealMissingPauseStatuses() {
}
}

func (r *TestWorkflowResult) healPredictedStatus() {
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)
return
}

// Determine if there are some steps failed
loop:
for ref := range r.Steps {
// Ignore optional steps
for i := range sigSequence {
if sigSequence[i].Ref == ref {
if sigSequence[i].Optional {
continue loop
}
break
}
}

// Predict failure on step error
if r.Steps[ref].Status != nil && r.Steps[ref].Status.AnyError() {
r.PredictedStatus = common.Ptr(FAILED_TestWorkflowStatus)
return
Expand All @@ -361,8 +373,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 fb3dd1a

Please sign in to comment.