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 cca81a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 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,8 @@ 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() {
optional := isStepOptional(sigSequence, ref)
if r.Steps[ref].Status != nil && ((optional && r.Steps[ref].Status.Aborted()) || (!optional && r.Steps[ref].Status.AnyError())) {
r.PredictedStatus = common.Ptr(FAILED_TestWorkflowStatus)
return
}
Expand All @@ -361,8 +371,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 cca81a0

Please sign in to comment.