Repository navigation
Log Info when a re-queue happens due to optimistic locking - #3794
Conversation
|
/kind cleanup |
|
Hm, I'm uneasy about this change.. won't this make it seem like a sync had succeeded from the log output point of view? In cases where legitimate thrashing is occurring on a resource, this could really send people down a rabbit hole. |
|
If this is our own behavior causing this, it'd make sense to try and address the root cause of the problem rather than just hiding the messages IMO |
wallrj
left a comment
There was a problem hiding this comment.
I assume that multiple controllers are attempting to update the Certificate.Status.
Should we attempt to impose order on the controller operations by having each of them set a controller specific Condition to true when they have completed their operations.
And each controller could declare its dependencies in terms of other controller Conditions and ignore resources that do not have the required conditions matching the current resource generation.
There was a problem hiding this comment.
To me it seems like at the moment this is the better easy fix.
I have observed these messages when a Certificate is being renewed as the multiple control loops attempt to update Certficate's status.
This does not seem to be causing issues as such as the loops eventually stabilize.
These messages seem to be quite misleading for users - i.e if someone's Certificate is not being renewed correctly and they are looking at the controller logs- these error messages will be there in both success and error cases and, even though if there were 'too many' of them that would signal another issue this probably isn't helpful for someone looking at the controller logs first time- they end up missing the actual problem in most cases I have seen.
I think in the case if the controller was sending too many updates to the API server, we would get throttled and that error message would then appear in the logs as expected.
Example output here from when a Certificate is being renewed. There is also no indication of having recovered from these 'errors'
W0326 14:07:10.488153 1 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
I0326 14:15:48.000916 1 trigger_controller.go:189] cert-manager/controller/certificates-trigger "msg"="Certificate must be re-issued" "key"="default/test5" "message"="Renewing certificate as renewal was scheduled at 2021-03-26 14:15:48 +0000 UTC" "reason"="Renewing"
I0326 14:15:48.000959 1 conditions.go:182] Setting lastTransitionTime for Certificate "test5" condition "Issuing" to 2021-03-26 14:15:48.000952589 +0000 UTC m=+3653.661894848
I0326 14:15:48.048530 1 conditions.go:242] Setting lastTransitionTime for CertificateRequest "test5-428j8" condition "Approved" to 2021-03-26 14:15:48.048522624 +0000 UTC m=+3653.709464843
I0326 14:15:48.050203 1 conditions.go:242] Setting lastTransitionTime for CertificateRequest "test5-428j8" condition "Ready" to 2021-03-26 14:15:48.050198257 +0000 UTC m=+3653.711140469
E0326 14:15:48.060921 1 controller.go:158] cert-manager/controller/certificaterequests-issuer-selfsigned "msg"="re-queuing item due to error processing" "error"="Operation cannot be fulfilled on certificaterequests.cert-manager.io \"test5-428j8\": the object has been modified; please apply your changes to the latest version and try again" "key"="default/test5-428j8"
I0326 14:15:48.062351 1 conditions.go:242] Setting lastTransitionTime for CertificateRequest "test5-428j8" condition "Ready" to 2021-03-26 14:15:48.062346889 +0000 UTC m=+3653.723289101
E0326 14:15:48.078118 1 controller.go:158] cert-manager/controller/certificates-readiness "msg"="re-queuing item due to error processing" "error"="Operation cannot be fulfilled on certificates.cert-manager.io \"test5\": the object has been modified; please apply your changes to the latest version and try again" "key"="default/test5"
E0326 14:15:48.082165 1 controller.go:158] cert-manager/controller/certificates-issuing "msg"="re-queuing item due to error processing" "error"="Operation cannot be fulfilled on certificates.cert-manager.io \"test5\": the object has been modified; please apply your changes to the latest version and try again" "key"="default/test5"
E0326 14:15:48.084272 1 controller.go:158] cert-manager/controller/certificates-key-manager "msg"="re-queuing item due to error processing" "error"="Operation cannot be fulfilled on certificates.cert-manager.io \"test5\": the object has been modified; please apply your changes to the latest version and try again" "key"="default/test5"
W0326 14:16:50.488454 1 warnings.go:67] networking.k8s.io/v1beta1 Ingress is deprecated in v1.19+, unavailable in v1.22+;
|
Adding a hold to this as not everyone agreed with the approach, but feel free to unhold. /hold |
| err := b.syncHandler(ctx, key) | ||
| if err != nil { | ||
| if strings.Contains(err.Error(), genericregistry.OptimisticLockErrorMsg) { | ||
| log.V(logf.DebugLevel).Error(err, "re-queuing item due to optimistic locking") |
There was a problem hiding this comment.
Knowing when a resync happens due to optimistic locking is still important information to anyone since it allows to understand that the sync is being retried (useful to understand why the same log line appears twice for example).
Pushing this log line to -v=4 seems unfortunate to me since most users use -v=2 at this point. Would it make sense to use logf.InfoLevel + Info instead?
| log.V(logf.DebugLevel).Error(err, "re-queuing item due to optimistic locking") | |
| log.V(logf.InfoLevel).Info(err, "re-queuing item due to optimistic locking") |
Personally I'm not sure I agree, but I'll leave it up to the group :) I think this does hide transient errors somewhat, however in cases where users are running into genuine failures, this will make it a lot harder to actually dig in/work out what's going wrong. I'd strongly advocate for actually fixing the underlying issue - if we are going to merge this change, can we make it a priority to come up with a strategy that avoids these messages in the first place? Given that each one of these controllers actually only manages a very specific subset of the Certificate status, some careful programming and a switch to either managed fields based server-side apply (or perhaps more simply right now, a patch operation) would help a lot. As an alternative, instead of hiding these messages, could we add some additional text to the error when it is logged for the Certificate controllers cases? e.g. "Failed to update status, this is likely to not be an error and will be corrected on the next sync iteration: Operation could not be fulfilled..." (potentially with a link to the GitHub issue tracking these errors too, so the user has more information they can follow along with?) |
At the moment there are conditions that are managed by multiple controllers (i.e We could prioritize re-designing it so that each condition is only managed by a single controller and that would allow patching the status updates? Is it generally a bad practice if multiple controllers manage a condition? |
That's true, however, the design for the certificates controller is such that one controllers adds the condition, and then the issuing controller removes it after a complete issuance. We could re-design this, however I think given the fact that an issuance has to happen in between these two events (which implies caches have observed changes to add the condition), this is actually a case that is very unlikely to be causing the conflict. You can see this noted here: https://github.com/jetstack/cert-manager/blob/master/design/20200326.extensible-certificate-controller.md#proposal
(added emphasis :)) |
|
Perhaps leaving these two specific cases to continue using an |
|
I wonder if it'd be confusing if some were patched some not, but I guess we can live with that? |
|
I am also in favor of not hiding these messages under the -E0326 controller.go:158] "msg"="re-queuing item due to error processing" "error"="Operation cannot be fulfilled on certificates.cert-manager.io \"test5\": the object has been modified; please apply your changes to the latest version and try again" "key"="default/test5"
+I0326 controller.go:158] "msg"="happily re-queuing item thanks to optimistic locking" "key"="default/test5"
Good point, I never thought about managed fields + server-side apply. I guess we can investigate this idea. Regarding the |
|
/close It is clear to me that this is not a good approach to fixing these error logs. Rather than suppressing these messages which are a symptom of a larger problem, we should fix that larger problem. I'm closing this PR since I don't think it is relevant for fixing this separate issue. |
|
@JoshVanL: Closed this PR. 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/test-infra repository. |
I am a bit confused, why close the PR? |
locking Signed-off-by: joshvanl <[email protected]>
|
/close cancel As discussed, I am changing this PR to instead Info log that the resource will be re-queued due to optimistic locking, rather than suppressing the log at debug. |
Signed-off-by: joshvanl <[email protected]>
6c754aa to
b543d10
Compare
jakexks
left a comment
There was a problem hiding this comment.
/lgtm
I would suggest a release note for this, on the lines of
Optimistic locking messages (the object has been modified) are now logged at the Info level instead of the Error level, as cert-manager controllers will automatically retry until successful.
/hold
Hold until after the 1.4-alpha.0 release
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irbekrm, jakexks, JoshVanL The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
This PR stops the pollution of cert-manager-controller logs with errors from multiple controllers attempting to update the same object version. Instead, we log to info, however we still re-queue the object so has not functional change to any controller.
/assign @irbekrm @jakexks @maelvls @wallrj
/milestone v1.3
/cleanup
fixes #3667