wangyang0918 commented on a change in pull request #29:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/29#discussion_r816555181



##########
File path: 
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/DefaultDeploymentValidator.java
##########
@@ -86,12 +87,26 @@
         return Optional.empty();
     }
 
-    private Optional<String> validateJmSpec(JobManagerSpec jmSpec) {
+    private Optional<String> validateJmSpec(JobManagerSpec jmSpec, Map<String, 
String> confMap) {
         if (jmSpec == null) {
             return Optional.empty();
         }
 
-        return validateResources("JobManager", jmSpec.getResource());
+        return firstPresent(
+                validateResources("JobManager", jmSpec.getResource()),
+                validateJmReplicas("JobManager", jmSpec.getReplicas(), 
confMap));
+    }
+
+    private Optional<String> validateJmReplicas(
+            String component, int replicas, Map<String, String> confMap) {
+        if (!confMap.containsKey(HighAvailabilityOptions.HA_MODE.key()) && 
replicas != 1) {

Review comment:
       We should use 
`HighAvailabilityMode.isHighAvailabilityModeActivated(conf)` instead here.
   
   The following is the pre-check in Flink.
   ```
       public int getReplicas() {
           final int replicas =
                   
flinkConfig.get(KubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS);
           if (replicas < 1) {
               throw new IllegalConfigurationException(
                       String.format(
                               "'%s' should not be configured less than one.",
                               
KubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS.key()));
           } else if (replicas > 1
                   && 
!HighAvailabilityMode.isHighAvailabilityModeActivated(flinkConfig)) {
               throw new IllegalConfigurationException(
                       "High availability should be enabled when starting 
standby JobManagers.");
           }
           return replicas;
       }
   ```




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