Skip to content

Commit 909e524

Browse files
committed
chore: refining logging related to execution errors that may be retried
this addressed operator-framework#409 where the log contains verbose error messages related to status update conflicts
1 parent 0843339 commit 909e524

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void handleRetryOnException(ExecutionScope executionScope) {
162162
}
163163
Optional<Long> nextDelay = execution.nextDelay();
164164

165-
nextDelay.ifPresent(
165+
nextDelay.ifPresentOrElse(
166166
delay -> {
167167
log.debug(
168168
"Scheduling timer event for retry with delay:{} for resource: {}",
@@ -171,6 +171,9 @@ private void handleRetryOnException(ExecutionScope executionScope) {
171171
eventSourceManager
172172
.getRetryTimerEventSource()
173173
.scheduleOnce(executionScope.getCustomResource(), delay);
174+
},
175+
() -> {
176+
log.error("Exhausted retries for {}", executionScope);
174177
});
175178
}
176179

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
88
import io.fabric8.kubernetes.client.CustomResource;
9+
import io.fabric8.kubernetes.client.KubernetesClientException;
910
import io.fabric8.kubernetes.client.dsl.MixedOperation;
1011
import io.fabric8.kubernetes.client.dsl.Resource;
1112
import io.javaoperatorsdk.operator.api.Context;
@@ -53,6 +54,13 @@ public void setEventSourceManager(EventSourceManager eventSourceManager) {
5354
public PostExecutionControl handleExecution(ExecutionScope<R> executionScope) {
5455
try {
5556
return handleDispatch(executionScope);
57+
} catch (KubernetesClientException e) {
58+
log.info(
59+
"Kubernetes exception {} {} during event processing, {} failed",
60+
e.getCode(),
61+
e.getMessage(),
62+
executionScope);
63+
return PostExecutionControl.exceptionDuringExecution(e);
5664
} catch (RuntimeException e) {
5765
log.error("Error during event processing {} failed.", executionScope, e);
5866
return PostExecutionControl.exceptionDuringExecution(e);

0 commit comments

Comments
 (0)