lajith2006 commented on code in PR #957:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/957#discussion_r2068571812
##########
flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/FlinkDeploymentStatus.java:
##########
@@ -55,4 +60,188 @@ public class FlinkDeploymentStatus extends
CommonStatus<FlinkDeploymentSpec> {
/** Information about the TaskManagers for the scale subresource. */
private TaskManagerInfo taskManager;
+
+ /** Condition of the CR . */
+ private List<Condition> conditions = new ArrayList<>();
+
+ private String phase;
+
+ public List<Condition> getConditions() {
+ if (reconciliationStatus != null
+ && reconciliationStatus.deserializeLastReconciledSpec() != null
+ &&
reconciliationStatus.deserializeLastReconciledSpec().getJob() == null) {
+ // Populate conditions for SessionMode deployment
+ switch (jobManagerDeploymentStatus) {
+ case READY:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+ ConditionUtils.SESSION_MODE_CONDITION.get(
+
JobManagerDeploymentStatus.READY.name())));
+ break;
+ case MISSING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+ ConditionUtils.SESSION_MODE_CONDITION.get(
+
JobManagerDeploymentStatus.MISSING.name())));
+ break;
+ case DEPLOYING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+ ConditionUtils.SESSION_MODE_CONDITION.get(
+
JobManagerDeploymentStatus.DEPLOYING.name())));
+ break;
+ case DEPLOYED_NOT_READY:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+ ConditionUtils.SESSION_MODE_CONDITION.get(
+
JobManagerDeploymentStatus.DEPLOYED_NOT_READY.name())));
+ break;
+ case ERROR:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+ ConditionUtils.SESSION_MODE_CONDITION.get(
+
JobManagerDeploymentStatus.ERROR.name())));
+ }
+ } else if (getJobStatus() != null && getJobStatus().getState() !=
null) {
+ // Populate conditions for ApplicationMode deployment
+ switch (getJobStatus().getState()) {
+ case RECONCILING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.RECONCILING.name())));
+ break;
+ case CREATED:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.CREATED.name())));
+ break;
+ case RUNNING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.RUNNING.name())));
+ break;
+ case FAILING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.FAILING.name())));
+ break;
+ case RESTARTING:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.RESTARTING.name())));
+ break;
+ case FAILED:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.FAILED.name())));
+ break;
+ case FINISHED:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.FINISHED.name())));
+ break;
+
+ case CANCELED:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.CANCELED.name())));
+ break;
+ case SUSPENDED:
+ updateCondition(
+ conditions,
+ ConditionUtils.crCondition(
+
ConditionUtils.APPLICATION_MODE_CONDITION.get(
+ JobStatus.SUSPENDED.name())));
+ break;
+ }
+ }
+ return conditions;
+ }
+
+ public String getPhase() {
+ if (reconciliationStatus != null
+ && reconciliationStatus.deserializeLastReconciledSpec() != null
+ &&
reconciliationStatus.deserializeLastReconciledSpec().getJob() == null) {
+ // populate phase for SessionMode deployment
+ switch (jobManagerDeploymentStatus) {
+ case READY:
+ phase = "Running";
+ break;
+ case MISSING:
+ case DEPLOYING:
+ phase = "Pending";
+ break;
+ case ERROR:
+ phase = "Failed";
+ break;
+ }
+ } else if (getJobStatus() != null && getJobStatus().getState() !=
null) {
+ // populate phase for ApplicationMode deployment
+ switch (getJobStatus().getState()) {
+ case RECONCILING:
+ phase = "Pending";
+ break;
+ case CREATED:
+ phase = JobStatus.CREATED.name();
+ break;
+ case RUNNING:
+ phase = JobStatus.RUNNING.name();
+ break;
+ case FAILING:
+ phase = JobStatus.FAILING.name();
+ break;
+ case RESTARTING:
+ phase = JobStatus.RESTARTING.name();
+ break;
+ case FAILED:
+ phase = JobStatus.FAILED.name();
+ break;
+ case FINISHED:
+ phase = JobStatus.FINISHED.name();
+ break;
+ case CANCELED:
+ phase = JobStatus.CANCELED.name();
+ break;
+ case SUSPENDED:
+ phase = JobStatus.SUSPENDED.name();
+ break;
+ }
+ }
+ return phase;
+ }
+
+ private static void updateCondition(List<Condition> conditions, Condition
condition) {
+ if (conditions.isEmpty()) {
+ conditions.add(condition);
+ return;
+ }
+ // If new condition is same as last condition, ignore
+ Condition existingCondition = conditions.get(conditions.size() - 1);
+ if (existingCondition.getType().equals(condition.getType())
+ &&
existingCondition.getMessage().equals(condition.getMessage())) {
+ return;
+ }
+ conditions.add(condition);
Review Comment:
Thanks for clarification @gyfora
So just to be align with what you have mentioned , for an example , when we
do an application cluster deployment, as Job cycles goes through
CREATED>RUNNING
initially conditions will have as below
```
status
conditions:
- type: Running
status: "False"
reason: Job is created
message: "Job is newly created, no task has started to run"
lastTransitionTime: 2025-04-030T06:17:08Z
```
And then when the Job starts running at `2025-04-030T06:19:01Z` , condition
will have as below
```
status
conditions:
- type: Running
status: "True"
reason: Job is running
message: "Job is running"
lastTransitionTime: 2025-04-030T06:19:01Z
```
and then later at `2025-04-030T07:00:01Z`. when job gets finished ,
condition will have as below.
```
status
conditions:
- type: Running
status: "False"
reason: Job's tasks have successfully finished
message: Job's tasks have successfully finished
lastTransitionTime: 2025-04-030T07:00:01Z
```
which means ideally we will not have an history in the condition when the
Job goes through different job lifecycle , instead only single condition and
lastTransitionTime will reflect when the status was changed.
--
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]