Skip to content

improve: logging for tracing issues with events #2260

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
Mar 5, 2024
Merged
Show file tree
Hide file tree
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 @@ -285,11 +285,12 @@ private void updatePostExecutionControlWithReschedule(

private PostExecutionControl<P> handleCleanup(P resource,
Context<P> context) {
log.debug(
"Executing delete for resource: {} with version: {}",
getName(resource),
getVersion(resource));

if (log.isDebugEnabled()) {
log.debug(
"Executing delete for resource: {} with version: {}",
ResourceID.fromResource(resource),
getVersion(resource));
}
DeleteControl deleteControl = controller.cleanup(resource, context);
final var useFinalizer = controller.useFinalizer();
if (useFinalizer) {
Expand Down Expand Up @@ -345,7 +346,7 @@ ControllerConfiguration<P> configuration() {

public P conflictRetryingUpdate(P resource, Function<P, Boolean> modificationFunction) {
if (log.isDebugEnabled()) {
log.debug("Removing finalizer on resource: {}", ResourceID.fromResource(resource));
log.debug("Conflict retrying update for: {}", ResourceID.fromResource(resource));
}
int retryIndex = 0;
while (true) {
Expand Down Expand Up @@ -393,10 +394,12 @@ public R getResource(String namespace, String name) {
}

public R updateResource(R resource) {
log.debug(
"Trying to replace resource {}, version: {}",
getName(resource),
resource.getMetadata().getResourceVersion());
if (log.isDebugEnabled()) {
log.debug(
"Trying to replace resource {}, version: {}",
ResourceID.fromResource(resource),
resource.getMetadata().getResourceVersion());
}
return resource(resource).lockResourceVersion(resource.getMetadata().getResourceVersion())
.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ public synchronized void start() {

public void eventReceived(ResourceAction action, T resource, T oldResource) {
try {
log.debug("Event received for resource: {}", getName(resource));
if (log.isDebugEnabled()) {
log.debug("Event received for resource: {} version: {} uuid: {} action: {}",
ResourceID.fromResource(resource),
getVersion(resource), resource.getMetadata().getUid(), action);
log.trace("Event Old resource: {},\n new resource: {}", oldResource, resource);
}
MDCUtils.addResourceInfo(resource);
controller.getEventSourceManager().broadcastOnResourceEvent(action, resource, oldResource);
if ((legacyFilters == null ||
Expand All @@ -75,8 +80,8 @@ && isAcceptedByFilters(action, resource, oldResource)) {
getEventHandler().handleEvent(
new ResourceEvent(action, ResourceID.fromResource(resource), resource));
} else {
log.debug("Skipping event handling resource {} with version: {}", getUID(resource),
getVersion(resource));
log.debug("Skipping event handling resource {}",
ResourceID.fromResource(resource));
}
} finally {
MDCUtils.removeResourceInfo();
Expand Down