Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refining status when Condition failed #1696

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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