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


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/AbstractFlinkService.java:
##########
@@ -805,28 +805,8 @@ public CheckpointStatsResult fetchCheckpointStats(
     }
 
     @Override
-    public ClusterInfo getClusterInfo(Configuration conf, @Nullable String 
jobId) throws Exception {

Review Comment:
   Is there a good reason for breaking this method up and scattering the logic 
in different places? Maybe it's better to run this logic later but together



##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/deployment/AbstractFlinkDeploymentObserver.java:
##########
@@ -60,42 +84,72 @@ public AbstractFlinkDeploymentObserver(EventRecorder 
eventRecorder) {
     @Override
     public void observeInternal(FlinkResourceContext<FlinkDeployment> ctx) {
         var flinkDep = ctx.getResource();
-        if (!isJmDeploymentReady(flinkDep)) {
-            // Only observe the JM if we think it's in bad state
+        if (!isJmDeployed(flinkDep)) {
             observeJmDeployment(ctx);
-        }
-
-        if (isJmDeploymentReady(flinkDep)) {
-            // Only observe session/application if JM is ready
+        } else {
             observeFlinkCluster(ctx);
         }
 
-        if (isJmDeploymentReady(flinkDep)) {
-            observeClusterInfo(ctx);
+        if (isJmReady(flinkDep)) {
+            observeJob(ctx);
         }
 
         clearErrorsIfDeploymentIsHealthy(flinkDep);
     }
 
-    private void observeClusterInfo(FlinkResourceContext<FlinkDeployment> ctx) 
{
+    protected void observeFlinkCluster(FlinkResourceContext<FlinkDeployment> 
ctx) {
         var flinkApp = ctx.getResource();
+        var status = flinkApp.getStatus();
         try {
-            var clusterInfo =
-                    ctx.getFlinkService()
-                            .getClusterInfo(
-                                    ctx.getObserveConfig(),
-                                    
flinkApp.getStatus().getJobStatus().getJobId());
-            
flinkApp.getStatus().getClusterInfo().putAll(clusterInfo.getInfo());
-            logger.debug("ClusterInfo: {}", 
flinkApp.getStatus().getClusterInfo());
+            var clusterInfo = 
ctx.getFlinkService().getClusterInfo(ctx.getObserveConfig());
+            status.getClusterInfo().putAll(clusterInfo);
+        } catch (Exception e) {
+            if (isJmReady(flinkApp)) {
+                logger.warn("JobManager REST API stopped answering", e);
+                if (JobStatus.RUNNING == status.getJobStatus().getState()) {
+                    // The job was last observed RUNNING, its state is unknown 
until the REST API
+                    // answers again
+                    status.getJobStatus().setState(JobStatus.RECONCILING);
+                }
+            } else if (e instanceof TimeoutException) {
+                logger.info(
+                        "JobManager REST API is not ready yet, no answer 
within {}",
+                        TimeUtils.formatWithHighestUnit(
+                                
ctx.getOperatorConfig().getFlinkClientTimeout()));
+            } else {
+                logger.info("JobManager REST API is not ready yet: {}", 
e.toString());
+            }
+            // Either way, find out what happened to the JobManager pod
+            observeJmDeployment(ctx);

Review Comment:
   So this would always set the state back to either MISSING, DEPLOYING or 
DEPLOYED_NOT_READY. I was missing this a little from the comment / was a bit 
implicit in the logic



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