Skip to content
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
@@ -1,10 +1,12 @@
package io.javaoperatorsdk.operator.processing.event;

import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.util.function.Function;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
Expand Down Expand Up @@ -216,12 +218,35 @@ public boolean isLastAttempt() {
customResourceFacade.patchStatus(
errorStatusUpdateControl.getResource().orElseThrow(), originalResource);
} catch (Exception ex) {
log.error(
"updateErrorStatus failed for resource: {} with version: {} for error {}",
getUID(resource),
getVersion(resource),
e.getMessage(),
ex);
int code = ex instanceof KubernetesClientException kcex ? kcex.getCode() : -1;
Level exceptionLevel = Level.ERROR;
String failedMessage = "";
if (context.isNextReconciliationImminent()
|| !(errorStatusUpdateControl.isNoRetry() || retryInfo.isLastAttempt())) {
if (code == HttpURLConnection.HTTP_CONFLICT
|| (originalResource.getMetadata().getResourceVersion() != null && code == 422)) {
exceptionLevel = Level.DEBUG;
failedMessage = " due to conflict";
log.info(
"ErrorStatusUpdateControl.patchStatus of {} failed due to a conflict, but the next"
+ " reconiliation is imminent.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
+ " reconiliation is imminent.",
+ " reconciliation is imminent.",

ResourceID.fromResource(originalResource));
} else {
exceptionLevel = Level.WARN;
failedMessage = ", but will be retried soon,";
}
}

log.atLevel(exceptionLevel)
.log(
"ErrorStatusUpdateControl.patchStatus failed{} for {} with UID: {} and version: {}"
+ " for error {}",
failedMessage,
ResourceID.fromResource(originalResource),
getUID(resource),
getVersion(resource),
e.getMessage(),
ex);
}
}
if (errorStatusUpdateControl.isNoRetry()) {
Expand Down