Hean-Chhinling commented on code in PR #8641:
URL: https://github.com/apache/hadoop/pull/8641#discussion_r3794884915


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfigValidator.java:
##########
@@ -114,6 +120,68 @@ public static void validateVCores(Configuration conf) {
     }
   }
 
+  /**
+   * Validates that queue's partition capacity.
+   * It could only be configured if the queue is accessible by that label and 
vice versa,
+   * the label that is accessible by the queue could not be removed if
+   * it has capacity or max-capacity configured in queue's partition
+   *
+   * @param conf Capacity Scheduler configuration to validate
+   * @throws IOException when the above rules have been violated
+   */
+  public static void validateQueueAccessibleLabels(Configuration conf) throws 
IOException {
+    CapacitySchedulerConfiguration csConf = new 
CapacitySchedulerConfiguration(conf);
+
+    for (String queuePath : csConf.getConfiguredNodeLabelsByQueue().keySet()) {
+      QueuePath queue = new QueuePath(queuePath);
+      if (queue.isRoot()) {
+        continue;
+      }
+
+      for (String label : csConf.getConfiguredNodeLabels(queue)) {
+        if (RMNodeLabelsManager.NO_LABEL.equals(label)
+            || !hasQueuePartitionCapacity(csConf, queue, label)
+            || isLabelAccessibleByQueue(csConf, queue, label)) {
+          continue;
+        }
+
+        throw new IOException("Queue: " + queuePath +
+          " must have accessible-node-labels and its capacity together");
+      }
+    }
+  }
+
+  private static boolean hasQueuePartitionCapacity(
+      CapacitySchedulerConfiguration conf, QueuePath queue, String label) {
+    String labelPrefix = QueuePrefixes.getNodeLabelPrefix(queue, label);
+    String capacity = conf.get(labelPrefix + CAPACITY);
+    if (capacity != null && !capacity.trim().isEmpty()) {
+      return true;
+    }
+    String maxCapacity = conf.get(labelPrefix + MAXIMUM_CAPACITY);
+    return maxCapacity != null && !maxCapacity.trim().isEmpty();
+  }
+
+  /**
+   * Requires queue in the queue-path to declare accessible-node-labels 
explicitly.
+   * The inheritance from root’s implicit * label is not accepted here.

Review Comment:
   Thanks you so much for the review @brumi1024!
   Yep, in that case the inherited behaviour from root queue will be rejected.
   I understand that this would contradict the documentation however the CS 
configs is arguable not ideal as you said. 
   
   I come up with the following solution to align with the documentation and 
not breaking existing configs:
   
   1. At the `isLabelAccessibleByQueue()` I will not skip the `root` queue that 
way it will inherit the implicit * labels from root queue. Thus, the above 
configs you suggested will be valid.
   2. Keep the strict validation that queue accessible label should declare on 
the Capacity Scheduler UI while allows * inheritance from the root queue.
   
   Please let me know what do you think or you have a better suggestion



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