vsantwana commented on code in PR #1236:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/1236#discussion_r4454922027


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/DefaultValidator.java:
##########
@@ -328,37 +320,44 @@ private Optional<String> 
validateSessionJobJarURI(FlinkSessionJob sessionJob) {
     }
 
     private Optional<String> validateJmSpec(JobManagerSpec jmSpec, Map<String, 
String> confMap) {
-        Configuration conf = Configuration.fromMap(confMap);
-        // Either the resource memory or the resource requirements memory must 
be defined.
-        boolean jmMemoryDefined =
-                jmSpec != null
-                        && (isMemoryDefined(jmSpec.getResource())
-                                || isMemoryDefined(jmSpec.getResources()));
-        Optional<String> jmMemoryValidation =
-                jmMemoryDefined ? Optional.empty() : 
validateJmMemoryConfig(conf);
-
         if (jmSpec == null) {
-            return jmMemoryValidation;
+            return validateJmMemoryConfig(null, confMap);
         }
 
         return firstPresent(
-                jmMemoryValidation,
-                validateResources("JobManager", jmSpec.getResource()),
-                validateResourceRequirements("JobManager", 
jmSpec.getResources()),
-                validateJmReplicas(jmSpec.getReplicas(), confMap));
-    }
-
-    private Optional<String> validateJmMemoryConfig(Configuration conf) {
+                        validateResources("JobManager", jmSpec.getResource()),
+                        validateResourceRequirements("JobManager", 
jmSpec.getResources()),
+                        validateJmReplicas(jmSpec.getReplicas(), confMap))
+                .or(() -> validateJmMemoryConfig(jmSpec, confMap));
+    }
+
+    private Optional<String> validateJmMemoryConfig(
+            @Nullable JobManagerSpec jmSpec, Map<String, String> confMap) {
+        final String processMemory =
+                jmSpec == null
+                        ? null
+                        : ResourceConfigUtils.getProcessMemory(
+                                jmSpec.getResources(), jmSpec.getResource());
+        final Configuration conf = Configuration.fromMap(confMap);
+        if (processMemory != null) {
+            conf.setString(JobManagerOptions.TOTAL_PROCESS_MEMORY.key(), 
processMemory);

Review Comment:
   I don't think this one is redundant. The validator doesn't go through 
`FlinkConfigBuilder`. It checks the operator defaults plus 
`spec.flinkConfiguration`, so this line is how the memory from 
`spec.jobManager` reaches the check. I removed it and the TaskManager one and 
ran `DefaultValidatorTest`. 30 of 44 tests fail with "Either required 
fine-grained memory (jobmanager.memory.heap.size), or Total Flink Memory size 
..., or Total Process Memory size ... need to be configured explicitly", 
because a valid spec no longer passes.
   



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