-
Notifications
You must be signed in to change notification settings - Fork 23
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
Infinite loop causing increase in certificaterequestpolicies version #341
Comments
@hrbasic Thanks for registering this issue. I haven't observed this behavior, but we had a related bug in trust-manager. This was fixed by cert-manager/trust-manager#260. Please prepare a PR to fix this! Maybe you can be inspired by the tests added in the referenced PR to ensure this bug doesn't come back? |
Sure, thanks for hint. I'll prepare PR. |
Hey, I've prepared PR: #353 The issue arises when multiple policies are created. In such cases, policies enter an infinite loop during the patching process. In an attempt to understand the root cause, I created a single policy and introduced a brief pause (a one-second sleep) immediately after the patch operation: Without Sleep
With Sleep
It appears that when the controller is not busy, it processes events rapidly, preventing the resource version from increasing and creating an infinite loop. However, if the controller is busy, constant updates to the resource version result in an infinite loop. Anyway, this will fix bug, more info regarding this issue can be found here: kubernetes-sigs/kubebuilder#618 |
Description: I have encountered an issue where an infinite loop is causing an increase in the certificate request policy version. I found that the root cause of the infinite loop is related to the
setCertificateRequestPolicyCondition()
function in the certificaterequestpolicies.go file.First problem is here: https://github.com/cert-manager/approver-policy/blob/main/pkg/internal/controllers/certificaterequestpolicies.go#L208, empty list is created which will cause
setCertificateRequestPolicyCondition()
to always append condition in the list and try to patch object inReconcile()
. Furthermore, I believe if object is patched even when it is already in a ready state, that this behavior leads to an infinite loop, as the object is modified and triggers a new event for the patched object (shouldn't we patch object only if it's not ready?):I've tested fix locally and something like this should be solution:
Then reconcile should patch object only if it's not in desired state:
How to reproduce:
If you confirm that this is indeed a bug, I am willing to assist in fixing it and creating a pull request (PR) if you need assistance.
/kind bug
The text was updated successfully, but these errors were encountered: