You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/05/07 03:04:33 UTC

[GitHub] [flink] xintongsong commented on a change in pull request #15815: [FLINK-22505][core] Limit the scale of Resource to 8

xintongsong commented on a change in pull request #15815:
URL: https://github.com/apache/flink/pull/15815#discussion_r627889619



##########
File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesResourceManagerDriverTest.java
##########
@@ -362,7 +362,12 @@ protected void validateRequestedResources(
                                             .getMebiBytes())));
             assertThat(
                     resourceRequirements.getRequests().get(Constants.RESOURCE_NAME_CPU).getAmount(),
-                    is(String.valueOf(taskExecutorProcessSpec.getCpuCores().getValue())));
+                    is(
+                            String.valueOf(
+                                    taskExecutorProcessSpec
+                                            .getCpuCores()
+                                            .getValue()
+                                            .doubleValue())));

Review comment:
       I think this is an indicator that this PR changes `Resource` in a way that `Resource#getValue#toString` now may contain trailing zeros, which is probably undesired. E.g., this may affect log readabilities.
   
   We can use `BigDecimal#stripTrailingZeros` to make `Resource` avoid trailing zeros.

##########
File path: flink-core/src/main/java/org/apache/flink/api/common/resources/Resource.java
##########
@@ -45,11 +45,13 @@ protected Resource(String name, double value) {
 
     protected Resource(String name, BigDecimal value) {
         checkNotNull(value);
+        final BigDecimal valueRoundDown = value.setScale(8, RoundingMode.DOWN);

Review comment:
       Maybe introduce a constant `MAX_VALUE_SCALE`.




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

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