Skip to content

Commit

Permalink
Refactored phase status checking. (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
harryge00 authored and alenkacz committed Jan 21, 2020
1 parent e737ccd commit 23f0c85
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions pkg/engine/workflow/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func Execute(pl *ActivePlan, em *engine.Metadata, c client.Client, enh renderer.
}

// Check current phase status: skip if finished, proceed if in progress, break out if a fatal error has occurred
if isFinished(phaseStatus.Status) {
if phaseStatus.Status.IsFinished() {
phasesLeft = phasesLeft - 1
continue
} else if isInProgress(phaseStatus.Status) {
} else if phaseStatus.Status.IsRunning() {
phaseStatus.Set(v1beta1.ExecutionInProgress)
} else {
break
Expand All @@ -112,10 +112,10 @@ func Execute(pl *ActivePlan, em *engine.Metadata, c client.Client, enh renderer.
}

// Check current phase status: skip if finished, proceed if in progress, break out if a fatal error has occurred
if isFinished(stepStatus.Status) {
if stepStatus.Status.IsFinished() {
delete(stepsLeft, stepStatus.Name)
continue
} else if isInProgress(stepStatus.Status) {
} else if stepStatus.Status.IsRunning() {
stepStatus.Set(v1beta1.ExecutionInProgress)
} else {
// we are not in progress and not finished. An unexpected error occurred so that we can not proceed to the next phase
Expand Down Expand Up @@ -278,11 +278,3 @@ func getPhaseStatus(phaseName string, planStatus *v1beta1.PlanStatus) *v1beta1.P

return nil
}

func isFinished(state v1beta1.ExecutionStatus) bool {
return state == v1beta1.ExecutionComplete
}

func isInProgress(state v1beta1.ExecutionStatus) bool {
return state == v1beta1.ExecutionInProgress || state == v1beta1.ExecutionPending || state == v1beta1.ErrorStatus
}

0 comments on commit 23f0c85

Please sign in to comment.