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 sn...@apache.org on 2022/11/22 12:38:29 UTC
[hadoop] branch trunk updated: YARN-8262. get_executable in container-executor should provide meaningful error codes. Contributed by Susheel Gupta
This is an automated email from the ASF dual-hosted git repository.
snemeth pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 3c37a01654e YARN-8262. get_executable in container-executor should provide meaningful error codes. Contributed by Susheel Gupta
3c37a01654e is described below
commit 3c37a01654e0ddca3d88a9fe7ba7b0830ac44ea6
Author: Szilard Nemeth <sn...@apache.org>
AuthorDate: Tue Nov 22 13:37:55 2022 +0100
YARN-8262. get_executable in container-executor should provide meaningful error codes. Contributed by Susheel Gupta
---
.../server/nodemanager/LinuxContainerExecutor.java | 8 ++++++--
.../container-executor/impl/get_executable.c | 22 +++++++++++-----------
.../src/main/native/container-executor/impl/util.c | 10 ++++++++++
.../src/main/native/container-executor/impl/util.h | 7 ++++++-
4 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
index e899215291b..ea4595dffc4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LinuxContainerExecutor.java
@@ -175,8 +175,12 @@ public class LinuxContainerExecutor extends ContainerExecutor {
COULD_NOT_CREATE_WORK_DIRECTORIES(35),
COULD_NOT_CREATE_APP_LOG_DIRECTORIES(36),
COULD_NOT_CREATE_TMP_DIRECTORIES(37),
- ERROR_CREATE_CONTAINER_DIRECTORIES_ARGUMENTS(38);
-
+ ERROR_CREATE_CONTAINER_DIRECTORIES_ARGUMENTS(38),
+ CANNOT_GET_EXECUTABLE_NAME_FROM_READLINK(80),
+ TOO_LONG_EXECUTOR_PATH(81),
+ CANNOT_GET_EXECUTABLE_NAME_FROM_KERNEL(82),
+ CANNOT_GET_EXECUTABLE_NAME_FROM_PID(83),
+ WRONG_PATH_OF_EXECUTABLE(84);
private final int code;
ExitCode(int exitCode) {
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/get_executable.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/get_executable.c
index e1ec293cd47..b027e51bd31 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/get_executable.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/get_executable.c
@@ -56,17 +56,17 @@ char *__get_exec_readproc(char *procfn) {
filename = malloc(EXECUTOR_PATH_MAX);
if (!filename) {
fprintf(ERRORFILE,"cannot allocate memory for filename before readlink: %s\n",strerror(errno));
- exit(-1);
+ exit(OUT_OF_MEMORY);
}
len = readlink(procfn, filename, EXECUTOR_PATH_MAX);
if (len == -1) {
- fprintf(ERRORFILE,"Can't get executable name from %s - %s\n", procfn,
+ fprintf(ERRORFILE,"Cannot get executable name from %s - %s\n", procfn,
strerror(errno));
- exit(-1);
+ exit(CANNOT_GET_EXECUTABLE_NAME_FROM_READLINK);
} else if (len >= EXECUTOR_PATH_MAX) {
fprintf(ERRORFILE,"Resolved path for %s [%s] is longer than %d characters.\n",
procfn, filename, EXECUTOR_PATH_MAX);
- exit(-1);
+ exit(TOO_LONG_EXECUTOR_PATH);
}
filename[len] = '\0';
return filename;
@@ -88,14 +88,14 @@ char *__get_exec_sysctl(int *mib)
len = sizeof(buffer);
if (sysctl(mib, 4, buffer, &len, NULL, 0) == -1) {
- fprintf(ERRORFILE,"Can't get executable name from kernel: %s\n",
+ fprintf(ERRORFILE,"Cannot get executable name from kernel: %s\n",
strerror(errno));
- exit(-1);
+ exit(CANNOT_GET_EXECUTABLE_NAME_FROM_KERNEL);
}
filename=malloc(EXECUTOR_PATH_MAX);
if (!filename) {
fprintf(ERRORFILE,"cannot allocate memory for filename after sysctl: %s\n",strerror(errno));
- exit(-1);
+ exit(OUT_OF_MEMORY);
}
snprintf(filename,EXECUTOR_PATH_MAX,"%s",buffer);
return filename;
@@ -120,13 +120,13 @@ char* get_executable(char *argv0) {
filename = malloc(PROC_PIDPATHINFO_MAXSIZE);
if (!filename) {
fprintf(ERRORFILE,"cannot allocate memory for filename before proc_pidpath: %s\n",strerror(errno));
- exit(-1);
+ exit(OUT_OF_MEMORY);
}
pid = getpid();
if (proc_pidpath(pid,filename,PROC_PIDPATHINFO_MAXSIZE) <= 0) {
- fprintf(ERRORFILE,"Can't get executable name from pid %u - %s\n", pid,
+ fprintf(ERRORFILE,"Cannot get executable name from pid %u - %s\n", pid,
strerror(errno));
- exit(-1);
+ exit(CANNOT_GET_EXECUTABLE_NAME_FROM_PID);
}
return filename;
}
@@ -194,7 +194,7 @@ char* get_executable (char *argv0) {
if (!filename) {
fprintf(ERRORFILE,"realpath of executable: %s\n",strerror(errno));
- exit(-1);
+ exit(WRONG_PATH_OF_EXECUTABLE);
}
return filename;
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.c b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.c
index c8ee7b461e6..33a388fc646 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.c
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.c
@@ -337,6 +337,16 @@ const char *get_error_message(const int error_code) {
return "runC run failed";
case ERROR_RUNC_REAP_LAYER_MOUNTS_FAILED:
return "runC reap layer mounts failed";
+ case CANNOT_GET_EXECUTABLE_NAME_FROM_READLINK:
+ return "Cannot get executable name from readlink";
+ case TOO_LONG_EXECUTOR_PATH:
+ return "Too long executor path";
+ case CANNOT_GET_EXECUTABLE_NAME_FROM_KERNEL:
+ return "Cannot get executable name from kernel";
+ case CANNOT_GET_EXECUTABLE_NAME_FROM_PID:
+ return "Cannot get executable name from pid";
+ case WRONG_PATH_OF_EXECUTABLE:
+ return "Wrong path of executable";
default:
return "Unknown error code";
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.h b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.h
index 920888f1eff..73dfeb629d7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.h
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/util.h
@@ -104,7 +104,12 @@ enum errorcodes {
ERROR_RUNC_SETUP_FAILED = 76,
ERROR_RUNC_RUN_FAILED = 77,
ERROR_RUNC_REAP_LAYER_MOUNTS_FAILED = 78,
- ERROR_DOCKER_CONTAINER_EXEC_FAILED = 79
+ ERROR_DOCKER_CONTAINER_EXEC_FAILED = 79,
+ CANNOT_GET_EXECUTABLE_NAME_FROM_READLINK = 80,
+ TOO_LONG_EXECUTOR_PATH = 81,
+ CANNOT_GET_EXECUTABLE_NAME_FROM_KERNEL = 82,
+ CANNOT_GET_EXECUTABLE_NAME_FROM_PID = 83,
+ WRONG_PATH_OF_EXECUTABLE = 84
};
/* Macros for min/max. */
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org