srpraneeth commented on code in PR #670:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/670#discussion_r1326652816


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/config/FlinkConfigBuilder.java:
##########
@@ -420,13 +421,24 @@ private void setResource(Resource resource, Configuration 
effectiveConfig, boole
                             ? JobManagerOptions.TOTAL_PROCESS_MEMORY
                             : TaskManagerOptions.TOTAL_PROCESS_MEMORY;
             if (resource.getMemory() != null) {
-                effectiveConfig.setString(memoryConfigOption.key(), 
resource.getMemory());
+                effectiveConfig.setString(
+                        memoryConfigOption.key(), 
parseResourceMemoryString(resource.getMemory()));
             }
 
             configureCpu(resource, effectiveConfig, isJM);
         }
     }
 
+    // Using the K8s units specification for the JM and TM memory settings
+    private String parseResourceMemoryString(String memory) {
+        try {
+            return MemorySize.parse(memory).toString();

Review Comment:
   After addressing the comments and using the Quantity as fall back logic, 
below is the behaviour for different cases. 
   Please review the same
   
   | Configuration | Previous InterpretedValue                  | New 
InterpretedValue (Approach2)      |
   
|---------------|---------------------------------------|-----------------------------------|
   | 2g            | 2147483648 b                               | 2147483648 b  
                                |
   | 2gb           | 2147483648 b                               | 2147483648 b  
                                |
   | 2G            | 2147483648 b                               | 2147483648 b  
                                |
   | 2 g           | 2147483648 b                               | 2147483648 b  
                                        |
   | 512m          | 536870912 b                                                
        | 536870912 b                                   |
   | 2gi           | Fail (Could not parse value '2gi')         | 2147483648 b  
                                        |
   | 2Gi           | Fail (Could not parse value '2Gi') | 2147483648 b          
                        |
   | 2gib          | Fail (Could not parse value '2gi')         | 2147483648 b  
                                        |
   | 2 Gi          | Fail (Could not parse value '2 Gi')        | 2147483648 b  
                                        |
   | 512mi         | Fail (Could not parse value '512mi')       | 536870912 b   
                                        |
   | 1000000b      | 1000000b                                                   
        | 1000000 b                                             |
   | 1000000 b     | 1000000b                                                   
        | 1000000 b                                             |
   | 1e6 b      | Fail (Could not parse value '1e6 b')  | 1000000 b             
                                |
   | 1e6                    | Fail (Could not parse value '1e6')    | 1000000 b 
                                                |
   
   
   The only way for user to configure the giga(decimal) bytes is to convert 
into the numerical bytes and then use it.
   For ex: 2G = 2 * 1000 * 1000 * 1000 b = 2000000000 b



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to