Gargi-jais11 commented on code in PR #11965:
URL: https://github.com/apache/ozone/pull/11965#discussion_r4611429401


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -473,7 +486,10 @@ public BackgroundTaskQueue getTasks() {
           LOG.warn("Failed to persist updated DiskBalancerInfo to file.", e);
         }
       }
-      metrics.incrIdleLoopNoAvailableVolumePairCount();
+      // Rejection by the service does not mean the policy found no balancing 
work.
+      if (!rejectedCandidate) {
+        metrics.incrIdleLoopNoAvailableVolumePairCount();
+      }

Review Comment:
   With only /data/ssd (SSD, 90%) and /data/hdd (DISK, 20%), a custom policy 
offers container 101 from SSD to DISK and then returns null. The move is 
rejected, the queue stays empty, and nothing is in progress. 
`!rejectedCandidate `keeps the service RUNNING. Bytes moved are 0, so 
`shouldDelay()` adds no pause, and the same warning repeats on every 60s cycle. 
**idleLoopNoAvailableVolumePairCount** also stays unchanged, so the status 
looks like balancing is still in progress. The disks are not even here. The 
balancer is stopping because the policy offered no same-type pair, so the log 
should name the policy.
   
   continue in the loop is right. 
   
   `testCustomPolicyCannotMoveAcrossStorageTypes `currently expects RUNNING and 
an idle count of 0. It should expect STOPPED, this warning, and an idle count 
of 1.
    I think this would look more appropriate:
   ```
   if (queue.isEmpty() && inProgressContainers.isEmpty()) {
     if (stopAfterDiskEven) {
       // Containers only move between volumes of the same StorageType, so no 
volume pair is also
       // reported when every StorageType has fewer than two volumes, even if 
those volumes are
       // unevenly used.
       if (rejectedCandidate) {
         LOG.warn("Disk balancer is stopped because the container choosing 
policy {} returned only volume pairs" +
             " of different StorageTypes as the property StopAfterDiskEven is 
set to true.",
             volumeContainerChoosingPolicy.getClass().getName());
       } else {
         LOG.info("Disk balancer is stopped because no volume pair of the same 
StorageType needs" +
             " balancing as the property StopAfterDiskEven is set to true.");
       }
       this.operationalState = DiskBalancerRunningStatus.STOPPED;
       // persist DiskBalancerInfo, unchanged
     }
     metrics.incrIdleLoopNoAvailableVolumePairCount();
     cleanupPendingDeletionContainers();
   }
   ```



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