davidradl commented on code in PR #1064:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1064#discussion_r2867575630


##########
flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/FlinkDeploymentStatus.java:
##########
@@ -68,4 +77,96 @@ public class FlinkDeploymentStatus extends 
CommonStatus<FlinkDeploymentSpec> {
     public boolean isJobCancellable() {
         return super.isJobCancellable() && 
jobManagerDeploymentStatus.isRestApiAvailable();
     }
+
+    /**
+     * Computes and returns a List of Condition objects based on the current 
FlinkDeploymentStatus.
+     * This method should be called to generate conditions that can then be 
set using
+     * setConditions().
+     *
+     * @return a list of Condition object representing the current status of 
the Flink deployment
+     */
+    public List<Condition> computeConditions() {
+        Condition conditionToAdd = null;
+
+        if (reconciliationStatus != null) {
+            FlinkDeploymentSpec deploymentSpec =
+                    reconciliationStatus.deserializeLastReconciledSpec();
+
+            if (deploymentSpec != null) {
+                switch (Mode.getMode(deploymentSpec)) {
+                    case APPLICATION:
+                        conditionToAdd = 
createApplicationModeCondition(getJobStatus().getState());
+                        break;
+                    case SESSION:
+                        conditionToAdd = 
createSessionModeCondition(jobManagerDeploymentStatus);
+                }
+                updateLastTransitionTime(conditions, conditionToAdd);
+            }
+        }
+        return conditionToAdd == null ? List.of() : List.of(conditionToAdd);
+    }
+
+    private void updateLastTransitionTime(List<Condition> conditions, 
Condition condition) {
+        if (condition == null) {
+            return;
+        }
+        Condition existingCondition =
+                conditions.stream()
+                        .filter(c -> c.getType().equals(condition.getType()))
+                        .findFirst()
+                        .orElse(null);
+        
condition.setLastTransitionTime(getLastTransitionTimeStamp(existingCondition, 
condition));
+    }
+
+    private Condition createApplicationModeCondition(JobStatus jobStatus) {

Review Comment:
   Now I have moved these methods to ConditionsUtil - they are all static.They 
could have been before I you rightly pointed out.  



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