YARN-8587. Added retries for fetching docker exit code.
Contributed by Charo Zhang
This commit is contained in:
parent
e374584479
commit
c16c49b8c3
@ -2006,20 +2006,22 @@ int launch_docker_container_as_user(const char * user, const char *app_id,
|
|||||||
docker_binary, container_id);
|
docker_binary, container_id);
|
||||||
fprintf(LOGFILE, "Obtaining the exit code...\n");
|
fprintf(LOGFILE, "Obtaining the exit code...\n");
|
||||||
fprintf(LOGFILE, "Docker inspect command: %s\n", docker_inspect_exitcode_command);
|
fprintf(LOGFILE, "Docker inspect command: %s\n", docker_inspect_exitcode_command);
|
||||||
|
int count = 0;
|
||||||
|
int max_retries = get_max_retries(&CFG);
|
||||||
|
while (count < max_retries) {
|
||||||
FILE* inspect_exitcode_docker = popen(docker_inspect_exitcode_command, "r");
|
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);
|
res = fscanf (inspect_exitcode_docker, "%d", &exit_code);
|
||||||
if (pclose (inspect_exitcode_docker) != 0 || res <= 0) {
|
if (pclose (inspect_exitcode_docker) != 0 || res <= 0) {
|
||||||
fprintf (ERRORFILE,
|
fprintf (ERRORFILE, "Could not inspect docker to get Exit code %s.\n", docker_inspect_exitcode_command);
|
||||||
"Could not inspect docker to get exitcode: %s.\n", docker_inspect_exitcode_command);
|
|
||||||
fflush(ERRORFILE);
|
fflush(ERRORFILE);
|
||||||
exit_code = -1;
|
exit_code = -1;
|
||||||
goto cleanup;
|
} else {
|
||||||
|
if (exit_code != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
fprintf(LOGFILE, "Exit code from docker inspect: %d\n", exit_code);
|
fprintf(LOGFILE, "Exit code from docker inspect: %d\n", exit_code);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user