hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject hadoop git commit: YARN-4459. container-executor should only kill process groups. Contributed by Jun Gong (cherry picked from commit 1ba31fe9e906dbd093afd4b254216601967a4a7b)
Date Wed, 25 May 2016 21:29:43 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 e5dab6806 -> da7704079


YARN-4459. container-executor should only kill process groups. Contributed by Jun Gong
(cherry picked from commit 1ba31fe9e906dbd093afd4b254216601967a4a7b)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/da770407
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/da770407
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/da770407

Branch: refs/heads/branch-2
Commit: da77040793237fe68f9ffed2615b1ad1abac86a1
Parents: e5dab68
Author: Jason Lowe <jlowe@apache.org>
Authored: Wed May 25 21:24:55 2016 +0000
Committer: Jason Lowe <jlowe@apache.org>
Committed: Wed May 25 21:29:27 2016 +0000

----------------------------------------------------------------------
 .../impl/container-executor.c                   | 19 ++------
 .../test/test-container-executor.c              | 49 --------------------
 2 files changed, 5 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/da770407/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 970085b..459dc8e 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
@@ -1540,21 +1540,13 @@ int signal_container_as_user(const char *user, int pid, int sig) {
   }
 
   //Don't continue if the process-group is not alive anymore.
-  int has_group = 1;
   if (kill(-pid,0) < 0) {
-    if (kill(pid, 0) < 0) {
-      if (errno == ESRCH) {
-        return INVALID_CONTAINER_PID;
-      }
-      fprintf(LOGFILE, "Error signalling container %d with %d - %s\n",
-	      pid, sig, strerror(errno));
-      return -1;
-    } else {
-      has_group = 0;
-    }
+    fprintf(LOGFILE, "Error signalling not exist process group %d "
+            "with signal %d\n", pid, sig);
+    return INVALID_CONTAINER_PID;
   }
 
-  if (kill((has_group ? -1 : 1) * pid, sig) < 0) {
+  if (kill(-pid, sig) < 0) {
     if(errno != ESRCH) {
       fprintf(LOGFILE, 
               "Error signalling process group %d with signal %d - %s\n", 
@@ -1568,8 +1560,7 @@ int signal_container_as_user(const char *user, int pid, int sig) {
       return INVALID_CONTAINER_PID;
     }
   }
-  fprintf(LOGFILE, "Killing process %s%d with %d\n",
-	  (has_group ? "group " :""), pid, sig);
+  fprintf(LOGFILE, "Killing process group %d with %d\n", pid, sig);
   return 0;
 }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/da770407/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 67f0357..e9ad370 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
@@ -471,54 +471,6 @@ void run_test_in_child(const char* test_name, void (*func)()) {
   }
 }
 
-void test_signal_container() {
-  sigset_t set;
-
-  // unblock SIGQUIT
-  sigemptyset(&set);
-  sigaddset(&set, SIGQUIT);
-  sigprocmask(SIG_UNBLOCK, &set, NULL);
-
-  printf("\nTesting signal_container\n");
-  fflush(stdout);
-  fflush(stderr);
-  pid_t child = fork();
-  if (child == -1) {
-    printf("FAIL: fork failed\n");
-    exit(1);
-  } else if (child == 0) {
-    printf("\nSwitching to user %d\n", user_detail->pw_uid);
-    if (change_user(user_detail->pw_uid, user_detail->pw_gid) != 0) {
-      exit(1);
-    }
-    sleep(3600);
-    exit(0);
-  } else {
-    printf("Child container launched as %" PRId64 "\n", (int64_t)child);
-    printf("Signaling container as user %s\n", yarn_username);
-    // there's a race condition for child calling change_user and us
-    // calling signal_container_as_user, hence sleeping
-    sleep(3);
-    if (signal_container_as_user(yarn_username, child, SIGQUIT) != 0) {
-      exit(1);
-    }
-    int status = 0;
-    if (waitpid(child, &status, 0) == -1) {
-      printf("FAIL: waitpid failed - %s\n", strerror(errno));
-      exit(1);
-    }
-    if (!WIFSIGNALED(status)) {
-      printf("FAIL: child wasn't signalled - %d\n", status);
-      exit(1);
-    }
-    if (WTERMSIG(status) != SIGQUIT) {
-      printf("FAIL: child was killed with %d instead of %d\n", 
-	     WTERMSIG(status), SIGQUIT);
-      exit(1);
-    }
-  }
-}
-
 void test_signal_container_group() {
   printf("\nTesting group signal_container\n");
   fflush(stdout);
@@ -931,7 +883,6 @@ int main(int argc, char **argv) {
 
   // the tests that change user need to be run in a subshell, so that
   // when they change user they don't give up our privs
-  run_test_in_child("test_signal_container", test_signal_container);
   run_test_in_child("test_signal_container_group", test_signal_container_group);
 
   // init app and run container can't be run if you aren't testing as root


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message