-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add variables context.pipelineTask.retries and context.task.retry-count #3770
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
Conversation
|
The following is the coverage report on the affected files.
|
|
/assign @bobcatfish |
|
/assign @sbwsg |
|
This looks pretty ready to me. I have two suggested changes:
|
63d34d2 to
7e2ba6f
Compare
|
The following is the coverage report on the affected files.
|
@sbwsg I added a section in |
examples/v1beta1/pipelineruns/using-retries-and-retry-count-variables.yaml
Outdated
Show resolved
Hide resolved
No that's ok - the docs you've added look good to me! |
de961a9 to
07ce64a
Compare
|
Thanks for this @yaoxiaoqi ! I left one more small comment but not a blocker. |
07ce64a to
d9b8d14
Compare
|
/retest |
|
/test pull-tekton-pipeline-integration-tests |
|
It looks like the cluster is so busy it's taking forever for the workspace-in-sidecar sidecar to start up, resulting in the examples test timing out. /test pull-tekton-pipeline-integration-tests |
|
Would another option be to have func (c *Reconciler) createTaskRun(ctx, rprt, pr, storageBase) {
logger := logging.FromContext(ctx)
tr, _ := c.taskRunLister.TaskRuns(pr.Namespace).Get(rprt.TaskRunName)
if tr == nil {
rprt.PipelineTask = resources.ApplyRetryCount(rprt.PipelineTask, 0)
} else {
rprt.PipelineTask = resources.ApplyRetryCount(rprt.PipelineTask, len(tr.Status.RetriesStatus))
}
// ...Edit: I might be misunderstanding something fundamental that means this wouldn't work? |
Yeah I don't this so it would work for this reason (I haven't tried so cannot say for sure 😉 ): In case of a task being retried, tr, _ := c.taskRunLister.TaskRuns(pr.Namespace).Get(rprt.TaskRunName)
if tr != nil {
//is a retry
addRetryHistory(tr)
clearStatus(tr)
tr.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
})
return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).UpdateStatus(ctx, tr, metav1.UpdateOptions{})
} |
|
@yaoxiaoqi what do you think of taking this approach so that all of the retry-related changes remain in the pipelinerun reconciler? |
Hi @sbwsg , things would definitely be much cleaner if we align the replacement behavior of Actually, I considered your option when designing. But the problem is as pritidesai said even though you updated the parameters in pipelineTask, you can't update the params in the taskRun, since we only replace the params once in this line. When the same taskRun retries, we won't replace the params again. If we want to update the parameters, we can't just call original code: pipeline/pkg/reconciler/pipelinerun/pipelinerun.go Lines 698 to 708 in 18f337d
I did something like this: if tr != nil {
//is a retry
addRetryHistory(tr)
clearStatus(tr)
tr.Status.SetCondition(&apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
})
rprt.PipelineTask = resources.ApplyPipelineTaskContexts(rprt.PipelineTask, tr)
tr, _ = c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).UpdateStatus(ctx, tr, metav1.UpdateOptions{})
tr.Spec.Params = rprt.PipelineTask.Params
return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).Update(ctx, tr, metav1.UpdateOptions{})
} |
Hi @pritidesai , I would like to know where I can get the |
Ahhhh ok, I didn't understand that this was happening. It's really interesting! I hadn't seen this behaviour before but I can confirm this happens in my testing as well: I added a little bit of code to do the replacement in the PipelineRun reconciler and update TaskRun's |
|
OK, I am happy to go ahead with the There's one remaining nit I added to move the /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3548a66 to
9da0ca4
Compare
|
The following is the coverage report on the affected files.
|
…y-count` `context.pipelineTask.retries` exposes the total retries of a pipelineTask. `context.task.retry-count` exposes the current number of retry. The reason why the variable isn't `context.pipelineTask.retry-count` is that every task has a retry count, only pipelineTask has retries. Rename function `ApplyPipelineTaskContext` to `ApplyPipelineTaskStateContext` in "pipelinerun/apply.go" to distinguish from `ApplyPipelineTaskContexts`.
9da0ca4 to
12edacb
Compare
Done |
|
The following is the coverage report on the affected files.
|
|
/test pull-tekton-pipeline-integration-tests |
|
sorry @yaoxiaoqi haven't been able to review this since the latest updates, will review it later in the week 🙏 |
| return c.PipelineClientSet.TektonV1beta1().TaskRuns(pr.Namespace).UpdateStatus(ctx, tr, metav1.UpdateOptions{}) | ||
| } | ||
|
|
||
| rprt.PipelineTask = resources.ApplyPipelineTaskContexts(rprt.PipelineTask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to merge this as is, but setting the context variable here will only make it available to pipelineTask and will not be able to custom task. Since the retries is constant and does not change with the pipeline execution, we can set this while resolving a pipeline task.
|
/lgtm thanks @yaoxiaoqi for your patience and all the work 🙏 The changes look much cleaner now 🎉 |
|
/test pull-tekton-pipeline-alpha-integration-tests |
Changes
context.pipelineTask.retriesexposes the total retries of a pipelineTask.context.task.retry-countexposes the current number of retry. The reason why thevariable isn't named
context.pipelineTask.retry-countis that every task has a retrycount, only pipelineTask has retries.
Rename function
ApplyPipelineTaskContexttoApplyPipelineTaskStateContextin"pipelinerun/apply.go" to distinguish from
ApplyPipelineTaskContexts.related issue: #2725
TEP: https://github.com/tektoncd/community/blob/main/teps/0039-add-variable-retries-and-retrycount.md
/kind feature
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmddir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes