YARN-3088. LinuxContainerExecutor.deleteAsUser can throw NPE if native executor returns an error. Contributed by Eric Payne
(cherry picked from commit 902c6ea7e4
)
This commit is contained in:
parent
c081fa6ae8
commit
07fe6a36cb
|
@ -375,6 +375,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
YARN-3082. Non thread safe access to systemCredentials in NodeHeartbeatResponse
|
YARN-3082. Non thread safe access to systemCredentials in NodeHeartbeatResponse
|
||||||
processing. (Anubhav Dhoot via ozawa)
|
processing. (Anubhav Dhoot via ozawa)
|
||||||
|
|
||||||
|
YARN-3088. LinuxContainerExecutor.deleteAsUser can throw NPE if native
|
||||||
|
executor returns an error (Eric Payne via jlowe)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -390,18 +390,23 @@ public class LinuxContainerExecutor extends ContainerExecutor {
|
||||||
verifyUsernamePattern(user);
|
verifyUsernamePattern(user);
|
||||||
String runAsUser = getRunAsUser(user);
|
String runAsUser = getRunAsUser(user);
|
||||||
|
|
||||||
|
String dirString = dir == null ? "" : dir.toUri().getPath();
|
||||||
|
|
||||||
List<String> command = new ArrayList<String>(
|
List<String> command = new ArrayList<String>(
|
||||||
Arrays.asList(containerExecutorExe,
|
Arrays.asList(containerExecutorExe,
|
||||||
runAsUser,
|
runAsUser,
|
||||||
user,
|
user,
|
||||||
Integer.toString(Commands.DELETE_AS_USER.getValue()),
|
Integer.toString(Commands.DELETE_AS_USER.getValue()),
|
||||||
dir == null ? "" : dir.toUri().getPath()));
|
dirString));
|
||||||
|
List<String> pathsToDelete = new ArrayList<String>();
|
||||||
if (baseDirs == null || baseDirs.length == 0) {
|
if (baseDirs == null || baseDirs.length == 0) {
|
||||||
LOG.info("Deleting absolute path : " + dir);
|
LOG.info("Deleting absolute path : " + dir);
|
||||||
|
pathsToDelete.add(dirString);
|
||||||
} else {
|
} else {
|
||||||
for (Path baseDir : baseDirs) {
|
for (Path baseDir : baseDirs) {
|
||||||
Path del = dir == null ? baseDir : new Path(baseDir, dir);
|
Path del = dir == null ? baseDir : new Path(baseDir, dir);
|
||||||
LOG.info("Deleting path : " + del);
|
LOG.info("Deleting path : " + del);
|
||||||
|
pathsToDelete.add(del.toString());
|
||||||
command.add(baseDir.toUri().getPath());
|
command.add(baseDir.toUri().getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,7 +422,7 @@ public class LinuxContainerExecutor extends ContainerExecutor {
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
int exitCode = shExec.getExitCode();
|
int exitCode = shExec.getExitCode();
|
||||||
LOG.error("DeleteAsUser for " + dir.toUri().getPath()
|
LOG.error("DeleteAsUser for " + StringUtils.join(" ", pathsToDelete)
|
||||||
+ " returned with exit code: " + exitCode, e);
|
+ " returned with exit code: " + exitCode, e);
|
||||||
LOG.error("Output from LinuxContainerExecutor's deleteAsUser follows:");
|
LOG.error("Output from LinuxContainerExecutor's deleteAsUser follows:");
|
||||||
logOutput(shExec.getOutput());
|
logOutput(shExec.getOutput());
|
||||||
|
|
|
@ -318,10 +318,57 @@ public class TestLinuxContainerExecutorWithMocks {
|
||||||
String cmd = String.valueOf(
|
String cmd = String.valueOf(
|
||||||
LinuxContainerExecutor.Commands.DELETE_AS_USER.getValue());
|
LinuxContainerExecutor.Commands.DELETE_AS_USER.getValue());
|
||||||
Path dir = new Path("/tmp/testdir");
|
Path dir = new Path("/tmp/testdir");
|
||||||
|
Path testFile = new Path("testfile");
|
||||||
|
Path baseDir0 = new Path("/grid/0/BaseDir");
|
||||||
|
Path baseDir1 = new Path("/grid/1/BaseDir");
|
||||||
|
|
||||||
mockExec.deleteAsUser(appSubmitter, dir);
|
mockExec.deleteAsUser(appSubmitter, dir);
|
||||||
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
appSubmitter, cmd, "/tmp/testdir"),
|
appSubmitter, cmd, "/tmp/testdir"),
|
||||||
readMockParams());
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, null);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, ""),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, testFile, baseDir0, baseDir1);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, testFile.toString(), baseDir0.toString(), baseDir1.toString()),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, null, baseDir0, baseDir1);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, "", baseDir0.toString(), baseDir1.toString()),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
File f = new File("./src/test/resources/mock-container-executer-with-error");
|
||||||
|
if (!FileUtil.canExecute(f)) {
|
||||||
|
FileUtil.setExecutable(f, true);
|
||||||
|
}
|
||||||
|
String executorPath = f.getAbsolutePath();
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(YarnConfiguration.NM_LINUX_CONTAINER_EXECUTOR_PATH, executorPath);
|
||||||
|
mockExec.setConf(conf);
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, dir);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, "/tmp/testdir"),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, null);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, ""),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, testFile, baseDir0, baseDir1);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, testFile.toString(), baseDir0.toString(), baseDir1.toString()),
|
||||||
|
readMockParams());
|
||||||
|
|
||||||
|
mockExec.deleteAsUser(appSubmitter, null, baseDir0, baseDir1);
|
||||||
|
assertEquals(Arrays.asList(YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER,
|
||||||
|
appSubmitter, cmd, "", baseDir0.toString(), baseDir1.toString()),
|
||||||
|
readMockParams());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue