Skip to content

Commit 318a56c

Browse files
committed
fix: refine retryAwareErrorLogging
and error handling for status patching closes: #2747 Signed-off-by: Steve Hawkins <[email protected]>
1 parent 7725ff4 commit 318a56c

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java

+22-14
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,29 @@ private void retryAwareErrorLogging(
349349
boolean eventPresent,
350350
Exception exception,
351351
ExecutionScope<P> executionScope) {
352-
if (!eventPresent
353-
&& !retry.isLastAttempt()
354-
&& exception instanceof KubernetesClientException ex) {
355-
if (ex.getCode() == HttpURLConnection.HTTP_CONFLICT) {
356-
log.debug(
357-
"Full client conflict error during event processing {}", executionScope, exception);
358-
log.warn(
359-
"Resource Kubernetes Resource Creator/Update Conflict during reconciliation. Message:"
360-
+ " {} Resource name: {}",
361-
ex.getMessage(),
362-
ex.getFullResourceName());
363-
return;
364-
}
352+
if (!retry.isLastAttempt()
353+
&& exception instanceof KubernetesClientException ex
354+
&& ex.getCode() == HttpURLConnection.HTTP_CONFLICT) {
355+
log.debug("Full client conflict error during event processing {}", executionScope, exception);
356+
log.info(
357+
"Resource Kubernetes Resource Creator/Update Conflict during reconciliation. Message:"
358+
+ " {} Resource name: {}",
359+
ex.getMessage(),
360+
ex.getFullResourceName());
361+
} else if (eventPresent || !retry.isLastAttempt()) {
362+
log.warn(
363+
"Uncaught error during event processing {} - but another reconciliation will be attempted"
364+
+ " because a superceding event has been recieved or another retry attempt is"
365+
+ " pending.",
366+
executionScope,
367+
exception);
368+
} else {
369+
log.error(
370+
"Uncaught error during event processing {} - no superceding event is present and this is"
371+
+ " the retry last attempt",
372+
executionScope,
373+
exception);
365374
}
366-
log.error("Error during event processing {}", executionScope, exception);
367375
}
368376

369377
private void cleanupOnSuccessfulExecution(ExecutionScope<P> executionScope) {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,18 @@ public boolean isLastAttempt() {
212212

213213
P updatedResource = null;
214214
if (errorStatusUpdateControl.getResource().isPresent()) {
215-
updatedResource =
216-
customResourceFacade.patchStatus(
217-
errorStatusUpdateControl.getResource().orElseThrow(), originalResource);
215+
try {
216+
updatedResource =
217+
customResourceFacade.patchStatus(
218+
errorStatusUpdateControl.getResource().orElseThrow(), originalResource);
219+
} catch (Exception ex) {
220+
log.error(
221+
"updateErrorStatus failed for resource: {} with version: {} for error {}",
222+
getUID(resource),
223+
getVersion(resource),
224+
e.getMessage(),
225+
ex);
226+
}
218227
}
219228
if (errorStatusUpdateControl.isNoRetry()) {
220229
PostExecutionControl<P> postExecutionControl;

0 commit comments

Comments
 (0)