Repository navigation
fix: use deterministic name for next-private-key Secret to prevent ra… - #8539
putongyong wants to merge 1 commit into
Conversation
…ce condition When multiple goroutines process the same Certificate concurrently, they could each call GenerateName which always produces a unique random name, resulting in duplicate next-private-key Secrets. The cleanup logic then deletes all of them, including ones already used to generate a CSR, causing InvalidCertificate failures with exponential backoff. Fix by using a deterministic name derived from the Certificate name so that concurrent Create calls result in AlreadyExists, making the operation idempotent. Fixes cert-manager#8514 Signed-off-by: putongyong <[email protected]>
|
@putongyong: The label(s) DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @putongyong. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
af3a44d to
93c31a9
Compare
|
Hi @putongyong
cert-manager, and Kubernetes operators in general, don't operate on the same object concurrently. Even if you increase the concurrency of controllers the workqueue logic ensures a single object is not reconciled by multiple go-routines at the same time. This being said, we do recognise that that we can get into a state where we create multiple secrets, usually via a subsequent reconcile happening before the informer cache has updated with the latest objects from the APIServer. Instead of changing the behaviour on how we name secrets the fix is probably to address this todo we have in our code. |
|
@ThatsMrTalbot Hi, thanks for the comment! You're right, this is quite an edge case. I believe it only occurs when one key manager instance is already processing a request for a secret, and another request for the same secret gets enqueued and processed before the first one completes. That solution looks much cleaner — I'll go ahead and update the pull request. |
|
@ThatsMrTalbot Reopening with updated solution in #8577 |
When multiple goroutines process the same Certificate concurrently, they could each call GenerateName which always produces a unique random name, resulting in duplicate next-private-key Secrets. The cleanup logic then deletes all of them, including ones already used to generate a CSR, causing InvalidCertificate failures with exponential backoff.
Fix by using a deterministic name derived from the Certificate name so that concurrent Create calls result in AlreadyExists, making the operation idempotent.
Fixes #8514
Pull Request Motivation
Kind
/kind
Release Note