Skip to content

Commit 606061a

Browse files
committed
YARN-9595. FPGA plugin: NullPointerException in FpgaNodeResourceUpdateHandler.updateConfiguredResource(). Contributed by Peter Bacsko.
1 parent 277e9a8 commit 606061a

File tree

2 files changed

+36
-2
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src
    • main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/fpga
    • test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/fpga

2 files changed

+36
-2
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/fpga/FpgaDiscoverer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public List<FpgaDevice> discover()
124124

125125
if (allowed == null || allowed.equalsIgnoreCase(
126126
YarnConfiguration.AUTOMATICALLY_DISCOVER_GPU_DEVICES)) {
127+
currentFpgaInfo = ImmutableList.copyOf(list);
127128
return list;
128129
} else if (allowed.matches("(\\d,)*\\d")){
129130
Set<String> minors = Sets.newHashSet(allowed.split(","));
@@ -134,6 +135,8 @@ public List<FpgaDevice> discover()
134135
.filter(dev -> minors.contains(String.valueOf(dev.getMinor())))
135136
.collect(Collectors.toList());
136137

138+
currentFpgaInfo = ImmutableList.copyOf(list);
139+
137140
// if the count of user configured is still larger than actual
138141
if (list.size() != minors.size()) {
139142
LOG.warn("We continue although there're mistakes in user's configuration " +
@@ -145,8 +148,6 @@ public List<FpgaDevice> discover()
145148
YarnConfiguration.NM_FPGA_ALLOWED_DEVICES + ":\"" + allowed + "\"");
146149
}
147150

148-
currentFpgaInfo = ImmutableList.copyOf(list);
149-
150151
return list;
151152
}
152153

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/fpga/TestFpgaDiscoverer.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,39 @@ public void testDiscoveryWhenExternalScriptCannotBeExecuted()
288288
}
289289
}
290290

291+
@Test
292+
public void testCurrentFpgaInfoWhenAllDevicesAreAllowed()
293+
throws YarnException {
294+
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
295+
"acl0/243:0,acl1/244:1");
296+
297+
fpgaDiscoverer.initialize(conf);
298+
List<FpgaDevice> devices = fpgaDiscoverer.discover();
299+
List<FpgaDevice> currentFpgaInfo = fpgaDiscoverer.getCurrentFpgaInfo();
300+
301+
assertEquals("Devices", devices, currentFpgaInfo);
302+
}
303+
304+
@Test
305+
public void testCurrentFpgaInfoWhenAllowedDevicesDefined()
306+
throws YarnException {
307+
conf.set(YarnConfiguration.NM_FPGA_AVAILABLE_DEVICES,
308+
"acl0/243:0,acl1/244:1");
309+
conf.set(YarnConfiguration.NM_FPGA_ALLOWED_DEVICES, "0");
310+
311+
fpgaDiscoverer.initialize(conf);
312+
List<FpgaDevice> devices = fpgaDiscoverer.discover();
313+
List<FpgaDevice> currentFpgaInfo = fpgaDiscoverer.getCurrentFpgaInfo();
314+
315+
assertEquals("Devices", devices, currentFpgaInfo);
316+
assertEquals("List of devices", 1, currentFpgaInfo.size());
317+
318+
FpgaDevice device = currentFpgaInfo.get(0);
319+
assertEquals("Device id", "acl0", device.getAliasDevName());
320+
assertEquals("Minor number", 0, device.getMinor());
321+
assertEquals("Major", 243, device.getMajor());
322+
}
323+
291324
private IntelFpgaOpenclPlugin.InnerShellExecutor mockPuginShell() {
292325
IntelFpgaOpenclPlugin.InnerShellExecutor shell = mock(IntelFpgaOpenclPlugin.InnerShellExecutor.class);
293326
when(shell.runDiagnose(anyString(),anyInt())).thenReturn("");

0 commit comments

Comments
 (0)