bgeng777 commented on a change in pull request #131:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/131#discussion_r840769013
##########
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:
hmmm, I made a silly mistake here :(
After fixing the Mode bug, I was wondering if there was any other spec
needed to be changed to last reconciled spec in Observer. When testing with
`DeploymentSpec spec = deployment.get().getSpec();` in `observeJmDeployment`, I
somehow broke my previous codes and committed the wrong codes.
It should be fixed by now.
--
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]