You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by zh...@apache.org on 2015/02/06 22:47:21 UTC
[49/50] [abbrv] hadoop git commit: YARN-3089. LinuxContainerExecutor
does not handle file arguments to deleteAsUser. Contributed by Eric Payne
YARN-3089. LinuxContainerExecutor does not handle file arguments to deleteAsUser. Contributed by Eric Payne
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2bb2df45
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2bb2df45
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2bb2df45
Branch: refs/heads/HDFS-EC
Commit: 2bb2df454b95588423c412996cb837c0a49155d2
Parents: 0d1ddeb
Author: Jason Lowe <jl...@apache.org>
Authored: Fri Feb 6 20:39:01 2015 +0000
Committer: Zhe Zhang <zh...@apache.org>
Committed: Fri Feb 6 13:45:53 2015 -0800
----------------------------------------------------------------------
hadoop-yarn-project/CHANGES.txt | 3 +++
.../impl/container-executor.c | 26 ++++++++++++++++----
.../test/test-container-executor.c | 21 ++++++++++++++++
3 files changed, 45 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bb2df45/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 2220c2a..51ed31f 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -504,6 +504,9 @@ Release 2.7.0 - UNRELEASED
YARN-2694. Ensure only single node label specified in ResourceRequest.
(Wangda Tan via jianhe)
+ YARN-3089. LinuxContainerExecutor does not handle file arguments to
+ deleteAsUser (Eric Payne via jlowe)
+
Release 2.6.0 - 2014-11-18
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bb2df45/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
index f73776e..04d0232 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c
@@ -1354,21 +1354,37 @@ int delete_as_user(const char *user,
const char *subdir,
char* const* baseDirs) {
int ret = 0;
-
+ int subDirEmptyStr = (subdir == NULL || subdir[0] == 0);
+ int needs_tt_user = subDirEmptyStr;
char** ptr;
// TODO: No switching user? !!!!
if (baseDirs == NULL || *baseDirs == NULL) {
- return delete_path(subdir, strlen(subdir) == 0);
+ return delete_path(subdir, needs_tt_user);
}
// do the delete
for(ptr = (char**)baseDirs; *ptr != NULL; ++ptr) {
- char* full_path = concatenate("%s/%s", "user subdir", 2,
- *ptr, subdir);
+ char* full_path = NULL;
+ struct stat sb;
+ if (stat(*ptr, &sb) != 0) {
+ fprintf(LOGFILE, "Could not stat %s\n", *ptr);
+ return -1;
+ }
+ if (!S_ISDIR(sb.st_mode)) {
+ if (!subDirEmptyStr) {
+ fprintf(LOGFILE, "baseDir \"%s\" is a file and cannot contain subdir \"%s\".\n", *ptr, subdir);
+ return -1;
+ }
+ full_path = strdup(*ptr);
+ needs_tt_user = 0;
+ } else {
+ full_path = concatenate("%s/%s", "user subdir", 2, *ptr, subdir);
+ }
+
if (full_path == NULL) {
return -1;
}
- int this_ret = delete_path(full_path, strlen(subdir) == 0);
+ int this_ret = delete_path(full_path, needs_tt_user);
free(full_path);
// delete as much as we can, but remember the error
if (this_ret != 0) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/2bb2df45/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
index e9ac234..7f08e06 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/test/test-container-executor.c
@@ -382,7 +382,28 @@ void test_delete_user() {
if (mkdirs(app_dir, 0700) != 0) {
exit(1);
}
+
char buffer[100000];
+ sprintf(buffer, "%s/test.cfg", app_dir);
+ if (write_config_file(buffer) != 0) {
+ exit(1);
+ }
+
+ char * dirs[] = {buffer, 0};
+ int ret = delete_as_user(yarn_username, "file1" , dirs);
+ if (ret == 0) {
+ printf("FAIL: if baseDir is a file, delete_as_user should fail if a subdir is also passed\n");
+ exit(1);
+ }
+
+ // Pass a file to delete_as_user in the baseDirs parameter. The file should
+ // be deleted.
+ ret = delete_as_user(yarn_username, "" , dirs);
+ if (ret != 0) {
+ printf("FAIL: delete_as_user could not delete baseDir when baseDir is a file: return code is %d\n", ret);
+ exit(1);
+ }
+
sprintf(buffer, "%s/local-1/usercache/%s", TEST_ROOT, yarn_username);
if (access(buffer, R_OK) != 0) {
printf("FAIL: directory missing before test\n");