rgsriram commented on code in PR #437:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/437#discussion_r1020282292


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/deployment/ApplicationReconciler.java:
##########
@@ -318,6 +319,31 @@ private boolean shouldRestartJobBecauseUnhealthy(
         return restartNeeded;
     }
 
+    private boolean cleanupTerminalJmAfterTtl(
+            FlinkDeployment deployment, Configuration observeConfig) {
+        var status = deployment.getStatus();
+        boolean terminal = ReconciliationUtils.isJobInTerminalState(status);
+        boolean jmStillRunning =
+                status.getJobManagerDeploymentStatus() != 
JobManagerDeploymentStatus.MISSING;
+
+        if (terminal && jmStillRunning) {
+            var ttl = 
observeConfig.get(KubernetesOperatorConfigOptions.OPERATOR_JM_SHUTDOWN_TTL);
+            boolean ttlPassed =
+                    Instant.now()
+                            .isAfter(
+                                    Instant.ofEpochMilli(
+                                                    Long.parseLong(
+                                                            
status.getJobStatus().getUpdateTime()))
+                                            .plus(ttl));
+            if (ttlPassed) {
+                LOG.info("Removing JobManager deployment for terminal 
application.");
+                flinkService.deleteClusterDeployment(deployment.getMetadata(), 
status, false);

Review Comment:
   Should we need not delete HA metadata also?



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to