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 authored and tekton-robot committed Feb 19, 2020
1 parent aedea67 commit 837fe54
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const (
// completed successfully
ReasonSucceeded = "Succeeded"

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

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

allTasks := []string{}
successOrSkipTasks := []string{}
skipTasks := int(0)

// 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) {
skipTasks++
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 skipTasks != 0 {
reason = ReasonCompleted
}

return &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: ReasonSucceeded,
Message: "All Tasks have completed executing",
Reason: reason,
Message: fmt.Sprintf("Tasks Completed: %d, Skipped: %d", len(successOrSkipTasks)-skipTasks, skipTasks),
}
}

Expand All @@ -436,7 +450,7 @@ func GetPipelineConditionStatus(pr *v1alpha1.PipelineRun, state PipelineRunState
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: ReasonRunning,
Message: "Not all Tasks in the Pipeline have finished executing",
Message: fmt.Sprintf("Tasks Completed: %d, Incomplete: %d, Skipped: %d", len(successOrSkipTasks)-skipTasks, len(allTasks)-len(successOrSkipTasks), skipTasks),
}
}

Expand Down

0 comments on commit 837fe54

Please sign in to comment.