Skip to content

Commit

Permalink
Set status to succeeded when the reason is Completed
Browse files Browse the repository at this point in the history
When a task is skipped, the reason becomes Completed, which shows as
succeeded (Completed). This can be confusing compared to other tasks
that are succeeded but not completed.

Users would not be able to tell the difference when they essentially
mean the same thing.

Therefore, set the status to succeeded when the reason is Completed
without displaying the reason.
  • Loading branch information
chmouel authored and tekton-robot committed Nov 6, 2024
1 parent 5e60e38 commit 630441f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/formatted/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func Condition(c v1.Conditions) string {
status = "Running"
}

if c[0].Reason != "" && c[0].Reason != status {
if c[0].Reason == "Completed" && status == "Succeeded" {
return ColorStatus(status)
} else if c[0].Reason != "" && c[0].Reason != status {
switch c[0].Reason {
case "PipelineRunCancelled", "TaskRunCancelled", "Cancelled":
return ColorStatus("Cancelled") + "(" + c[0].Reason + ")"
Expand Down
9 changes: 9 additions & 0 deletions pkg/formatted/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ func TestCondition(t *testing.T) {
}},
want: "Running",
},
{
name: "PipelineRunCompleted status reason",
condition: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: "Completed",
}},
want: "Succeeded",
},
{
name: "PipelineRunCanceled status reason",
condition: []apis.Condition{{
Expand Down

0 comments on commit 630441f

Please sign in to comment.