Repository: hadoop
Updated Branches:
  refs/heads/trunk e37458447 -> c16c49b8c


YARN-8587. Added retries for fetching docker exit code.
           Contributed by Charo Zhang


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

Branch: refs/heads/trunk
Commit: c16c49b8c3b8e2e42c00e79a50e7ae029ebe98e2
Parents: e374584
Author: Eric Yang <[email protected]>
Authored: Wed Oct 24 17:28:23 2018 -0400
Committer: Eric Yang <[email protected]>
Committed: Wed Oct 24 17:29:46 2018 -0400

----------------------------------------------------------------------
 .../impl/container-executor.c                   | 30 +++++++++++---------
 1 file changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c16c49b8/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 6704177..1ca94fe 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
@@ -2006,20 +2006,22 @@ int launch_docker_container_as_user(const char * user, 
const char *app_id,
   docker_binary, container_id);
   fprintf(LOGFILE, "Obtaining the exit code...\n");
   fprintf(LOGFILE, "Docker inspect command: %s\n", 
docker_inspect_exitcode_command);
-  FILE* inspect_exitcode_docker = popen(docker_inspect_exitcode_command, "r");
-  if(inspect_exitcode_docker == NULL) {
-    fprintf(ERRORFILE, "Done with inspect_exitcode, inspect_exitcode_docker is 
null\n");
-    fflush(ERRORFILE);
-    exit_code = -1;
-    goto cleanup;
-  }
-  res = fscanf (inspect_exitcode_docker, "%d", &exit_code);
-  if (pclose (inspect_exitcode_docker) != 0 || res <= 0) {
-  fprintf (ERRORFILE,
-   "Could not inspect docker to get exitcode:  %s.\n", 
docker_inspect_exitcode_command);
-    fflush(ERRORFILE);
-    exit_code = -1;
-    goto cleanup;
+  int count = 0;
+  int max_retries = get_max_retries(&CFG);
+  while (count < max_retries) {
+    FILE* inspect_exitcode_docker = popen(docker_inspect_exitcode_command, 
"r");
+    res = fscanf (inspect_exitcode_docker, "%d", &exit_code);
+    if (pclose (inspect_exitcode_docker) != 0 || res <= 0) {
+      fprintf (ERRORFILE, "Could not inspect docker to get Exit code %s.\n", 
docker_inspect_exitcode_command);
+      fflush(ERRORFILE);
+      exit_code = -1;
+    } else {
+      if (exit_code != 0) {
+        break;
+      }
+    }
+    sleep(3);
+    count++;
   }
   fprintf(LOGFILE, "Exit code from docker inspect: %d\n", exit_code);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to