Skip to content

improve: logging if no primary found for resource id #2036

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

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ private void submitReconciliationExecution(ResourceState state) {
controllerUnderExecution,
maybeLatest.isPresent());
if (maybeLatest.isEmpty()) {
log.debug("no custom resource found in cache for resource id: {}", resourceID);
// there can be multiple reasons why the primary resource is not present, one is that the
// informer is currently disconnected from k8s api server, but will eventually receive the
// resource. Other is that simply there is no primary resource present for an event, this
// might indicate issue with the implementation, but could happen also naturally, thus
// this is not necessarily a problem.
log.debug("no primary resource found in cache with resource id: {}", resourceID);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better but still doesn't address the fact that we might get into that state because we're triggering event processing even though we don't expect a resource to even exist in the cache (like if a user sends events for resources that are not tracked by the Reconciler), i.e. the cache is an implementation detail that might be confusing, i.e. a user might then think: ok, it's not in cache, then fetch it from the server instead!
That said, it's indeed a debug level log so maybe it doesn't matter all that much.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't expect a resource to even exist in the cache

Yeah, but this is not always the case, if the controller informer is lagging (reconnect issues), the resource might be actually expected, just not yet there.

it's not in cache, then fetch it from the server instead!

this is for primary, not sure if there is a place to fetch it; since the reconciler never triggered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But can add some comments there above the log message, to explain why this can happen.

}
}
} finally {
Expand Down