compositor: minimal invasive name generation without dry-run #4858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of your changes
Fixes #4712.
The old code used dry-run to make the apiserver generate a name for unnamed resources. But dry-run has side-effects, namely it validates. With that name generation could fail in the past and generate error messages containing an ever changing name, leading to continuous event generation.
This PR replaces the dry-run with an equivalent name generation that does not validate:
client.Get
that the name is not taken. Try another name if it is, up to 10 times.There are 8 million names (length 5, 27 different characters). The chance that a random name is taken with 10k objects is pretty low. With 10 tries, the chance is practically zero.
Note: this is a minimal invasive change. As before, a name can be taken when the composed resource is eventually created. Again, the chance is super low, even lower than before because only newly created objects can conflict. So it is far less than 10k objects that have the chance to conflict.
Peer PR to #4780, which removes dry-run in the claim controller with a similar attempt, but less minimal invasive, but also 100% correct in the sense that it handles all kind of conflicts gracefully.
I have:
Added or updated e2e tests, if necessary. (check with reviewers/maintainers if you're unsure whether E2E tests are necessary for the change).make reviewable
to ensure this PR is ready for review.Addedbackport release-x.y
labels to auto-backport this PR, if necessary.Opened a PR updating the docs, if necessary.