Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ private void initializeNodeLabels(CapacitySchedulerConfiguration configuration,
}

private void initializeAccessibleLabels(CapacitySchedulerConfiguration configuration) {
this.accessibleLabels = configuration.getAccessibleNodeLabels(queuePath.getFullPath());
// Inherit labels from parent if not set
if (this.accessibleLabels == null && parent != null) {
Set<String> nodeLabels = configuration.getAccessibleNodeLabels(queuePath.getFullPath());
if (null != nodeLabels) {
// Reading "accessibleLabels" can cause NPE without ReadLock.
// Since getAccessibleNodeLabels() can return null, If someone access
// "accessibleLabels" before assigning it from parent can cause NPE.
// So use local instance and assign it only if not null
this.accessibleLabels = nodeLabels;
} else if (null != parent) {
// Inherit labels from parent if not set
this.accessibleLabels = parent.getAccessibleNodeLabels();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5431,4 +5431,23 @@ public void testSubmitUsingRealUserAcls() throws Exception {
rm.stop();
rm.close();
}

@Test
public void testLeafHasAllNodeLabelsOfItsRoot() throws IOException {

CapacitySchedulerConfiguration conf = csConf;
String rootChild = root.getChildQueues().get(0).getQueuePath();
ParentQueue rootQueue = (ParentQueue) cs.getRootQueue();
ConfiguredNodeLabels nodeLabelsForAllQueues =
rootQueue.getQueueContext().getQueueManager().getConfiguredNodeLabelsForAllQueues();

QueueNodeLabelsSettings labelsSettings =
new QueueNodeLabelsSettings(conf, root, new QueuePath(rootQueue.getQueuePath(), "test"), nodeLabelsForAllQueues);
Assert.assertEquals(labelsSettings.getAccessibleNodeLabels(), "*");

labelsSettings = new QueueNodeLabelsSettings(conf, root,
new QueuePath(rootQueue.getQueuePath(), rootQueue.getChildQueues().get(0).getQueuePath()),
nodeLabelsForAllQueues);
Assert.assertEquals(labelsSettings.getAccessibleNodeLabels(), "*");
}
}