gyfora commented on code in PR #1248:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1248#discussion_r4720539426


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentController.java:
##########
@@ -110,17 +115,28 @@ public DeleteControl cleanup(FlinkDeployment flinkApp, 
Context<FlinkDeployment>
             LOG.error("Error while observing for cleanup", err);
         }
 
-        var deleteControl = 
reconcilerFactory.getOrCreate(flinkApp).cleanup(ctx);
+        DeleteControl deleteControl;
+        try {
+            deleteControl = 
reconcilerFactory.getOrCreate(flinkApp).cleanup(ctx);
+        } catch (RuntimeException e) {
+            // Keep the status changes of the failed attempt, e.g. a completed 
savepoint
+            statusRecorder.patchAndCacheStatus(flinkApp, 
ctx.getKubernetesClient());
+            throw e;
+        }
         if (deleteControl.isRemoveFinalizer()) {
-            
flinkApp.getStatus().setLifecycleState(ResourceLifecycleState.DELETED);
-            statusRecorder.cleanupForDeletion(flinkApp);
-            ctxFactory.cleanup(flinkApp);
+            onCleanupFinished(flinkApp);
         } else {
             statusRecorder.patchAndCacheStatus(flinkApp, 
ctx.getKubernetesClient());
         }
         return deleteControl;
     }
 
+    private void onCleanupFinished(FlinkDeployment flinkApp) {
+        flinkApp.getStatus().setLifecycleState(ResourceLifecycleState.DELETED);

Review Comment:
   We could add a jira if we want to tackle this, it's a bit of a messy 
situation to tackle due to the async metric reporting



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to