Skip to content
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

Improve owner not found errors #4369

Merged

Conversation

irbekrm
Copy link
Contributor

@irbekrm irbekrm commented Aug 17, 2021

What this PR does / why we need it:

This PR changes the utility function that enqueues the owner of a resource to not error, but instead log an info message if it does not find the owner in the informers cache.
This is to fix a situation where at the time when the controller is started (often after cert-manager upgrade, when folks are watching the logs) owned resources' handlers run when the owners are not yet in cache and cert-manager throws errors.

In the 'certificaterequests' control loop, we watch for changes to Orders and reconcile the owning CertificateRequest. The owning CertificateRequest is obtained by getting it from the informers' cache- see the getter func passed as argument to HandleOwnedResourceNamespacedFunc.
At the time when a controller starts each informer needs to sync and it appears that at that time the Orders handler runs before the CertificateRequests have been cached and we consistently get these errors on startup for each Order present in the cluster:

E0816 11:52:45.832407       1 util.go:80] cert-manager/controller/certificaterequests/handleOwnedResource "msg"="error getting referenced owning resource" "error"="certificaterequest.cert-manager.io \"test-acme-certificate-2-fdddc\" not found" "related_resource_kind"="CertificateRequest" "related_resource_name"="test-acme-certificate-2-fdddc" "related_resource_namespace"="default" "resource_kind"="Order" "resource_name"="test-acme-certificate-2-fdddc-3482818700" "resource_namespace"="default" "resource_version"="v1" 
E0816 11:52:45.832508       1 util.go:80] cert-manager/controller/certificaterequests/handleOwnedResource "msg"="error getting referenced owning resource" "error"="certificaterequest.cert-manager.io \"test-acme-certificate-1-f6qwf\" not found" "related_resource_kind"="CertificateRequest" "related_resource_name"="test-acme-certificate-1-f6qwf" "related_resource_namespace"="default" "resource_kind"="Order" "resource_name"="test-acme-certificate-1-f6qwf-3604531314" "resource_namespace"="default" "resource_version"="v1"

This seems confusing for users who are potentially debugging other issues as the errors reads as if cert-manager was not able to get the CertificateRequest from kube API server, see #4345 and various Slack chats here, here, here and other places.

Special notes for your reviewer:

Alternatively this could have been solved by not looking up the owner object in cache in the handler, just enqueing the key, but I guess we still want to check that the owner exists and not do extra work if it is i.e deleted.

I considered whether this risks not showing users some actually important errors, but I think that if the owner is actually permanently not found the owned resource would eventually be garbage collected anyway.

Improves logging for 'owner not found' errors for `CertificateRequest`s owning `Order`s.

Signed-off-by: irbekrm <irbekrm@gmail.com>
@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 17, 2021
@irbekrm
Copy link
Contributor Author

irbekrm commented Aug 17, 2021

/kind cleanup

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Aug 17, 2021
@irbekrm
Copy link
Contributor Author

irbekrm commented Aug 17, 2021

e2e tests are failing because Venafi Cloud is broken I think

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Looks like a good improvement to me 👍

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2021
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irbekrm, SgtCoDFish

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@SgtCoDFish
Copy link
Member

/test pull-cert-manager-e2e-v1-22

1 similar comment
@irbekrm
Copy link
Contributor Author

irbekrm commented Aug 18, 2021

/test pull-cert-manager-e2e-v1-22

@jetstack-bot jetstack-bot merged commit bea6c20 into cert-manager:master Aug 18, 2021
@irbekrm irbekrm deleted the improve_owner_not_found_errors branch August 19, 2021 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants