gyfora commented on a change in pull request #131:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/131#discussion_r840740946
##########
File path:
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/Mode.java
##########
@@ -19,13 +19,33 @@
package org.apache.flink.kubernetes.operator.config;
import org.apache.flink.kubernetes.operator.crd.FlinkDeployment;
+import org.apache.flink.kubernetes.operator.crd.spec.FlinkDeploymentSpec;
/** The mode of {@link FlinkDeployment}. */
public enum Mode {
APPLICATION,
SESSION;
+ /**
+ * Return the mode of the given FlinkDeployment for Observer and
Reconciler. Note, switching
+ * mode for an existing deployment is not allowed.
+ *
+ * @param flinkApp given FlinkDeployment
+ * @return Mode
+ */
public static Mode getMode(FlinkDeployment flinkApp) {
- return flinkApp.getSpec().getJob() != null ? APPLICATION : SESSION;
+ // Try to use lastReconciledSpec if it exists.
+ // The mode derived from last-reconciled spec or current spec should
be same.
+ // If they are different, observation phase will use last-reconciled
spec and validation
+ // phase will fail.
+ FlinkDeploymentSpec lastReconciledSpec =
+
flinkApp.getStatus().getReconciliationStatus().getLastReconciledSpec();
+ return lastReconciledSpec == null
+ ? getMode(flinkApp.getSpec())
+ : getMode(flinkApp.getSpec());
Review comment:
should this be `getMode(lastReconciledSpec)` here ? Maybe something is
wrong with the test you added :)
--
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]