diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java index 0239d2cbcc..015a2f5c31 100644 --- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java +++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java @@ -38,11 +38,17 @@ class ReconciliationDispatcher
{ private final Controller
controller; private final CustomResourceFacade
customResourceFacade; + // this is to handle corner case, when there is a retry, but it is actually limited to 0. + // Usually for testing purposes. + private final boolean retryConfigurationHasZeroAttempts; ReconciliationDispatcher(Controller
controller, CustomResourceFacade
customResourceFacade) { this.controller = controller; this.customResourceFacade = customResourceFacade; + + var retry = controller.getConfiguration().getRetry(); + retryConfigurationHasZeroAttempts = retry == null || retry.initExecution().isLastAttempt(); } public ReconciliationDispatcher(Controller
controller) { @@ -173,7 +179,9 @@ public int getAttemptCount() { @Override public boolean isLastAttempt() { - return controller.getConfiguration().getRetry() == null; + // check also if the retry is limited to 0 + return retryConfigurationHasZeroAttempts || + controller.getConfiguration().getRetry() == null; } }); ((DefaultContext
) context).setRetryInfo(retryInfo);
diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java
index 72406094fc..892fffcdbb 100644
--- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java
+++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcherTest.java
@@ -11,6 +11,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatcher;
import org.mockito.ArgumentMatchers;
import org.mockito.stubbing.Answer;
@@ -110,7 +111,10 @@ private