Dennis-Mircea commented on code in PR #1267:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1267#discussion_r4783724870


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/snapshot/StateSnapshotReconciler.java:
##########
@@ -96,6 +99,45 @@ public void reconcile(FlinkStateSnapshotContext ctx) {
     }
 
     public DeleteControl cleanup(FlinkStateSnapshotContext ctx) throws 
Exception {
+        var deleteControl = tryCleanup(ctx);
+        if (!deleteControl.isRemoveFinalizer() && cleanupTimedOut(ctx)) {
+            giveUpCleanup(ctx);
+            return DeleteControl.defaultDelete();
+        }
+        return deleteControl;
+    }
+
+    private boolean cleanupTimedOut(FlinkStateSnapshotContext ctx) {
+        Duration timeout = ctx.getOperatorConfig().getSnapshotCleanupTimeout();
+        var deletionTimestamp = 
ctx.getResource().getMetadata().getDeletionTimestamp();
+        if (timeout.isZero() || timeout.isNegative() || deletionTimestamp == 
null) {
+            return false;
+        }
+        return Instant.now()
+                
.isAfter(DateTimeUtils.parseKubernetes(deletionTimestamp).plus(timeout));
+    }
+
+    private void giveUpCleanup(FlinkStateSnapshotContext ctx) {
+        var resource = ctx.getResource();
+        var path = resource.getStatus().getPath();
+        var message =
+                String.format(
+                        "Giving up on the cleanup of snapshot %s after %s in 
state %s%s",
+                        resource.getMetadata().getName(),
+                        ctx.getOperatorConfig().getSnapshotCleanupTimeout(),
+                        resource.getStatus().getState(),
+                        path == null ? "" : ", savepoint " + path + " may be 
left behind");
+        LOG.warn(message);

Review Comment:
   Right. I removed it.



-- 
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