rakeshadr commented on code in PR #10054:
URL: https://github.com/apache/ozone/pull/10054#discussion_r3051784613


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java:
##########
@@ -753,6 +768,21 @@ private void validateMinFreeSpace() {
           minFreeSpaceRatio);
       minFreeSpaceRatio = HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_PERCENT_DEFAULT;
     }
+    if (minFreeSpaceHardLimitRatio > 1 || minFreeSpaceHardLimitRatio < 0) {
+      LOG.warn("{} = {} is invalid, should be between 0 and 1",

Review Comment:
   Please modify the log message with default value.
         
   ```
   LOG.warn("{} = {} is invalid, should be between 0 and 1; resetting to 
default {}",
             HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_HARD_LIMIT_PERCENT,
             minFreeSpaceHardLimitRatio,
             HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_HARD_LIMIT_PERCENT_DEFAULT);
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java:
##########
@@ -819,10 +849,38 @@ public void setContainerCloseThreads(int 
containerCloseThreads) {
     this.containerCloseThreads = containerCloseThreads;
   }
 
+  /**
+   * Minimum free space reported to SCM (freeSpaceToSpare in storage reports).
+   * <p>If {@code min.free.space.hard.limit.percent &gt; 
min.free.space.percent} (invalid combo),
+   * this returns the same value as {@link #getHardLimitMinFreeSpace(long)} so 
SCM uses the
+   * hard-limit threshold only; there is no soft band until ratios are 
fixed.</p>
+   */
   public long getMinFreeSpace(long capacity) {
+    if (minFreeSpaceHardLimitRatio > minFreeSpaceRatio) {

Review Comment:
   After fixing[ this review 
comment](https://github.com/apache/ozone/pull/10054/changes#r3051805235), this 
if conditional check is no longer needed.



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java:
##########
@@ -819,10 +849,38 @@ public void setContainerCloseThreads(int 
containerCloseThreads) {
     this.containerCloseThreads = containerCloseThreads;
   }
 
+  /**
+   * Minimum free space reported to SCM (freeSpaceToSpare in storage reports).
+   * <p>If {@code min.free.space.hard.limit.percent &gt; 
min.free.space.percent} (invalid combo),
+   * this returns the same value as {@link #getHardLimitMinFreeSpace(long)} so 
SCM uses the
+   * hard-limit threshold only; there is no soft band until ratios are 
fixed.</p>
+   */
   public long getMinFreeSpace(long capacity) {
+    if (minFreeSpaceHardLimitRatio > minFreeSpaceRatio) {
+      return getHardLimitMinFreeSpace(capacity);
+    }
     return Math.max((long) (capacity * minFreeSpaceRatio), minFreeSpace);
   }
 
+  /**
+   * Minimum free space enforced locally for writes (disk full / out-of-space)
+   * and for choosing a volume for a new container (same threshold as writes).
+   */
+  public long getHardLimitMinFreeSpace(long capacity) {
+    return Math.max((long) (capacity * minFreeSpaceHardLimitRatio), 
minFreeSpace);
+  }
+
+  /**
+   * Width of the soft band: reported spare minus hard spare. For example, 
with 2000GB capacity,
+   * 2% reported (40GB) and 1.5% hard (30GB), this is 10GB — the gap where the 
DN may send
+   * close-container actions while writes still succeed.
+   */
+  public long getSoftBandMinFreeSpaceWidth(long capacity) {

Review Comment:
   Please add @VisibleForTesting annotationhere . Its only used in UTs.
   
   Note: Please add all the functions with the annotations, if its only used in 
tests.



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java:
##########
@@ -753,6 +768,21 @@ private void validateMinFreeSpace() {
           minFreeSpaceRatio);
       minFreeSpaceRatio = HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_PERCENT_DEFAULT;
     }
+    if (minFreeSpaceHardLimitRatio > 1 || minFreeSpaceHardLimitRatio < 0) {
+      LOG.warn("{} = {} is invalid, should be between 0 and 1",
+          HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_HARD_LIMIT_PERCENT,
+          minFreeSpaceHardLimitRatio);
+      minFreeSpaceHardLimitRatio =
+          HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_HARD_LIMIT_PERCENT_DEFAULT;
+    }
+    if (minFreeSpaceHardLimitRatio > minFreeSpaceRatio) {
+      LOG.warn("{} = {} is greater than {} = {}. SCM-reported spare will match 
the "

Review Comment:
   Please modify the log message and sets hard limit to soft limit
   
   ```
   LOG.warn("{} = {} must not exceed {} = {}, setting hard limit to soft limit. 
"
           + "Set hard.limit.percent <= min.free.space.percent to enable the 
soft band.",
       HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_HARD_LIMIT_PERCENT,
       minFreeSpaceHardLimitRatio,
       HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_PERCENT,
       minFreeSpaceRatio);
   
   minFreeSpaceHardLimitRatio = minFreeSpaceRatio;
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to