Skip to content

Commit

Permalink
Add message and reason fields for each stage of a taskRun. This will …
Browse files Browse the repository at this point in the history
…add consistency for the fields present in the resource definition at different stages. Closes#981
  • Loading branch information
steveodonovan authored and tekton-robot committed Jul 8, 2019
1 parent 196a945 commit 578a426
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/reconciler/v1alpha1/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ func TestReconcilePodUpdateStatus(t *testing.T) {
if d := cmp.Diff(newTr.Status.GetCondition(apis.ConditionSucceeded), &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: status.ReasonSucceeded,
Message: "All Steps have completed executing",
}, ignoreLastTransitionTime); d != "" {
t.Errorf("Taskrun Status diff -got, +want: %v", d)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/status/taskrunpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ func updateCompletedTaskRun(taskRun *v1alpha1.TaskRun, pod *corev1.Pod) {
taskRun.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: ReasonFailed,
Message: msg,
})
} else {
taskRun.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: ReasonSucceeded,
Message: "All Steps have completed executing",
})
}
// update tr completed time
Expand All @@ -78,6 +81,7 @@ func updateIncompleteTaskRun(taskRun *v1alpha1.TaskRun, pod *corev1.Pod) {
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: ReasonBuilding,
Message: "Not all Steps in the Task have finished executing",
})
case corev1.PodPending:
var reason, msg string
Expand Down
6 changes: 6 additions & 0 deletions pkg/status/taskrunpod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ func TestUpdateStatusFromPod(t *testing.T) {
conditionTrue := apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionTrue,
Reason: ReasonSucceeded,
Message: "All Steps have completed executing",
}
conditionBuilding := apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: ReasonBuilding,
Message: "Not all Steps in the Task have finished executing",
}
for _, c := range []struct {
desc string
Expand Down Expand Up @@ -177,6 +180,7 @@ func TestUpdateStatusFromPod(t *testing.T) {
Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: ReasonFailed,
Message: `"step-failure" exited with code 123 (image: "image-id"); for logs run: kubectl -n foo logs pod -c step-failure`,
}},
},
Expand All @@ -201,6 +205,7 @@ func TestUpdateStatusFromPod(t *testing.T) {
Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: ReasonFailed,
Message: "boom",
}},
},
Expand All @@ -216,6 +221,7 @@ func TestUpdateStatusFromPod(t *testing.T) {
Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: ReasonFailed,
Message: "build failed for unspecified reasons.",
}},
},
Expand Down
7 changes: 7 additions & 0 deletions pkg/status/taskrunreasons.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ const (
// reasonExceededNodeResources indicates that the TaskRun's pod has failed to start due
// to resource constraints on the node
ReasonExceededNodeResources = "ExceededNodeResources"

// ReasonSucceeded indicates that the reason for the finished status is that all of the steps
// completed successfully
ReasonSucceeded = "Succeeded"

// ReasonFailed indicates that the reason for the failure status is unknown or that one of the steps failed
ReasonFailed = "Failed"
)

0 comments on commit 578a426

Please sign in to comment.