Skip to content

Commit

Permalink
Refining status when Condition failed
Browse files Browse the repository at this point in the history
Introduce new state: `ReasonSucceededWithConditionCheckFailed`, indicates the scenario `pipeline` succeeded but with `Condition` checking failed.
  • Loading branch information
vincent-pli committed Dec 6, 2019
1 parent fb36ff3 commit fc0362c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const (
// completed successfully
ReasonSucceeded = "Succeeded"

// ReasonSucceededWithConditionCheckFailed indicates that the reason for the finished status is that all of the TaskRuns
// completed successfully but with some conditions checking failed
ReasonSucceededWithConditionCheckFailed = "SucceededWithConditionCheckFailed"

// ReasonTimedOut indicates that the PipelineRun has taken longer than its configured
// timeout
ReasonTimedOut = "PipelineRunTimeout"
Expand Down Expand Up @@ -348,21 +352,31 @@ func GetPipelineConditionStatus(pr *v1alpha1.PipelineRun, state PipelineRunState

allTasks := []string{}
successOrSkipTasks := []string{}
hasSkipped := false

// Check to see if all tasks are success or skipped
for _, rprt := range state {
allTasks = append(allTasks, rprt.PipelineTask.Name)
if rprt.IsSuccessful() || isSkipped(rprt, state.toMap(), dag) {
if rprt.IsSuccessful() {
successOrSkipTasks = append(successOrSkipTasks, rprt.PipelineTask.Name)
}
if isSkipped(rprt, state.toMap(), dag) {
hasSkipped = true
successOrSkipTasks = append(successOrSkipTasks, rprt.PipelineTask.Name)
}
}

if reflect.DeepEqual(allTasks, successOrSkipTasks) {
logger.Infof("All TaskRuns have finished for PipelineRun %s so it has finished", pr.Name)
reason := ReasonSucceeded
if hasSkipped {
reason = ReasonSucceededWithConditionCheckFailed
}

return &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: ReasonSucceeded,
Reason: reason,
Message: "All Tasks have completed executing",
}
}
Expand Down

0 comments on commit fc0362c

Please sign in to comment.