-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use kmeta.ChildName for child resources #4361
Conversation
The following is the coverage report on the affected files.
|
This looks great! What's WIP about it? (aside from unit tests 😈 ) |
Only that I need to fix the tests first :P |
eaee88d
to
9de77ec
Compare
There may be something to check about retries:
Also I need to make sure that failures like this are considered transient and do not cause taskruns or pipelineruns to fail. |
1ae95c5
to
15732f2
Compare
The following is the coverage report on the affected files.
|
For retries, the |
/test pull-tekton-pipeline-alpha-integration-tests |
I think the failures on |
15732f2
to
1d1a365
Compare
The following is the coverage report on the affected files.
|
1d1a365
to
fa56d38
Compare
The following is the coverage report on the affected files.
|
/test pull-tekton-pipeline-alpha-integration-tests |
The following is the coverage report on the affected files.
|
/lgtm |
The
It looks like this has been recently fixed in /test pull-tekton-pipeline-integration-tests |
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.
thanks @afrittoli 🎉
added a comment documenting the change to Runs
as well
@@ -572,8 +573,7 @@ func getRunName(runsStatus map[string]*v1beta1.PipelineRunRunStatus, ptName, prN | |||
return k | |||
} | |||
} | |||
|
|||
return names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-%s", prName, ptName)) | |||
return kmeta.ChildName(prName, fmt.Sprintf("-%s", ptName)) |
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.
looks like you've made the same change to Runs
as well, please documentation for that like you've done for TaskRuns
and Pods
adding that detail to the commit message and pr description would be great too!
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.
Nice catch, thank you. Fixed.
Thanks @afrittoli for this PR 🙏 I think this also fixes (both were closed but I just reopened them since the issues are still seen with recent releases) : |
I might be missing something but can we please add some tests around the release note if they don't exist already:
Documenting some samples would be ideal for the folks creating |
d0b946a
to
645cf5a
Compare
The following is the coverage report on the affected files.
|
Thank you - the logic of the
Good idea, done! |
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.
examples_test.go:144: exit status 1 Output: Error from server (InternalError): error when creating "STDIN": Internal error occurred: failed calling webhook "webhook.pipeline.tekton.dev": Post "https://tekton-pipelines-webhook.tekton-pipelines.svc:443/defaulting?timeout=10s": context deadline exceeded
/test pull-tekton-pipeline-alpha-integration-tests
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.
thank you @afrittoli
a couple of minor nits but otherwise looks great, thank you for fixing this 🙏
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pritidesai 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 |
When a reconciler generates a child resource, it risks creating a duplicate resource because of stale informer cache. This may happen for instance when two reconciliations of the same resource happen almost at the same time. To avoid this risk, children resources should use a name that is uniquely associated to that of the parent, so that any attempt of recreation would fail. Such failure, when it happens, is considered as a transient error, and it does not cause the TaskRun or the PipelineRun to fail. We use kmeta.ChildName to generate the names. This applies to Pods generated by TaskRuns and TaskRuns and Runs generated by PipelineRuns. ChildName combines a base name with a suffix, and if the resulting name is too long it shortens it by truncating it and appending an hash of the original name: https://pkg.go.dev/github.com/knative/pkg/kmeta#ChildName Resources that are not k8s resources, such as steps or scripts, are not affected by this change. Fixes tektoncd#4358 Signed-off-by: Andrea Frittoli <[email protected]>
645cf5a
to
82a43dc
Compare
The following is the coverage report on the affected files.
|
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.
/lgtm
Changes
When a reconciler generates a child resource, it risks creating a
duplicate resource because of stale informer cache. This may happen
for instance when two reconciliations of the same resource happen
almost at the same time.
To avoid this risk, children resources should use a name that is uniquely
associated to that of the parent, so that any attempt of recreation would
fail. Such failure, when it happens, is considered as a transient error,
and it does not cause the TaskRun or the PipelineRun to fail.
We use kmeta.ChildName to generate the names. This applies to Pods
generated by TaskRuns and TaskRuns and Runs generated by PipelineRuns.
ChildName combines a base name with a suffix, and if the resulting name is
too long it shortens it by truncating it and appending an hash of the
original name: https://pkg.go.dev/github.com/knative/pkg/kmeta#ChildName
Resources that are not k8s resources, such as steps or scripts, are not
affected by this change.
Fixes #4358
Signed-off-by: Andrea Frittoli [email protected]
/kind bug
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
Release Notes