Copilot commented on code in PR #8573:
URL: https://github.com/apache/ozone/pull/8573#discussion_r2131942245


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java:
##########
@@ -346,6 +349,31 @@ public VolumeCheckResult checkDbHealth(File dbFile) throws 
InterruptedException
     return VolumeCheckResult.HEALTHY;
   }
 
+  @VisibleForTesting
+  public void checkVolumeUsages() {
+    boolean isEnoughSpaceAvailable = true;
+    SpaceUsageSource currentUsage = getCurrentUsage();
+    long getFreeSpaceToSpare = getFreeSpaceToSpare(currentUsage.getCapacity());
+    if (currentUsage.getAvailable() < getFreeSpaceToSpare) {
+      LOG.warn("Volume {} has insufficient space for write operation. 
Available: {}, Free space to spare: {}",
+          getStorageDir(), currentUsage.getAvailable(), getFreeSpaceToSpare);
+      isEnoughSpaceAvailable = false;
+    } else if (committedBytes.get() > 0 && currentUsage.getAvailable() < 
committedBytes.get() + getFreeSpaceToSpare) {
+      LOG.warn("Volume {} has insufficient space for on-going container write 
operation. " +
+              "Committed: {}, Available: {}, Free space to spare: {}",
+          getStorageDir(), committedBytes.get(), currentUsage.getAvailable(), 
getFreeSpaceToSpare);
+      isEnoughSpaceAvailable = false;
+    }
+
+    volumeInfoMetrics.setAvailableSpaceInsufficient(!isEnoughSpaceAvailable);
+
+    if 
(!getVolumeUsage().map(VolumeUsage::isReservedUsagesInRange).orElse(true)) {

Review Comment:
   The `reservedCrossesLimit` gauge is only set to true when the limit is 
crossed but is never reset to false when usage returns to normal. Add an `else` 
case to call `volumeInfoMetrics.setReservedCrossesLimit(false);`.



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