ayushtkn commented on code in PR #5569:
URL: https://github.com/apache/hadoop/pull/5569#discussion_r1192914285


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeResourceChecker.java:
##########
@@ -174,6 +174,19 @@ private void addDirToCheck(URI directoryToCheck, boolean 
required)
    *         otherwise.
    */
   public boolean hasAvailableDiskSpace() {
+    try {
+      if (minimumRedundantVolumes > volumes.size()){
+        throw new IllegalArgumentException("The value of "
+        + DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_KEY
+        + " is " + minimumRedundantVolumes
+        + " which is greater than the total number of existing storage volumes 
"
+        + volumes.size() + " .");
+      }
+    } catch (IllegalArgumentException e){
+      LOG.warn("The value of " + 
DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_KEY
+        + " is greater than the total number of existing storage volumes"
+        + " and will result in adding resources and still not being able to 
turn off safe mode.", e);
+    }
     return NameNodeResourcePolicy.areResourcesAvailable(volumes.values(),
         minimumRedundantVolumes);

Review Comment:
   minimumRedundantVolumes isn't always an issue if it is more than 
volume.size()
   If you go inside ``areResourcesAvailable``
   this does return true
   ```
       if (redundantResourceCount == 0) {
         // If there are no redundant resources, return true if there are any
         // required resources available.
         return requiredResourceCount > 0;
       }
   ```
   When there is no redundant resource irrespective of 
``minimumRedundantVolumes`` value
   
   Second, if
   
   ```
       // - during startup, if there are no edits dirs on disk, then there is
       // a call to areResourcesAvailable() with no dirs at all, which was
       // previously causing the NN to enter safemode
       if (resources.isEmpty()) {
         return true;
       }
   
   ```
   
   Any place where a log line can be added is here, and that too if it is 
``false``, telling about all these numbers + the total number of values
   ```
       } else {
         return redundantResourceCount - disabledRedundantResourceCount >=
             minimumRedundantResources;
       }
   ```



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