Skip to content

YARN-11449. Fix for Intermittent NPE while getting node labels for queue #5466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
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(), "*");
}
}