Skip to content

Commit 716399e

Browse files
committed
fix: do not update cache if the execution failed
1 parent a442af1 commit 716399e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ private RetryExecution getOrInitRetryExecution(ExecutionScope executionScope) {
199199
*/
200200
private void cacheUpdatedResourceIfChanged(
201201
ExecutionScope executionScope, PostExecutionControl postExecutionControl) {
202-
if (postExecutionControl.customResourceUpdatedDuringExecution()) {
202+
// only update the cache if the execution didn't fail and the resource was updated
203+
if (!postExecutionControl.exceptionDuringExecution()
204+
&& postExecutionControl.customResourceUpdatedDuringExecution()) {
203205
CustomResource originalCustomResource = executionScope.getCustomResource();
204206
CustomResource customResourceAfterExecution =
205207
postExecutionControl.getUpdatedCustomResource().get();

0 commit comments

Comments
 (0)