Skip to content

Commit

Permalink
fix: clean results when taskrun retries
Browse files Browse the repository at this point in the history
  • Loading branch information
cugykw authored and tekton-robot committed Sep 20, 2023
1 parent 503cc3d commit 6364191
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/taskruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ Type: Succeeded
Status: Unknown
Reason: ToBeRetried
```
- `status.StartTime` and `status.PodName` are unset to trigger another retry attempt.
- `status.StartTime`, `status.PodName` and `status.Results` are unset to trigger another retry attempt.

### Configuring the failure timeout

Expand Down
1 change: 1 addition & 0 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ func retryTaskRun(tr *v1.TaskRun, message string) {
tr.Status.StartTime = nil
tr.Status.CompletionTime = nil
tr.Status.PodName = ""
tr.Status.Results = nil
taskRunCondSet := apis.NewBatchConditionSet()
taskRunCondSet.Manage(&tr.Status).MarkUnknown(apis.ConditionSucceeded, v1.TaskRunReasonToBeRetried.String(), message)
}
53 changes: 53 additions & 0 deletions pkg/reconciler/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,50 @@ status:
ResultExtractionMethod: "termination-message"
MaxResultSize: 4096
Coschedule: "workspaces"
`)
toBeRetriedWithResultsTaskRun = parse.MustParseV1TaskRun(t, `
metadata:
name: test-taskrun-with-results-to-be-retried
namespace: foo
spec:
retries: 1
taskRef:
name: test-results-task
status:
startTime: "2021-12-31T23:59:59Z"
results:
- name: aResult
type: string
value: aResultValue
conditions:
- reason: Failed
status: "False"
type: Succeeded
`)
retriedWithResultsTaskRun = parse.MustParseV1TaskRun(t, `
metadata:
name: test-taskrun-with-results-to-be-retried
namespace: foo
spec:
retries: 1
taskRef:
name: test-results-task
status:
podName: ""
conditions:
- reason: ToBeRetried
status: Unknown
type: Succeeded
retriesStatus:
- conditions:
- reason: Failed
status: "False"
type: Succeeded
results:
- name: aResult
type: string
value: aResultValue
startTime: "2021-12-31T23:59:59Z"
`)
)

Expand Down Expand Up @@ -1823,6 +1867,15 @@ status:
tr: toBeRetriedTaskRun,
wantTr: retriedTaskRun,
wantStartTime: true,
}, {
name: "TaskRun retry and clear the results",
testData: test.Data{
TaskRuns: []*v1.TaskRun{toBeRetriedWithResultsTaskRun},
Tasks: []*v1.Task{resultsTask},
},
tr: toBeRetriedWithResultsTaskRun,
wantTr: retriedWithResultsTaskRun,
wantStartTime: false,
}} {
t.Run(tc.name, func(t *testing.T) {
testAssets, cancel := getTaskRunController(t, tc.testData)
Expand Down

0 comments on commit 6364191

Please sign in to comment.