This is an automated email from the ASF dual-hosted git repository. snemeth pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new cacc870 YARN-10593. Fix incorrect string comparison in GpuDiscoverer. Contributed by Peter Bacsko cacc870 is described below commit cacc87038966a62e1d5a603a4aa40c9d28bc7d87 Author: Szilard Nemeth <snem...@apache.org> AuthorDate: Wed Feb 10 13:09:11 2021 +0100 YARN-10593. Fix incorrect string comparison in GpuDiscoverer. Contributed by Peter Bacsko --- .../resourceplugin/gpu/GpuDiscoverer.java | 7 +++--- .../resourceplugin/gpu/TestGpuDiscoverer.java | 29 ++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java index 0d05c9e..f9be9fe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/GpuDiscoverer.java @@ -284,11 +284,12 @@ public class GpuDiscoverer extends Configured { binaryPath = configuredBinaryFile; // If path exists but file name is incorrect don't execute the file String fileName = binaryPath.getName(); - if (DEFAULT_BINARY_NAME.equals(fileName)) { + if (!DEFAULT_BINARY_NAME.equals(fileName)) { String msg = String.format("Please check the configuration value of" - +" %s. It should point to an %s binary.", + +" %s. It should point to an %s binary, which is now %s", YarnConfiguration.NM_GPU_PATH_TO_EXEC, - DEFAULT_BINARY_NAME); + DEFAULT_BINARY_NAME, + fileName); throwIfNecessary(new YarnException(msg), config); LOG.warn(msg); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java index 6da23858..06791c8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/resourceplugin/gpu/TestGpuDiscoverer.java @@ -79,12 +79,23 @@ public class TestGpuDiscoverer { } private File setupFakeBinary(Configuration conf) { + return setupFakeBinary(conf, + GpuDiscoverer.DEFAULT_BINARY_NAME, false); + } + + private File setupFakeBinary(Configuration conf, String filename, + boolean useFullPath) { File fakeBinary; try { fakeBinary = new File(getTestParentFolder(), - GpuDiscoverer.DEFAULT_BINARY_NAME); + filename); touchFile(fakeBinary); - conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, getTestParentFolder()); + if (useFullPath) { + conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, + fakeBinary.getAbsolutePath()); + } else { + conf.set(YarnConfiguration.NM_GPU_PATH_TO_EXEC, getTestParentFolder()); + } } catch (Exception e) { throw new RuntimeException("Failed to init fake binary", e); } @@ -513,4 +524,18 @@ public class TestGpuDiscoverer { verify(gpuSpy, never()).getGpuDeviceInformation(); } + + @Test + public void testBinaryIsNotNvidiaSmi() throws YarnException { + exception.expect(YarnException.class); + exception.expectMessage(String.format( + "It should point to an %s binary, which is now %s", + "nvidia-smi", "badfile")); + + Configuration conf = new Configuration(false); + setupFakeBinary(conf, "badfile", true); + + GpuDiscoverer plugin = new GpuDiscoverer(); + plugin.initialize(conf, binaryHelper); + } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org