Skip to content

Commit 7c6a1fe

Browse files
committed
fix: fix lastAttempt value on first try when maxAttempt is zero
1 parent d500347 commit 7c6a1fe

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ public int getAttemptCount() {
173173

174174
@Override
175175
public boolean isLastAttempt() {
176-
return controller.getConfiguration().getRetry() == null;
176+
// on first try, we can only rely on the configured behavior
177+
// if enabled, will at least produce one RetryExecution
178+
return !controller.getConfiguration().getRetry().enabled();
177179
}
178180
});
179181
((DefaultContext<P>) context).setRetryInfo(retryInfo);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ public GenericRetry withLinearRetry() {
9292
return this;
9393
}
9494

95+
@Override
96+
public boolean enabled() {
97+
return this.maxAttempts > 0;
98+
}
99+
95100
@Override
96101
public void initFrom(GradualRetry configuration) {
97102
this.initialInterval = configuration.initialInterval();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ public interface Retry {
55

66
RetryExecution initExecution();
77

8+
default boolean enabled() {
9+
return false;
10+
}
11+
812
}

0 commit comments

Comments
 (0)