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


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EventRecorder.java:
##########
@@ -409,6 +409,7 @@ public enum Reason {
         CheckpointError,
         Cleanup,
         CleanupFailed,
+        CleanupTimeout,

Review Comment:
   We have been using the cleanup failed event for this purpose in other 
places, I suggest we reuse the existing logic. Timeout is a form of failure.



##########
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:
   Remove redundant warn log, event trigger already logs 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