diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java index 65061ba40e9..10d07d1f9aa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java @@ -1415,18 +1415,32 @@ private Resource assignContainer(Resource clusterResource, FiCaSchedulerNode nod + " priority=" + priority.getPriority() + " request=" + request + " type=" + type); } - - // check if the resource request can access the label - if (!SchedulerUtils.checkNodeLabelExpression( - node.getLabels(), - request.getNodeLabelExpression())) { - // this is a reserved container, but we cannot allocate it now according - // to label not match. This can be caused by node label changed - // We should un-reserve this container. - if (rmContainer != null) { - unreserve(application, priority, node, rmContainer); + + String requestedResourceName = request.getResourceName(); + if (requestedResourceName.equals(ResourceRequest.ANY)) { + // check if the resource request can access the label + if (!SchedulerUtils.checkNodeLabelExpression( + node.getLabels(), + request.getNodeLabelExpression())) { + // this is a reserved container, but we cannot allocate it now according + // to label not match. This can be caused by node label changed + // We should un-reserve this container. + if (rmContainer != null) { + unreserve(application, priority, node, rmContainer); + } + return Resources.none(); + } + } else { + // In addition, we use the requested resource name to match the node. + // It is safe, since the node which is not accessible for the queue will + // not be sent here. + if (!requestedResourceName.equals(node.getNodeName()) && + !requestedResourceName.equals(node.getRackName())) { + if (rmContainer != null) { + unreserve(application, priority, node, rmContainer); + } + return Resources.none(); } - return Resources.none(); } Resource capability = request.getCapability();