Skip to content

Commit 6c20512

Browse files
committed
Revert "YARN-9561. Add C changes for the new RuncContainerRuntime. Contributed by Eric Badger"
This reverts commit 289bbca.
1 parent f8e36e0 commit 6c20512

File tree

27 files changed

+155
-8496
lines changed

27 files changed

+155
-8496
lines changed

LICENSE.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -256,26 +256,3 @@ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/st
256256
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jquery
257257
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js
258258
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/resources/TERMINAL
259-
260-
=======
261-
For hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/utils/cJSON.[ch]:
262-
263-
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
264-
265-
Permission is hereby granted, free of charge, to any person obtaining a copy
266-
of this software and associated documentation files (the "Software"), to deal
267-
in the Software without restriction, including without limitation the rights
268-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
269-
copies of the Software, and to permit persons to whom the Software is
270-
furnished to do so, subject to the following conditions:
271-
272-
The above copyright notice and this permission notice shall be included in
273-
all copies or substantial portions of the Software.
274-
275-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
276-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
277-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
278-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
279-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
280-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
281-
THE SOFTWARE.

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/CMakeLists.txt

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
1818

19-
set(HADOOP_COMMON_PATH ${CMAKE_SOURCE_DIR}/../../../../../hadoop-common-project/hadoop-common)
20-
list(APPEND CMAKE_MODULE_PATH ${HADOOP_COMMON_PATH})
19+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../../../hadoop-common-project/hadoop-common)
2120
include(HadoopCommon)
2221

2322
# Set gtest path
@@ -116,7 +115,6 @@ include_directories(
116115
main/native/container-executor
117116
main/native/container-executor/impl
118117
main/native/oom-listener/impl
119-
${HADOOP_COMMON_PATH}/src/main/native/src/org/apache/hadoop/security
120118
)
121119
# add gtest as system library to suppress gcc warnings
122120
include_directories(SYSTEM ${GTEST_SRC_DIR}/include)
@@ -131,7 +129,6 @@ add_library(container
131129
main/native/container-executor/impl/configuration.c
132130
main/native/container-executor/impl/container-executor.c
133131
main/native/container-executor/impl/get_executable.c
134-
main/native/container-executor/impl/utils/file-utils.c
135132
main/native/container-executor/impl/utils/string-utils.c
136133
main/native/container-executor/impl/utils/path-utils.c
137134
main/native/container-executor/impl/modules/cgroups/cgroups-operations.c
@@ -141,12 +138,6 @@ add_library(container
141138
main/native/container-executor/impl/modules/devices/devices-module.c
142139
main/native/container-executor/impl/utils/docker-util.c
143140
main/native/container-executor/impl/utils/mount-utils.c
144-
main/native/container-executor/impl/utils/cJSON/cJSON.c
145-
main/native/container-executor/impl/runc/runc.c
146-
main/native/container-executor/impl/runc/runc_base_ctx.c
147-
main/native/container-executor/impl/runc/runc_launch_cmd.c
148-
main/native/container-executor/impl/runc/runc_reap.c
149-
main/native/container-executor/impl/runc/runc_write_config.c
150141
)
151142

152143
add_executable(container-executor
@@ -155,8 +146,6 @@ add_executable(container-executor
155146

156147
target_link_libraries(container-executor
157148
container
158-
${HADOOP_COMMON_PATH}/target/native/target/usr/local/lib/libhadoop.a
159-
crypto
160149
)
161150

162151
output_directory(container-executor target/usr/local/bin)
@@ -166,10 +155,7 @@ add_executable(test-container-executor
166155
main/native/container-executor/test/test-container-executor.c
167156
)
168157
target_link_libraries(test-container-executor
169-
container
170-
${EXTRA_LIBS}
171-
${HADOOP_COMMON_PATH}/target/native/target/usr/local/lib/libhadoop.a
172-
crypto
158+
container ${EXTRA_LIBS}
173159
)
174160

175161
output_directory(test-container-executor target/usr/local/bin)
@@ -187,16 +173,8 @@ add_executable(cetest
187173
main/native/container-executor/test/modules/fpga/test-fpga-module.cc
188174
main/native/container-executor/test/modules/devices/test-devices-module.cc
189175
main/native/container-executor/test/test_util.cc
190-
main/native/container-executor/test/utils/test_docker_util.cc
191-
main/native/container-executor/test/utils/test_runc_util.cc
192-
)
193-
target_link_libraries(cetest
194-
gtest
195-
container
196-
${HADOOP_COMMON_PATH}/target/native/target/usr/local/lib/libhadoop.a
197-
crypto
198-
)
199-
176+
main/native/container-executor/test/utils/test_docker_util.cc)
177+
target_link_libraries(cetest gtest container)
200178
output_directory(cetest test)
201179

202180
# CGroup OOM listener

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/container-executor.c

Lines changed: 6 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "utils/docker-util.h"
2222
#include "utils/path-utils.h"
2323
#include "utils/string-utils.h"
24-
#include "runc/runc.h"
2524
#include "util.h"
2625
#include "config.h"
2726

@@ -79,7 +78,6 @@ static const int DEFAULT_DOCKER_SUPPORT_ENABLED = 0;
7978
static const int DEFAULT_TC_SUPPORT_ENABLED = 0;
8079
static const int DEFAULT_MOUNT_CGROUP_SUPPORT_ENABLED = 0;
8180
static const int DEFAULT_YARN_SYSFS_SUPPORT_ENABLED = 0;
82-
static const int DEFAULT_RUNC_SUPPORT_ENABLED = 0;
8381

8482
static const char* PROC_PATH = "/proc";
8583

@@ -193,7 +191,7 @@ int check_executor_permissions(char *executable_file) {
193191
/**
194192
* Change the effective user id to limit damage.
195193
*/
196-
int change_effective_user(uid_t user, gid_t group) {
194+
static int change_effective_user(uid_t user, gid_t group) {
197195
if (geteuid() == user) {
198196
return 0;
199197
}
@@ -213,10 +211,6 @@ int change_effective_user(uid_t user, gid_t group) {
213211
return 0;
214212
}
215213

216-
int change_effective_user_to_nm() {
217-
return change_effective_user(nm_uid, nm_gid);
218-
}
219-
220214
#ifdef __linux
221215
/**
222216
* Write the pid of the current process to the cgroup file.
@@ -414,7 +408,7 @@ static int wait_and_get_exit_code(pid_t pid) {
414408
* the exit code file.
415409
* Returns the exit code of the container process.
416410
*/
417-
int wait_and_write_exit_code(pid_t pid, const char* exit_code_file) {
411+
static int wait_and_write_exit_code(pid_t pid, const char* exit_code_file) {
418412
int exit_code = -1;
419413

420414
exit_code = wait_and_get_exit_code(pid);
@@ -516,12 +510,6 @@ int is_yarn_sysfs_support_enabled() {
516510
DEFAULT_YARN_SYSFS_SUPPORT_ENABLED, &executor_cfg);
517511
}
518512

519-
int is_runc_support_enabled() {
520-
return is_feature_enabled(RUNC_SUPPORT_ENABLED_KEY,
521-
DEFAULT_RUNC_SUPPORT_ENABLED, &executor_cfg)
522-
|| runc_module_enabled(&CFG);
523-
}
524-
525513
/**
526514
* Utility function to concatenate argB to argA using the concat_pattern.
527515
*/
@@ -654,20 +642,6 @@ char *get_tmp_directory(const char *work_dir) {
654642
return concatenate("%s/%s", "tmp dir", 2, work_dir, TMP_DIR);
655643
}
656644

657-
/**
658-
* Get the private /tmp directory under the working directory
659-
*/
660-
char *get_privatetmp_directory(const char *work_dir) {
661-
return concatenate("%s/%s", "private /tmp dir", 2, work_dir, ROOT_TMP_DIR);
662-
}
663-
664-
/**
665-
* Get the private /tmp directory under the working directory
666-
*/
667-
char *get_private_var_tmp_directory(const char *work_dir) {
668-
return concatenate("%s/%s", "private /var/tmp dir", 2, work_dir, ROOT_VAR_TMP_DIR);
669-
}
670-
671645
/**
672646
* Ensure that the given path and all of the parent directories are created
673647
* with the desired permissions.
@@ -836,51 +810,17 @@ static int create_container_directories(const char* user, const char *app_id,
836810
return result;
837811
}
838812

813+
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
839814
// also make the tmp directory
840815
char *tmp_dir = get_tmp_directory(work_dir);
841-
char *private_tmp_dir = get_privatetmp_directory(work_dir);
842-
char *private_var_tmp_dir = get_private_var_tmp_directory(work_dir);
843816

844-
if (tmp_dir == NULL || private_tmp_dir == NULL || private_var_tmp_dir == NULL) {
817+
if (tmp_dir == NULL) {
845818
return OUT_OF_MEMORY;
846819
}
847-
848-
if (mkdirs(tmp_dir, perms) != 0) {
849-
fprintf(ERRORFILE, "Could not create tmp_dir: %s\n", tmp_dir);
850-
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
851-
goto cleanup;
852-
}
853-
854-
if (mkdirs(private_tmp_dir, perms) != 0) {
855-
fprintf(ERRORFILE, "Could not create private_tmp_dir: %s\n", private_tmp_dir);
856-
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
857-
goto cleanup;
858-
}
859-
860-
// clear group sticky bit on private_tmp_dir
861-
if (chmod(private_tmp_dir, perms) != 0) {
862-
fprintf(ERRORFILE, "Could not chmod private_tmp_dir: %s\n", private_tmp_dir);
863-
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
864-
goto cleanup;
865-
}
866-
867-
if (mkdirs(private_var_tmp_dir, perms) != 0) {
868-
fprintf(ERRORFILE, "Could not create private_var_tmp_dir: %s\n", private_var_tmp_dir);
869-
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
870-
goto cleanup;
871-
}
872-
873-
// clear group sticky bit on private_tmp_dir
874-
if (chmod(private_var_tmp_dir, perms) != 0) {
875-
fprintf(ERRORFILE, "Could not chmod private_var_tmp_dir: %s\n", private_var_tmp_dir);
876-
result = COULD_NOT_CREATE_TMP_DIRECTORIES;
877-
goto cleanup;
820+
if (mkdirs(tmp_dir, perms) == 0) {
821+
result = 0;
878822
}
879-
880-
cleanup:
881823
free(tmp_dir);
882-
free(private_tmp_dir);
883-
free(private_var_tmp_dir);
884824

885825
return result;
886826
}
@@ -1111,36 +1051,6 @@ static int open_file_as_nm(const char* filename) {
11111051
return result;
11121052
}
11131053

1114-
/**
1115-
* Check the pidfile as the node manager. File should not exist.
1116-
* Returns 0 on file doesn't exist and -1 on file does exist.
1117-
*/
1118-
int check_pidfile_as_nm(const char* pidfile) {
1119-
int result = 0;
1120-
uid_t user = geteuid();
1121-
gid_t group = getegid();
1122-
if (change_effective_user(nm_uid, nm_gid) != 0) {
1123-
return -1;
1124-
}
1125-
1126-
struct stat statbuf;
1127-
if (stat(pidfile, &statbuf) == 0) {
1128-
fprintf(ERRORFILE, "pid file already exists: %s\n", pidfile);
1129-
result = -1;
1130-
}
1131-
1132-
if (errno != ENOENT) {
1133-
fprintf(ERRORFILE, "Error accessing %s : %s\n", pidfile,
1134-
strerror(errno));
1135-
result = -1;
1136-
}
1137-
1138-
if (change_effective_user(user, group)) {
1139-
result = -1;
1140-
}
1141-
return result;
1142-
}
1143-
11441054
/**
11451055
* Copy a file from a fd to a given filename.
11461056
* The new file must not exist and it is created with permissions perm.
@@ -1953,61 +1863,6 @@ int create_yarn_sysfs(const char* user, const char *app_id,
19531863
return result;
19541864
}
19551865

1956-
int setup_container_paths(const char* user, const char* app_id,
1957-
const char *container_id, const char *work_dir, const char *script_name,
1958-
const char *cred_file, int https, const char *keystore_file, const char *truststore_file,
1959-
char* const* local_dirs, char* const* log_dirs) {
1960-
char *script_file_dest = NULL;
1961-
char *cred_file_dest = NULL;
1962-
char *keystore_file_dest = NULL;
1963-
char *truststore_file_dest = NULL;
1964-
int container_file_source = -1;
1965-
int cred_file_source = -1;
1966-
int keystore_file_source = -1;
1967-
int truststore_file_source = -1;
1968-
1969-
int result = initialize_user(user, local_dirs);
1970-
if (result != 0) {
1971-
return result;
1972-
}
1973-
1974-
int rc = create_script_paths(
1975-
work_dir, script_name, cred_file, https, keystore_file, truststore_file, &script_file_dest, &cred_file_dest,
1976-
&keystore_file_dest, &truststore_file_dest, &container_file_source, &cred_file_source, &keystore_file_source, &truststore_file_source);
1977-
1978-
if (rc != 0) {
1979-
fputs("Could not create script path\n", ERRORFILE);
1980-
goto cleanup;
1981-
}
1982-
1983-
rc = create_log_dirs(app_id, log_dirs);
1984-
if (rc != 0) {
1985-
fputs("Could not create log files and directories\n", ERRORFILE);
1986-
goto cleanup;
1987-
}
1988-
1989-
rc = create_local_dirs(user, app_id, container_id,
1990-
work_dir, script_name, cred_file, https, keystore_file, truststore_file, local_dirs, log_dirs,
1991-
1, script_file_dest, cred_file_dest, keystore_file_dest, truststore_file_dest,
1992-
container_file_source, cred_file_source, keystore_file_source, truststore_file_source);
1993-
1994-
if (rc != 0) {
1995-
fputs("Could not create local files and directories\n", ERRORFILE);
1996-
goto cleanup;
1997-
}
1998-
1999-
rc = create_yarn_sysfs(user, app_id, container_id, work_dir, local_dirs);
2000-
if (rc != 0) {
2001-
fputs("Could not create user yarn sysfs directory\n", ERRORFILE);
2002-
goto cleanup;
2003-
}
2004-
2005-
cleanup:
2006-
free(script_file_dest);
2007-
free(cred_file_dest);
2008-
return rc;
2009-
}
2010-
20111866
int launch_docker_container_as_user(const char * user, const char *app_id,
20121867
const char *container_id, const char *work_dir,
20131868
const char *script_name, const char *cred_file,

0 commit comments

Comments
 (0)