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


##########
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:
   @gyfora Sorry my bad I should not have force pushed. 
   
   Just for the sake of understanding I am using the term Approach 1 with the 
current approach and Approach2 using try/catch as suggested by Gyula(My 
previous approach). 
   The interpreted values for different configurations is listed below. 
   
   | Configuration | Previous InterpretedValue                  | New 
InterpretedValue (Approach1)      | New InterpretedValue (Approach2)            
                                                                                
                            | 
   
|---------------|---------------------------------------|-----------------------------------|-------------------------------------------------------------------------------------------------|
   | 2g            | 2147483648 b                               | 2000000000 b  
                                | 2147483648 b                                  
                                                                                
                                                  |
   | 2gb           | 2147483648 b                               | 2000000000 b  
                                | Fail (Could not parse the syntax i by the 
MemorySize, could not parse the syntax g by K8s spec) |
   | 2G            | 2147483648 b                               | 2000000000 b  
                                | 2147483648 b                                  
                                                                                
                                                  |
   | 2 g           | 2147483648 b                               | 2000000000 b  
                                        | 2147483648 b                          
                                                                                
                                                          |
   | 512m          | 536870912 b                                                
        | 512000000 b                                   | 536870912 b           
                                                                                
                                                                          |
   | 2gi           | Fail (Could not parse value '2gi')         | 2147483648 b  
                                        | Fail (Could not parse the syntax i by 
the MemorySize, could not parse the syntax g by K8s spec) |
   | 2Gi           | Fail (Could not parse value '2Gi') | 2147483648 b          
                        | 2147483648 b                                          
                                                                                
                                          |
   | 2gib          | Fail (Could not parse value '2gi')         | 2147483648 b  
                                        | Fail (Could not parse the syntax i by 
the MemorySize, could not parse the syntax g by K8s spec) |
   | 2 Gi          | Fail (Could not parse value '2 Gi')        | 2147483648 b  
                                        | 2147483648 b                          
                                                                                
                                                          |
   | 512mi         | Fail (Could not parse value '512mi')       | 536870912 b   
                                        | Fail (Could not parse the syntax i by 
the MemorySize, could not parse the syntax g by K8s spec) |
   | 1000000b      | 1000000b                                                   
        | 1000000 b                                             | 1000000 b     
                                                                                
                                                                                
  |
   | 1000000 b     | 1000000b                                                   
        | 1000000 b                                             | 1000000 b     
                                                                                
                                                                                
  |
   | 1e6 b      | Fail (Could not parse value '1e6 b')  | 1000000 b             
                                | Fail (Could not parse the syntax i by the 
MemorySize, could not parse the syntax g by K8s spec) |
   | 1e6                    | Fail (Could not parse value '1e6')    | 1000000 b 
                                                | 1000000 b                     
                                                                                
                                                                  |
   
   
   The problem with the Approach 2 is the Flink MemorySize interprets the value 
incorrectly.
   So if user try to configure 2g or 2G then the flink memorysize will parse it 
successfully but would interpret it as 2 gibibytes instead of 2 Gigabytes. The 
only thing that this cant parse is the configurations with i syntax like 2Gi 
and when K8s Quantity.parse would parse this it will interpret again it as 2 
gibibytes and because of this problem the user would never be able to configure 
the 2 gigabytes (2000000000 b) with Approach2.
   So both the try and catch part of the code would result in same 
interpretation of the values which is Bi bytes. 
   
   
   So I dont see a way to make this change happen without breaking users or 
coming up with another syntax for configuring the memory in decimal bytes.
   But I do agree with @gyfora 7% difference in the allocation may create 
issues for users.
   



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