diff --git a/0001-add-omitted-musl-adaption-code.patch b/0001-add-omitted-musl-adaption-code.patch new file mode 100644 index 0000000..ece3f8c --- /dev/null +++ b/0001-add-omitted-musl-adaption-code.patch @@ -0,0 +1,44 @@ +From 79a0eeae7ebfc2379917144befe5b0b5e39656e4 Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Wed, 18 Jan 2023 10:08:22 +0800 +Subject: [PATCH 01/19] add omitted musl adaption code + +Signed-off-by: zhongtao +--- + cmake/set_build_flags.cmake | 4 ++-- + src/daemon/executor/container_cb/execution_stream.c | 2 ++ + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake +index 89c9468c..aa1b1193 100644 +--- a/cmake/set_build_flags.cmake ++++ b/cmake/set_build_flags.cmake +@@ -1,9 +1,9 @@ + # set common FLAGS +-set(CMAKE_C_FLAGS "-fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -fPIE") ++set(CMAKE_C_FLAGS "-fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -fPIE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + + if (GRPC_CONNECTOR) +- set(CMAKE_CXX_FLAGS "-fPIC -std=c++11 -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror") ++ set(CMAKE_CXX_FLAGS "-fPIC -std=c++11 -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -shared -pthread") +diff --git a/src/daemon/executor/container_cb/execution_stream.c b/src/daemon/executor/container_cb/execution_stream.c +index ebb9ee2b..fde0335e 100644 +--- a/src/daemon/executor/container_cb/execution_stream.c ++++ b/src/daemon/executor/container_cb/execution_stream.c +@@ -68,7 +68,9 @@ + #define PTHREAD_CANCEL_ENABLE 1 + #define PTHREAD_CANCEL_DISABLE 0 + ++#if defined __ANDROID__ + typedef long pthread_t; ++#endif + + static int pthread_setcancelstate(int state, int *oldstate) + { +-- +2.25.1 + diff --git a/0002-add-cpu-rt-CI.patch b/0002-add-cpu-rt-CI.patch new file mode 100644 index 0000000..2bf2b4e --- /dev/null +++ b/0002-add-cpu-rt-CI.patch @@ -0,0 +1,162 @@ +From dc36962aa20a2a0d29b070bad2d419ae77d56dfd Mon Sep 17 00:00:00 2001 +From: songbuhuang <544824346@qq.com> +Date: Mon, 30 Jan 2023 15:33:55 +0800 +Subject: [PATCH 02/19] add cpu-rt CI + +Signed-off-by: songbuhuang <544824346@qq.com> +--- + CI/test_cases/container_cases/cpu_rt.sh | 142 ++++++++++++++++++++++++ + 1 file changed, 142 insertions(+) + create mode 100644 CI/test_cases/container_cases/cpu_rt.sh + +diff --git a/CI/test_cases/container_cases/cpu_rt.sh b/CI/test_cases/container_cases/cpu_rt.sh +new file mode 100644 +index 00000000..3d70c840 +--- /dev/null ++++ b/CI/test_cases/container_cases/cpu_rt.sh +@@ -0,0 +1,142 @@ ++#!/bin/bash ++# ++# attributes: isulad basic cpu realtime ++# concurrent: NA ++ ++####################################################################### ++##- Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. ++# - iSulad licensed under the Mulan PSL v2. ++# - You can use this software according to the terms and conditions of the Mulan PSL v2. ++# - You may obtain a copy of Mulan PSL v2 at: ++# - http://license.coscl.org.cn/MulanPSL2 ++# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++# - PURPOSE. ++# - See the Mulan PSL v2 for more details. ++##- @Description:CI ++##- @Author: huangsong ++##- @Create: 2023-01-29 ++####################################################################### ++ ++declare -r curr_path=$(dirname $(readlink -f "$0")) ++source ../helpers.sh ++ ++function test_cpu_rt_isulad_spec() ++{ ++ local ret=0 ++ local test="isulad cpu realtime test => (${FUNCNAME[@]})" ++ ++ msg_info "${test} starting..." ++ ++ isulad --cpu-rt-period xx --cpu-rt-runtime 950000 /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument' ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-period" && ((ret++)) ++ ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime xx /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} ++} ++ ++function test_cpu_rt_isula_spec() ++{ ++ local ret=0 ++ local image="busybox" ++ local test="container cpu realtime test => (${FUNCNAME[@]})" ++ ++ msg_info "${test} starting..." ++ ++ #start isulad without cpu_rt ++ start_isulad_without_valgrind ++ ++ isula pull ${image} ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} ++ ++ isula images | grep busybox ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) ++ ++ test_isula_run_spec ++ ++ #start isulad without cpu_rt:isulad cpu.rt_period_us default value is the cpu.rt_period_us of the upper-layer directory,cpu.rt_runtime_us is 0. ++ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "failed to write 10000" | grep "cpu.rt_runtime_us: Invalid argument" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ ++ stop_isulad_without_valgrind ++ ++ #start isulad with cpu_rt ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ ++ test_isula_run_spec ++ ++ c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 950000 ${image} sh` ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) ++ ++ isula update --cpu-rt-runtime 90000 $c_id ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++)) ++ ++ isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us" | grep "90000" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_runtime_us: 90000" && ((ret++)) ++ ++ isula rm -f $c_id ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++)) ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} ++} ++ ++function test_kernel_without_cpu_rt_spec() ++{ ++ local ret=0 ++ local image="busybox" ++ local test="kernel does not support cpu-rt test => (${FUNCNAME[@]})" ++ ++ msg_info "${test} starting..." ++ ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ ++ isula pull ${image} ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} ++ ++ isula images | grep busybox ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 900000 $image /bin/sh 2>&1 | grep "Your kernel does not support cgroup rt" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - kernel does not support cpu-rt" && ((ret++)) ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} ++} ++ ++function test_isula_run_spec() ++{ ++ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime -1 $image /bin/sh 2>&1 | grep "failed to write -1" | grep "cpu.rt_runtime_us: Invalid argument" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period xx --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument' ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-period" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime xx $image /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period xx --cpu-rt-runtime xx $image /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument' ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-period" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period -1 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - cpu-rt-runtime cannot be higher than cpu-rt-period" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period 100 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - cpu-rt-runtime cannot be higher than cpu-rt-period" && ((ret++)) ++} ++ ++declare -i ans=0 ++ ++if [ -f "/sys/fs/cgroup/cpu/cpu.rt_runtime_us" ];then ++ test_cpu_rt_isulad_spec || ((ans++)) ++ test_cpu_rt_isula_spec || ((ans++)) ++else ++ test_kernel_without_cpu_rt_spec || ((ans++)) ++fi ++ ++show_result ${ans} "${curr_path}/${0}" +-- +2.25.1 + diff --git a/0003-add-cpu-rt-ut.patch b/0003-add-cpu-rt-ut.patch new file mode 100644 index 0000000..b17d07c --- /dev/null +++ b/0003-add-cpu-rt-ut.patch @@ -0,0 +1,141 @@ +From c798e4f1abb27d950af6698903891bd2f4dbc63e Mon Sep 17 00:00:00 2001 +From: songbuhuang <544824346@qq.com> +Date: Mon, 30 Jan 2023 15:34:34 +0800 +Subject: [PATCH 03/19] add cpu-rt ut + +Signed-off-by: songbuhuang <544824346@qq.com> +--- + test/CMakeLists.txt | 1 + + test/cgroup/CMakeLists.txt | 3 ++ + test/cgroup/cpu/CMakeLists.txt | 28 +++++++++++++++ + test/cgroup/cpu/cgroup_cpu_ut.cc | 61 ++++++++++++++++++++++++++++++++ + 4 files changed, 93 insertions(+) + create mode 100644 test/cgroup/CMakeLists.txt + create mode 100644 test/cgroup/cpu/CMakeLists.txt + create mode 100644 test/cgroup/cpu/cgroup_cpu_ut.cc + +diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt +index 06adb602..ad348131 100644 +--- a/test/CMakeLists.txt ++++ b/test/CMakeLists.txt +@@ -47,6 +47,7 @@ IF(ENABLE_UT) + add_subdirectory(sha256) + add_subdirectory(buffer) + add_subdirectory(console) ++ add_subdirectory(cgroup) + ENDIF(ENABLE_UT) + + IF(ENABLE_FUZZ) +diff --git a/test/cgroup/CMakeLists.txt b/test/cgroup/CMakeLists.txt +new file mode 100644 +index 00000000..d904a6a0 +--- /dev/null ++++ b/test/cgroup/CMakeLists.txt +@@ -0,0 +1,3 @@ ++project(iSulad_UT) ++ ++add_subdirectory(cpu) +diff --git a/test/cgroup/cpu/CMakeLists.txt b/test/cgroup/cpu/CMakeLists.txt +new file mode 100644 +index 00000000..159b0d85 +--- /dev/null ++++ b/test/cgroup/cpu/CMakeLists.txt +@@ -0,0 +1,28 @@ ++project(iSulad_UT) ++ ++SET(EXE cgroup_cpu_ut) ++ ++add_executable(${EXE} ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/path.c ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/err_msg.c ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/sysinfo.c ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/command_parser.c ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/daemon_arguments.c ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/isulad_config.c ++ cgroup_cpu_ut.cc) ++ ++target_include_directories(${EXE} PUBLIC ++ ${GTEST_INCLUDE_DIR} ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../include ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/common ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common ++ ${CMAKE_BINARY_DIR}/conf ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/config ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd ++ ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/isulad ++ ) ++ ++target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) ++add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) +diff --git a/test/cgroup/cpu/cgroup_cpu_ut.cc b/test/cgroup/cpu/cgroup_cpu_ut.cc +new file mode 100644 +index 00000000..1cfdf86f +--- /dev/null ++++ b/test/cgroup/cpu/cgroup_cpu_ut.cc +@@ -0,0 +1,61 @@ ++/* ++ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. ++ * iSulad licensed under the Mulan PSL v2. ++ * You can use this software according to the terms and conditions of the Mulan PSL v2. ++ * You may obtain a copy of Mulan PSL v2 at: ++ * http://license.coscl.org.cn/MulanPSL2 ++ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++ * PURPOSE. ++ * See the Mulan PSL v2 for more details. ++ * Description: specs unit test ++ * Author: huangsong ++ * Create: 2023-01-29 ++ */ ++ ++#include ++#include ++#include ++#include "daemon_arguments.h" ++#include "isulad_config.h" ++#include "utils.h" ++ ++struct service_arguments *new_args(int64_t cpu_rt_period, int64_t cpu_rt_runtime) ++{ ++ struct service_arguments *args = (struct service_arguments *)util_common_calloc_s(sizeof(struct service_arguments)); ++ if (args == nullptr) { ++ std::cerr << "Out of memory" << std::endl; ++ return nullptr; ++ } ++ ++ args->json_confs = (isulad_daemon_configs *)util_common_calloc_s(sizeof(isulad_daemon_configs)); ++ if (args->json_confs == nullptr) { ++ std::cerr << "Out of memory" << std::endl; ++ free(args); ++ return nullptr; ++ } ++ ++ args->json_confs->cpu_rt_period = cpu_rt_period; ++ args->json_confs->cpu_rt_runtime = cpu_rt_runtime; ++ ++ return args; ++} ++ ++TEST(CgroupCpuUnitTest, test_conf_get_cgroup_cpu_rt) ++{ ++ int64_t cpu_rt_period = 0; ++ int64_t cpu_rt_runtime = 0; ++ ++ ASSERT_EQ(conf_get_cgroup_cpu_rt(nullptr, nullptr), -1); ++ ASSERT_EQ(conf_get_cgroup_cpu_rt(&cpu_rt_period, nullptr), -1); ++ ASSERT_EQ(conf_get_cgroup_cpu_rt(nullptr, &cpu_rt_runtime), -1); ++ ++ struct service_arguments *args = new_args(cpu_rt_period, cpu_rt_runtime); ++ ASSERT_EQ(save_args_to_conf(args), 0); ++ ASSERT_EQ(conf_get_cgroup_cpu_rt(&cpu_rt_period, &cpu_rt_runtime), 0); ++ ASSERT_EQ(cpu_rt_period, 0); ++ ASSERT_EQ(cpu_rt_runtime, 0); ++ ++} ++ ++ +-- +2.25.1 + diff --git a/0004-add-info-log-when-isulad-shutdown.patch b/0004-add-info-log-when-isulad-shutdown.patch new file mode 100644 index 0000000..d3e69d3 --- /dev/null +++ b/0004-add-info-log-when-isulad-shutdown.patch @@ -0,0 +1,148 @@ +From d6632459d8fe0e3ddbce6b360ecaf765cf646fa3 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Mon, 30 Jan 2023 17:41:19 +0800 +Subject: [PATCH 04/19] add info log when isulad shutdown + +Signed-off-by: zhangxiaoyu +--- + src/cmd/isulad/main.c | 5 +++++ + src/daemon/entry/connect/service_common.c | 4 +++- + src/daemon/modules/image/image.c | 1 + + .../graphdriver/devmapper/deviceset.c | 17 +++++++++++++---- + .../storage/layer_store/graphdriver/driver.c | 2 ++ + 5 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c +index 9b664bee..d22ab407 100644 +--- a/src/cmd/isulad/main.c ++++ b/src/cmd/isulad/main.c +@@ -267,15 +267,20 @@ static void clean_residual_files() + + static void daemon_shutdown() + { ++ EVENT("Begin shutdown daemon"); ++ + /* shutdown server */ + server_common_shutdown(); + + /* clean resource first, left time to wait finish */ + image_module_exit(); ++ EVENT("Image module exit completed"); + + umount_daemon_mntpoint(); ++ EVENT("Umount daemon mntpoint completed"); + + clean_residual_files(); ++ EVENT("Clean residual files completed"); + + sem_post(&g_daemon_wait_shutdown_sem); + } +diff --git a/src/daemon/entry/connect/service_common.c b/src/daemon/entry/connect/service_common.c +index 162cec2b..093f05c0 100644 +--- a/src/daemon/entry/connect/service_common.c ++++ b/src/daemon/entry/connect/service_common.c +@@ -16,13 +16,13 @@ + #include "service_common.h" + + #include ++#include + + #include "daemon_arguments.h" + #ifdef GRPC_CONNECTOR + #include "grpc_service.h" + #else + #include "rest_service.h" +-#include "isula_libutils/log.h" + #endif + + /* server common init */ +@@ -58,8 +58,10 @@ void server_common_shutdown(void) + { + #ifdef GRPC_CONNECTOR + grpc_server_shutdown(); ++ EVENT("Grpc Server shutdown completed"); + #else + rest_server_shutdown(); ++ EVENT("Rest Server shutdown completed"); + #endif + } + +diff --git a/src/daemon/modules/image/image.c b/src/daemon/modules/image/image.c +index 6fac7cc4..158b3aa8 100644 +--- a/src/daemon/modules/image/image.c ++++ b/src/daemon/modules/image/image.c +@@ -1909,6 +1909,7 @@ void image_module_exit() + continue; + } + g_bims[i].ops->clean_resource(); ++ EVENT("Image %s clean resource completed", g_bims[i].image_type); + } + } + +diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c +index b157510a..76059b81 100644 +--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c ++++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c +@@ -3419,9 +3419,13 @@ static int umount_deactivate_dev_all(const struct device_set *devset) + + device_info = lookup_device(devset, entry->d_name); + if (device_info == NULL) { +- DEBUG("devmapper: shutdown lookup device %s err", entry->d_name); +- } else if (deactivate_device(devset, device_info->info) != 0) { +- DEBUG("devmapper: shutdown deactivate device %s err", entry->d_name); ++ WARN("devmapper: shutdown lookup device %s err", entry->d_name); ++ continue; ++ } ++ if (deactivate_device(devset, device_info->info) != 0) { ++ WARN("devmapper: shutdown deactivate device %s err", entry->d_name); ++ } else { ++ INFO("devmapper: shutdown deactivate device %s complete", entry->d_name); + } + devmapper_device_info_ref_dec(device_info); + } +@@ -3429,7 +3433,9 @@ static int umount_deactivate_dev_all(const struct device_set *devset) + device_info = lookup_device(devset, "base"); + if (device_info != NULL) { + if (deactivate_device(devset, device_info->info) != 0) { +- DEBUG("devmapper: shutdown deactivate base device err"); ++ WARN("devmapper: shutdown deactivate base device err"); ++ } else { ++ INFO("devmapper: shutdown deactivate base device complete"); + } + devmapper_device_info_ref_dec(device_info); + } +@@ -3453,15 +3459,18 @@ int device_set_shutdown(struct device_set *devset, const char *home) + return -1; + } + ++ EVENT("Devmapper: begin shutdown device set"); + if (save_deviceset_matadata(devset)) { + DEBUG("devmapper: save deviceset metadata failed"); + } ++ EVENT("Devmapper: save deviceset metadata completed"); + + if (umount_deactivate_dev_all(devset) != 0) { + ERROR("devmapper: Shutdown umount device failed"); + ret = -1; + goto free_out; + } ++ EVENT("Devmapper: Shutdown umount device completed"); + + free_out: + if (pthread_rwlock_unlock(&(devset->devmapper_driver_rwlock)) != 0) { +diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/driver.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/driver.c +index 4d685bb6..d3b5209a 100644 +--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/driver.c ++++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/driver.c +@@ -514,6 +514,8 @@ int graphdriver_cleanup(void) + // notes, do not call driver_unlock and destroy the lock, becase the other threads may wait for it + // if we unlock and destroy the lock, may cause the lock failure, and result to coredump + ++ EVENT("Graph driver %s cleanup completed", g_graphdriver->name); ++ + out: + return ret; + } +-- +2.25.1 + diff --git a/0005-create-a-log-file-for-shim-v2-and-remove-10-229-devi.patch b/0005-create-a-log-file-for-shim-v2-and-remove-10-229-devi.patch new file mode 100644 index 0000000..8706767 --- /dev/null +++ b/0005-create-a-log-file-for-shim-v2-and-remove-10-229-devi.patch @@ -0,0 +1,95 @@ +From 973c12fcddfb64bd14e0076bc5c21170f1feca6a Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Thu, 2 Feb 2023 10:51:42 +0800 +Subject: [PATCH 05/19] create a log file for shim v2 and remove 10,229 device + from the default config + +Signed-off-by: zhongtao +--- + src/common/constants.h | 4 ++++ + src/contrib/config/config.json | 7 ------- + src/daemon/modules/runtime/shim/shim_rt_ops.c | 18 ++++++++++++++++++ + 3 files changed, 22 insertions(+), 7 deletions(-) + +diff --git a/src/common/constants.h b/src/common/constants.h +index e6809998..93a069de 100644 +--- a/src/common/constants.h ++++ b/src/common/constants.h +@@ -126,6 +126,10 @@ extern "C" { + #define ISULAD_ENABLE_PLUGINS_SEPERATOR "," + #define ISULAD_ENABLE_PLUGINS_SEPERATOR_CHAR ',' + ++#ifdef ENABLE_SHIM_V2 ++#define SHIM_V2_LOG "/log" ++#endif ++ + #define MAX_HOSTS 10 + + #define OPT_MAX_LEN 255 +diff --git a/src/contrib/config/config.json b/src/contrib/config/config.json +index cfcdc375..f84f3394 100644 +--- a/src/contrib/config/config.json ++++ b/src/contrib/config/config.json +@@ -210,13 +210,6 @@ + "major": 10, + "minor": 200, + "access": "rwm" +- }, +- { +- "allow": false, +- "type": "c", +- "major": 10, +- "minor": 229, +- "access": "rwm" + } + ] + }, +diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c +index 9d23a0e7..1b497358 100644 +--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c ++++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c +@@ -250,9 +250,11 @@ int rt_shim_create(const char *id, const char *runtime, const rt_create_params_t + { + int ret = 0; + int pid = 0; ++ int fd = -1; + char addr[PATH_MAX] = {0}; + char *exit_fifo_path = NULL; + char *state_path = NULL; ++ char *log_path = NULL; + + if (id == NULL || runtime == NULL || params == NULL) { + ERROR("Invalid input params"); +@@ -273,6 +275,21 @@ int rt_shim_create(const char *id, const char *runtime, const rt_create_params_t + goto out; + } + ++ log_path = util_string_append(SHIM_V2_LOG, params->bundle); ++ if (log_path == NULL) { ++ ERROR("Fail to append log path"); ++ ret = -1; ++ goto out; ++ } ++ ++ fd = util_open(log_path, O_RDWR | O_CREAT | O_TRUNC, DEFAULT_SECURE_FILE_MODE); ++ if (fd < 0) { ++ ERROR("Failed to create log file for shim v2: %s", log_path); ++ ret = -1; ++ goto out; ++ } ++ close(fd); ++ + if (shim_bin_v2_create(runtime, id, params->bundle, NULL, addr, state_path) != 0) { + ERROR("%s: failed to create v2 shim", id); + ret = -1; +@@ -294,6 +311,7 @@ int rt_shim_create(const char *id, const char *runtime, const rt_create_params_t + } + + out: ++ free(log_path); + free(exit_fifo_path); + free(state_path); + return ret; +-- +2.25.1 + diff --git a/0006-ensure-isula-exec-inherits-the-config-of-create.patch b/0006-ensure-isula-exec-inherits-the-config-of-create.patch new file mode 100644 index 0000000..90d9f12 --- /dev/null +++ b/0006-ensure-isula-exec-inherits-the-config-of-create.patch @@ -0,0 +1,137 @@ +From d1960a64b04888f21173f5c4bb4993c86553f417 Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Thu, 2 Feb 2023 06:49:03 +0800 +Subject: [PATCH 06/19] ensure isula exec inherits the config of create. + +Signed-off-by: zhongtao +--- + .../modules/service/service_container.c | 73 ++++++++++++++++--- + 1 file changed, 63 insertions(+), 10 deletions(-) + +diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c +index 58c43476..340dea07 100644 +--- a/src/daemon/modules/service/service_container.c ++++ b/src/daemon/modules/service/service_container.c +@@ -1755,8 +1755,34 @@ out: + return ret; + } + ++static int append_rlimit_from_oci_spec(defs_process *spec, const oci_runtime_spec *oci_spec) ++{ ++ size_t j; ++ ++ spec->rlimits = (defs_process_rlimits_element **)util_smart_calloc_s(sizeof(defs_process_rlimits_element *), ++ (size_t)oci_spec->process->rlimits_len); ++ if (spec->rlimits == NULL) { ++ ERROR("Out of memory"); ++ return -1; ++ } ++ ++ for (j = 0; j < oci_spec->process->rlimits_len; j++) { ++ spec->rlimits[j] = util_common_calloc_s(sizeof(defs_process_rlimits_element)); ++ if (spec->rlimits[j] == NULL) { ++ ERROR("Out of memory"); ++ return -1; ++ } ++ spec->rlimits[j]->type = util_strdup_s(oci_spec->process->rlimits[j]->type); ++ spec->rlimits[j]->hard = oci_spec->process->rlimits[j]->hard; ++ spec->rlimits[j]->soft = oci_spec->process->rlimits[j]->soft; ++ spec->rlimits_len++; ++ } ++ ++ return 0; ++} ++ + static defs_process *make_exec_process_spec(const container_config *container_spec, defs_process_user *puser, +- const char *runtime, const container_exec_request *request) ++ const char *runtime, const container_exec_request *request, const oci_runtime_spec *oci_spec) + { + int ret = 0; + defs_process *spec = NULL; +@@ -1767,25 +1793,38 @@ static defs_process *make_exec_process_spec(const container_config *container_sp + } + + if (strcasecmp(runtime, "lcr") != 0) { ++ // for oci runtime: ++ // step 1: merge env from container; + ret = merge_exec_from_container_env(spec, container_spec); + if (ret != 0) { + ERROR("Failed to dup args for exec process spec"); + goto err_out; + } +- } +- +- ret = merge_envs_from_request_env(spec, (const char **)request->env, request->env_len); +- if (ret != 0) { +- ERROR("Failed to dup args for exec process spec"); +- goto err_out; +- } + +- if (strcasecmp(runtime, "lcr") != 0) { ++ // step 2: merge process env including PATH, HOATNAME and TERM(if tty is true); + ret = append_necessary_process_env(request->tty, container_spec, spec); + if (ret != 0) { + ERROR("Failed to append necessary for exec process spec"); + goto err_out; + } ++ ++ ret = append_rlimit_from_oci_spec(spec, oci_spec); ++ if (ret != 0) { ++ ERROR("Failed to append rlimit for exec process spec"); ++ goto err_out; ++ } ++ ++ spec->no_new_privileges = oci_spec->process->no_new_privileges; ++ } ++ ++ // for oci runtime: ++ // step 3 : Finally, merge env from request to ensure that the env in the request is not overwritten; ++ // for lcr: ++ // since the container env and the process env have been stored in the config file, lcr only needs to merge the env in the request. ++ ret = merge_envs_from_request_env(spec, (const char **)request->env, request->env_len); ++ if (ret != 0) { ++ ERROR("Failed to dup args for exec process spec"); ++ goto err_out; + } + + ret = util_dup_array_of_strings((const char **)request->argv, request->argv_len, &(spec->args), &(spec->args_len)); +@@ -1822,6 +1861,8 @@ static int do_exec_container(const container_t *cont, const char *runtime, char + char *engine_log_path = NULL; + char *loglevel = NULL; + char *logdriver = NULL; ++ const char *id = cont->common_config->id; ++ oci_runtime_spec *oci_spec = NULL; + defs_process *process_spec = NULL; + rt_exec_params_t params = { 0 }; + +@@ -1844,7 +1885,18 @@ static int do_exec_container(const container_t *cont, const char *runtime, char + goto out; + } + +- process_spec = make_exec_process_spec(cont->common_config->config, puser, runtime, request); ++ // lcr reads the config from the file and will not lose it. ++ // so there is no need to get the config from oci_spec. ++ if (strcasecmp(runtime, "lcr") != 0) { ++ oci_spec = load_oci_config(cont->root_path, id); ++ if (oci_spec == NULL) { ++ ERROR("Failed to load oci config"); ++ ret = -1; ++ goto out; ++ } ++ } ++ ++ process_spec = make_exec_process_spec(cont->common_config->config, puser, runtime, request, oci_spec); + if (process_spec == NULL) { + ERROR("Exec: Failed to make process spec"); + ret = -1; +@@ -1873,6 +1925,7 @@ out: + free(engine_log_path); + free(logdriver); + free_defs_process(process_spec); ++ free_oci_runtime_spec(oci_spec); + + return ret; + } +-- +2.25.1 + diff --git a/0007-Delete-meaningless-thread-creation-and-ensure-the-ta.patch b/0007-Delete-meaningless-thread-creation-and-ensure-the-ta.patch new file mode 100644 index 0000000..107a7be --- /dev/null +++ b/0007-Delete-meaningless-thread-creation-and-ensure-the-ta.patch @@ -0,0 +1,199 @@ +From 8ac6ba83be4514b94132748428cef0bbef7726d7 Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Sun, 29 Jan 2023 15:48:07 +0800 +Subject: [PATCH 07/19] Delete meaningless thread creation and ensure the + task_console_accept thread ends before destroying the io_thread + +Signed-off-by: zhongtao +--- + src/cmd/isulad-shim/main.c | 5 ++-- + src/cmd/isulad-shim/process.c | 52 ++++++++++++++++++++++------------- + src/cmd/isulad-shim/process.h | 4 +-- + 3 files changed, 38 insertions(+), 23 deletions(-) + +diff --git a/src/cmd/isulad-shim/main.c b/src/cmd/isulad-shim/main.c +index 3ab22d86..eedd8fda 100644 +--- a/src/cmd/isulad-shim/main.c ++++ b/src/cmd/isulad-shim/main.c +@@ -98,6 +98,7 @@ int main(int argc, char **argv) + int ret = SHIM_ERR; + int efd = -1; + process_t *p = NULL; ++ pthread_t tid_accept; + + g_log_fd = open_no_inherit(SHIM_LOG_NAME, O_CREAT | O_WRONLY | O_APPEND | O_SYNC, 0640); + if (g_log_fd < 0) { +@@ -151,7 +152,7 @@ int main(int argc, char **argv) + exit(EXIT_FAILURE); + } + +- ret = open_io(p); ++ ret = open_io(p, &tid_accept); + if (ret != SHIM_OK) { + exit(EXIT_FAILURE); + } +@@ -166,5 +167,5 @@ int main(int argc, char **argv) + + released_timeout_exit(); + +- return process_signal_handle_routine(p); ++ return process_signal_handle_routine(p, tid_accept); + } +diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c +index 92dd2701..66c604f3 100644 +--- a/src/cmd/isulad-shim/process.c ++++ b/src/cmd/isulad-shim/process.c +@@ -423,6 +423,14 @@ static int start_io_copy_threads(process_t *p) + + /* 4 threads for stdin, stdout, stderr and exec resize */ + for (i = 0; i < 4; i++) { ++ /* ++ * if the terminal is used, we do not need to active the io copy of stderr pipe, ++ * for stderr and stdout are mixed together ++ */ ++ if (i == STDID_ERR && p->state->terminal) { ++ continue; ++ } ++ + ret = create_io_copy_thread(p, i); + if (ret != SHIM_OK) { + return SHIM_ERR; +@@ -512,11 +520,6 @@ static void *task_console_accept(void *data) + int ret = SHIM_ERR; + console_accept_t *ac = (console_accept_t *)data; + +- if ((pthread_detach(pthread_self())) != 0) { +- write_message(g_log_fd, ERR_MSG, "detach thread failed"); +- return NULL; +- } +- + conn_fd = accept(ac->listen_fd, NULL, NULL); + if (conn_fd < 0) { + write_message(g_log_fd, ERR_MSG, "accept from fd %d failed:%d", ac->listen_fd, SHIM_SYS_ERR(errno)); +@@ -549,12 +552,6 @@ static void *task_console_accept(void *data) + goto out; + } + +- /* +- * if the terminal is used, we do not need to active the io copy of stderr pipe, +- * for stderr and stdout are mixed together +- */ +- destroy_io_thread(ac->p, STDID_ERR); +- + out: + /* release listen socket at the first time */ + close_fd(&ac->listen_fd); +@@ -634,7 +631,7 @@ static int new_temp_console_path(process_t *p) + return SHIM_OK; + } + +-static int console_init(process_t *p) ++static int console_init(process_t *p, pthread_t *tid_accept) + { + int ret = SHIM_ERR; + int fd = -1; +@@ -670,8 +667,7 @@ static int console_init(process_t *p) + ac->p = p; + ac->listen_fd = fd; + +- pthread_t tid_accept; +- ret = pthread_create(&tid_accept, NULL, task_console_accept, ac); ++ ret = pthread_create(tid_accept, NULL, task_console_accept, ac); + if (ret != SHIM_OK) { + goto failure; + } +@@ -762,7 +758,7 @@ failure: + return NULL; + } + +-static int open_terminal_io(process_t *p) ++static int open_terminal_io(process_t *p, pthread_t *tid_accept) + { + int ret = SHIM_ERR; + +@@ -773,7 +769,7 @@ static int open_terminal_io(process_t *p) + } + + /* begin listen and accept fd from p->console_sock_path */ +- return console_init(p); ++ return console_init(p, tid_accept); + } + + static int open_generic_io(process_t *p) +@@ -916,7 +912,7 @@ failure: + return NULL; + } + +-int open_io(process_t *p) ++int open_io(process_t *p, pthread_t *tid_accept) + { + int ret = SHIM_ERR; + +@@ -926,7 +922,7 @@ int open_io(process_t *p) + } + + if (p->state->terminal) { +- return open_terminal_io(p); ++ return open_terminal_io(p, tid_accept); + } + + return open_generic_io(p); +@@ -1216,12 +1212,13 @@ static int try_wait_all_child(void) { + return 1; + } + +-int process_signal_handle_routine(process_t *p) ++int process_signal_handle_routine(process_t *p, const pthread_t tid_accept) + { + int ret = SHIM_ERR; + bool exit_shim = false; + int nret = 0; + int i; ++ struct timespec ts; + + for (;;) { + int status; +@@ -1257,6 +1254,23 @@ int process_signal_handle_routine(process_t *p) + if (p->exit_fd > 0) { + (void)write_nointr(p->exit_fd, &status, sizeof(int)); + } ++ // wait for task_console_accept thread termination. In order to make sure that ++ // the io_copy connection is established and io_thread is not used by multiple threads. ++ if (p->state->terminal) { ++ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) { ++ write_message(g_log_fd, ERR_MSG, "Failed to get realtime"); ++ nret = pthread_join(tid_accept, NULL); ++ } else { ++ // Set the maximum waiting time to 60s to prevent stuck. ++ ts.tv_sec += 60; ++ nret = pthread_timedjoin_np(tid_accept, NULL, &ts); ++ } ++ ++ if (nret != 0) { ++ write_message(g_log_fd, ERR_MSG, "Failed to join task_console_accept thread"); ++ } ++ } ++ + for (i = 0; i < 3; i++) { + destroy_io_thread(p, i); + } +diff --git a/src/cmd/isulad-shim/process.h b/src/cmd/isulad-shim/process.h +index 11d1bf64..66820f68 100644 +--- a/src/cmd/isulad-shim/process.h ++++ b/src/cmd/isulad-shim/process.h +@@ -94,10 +94,10 @@ typedef struct { + + process_t* new_process(char *id, char *bundle, char *runtime); + +-int open_io(process_t *p); ++int open_io(process_t *p, pthread_t *tid_accept); + int process_io_init(process_t *p); + int create_process(process_t *p); +-int process_signal_handle_routine(process_t *p); ++int process_signal_handle_routine(process_t *p, const pthread_t tid_accept); + + #ifdef __cplusplus + } +-- +2.25.1 + diff --git a/0008-fix-cpu-rt-review-comments.patch b/0008-fix-cpu-rt-review-comments.patch new file mode 100644 index 0000000..54514f4 --- /dev/null +++ b/0008-fix-cpu-rt-review-comments.patch @@ -0,0 +1,44 @@ +From c05c92988577067ea376a2e7263a2c9080fcb478 Mon Sep 17 00:00:00 2001 +From: songbuhuang <544824346@qq.com> +Date: Mon, 13 Feb 2023 10:43:52 +0800 +Subject: [PATCH 08/19] fix cpu rt review comments + +Signed-off-by: songbuhuang <544824346@qq.com> +--- + src/daemon/executor/container_cb/execution_create.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c +index da01a57f..04154765 100644 +--- a/src/daemon/executor/container_cb/execution_create.c ++++ b/src/daemon/executor/container_cb/execution_create.c +@@ -1295,7 +1295,7 @@ static int save_container_config_before_create(const char *id, const char *runti + static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const char *path) + { + int ret; +- int fd = 0; ++ int fd = -1; + ssize_t nwrite; + char fpath[PATH_MAX] = { 0 }; + char buf[ISULAD_NUMSTRLEN64] = { 0 }; +@@ -1310,13 +1310,13 @@ static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const + return -1; + } + +- int nret = snprintf(fpath, sizeof(fpath), "%s/%s", path, file); +- if (nret < 0 || nret >= sizeof(fpath)) { ++ ret = snprintf(fpath, sizeof(fpath), "%s/%s", path, file); ++ if (ret < 0 || ret >= sizeof(fpath)) { + ERROR("Failed to print string"); + return -1; + } +- nret = snprintf(buf, sizeof(buf), "%lld", (long long int)value); +- if (nret < 0 || (size_t)nret >= sizeof(buf)) { ++ ret = snprintf(buf, sizeof(buf), "%lld", (long long int)value); ++ if (ret < 0 || (size_t)ret >= sizeof(buf)) { + ERROR("Failed to print string"); + return -1; + } +-- +2.25.1 + diff --git a/0009-fix-inspect.sh-failed.patch b/0009-fix-inspect.sh-failed.patch new file mode 100644 index 0000000..6f03751 --- /dev/null +++ b/0009-fix-inspect.sh-failed.patch @@ -0,0 +1,31 @@ +From 921de80e43a15392d14d53ef6cf7e61ff453685b Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Mon, 13 Feb 2023 17:42:30 +0800 +Subject: [PATCH 09/19] fix inspect.sh failed + +Signed-off-by: zhangxiaoyu +--- + CI/test_cases/container_cases/inspect.sh | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) + +diff --git a/CI/test_cases/container_cases/inspect.sh b/CI/test_cases/container_cases/inspect.sh +index 0d4ccb02..cde9ea1f 100755 +--- a/CI/test_cases/container_cases/inspect.sh ++++ b/CI/test_cases/container_cases/inspect.sh +@@ -103,12 +103,7 @@ function test_inspect_spec() + isula inspect --format='{{.Image}}' $containername 2>&1 | grep "sha256:${image_id}" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + +- if [ -d /sys/fs/cgroup/files ];then +- grepval="100" +- else +- grepval="0" +- fi +- isula inspect --format='{{json .HostConfig.FilesLimit}}' $containername 2>&1 | grep "$grepval" ++ isula inspect --format='{{json .HostConfig.FilesLimit}}' $containername 2>&1 | grep 0 + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((ret++)) + + isula inspect --format='{{json .Config.Env}}' $containername 2>&1 | grep "a=1" +-- +2.25.1 + diff --git a/0010-ensure-list-name-is-not-null.patch b/0010-ensure-list-name-is-not-null.patch new file mode 100644 index 0000000..85dd397 --- /dev/null +++ b/0010-ensure-list-name-is-not-null.patch @@ -0,0 +1,26 @@ +From 4d5fff88868354403fffa8ae0f6aa8e051842a70 Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Wed, 15 Feb 2023 11:27:04 +0800 +Subject: [PATCH 10/19] ensure list name is not null + +Signed-off-by: haozi007 +--- + src/daemon/entry/cri/cni_network_plugin.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/daemon/entry/cri/cni_network_plugin.cc b/src/daemon/entry/cri/cni_network_plugin.cc +index 976a21a4..9b03bea1 100644 +--- a/src/daemon/entry/cri/cni_network_plugin.cc ++++ b/src/daemon/entry/cri/cni_network_plugin.cc +@@ -296,7 +296,7 @@ void CniNetworkPlugin::GetDefaultCNINetwork(const std::string &confDir, std::vec + continue; + } + +- if (n_list == nullptr || n_list->plugin_len == 0) { ++ if (n_list == nullptr || n_list->name == nullptr || n_list->plugin_len == 0) { + WARN("CNI config list %s has no networks, skipping", elem.c_str()); + free_cni_network_list_conf(n_list); + n_list = nullptr; +-- +2.25.1 + diff --git a/0011-Bugfix-in-config-and-executor.patch b/0011-Bugfix-in-config-and-executor.patch new file mode 100644 index 0000000..edb1e72 --- /dev/null +++ b/0011-Bugfix-in-config-and-executor.patch @@ -0,0 +1,52 @@ +From 14d06efa2e5fad9986a12a067e1c6009bf58ad47 Mon Sep 17 00:00:00 2001 +From: Xuepeng Xu +Date: Wed, 15 Feb 2023 12:19:40 +0800 +Subject: [PATCH 11/19] Bugfix in config and executor + +Signed-off-by: Xuepeng Xu +--- + src/daemon/config/isulad_config.c | 2 +- + src/daemon/executor/container_cb/execution_create.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/daemon/config/isulad_config.c b/src/daemon/config/isulad_config.c +index 86a9609a..ad82aeff 100644 +--- a/src/daemon/config/isulad_config.c ++++ b/src/daemon/config/isulad_config.c +@@ -314,7 +314,7 @@ char *conf_get_routine_rootdir(const char *runtime) + } + + /* path = conf->rootpath + / + engines + / + runtime + /0 */ +- if (strlen(conf->json_confs->graph) > (SIZE_MAX - strlen(ENGINE_ROOTPATH_NAME)) - 3) { ++ if (strlen(conf->json_confs->graph) > (SIZE_MAX - strlen(ENGINE_ROOTPATH_NAME) - strlen(runtime)) - 3) { + ERROR("Graph path is too long"); + goto out; + } +diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c +index 04154765..0d03afcb 100644 +--- a/src/daemon/executor/container_cb/execution_create.c ++++ b/src/daemon/executor/container_cb/execution_create.c +@@ -587,7 +587,7 @@ static char *try_generate_id() + int i = 0; + int max_time = 10; + char *id = NULL; +- char *value = NULL; ++ container_t *value = NULL; + + id = util_smart_calloc_s(sizeof(char), (CONTAINER_ID_MAX_LEN + 1)); + if (id == NULL) { +@@ -601,9 +601,9 @@ static char *try_generate_id() + goto err_out; + } + +- value = container_name_index_get(id); ++ value = containers_store_get(id); + if (value != NULL) { +- free(value); ++ container_unref(value); + value = NULL; + continue; + } else { +-- +2.25.1 + diff --git a/0012-fix-isula-cpu-rt-CI.patch b/0012-fix-isula-cpu-rt-CI.patch new file mode 100644 index 0000000..6c0c893 --- /dev/null +++ b/0012-fix-isula-cpu-rt-CI.patch @@ -0,0 +1,204 @@ +From 3a85cbbb425fa6bd31efd4a296111b9ec3a5e99f Mon Sep 17 00:00:00 2001 +From: songbuhuang <544824346@qq.com> +Date: Tue, 14 Feb 2023 14:37:09 +0800 +Subject: [PATCH 12/19] fix isula cpu-rt CI + +Signed-off-by: songbuhuang <544824346@qq.com> +--- + CI/test_cases/container_cases/cpu_rt.sh | 118 ++++++++++++++++++------ + 1 file changed, 90 insertions(+), 28 deletions(-) + +diff --git a/CI/test_cases/container_cases/cpu_rt.sh b/CI/test_cases/container_cases/cpu_rt.sh +index 3d70c840..3dcf4791 100644 +--- a/CI/test_cases/container_cases/cpu_rt.sh ++++ b/CI/test_cases/container_cases/cpu_rt.sh +@@ -21,71 +21,91 @@ + declare -r curr_path=$(dirname $(readlink -f "$0")) + source ../helpers.sh + +-function test_cpu_rt_isulad_spec() ++function test_cpurt_isulad_abnormal() + { + local ret=0 +- local test="isulad cpu realtime test => (${FUNCNAME[@]})" ++ local test="isulad cpu realtime abnormal test => (${FUNCNAME[@]})" + +- msg_info "${test} starting..." ++ msg_info "${test} starting..." + +- isulad --cpu-rt-period xx --cpu-rt-runtime 950000 /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument' ++ isulad --cpu-rt-period xx --cpu-rt-runtime 950000 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-period: Invalid argument' + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-period" && ((ret++)) + +- isulad --cpu-rt-period 1000000 --cpu-rt-runtime xx /bin/sh 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime xx 2>&1 | grep 'Invalid value "xx" for flag --cpu-rt-runtime: Invalid argument' + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) + + msg_info "${test} finished with return ${ret}..." + return ${ret} + } + +-function test_cpu_rt_isula_spec() ++function test_isula_update_normal() + { + local ret=0 + local image="busybox" +- local test="container cpu realtime test => (${FUNCNAME[@]})" ++ local test="isulad update cpu realtime normal test => (${FUNCNAME[@]})" + + msg_info "${test} starting..." + +- #start isulad without cpu_rt +- start_isulad_without_valgrind ++ #start isulad with cpu_rt ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ ++ c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 1000 ${image} sh` ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + +- isula pull ${image} +- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} ++ isula update --cpu-rt-period 900000 --cpu-rt-runtime 2000 $c_id ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++)) + +- isula images | grep busybox +- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) ++ isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us" | grep "2000" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_runtime_us: 2000" && ((ret++)) + +- test_isula_run_spec ++ isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_period_us" | grep "900000" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_period_us: 900000" && ((ret++)) + +- #start isulad without cpu_rt:isulad cpu.rt_period_us default value is the cpu.rt_period_us of the upper-layer directory,cpu.rt_runtime_us is 0. +- isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "failed to write 10000" | grep "cpu.rt_runtime_us: Invalid argument" +- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ isula rm -f $c_id ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++)) + + stop_isulad_without_valgrind ++ #set cpu-rt to the initial state ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 0 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} ++} ++ ++function test_isula_update_abnormal() ++{ ++ local ret=0 ++ local image="busybox" ++ local test="isulad update cpu realtime abnormal test => (${FUNCNAME[@]})" + + #start isulad with cpu_rt + isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & + wait_isulad_running +- +- test_isula_run_spec + +- c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 950000 ${image} sh` ++ c_id=`isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 1000 ${image} sh` + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) + +- isula update --cpu-rt-runtime 90000 $c_id ++ isula update --cpu-rt-period 800000 --cpu-rt-runtime 900000 $c_id 2>&1 | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++)) + +- isula exec -it $c_id sh -c "cat /sys/fs/cgroup/cpu/cpu.rt_runtime_us" | grep "90000" +- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container cpu.rt_runtime_us: 90000" && ((ret++)) ++ isula update --cpu-rt-runtime 1000000 $c_id 2>&1 | grep "updating cgroup cpu.rt_runtime_us to 1000000: Invalid argument" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to update container cpu-rt-runtime" && ((ret++)) + + isula rm -f $c_id + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++)) + ++ stop_isulad_without_valgrind ++ #set cpu-rt to the initial state ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 0 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ + msg_info "${test} finished with return ${ret}..." + return ${ret} + } + +-function test_kernel_without_cpu_rt_spec() ++function test_kernel_without_cpurt() + { + local ret=0 + local image="busybox" +@@ -109,8 +129,24 @@ function test_kernel_without_cpu_rt_spec() + return ${ret} + } + +-function test_isula_run_spec() ++function test_isula_run_abnormal() + { ++ local ret=0 ++ local image="busybox" ++ local test="container cpu realtime test => (${FUNCNAME[@]})" ++ ++ msg_info "${test} starting..." ++ ++ #start isulad without cpu_rt ++ isulad --cpu-rt-period 1000000 --cpu-rt-runtime 950000 -l DEBUG > /dev/null 2>&1 & ++ wait_isulad_running ++ ++ isula pull ${image} ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to pull image: ${image}" && return ${FAILURE} ++ ++ isula images | grep busybox ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - missing list image: ${image}" && ((ret++)) ++ + isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime -1 $image /bin/sh 2>&1 | grep "failed to write -1" | grep "cpu.rt_runtime_us: Invalid argument" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) + +@@ -128,15 +164,41 @@ function test_isula_run_spec() + + isula run -itd --cpu-rt-period 100 --cpu-rt-runtime 10000 $image /bin/sh 2>&1 | grep "Invalid --cpu-rt-runtime: rt runtime cannot be higher than rt period" + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - cpu-rt-runtime cannot be higher than cpu-rt-period" && ((ret++)) ++ ++ isula run -itd --cpu-rt-period 1000000 --cpu-rt-runtime 960000 $image /bin/sh 2>&1 | grep "failed to write 960000" | grep "cpu.rt_runtime_us: Invalid argument" ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - Invalid argument for cpu-rt-runtime" && ((ret++)) ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} ++} ++ ++function test_isula_run_normal() ++{ ++ local ret=0 ++ local image="busybox" ++ ++ isula run -itd -n box --cpu-rt-period 1000000 --cpu-rt-runtime 1000 $image /bin/sh 2>&1 ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container" && ((ret++)) ++ ++ isula rm -f box ++ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to rm container ${c_id}" && ((ret++)) ++ ++ msg_info "${test} finished with return ${ret}..." ++ return ${ret} + } + + declare -i ans=0 + + if [ -f "/sys/fs/cgroup/cpu/cpu.rt_runtime_us" ];then +- test_cpu_rt_isulad_spec || ((ans++)) +- test_cpu_rt_isula_spec || ((ans++)) ++ test_isula_run_abnormal || ((ans++)) ++ test_isula_run_normal || ((ans++)) ++ test_cpurt_isulad_abnormal || ((ans++)) ++ test_isula_update_normal || ((ans++)) ++ test_isula_update_abnormal || ((ans++)) + else +- test_kernel_without_cpu_rt_spec || ((ans++)) ++ test_kernel_without_cpurt || ((ans++)) + fi + ++isula rm -f $(isula ps -aq) ++ + show_result ${ans} "${curr_path}/${0}" +-- +2.25.1 + diff --git a/0013-add-CRI-ContainerStats-Service.patch b/0013-add-CRI-ContainerStats-Service.patch new file mode 100644 index 0000000..dc1ea20 --- /dev/null +++ b/0013-add-CRI-ContainerStats-Service.patch @@ -0,0 +1,505 @@ +From 18c2515d9a630242387a90c70f421622531a8dec Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Thu, 16 Feb 2023 14:36:23 +0800 +Subject: [PATCH 13/19] add CRI ContainerStats Service + +Signed-off-by: zhangxiaoyu +--- + .../connect/grpc/runtime_image_service.cc | 12 ++--- + .../connect/grpc/runtime_runtime_service.cc | 45 +++++++++++----- + .../connect/grpc/runtime_runtime_service.h | 3 ++ + .../entry/cri/cri_container_manager_service.h | 3 ++ + .../cri/cri_container_manager_service_impl.cc | 54 +++++++++++++++++++ + .../cri/cri_container_manager_service_impl.h | 3 ++ + src/daemon/entry/cri/cri_runtime_service.h | 3 ++ + .../entry/cri/cri_runtime_service_impl.cc | 6 +++ + .../entry/cri/cri_runtime_service_impl.h | 3 ++ + src/daemon/modules/events/collector.c | 4 +- + src/daemon/modules/image/image.c | 16 +++--- + .../modules/image/oci/oci_common_operators.c | 8 +-- + 12 files changed, 128 insertions(+), 32 deletions(-) + +diff --git a/src/daemon/entry/connect/grpc/runtime_image_service.cc b/src/daemon/entry/connect/grpc/runtime_image_service.cc +index 23447baf..e593a9c6 100644 +--- a/src/daemon/entry/connect/grpc/runtime_image_service.cc ++++ b/src/daemon/entry/connect/grpc/runtime_image_service.cc +@@ -54,7 +54,7 @@ grpc::Status RuntimeImageServiceImpl::ListImages(grpc::ServerContext *context, + std::vector> images; + Errors error; + +- WARN("Event: {Object: CRI, Type: Listing all images}"); ++ INFO("Event: {Object: CRI, Type: Listing all images}"); + + rService->ListImages(request->filter(), &images, error); + if (!error.Empty()) { +@@ -70,7 +70,7 @@ grpc::Status RuntimeImageServiceImpl::ListImages(grpc::ServerContext *context, + *image = *(iter->get()); + } + +- WARN("Event: {Object: CRI, Type: Listed all images}"); ++ INFO("Event: {Object: CRI, Type: Listed all images}"); + + return grpc::Status::OK; + } +@@ -82,7 +82,7 @@ grpc::Status RuntimeImageServiceImpl::ImageStatus(grpc::ServerContext *context, + std::unique_ptr image_info = nullptr; + Errors error; + +- WARN("Event: {Object: CRI, Type: Statusing image %s}", request->image().image().c_str()); ++ INFO("Event: {Object: CRI, Type: Statusing image %s}", request->image().image().c_str()); + + image_info = rService->ImageStatus(request->image(), error); + if (!error.Empty() && !CRIHelpers::IsImageNotFoundError(error.GetMessage())) { +@@ -96,7 +96,7 @@ grpc::Status RuntimeImageServiceImpl::ImageStatus(grpc::ServerContext *context, + *image = *image_info; + } + +- WARN("Event: {Object: CRI, Type: Statused image %s}", request->image().image().c_str()); ++ INFO("Event: {Object: CRI, Type: Statused image %s}", request->image().image().c_str()); + + return grpc::Status::OK; + } +@@ -108,7 +108,7 @@ grpc::Status RuntimeImageServiceImpl::ImageFsInfo(grpc::ServerContext *context, + std::vector> usages; + Errors error; + +- WARN("Event: {Object: CRI, Type: Statusing image fs info}"); ++ INFO("Event: {Object: CRI, Type: Statusing image fs info}"); + + rService->ImageFsInfo(&usages, error); + if (!error.Empty()) { +@@ -125,7 +125,7 @@ grpc::Status RuntimeImageServiceImpl::ImageFsInfo(grpc::ServerContext *context, + *fs_info = *(iter->get()); + } + +- WARN("Event: {Object: CRI, Type: Statused image fs info}"); ++ INFO("Event: {Object: CRI, Type: Statused image fs info}"); + return grpc::Status::OK; + } + +diff --git a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc +index 7cceefc9..451eeeef 100644 +--- a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc ++++ b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc +@@ -181,7 +181,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainers(grpc::ServerContext *cont + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Listing all Container}"); ++ INFO("Event: {Object: CRI, Type: Listing all Container}"); + + std::vector> containers; + rService->ListContainers(request->has_filter() ? &request->filter() : nullptr, &containers, error); +@@ -199,7 +199,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainers(grpc::ServerContext *cont + *container = *(iter->get()); + } + +- WARN("Event: {Object: CRI, Type: Listed all Container}"); ++ INFO("Event: {Object: CRI, Type: Listed all Container}"); + + return grpc::Status::OK; + } +@@ -210,7 +210,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainerStats(grpc::ServerContext * + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Listing all Container stats}"); ++ INFO("Event: {Object: CRI, Type: Listing all Container stats}"); + + std::vector> containers; + rService->ListContainerStats(request->has_filter() ? &request->filter() : nullptr, &containers, error); +@@ -228,7 +228,28 @@ grpc::Status RuntimeRuntimeServiceImpl::ListContainerStats(grpc::ServerContext * + *container = *(iter->get()); + } + +- WARN("Event: {Object: CRI, Type: Listed all Container stats}"); ++ INFO("Event: {Object: CRI, Type: Listed all Container stats}"); ++ ++ return grpc::Status::OK; ++} ++ ++grpc::Status RuntimeRuntimeServiceImpl::ContainerStats(grpc::ServerContext *context, ++ const runtime::v1alpha2::ContainerStatsRequest *request, ++ runtime::v1alpha2::ContainerStatsResponse *reply) ++{ ++ Errors error; ++ ++ INFO("Event: {Object: CRI, Type: Getting Container Stats: %s}", request->container_id().c_str()); ++ ++ std::unique_ptr contStats = ++ rService->ContainerStats(request->container_id(), error); ++ if (!error.Empty() || !contStats) { ++ ERROR("Object: CRI, Type: Failed to get container stats %s", request->container_id().c_str()); ++ return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage()); ++ } ++ *(reply->mutable_stats()) = *contStats; ++ ++ INFO("Event: {Object: CRI, Type: Got Container stats: %s}", request->container_id().c_str()); + + return grpc::Status::OK; + } +@@ -239,7 +260,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ContainerStatus(grpc::ServerContext *con + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Statusing Container: %s}", request->container_id().c_str()); ++ INFO("Event: {Object: CRI, Type: Statusing Container: %s}", request->container_id().c_str()); + + std::unique_ptr contStatus = + rService->ContainerStatus(request->container_id(), error); +@@ -249,7 +270,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ContainerStatus(grpc::ServerContext *con + } + *(reply->mutable_status()) = *contStatus; + +- WARN("Event: {Object: CRI, Type: Statused Container: %s}", request->container_id().c_str()); ++ INFO("Event: {Object: CRI, Type: Statused Container: %s}", request->container_id().c_str()); + + return grpc::Status::OK; + } +@@ -339,7 +360,7 @@ grpc::Status RuntimeRuntimeServiceImpl::PodSandboxStatus(grpc::ServerContext *co + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Status Pod: %s}", request->pod_sandbox_id().c_str()); ++ INFO("Event: {Object: CRI, Type: Status Pod: %s}", request->pod_sandbox_id().c_str()); + + std::unique_ptr podStatus; + podStatus = rService->PodSandboxStatus(request->pod_sandbox_id(), error); +@@ -350,7 +371,7 @@ grpc::Status RuntimeRuntimeServiceImpl::PodSandboxStatus(grpc::ServerContext *co + } + *(reply->mutable_status()) = *podStatus; + +- WARN("Event: {Object: CRI, Type: Statused Pod: %s}", request->pod_sandbox_id().c_str()); ++ INFO("Event: {Object: CRI, Type: Statused Pod: %s}", request->pod_sandbox_id().c_str()); + + return grpc::Status::OK; + } +@@ -361,7 +382,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ListPodSandbox(grpc::ServerContext *cont + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Listing all Pods}"); ++ INFO("Event: {Object: CRI, Type: Listing all Pods}"); + + std::vector> pods; + rService->ListPodSandbox(request->has_filter() ? &request->filter() : nullptr, &pods, error); +@@ -378,7 +399,7 @@ grpc::Status RuntimeRuntimeServiceImpl::ListPodSandbox(grpc::ServerContext *cont + *pod = *(iter->get()); + } + +- WARN("Event: {Object: CRI, Type: Listed all Pods}"); ++ INFO("Event: {Object: CRI, Type: Listed all Pods}"); + + return grpc::Status::OK; + } +@@ -470,7 +491,7 @@ grpc::Status RuntimeRuntimeServiceImpl::Status(grpc::ServerContext *context, + { + Errors error; + +- WARN("Event: {Object: CRI, Type: Statusing daemon}"); ++ INFO("Event: {Object: CRI, Type: Statusing daemon}"); + + std::unique_ptr status = rService->Status(error); + if (status == nullptr || error.NotEmpty()) { +@@ -479,7 +500,7 @@ grpc::Status RuntimeRuntimeServiceImpl::Status(grpc::ServerContext *context, + } + *(reply->mutable_status()) = *status; + +- WARN("Event: {Object: CRI, Type: Statused daemon}"); ++ INFO("Event: {Object: CRI, Type: Statused daemon}"); + + return grpc::Status::OK; + } +diff --git a/src/daemon/entry/connect/grpc/runtime_runtime_service.h b/src/daemon/entry/connect/grpc/runtime_runtime_service.h +index f6e1634e..94543793 100644 +--- a/src/daemon/entry/connect/grpc/runtime_runtime_service.h ++++ b/src/daemon/entry/connect/grpc/runtime_runtime_service.h +@@ -58,6 +58,9 @@ public: + const runtime::v1alpha2::ListContainerStatsRequest *request, + runtime::v1alpha2::ListContainerStatsResponse *reply) override; + ++ grpc::Status ContainerStats(grpc::ServerContext *context, const runtime::v1alpha2::ContainerStatsRequest *request, ++ runtime::v1alpha2::ContainerStatsResponse *reply) override; ++ + grpc::Status ContainerStatus(grpc::ServerContext *context, + const runtime::v1alpha2::ContainerStatusRequest *request, + runtime::v1alpha2::ContainerStatusResponse *reply) override; +diff --git a/src/daemon/entry/cri/cri_container_manager_service.h b/src/daemon/entry/cri/cri_container_manager_service.h +index f9090971..f362f798 100644 +--- a/src/daemon/entry/cri/cri_container_manager_service.h ++++ b/src/daemon/entry/cri/cri_container_manager_service.h +@@ -46,6 +46,9 @@ public: + std::vector> *containerstats, + Errors &error) = 0; + ++ virtual auto ContainerStats(const std::string &containerID, ++ Errors &error) -> std::unique_ptr = 0; ++ + virtual auto ContainerStatus(const std::string &containerID, + Errors &error) -> std::unique_ptr = 0; + +diff --git a/src/daemon/entry/cri/cri_container_manager_service_impl.cc b/src/daemon/entry/cri/cri_container_manager_service_impl.cc +index b160ce31..93b939c9 100644 +--- a/src/daemon/entry/cri/cri_container_manager_service_impl.cc ++++ b/src/daemon/entry/cri/cri_container_manager_service_impl.cc +@@ -891,6 +891,60 @@ cleanup: + free_container_stats_response(response); + } + ++auto ContainerManagerServiceImpl::ContainerStats(const std::string &containerID, Errors &error) ++-> std::unique_ptr ++{ ++ container_stats_request *request { nullptr }; ++ container_stats_response *response { nullptr }; ++ std::unique_ptr contStats { nullptr }; ++ std::vector> contStatsVec; ++ ++ if (containerID.empty()) { ++ error.SetError("Empty container id"); ++ return nullptr; ++ } ++ ++ if (m_cb == nullptr || m_cb->container.stats == nullptr) { ++ error.SetError("Unimplemented callback"); ++ return nullptr; ++ } ++ ++ request = (container_stats_request *)util_common_calloc_s(sizeof(container_stats_request)); ++ if (request == nullptr) { ++ error.SetError("Out of memory"); ++ return nullptr; ++ } ++ ++ request->containers = (char **)util_smart_calloc_s(sizeof(char *), 1); ++ if (request->containers == nullptr) { ++ error.SetError("Out of memory"); ++ goto cleanup; ++ } ++ ++ request->containers[0] = util_strdup_s(containerID.c_str()); ++ request->containers_len = 1; ++ ++ if (m_cb->container.stats(request, &response) != 0) { ++ if (response != nullptr && response->errmsg != nullptr) { ++ error.SetError(response->errmsg); ++ } else { ++ error.SetError("Failed to call stats container callback"); ++ } ++ goto cleanup; ++ } ++ ++ ContainerStatsToGRPC(response, &contStatsVec, error); ++ if (error.NotEmpty()) { ++ goto cleanup; ++ } ++ contStats = std::move(contStatsVec[0]); ++ ++cleanup: ++ free_container_stats_request(request); ++ free_container_stats_response(response); ++ return contStats; ++} ++ + void ContainerManagerServiceImpl::PackContainerImageToStatus( + container_inspect *inspect, std::unique_ptr &contStatus, Errors &error) + { +diff --git a/src/daemon/entry/cri/cri_container_manager_service_impl.h b/src/daemon/entry/cri/cri_container_manager_service_impl.h +index 805ef100..6ac1cbc4 100644 +--- a/src/daemon/entry/cri/cri_container_manager_service_impl.h ++++ b/src/daemon/entry/cri/cri_container_manager_service_impl.h +@@ -56,6 +56,9 @@ public: + std::vector> *containerstats, + Errors &error) override; + ++ auto ContainerStats(const std::string &containerID, ++ Errors &error) -> std::unique_ptr override; ++ + auto ContainerStatus(const std::string &containerID, + Errors &error) -> std::unique_ptr override; + +diff --git a/src/daemon/entry/cri/cri_runtime_service.h b/src/daemon/entry/cri/cri_runtime_service.h +index 4727230f..5e4740cb 100644 +--- a/src/daemon/entry/cri/cri_runtime_service.h ++++ b/src/daemon/entry/cri/cri_runtime_service.h +@@ -49,6 +49,9 @@ public: + std::vector> *containerstats, + Errors &error) = 0; + ++ virtual auto ContainerStats(const std::string &containerID, ++ Errors &error) -> std::unique_ptr = 0; ++ + virtual auto ContainerStatus(const std::string &containerID, + Errors &error) -> std::unique_ptr = 0; + +diff --git a/src/daemon/entry/cri/cri_runtime_service_impl.cc b/src/daemon/entry/cri/cri_runtime_service_impl.cc +index 46643a05..e00bc6e2 100644 +--- a/src/daemon/entry/cri/cri_runtime_service_impl.cc ++++ b/src/daemon/entry/cri/cri_runtime_service_impl.cc +@@ -60,6 +60,12 @@ void CRIRuntimeServiceImpl::ListContainerStats(const runtime::v1alpha2::Containe + m_containerManager->ListContainerStats(filter, containerstats, error); + } + ++auto CRIRuntimeServiceImpl::ContainerStats(const std::string &containerID, ++ Errors &error) -> std::unique_ptr ++{ ++ return m_containerManager->ContainerStats(containerID, error); ++} ++ + auto CRIRuntimeServiceImpl::ContainerStatus(const std::string &containerID, + Errors &error) -> std::unique_ptr + { +diff --git a/src/daemon/entry/cri/cri_runtime_service_impl.h b/src/daemon/entry/cri/cri_runtime_service_impl.h +index 13d92aba..95f1424f 100644 +--- a/src/daemon/entry/cri/cri_runtime_service_impl.h ++++ b/src/daemon/entry/cri/cri_runtime_service_impl.h +@@ -58,6 +58,9 @@ public: + std::vector> *containerstats, + Errors &error) override; + ++ auto ContainerStats(const std::string &containerID, ++ Errors &error) -> std::unique_ptr override; ++ + auto ContainerStatus(const std::string &containerID, + Errors &error) -> std::unique_ptr override; + +diff --git a/src/daemon/modules/events/collector.c b/src/daemon/modules/events/collector.c +index 433cb88b..b3c7622a 100644 +--- a/src/daemon/modules/events/collector.c ++++ b/src/daemon/modules/events/collector.c +@@ -484,7 +484,7 @@ static int write_events_log(const struct isulad_events_format *events) + + len = calculate_annaotation_info_len(events); + if (len == 1) { +- WARN("Event: {Object: %s, Type: %s}", events->id, events->opt); ++ INFO("Event: {Object: %s, Type: %s}", events->id, events->opt); + } else { + annotation = (char *)util_common_calloc_s(len); + if (annotation == NULL) { +@@ -502,7 +502,7 @@ static int write_events_log(const struct isulad_events_format *events) + } + (void)strcat(annotation, ")"); + +- WARN("Event: {Object: %s, Type: %s %s}", events->id, events->opt, annotation); ++ INFO("Event: {Object: %s, Type: %s %s}", events->id, events->opt, annotation); + } + + out: +diff --git a/src/daemon/modules/image/image.c b/src/daemon/modules/image/image.c +index 158b3aa8..923e72b2 100644 +--- a/src/daemon/modules/image/image.c ++++ b/src/daemon/modules/image/image.c +@@ -400,7 +400,7 @@ int im_get_filesystem_info(const char *image_type, im_fs_info_response **respons + goto out; + } + +- WARN("Event: {Object: get image filesystem info, Type: inspecting}"); ++ INFO("Event: {Object: get image filesystem info, Type: inspecting}"); + ret = q->ops->get_filesystem_info(response); + if (ret != 0) { + if (response != NULL && *response != NULL) { +@@ -410,7 +410,7 @@ int im_get_filesystem_info(const char *image_type, im_fs_info_response **respons + } + goto out; + } +- WARN("Event: {Object: get image filesystem info, Type: inspected}"); ++ INFO("Event: {Object: get image filesystem info, Type: inspected}"); + + out: + return ret; +@@ -450,7 +450,7 @@ int im_get_container_filesystem_usage(const char *image_type, const char *id, im + request->name_id = util_strdup_s(id); + } + +- WARN("Event: {Object: container \'%s\' filesystem info, Type: inspecting}", id != NULL ? id : ""); ++ INFO("Event: {Object: container \'%s\' filesystem info, Type: inspecting}", id != NULL ? id : ""); + ret = q->ops->container_fs_usage(request, &filesystemusage); + if (ret != 0) { + ERROR("Failed to get filesystem usage for container %s", id); +@@ -460,7 +460,7 @@ int im_get_container_filesystem_usage(const char *image_type, const char *id, im + + *fs_usage = filesystemusage; + filesystemusage = NULL; +- WARN("Event: {Object: container \'%s\' filesystem info, Type: inspected}", id != NULL ? id : ""); ++ INFO("Event: {Object: container \'%s\' filesystem info, Type: inspected}", id != NULL ? id : ""); + + out: + free_im_container_fs_usage_request(request); +@@ -900,7 +900,7 @@ int im_list_images(const im_list_request *ctx, im_list_response **response) + return -1; + } + +- WARN("Event: {Object: list images, Type: listing}"); ++ INFO("Event: {Object: list images, Type: listing}"); + + for (i = 0; i < g_numbims; i++) { + if (g_bims[i].ops->list_ims == NULL) { +@@ -920,7 +920,7 @@ int im_list_images(const im_list_request *ctx, im_list_response **response) + images_tmp = NULL; + } + +- WARN("Event: {Object: list images, Type: listed}"); ++ INFO("Event: {Object: list images, Type: listed}"); + + if (g_isulad_errmsg != NULL) { + (*response)->errmsg = util_strdup_s(g_isulad_errmsg); +@@ -1655,7 +1655,7 @@ int im_inspect_image(const im_inspect_request *request, im_inspect_response **re + + image_ref = util_strdup_s(request->image.image); + +- WARN("Event: {Object: %s, Type: image inspecting}", image_ref); ++ INFO("Event: {Object: %s, Type: image inspecting}", image_ref); + + bim_type = bim_query(image_ref); + if (bim_type == NULL) { +@@ -1677,7 +1677,7 @@ int im_inspect_image(const im_inspect_request *request, im_inspect_response **re + goto pack_response; + } + +- WARN("Event: {Object: %s, Type: image inspected}", image_ref); ++ INFO("Event: {Object: %s, Type: image inspected}", image_ref); + + pack_response: + if (g_isulad_errmsg != NULL) { +diff --git a/src/daemon/modules/image/oci/oci_common_operators.c b/src/daemon/modules/image/oci/oci_common_operators.c +index 7be1ecaa..d33c3585 100644 +--- a/src/daemon/modules/image/oci/oci_common_operators.c ++++ b/src/daemon/modules/image/oci/oci_common_operators.c +@@ -431,7 +431,7 @@ int oci_summary_image(im_summary_request *request, im_summary_response *response + goto pack_response; + } + +- WARN("Event: {Object: %s, Type: statusing image summary}", resolved_name); ++ INFO("Event: {Object: %s, Type: statusing image summary}", resolved_name); + + image_summary = storage_img_get_summary(resolved_name); + if (image_summary == NULL) { +@@ -444,7 +444,7 @@ int oci_summary_image(im_summary_request *request, im_summary_response *response + response->image_summary = image_summary; + image_summary = NULL; + +- WARN("Event: {Object: %s, Type: statused image summary}", resolved_name); ++ INFO("Event: {Object: %s, Type: statused image summary}", resolved_name); + + pack_response: + free(resolved_name); +@@ -495,7 +495,7 @@ int oci_status_image(im_status_request *request, im_status_response *response) + goto pack_response; + } + +- WARN("Event: {Object: %s, Type: statusing image}", resolved_name); ++ INFO("Event: {Object: %s, Type: statusing image}", resolved_name); + + image_info = storage_img_get(resolved_name); + if (image_info == NULL) { +@@ -508,7 +508,7 @@ int oci_status_image(im_status_request *request, im_status_response *response) + response->image_info->image = image_info; + image_info = NULL; + +- WARN("Event: {Object: %s, Type: statused image}", resolved_name); ++ INFO("Event: {Object: %s, Type: statused image}", resolved_name); + + pack_response: + free(resolved_name); +-- +2.25.1 + diff --git a/0014-fix-selinux_label_ut-timeout-and-add-timeout-for-all.patch b/0014-fix-selinux_label_ut-timeout-and-add-timeout-for-all.patch new file mode 100644 index 0000000..112463d --- /dev/null +++ b/0014-fix-selinux_label_ut-timeout-and-add-timeout-for-all.patch @@ -0,0 +1,444 @@ +From 7890d218a8f19355630f859936c22ef43f91b178 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Thu, 16 Feb 2023 15:26:10 +0800 +Subject: [PATCH 14/19] fix selinux_label_ut timeout and add timeout for all ut + +Signed-off-by: zhangxiaoyu +--- + test/buffer/CMakeLists.txt | 1 + + test/cgroup/cpu/CMakeLists.txt | 1 + + test/cmd/isula/extend/pause/CMakeLists.txt | 1 + + test/cmd/isula/extend/resume/CMakeLists.txt | 2 +- + test/cmd/isula/information/info/CMakeLists.txt | 1 + + test/cmd/isula/information/ps/CMakeLists.txt | 1 + + test/cmd/isulad-shim/CMakeLists.txt | 1 + + test/console/CMakeLists.txt | 3 +-- + test/cutils/mainloop/CMakeLists.txt | 1 + + test/cutils/map/CMakeLists.txt | 1 + + test/cutils/path/CMakeLists.txt | 1 + + test/cutils/util_atomic/CMakeLists.txt | 1 + + test/cutils/utils_aes/CMakeLists.txt | 1 + + test/cutils/utils_array/CMakeLists.txt | 1 + + test/cutils/utils_base64/CMakeLists.txt | 1 + + test/cutils/utils_convert/CMakeLists.txt | 1 + + test/cutils/utils_error/CMakeLists.txt | 1 + + test/cutils/utils_file/CMakeLists.txt | 1 + + test/cutils/utils_filters/CMakeLists.txt | 1 + + test/cutils/utils_fs/CMakeLists.txt | 1 + + test/cutils/utils_mount_spec/CMakeLists.txt | 1 + + test/cutils/utils_namespace/CMakeLists.txt | 1 + + test/cutils/utils_network/CMakeLists.txt | 1 + + test/cutils/utils_pwgr/CMakeLists.txt | 1 + + test/cutils/utils_regex/CMakeLists.txt | 1 + + test/cutils/utils_string/CMakeLists.txt | 1 + + test/cutils/utils_timestamp/CMakeLists.txt | 1 + + test/cutils/utils_utils/CMakeLists.txt | 1 + + test/cutils/utils_verify/CMakeLists.txt | 1 + + test/image/oci/oci_config_merge/CMakeLists.txt | 1 + + test/image/oci/registry/CMakeLists.txt | 1 + + test/image/oci/storage/images/CMakeLists.txt | 1 + + test/image/oci/storage/layers/CMakeLists.txt | 2 ++ + test/image/oci/storage/rootfs/CMakeLists.txt | 1 + + test/runtime/isula/CMakeLists.txt | 1 + + test/runtime/lcr/CMakeLists.txt | 1 + + .../services/execution/execute/execution_extend/CMakeLists.txt | 1 + + test/services/execution/spec/CMakeLists.txt | 2 ++ + test/services/execution/spec/selinux_label_ut.cc | 2 ++ + test/specs/specs/CMakeLists.txt | 1 + + test/specs/specs_extend/CMakeLists.txt | 1 + + 41 files changed, 44 insertions(+), 3 deletions(-) + +diff --git a/test/buffer/CMakeLists.txt b/test/buffer/CMakeLists.txt +index f900b592..1e94cc02 100644 +--- a/test/buffer/CMakeLists.txt ++++ b/test/buffer/CMakeLists.txt +@@ -15,3 +15,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cgroup/cpu/CMakeLists.txt b/test/cgroup/cpu/CMakeLists.txt +index 159b0d85..6a8af719 100644 +--- a/test/cgroup/cpu/CMakeLists.txt ++++ b/test/cgroup/cpu/CMakeLists.txt +@@ -26,3 +26,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cmd/isula/extend/pause/CMakeLists.txt b/test/cmd/isula/extend/pause/CMakeLists.txt +index af48c23f..6eab5172 100644 +--- a/test/cmd/isula/extend/pause/CMakeLists.txt ++++ b/test/cmd/isula/extend/pause/CMakeLists.txt +@@ -47,3 +47,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cmd/isula/extend/resume/CMakeLists.txt b/test/cmd/isula/extend/resume/CMakeLists.txt +index 729c4d3b..0812a66e 100644 +--- a/test/cmd/isula/extend/resume/CMakeLists.txt ++++ b/test/cmd/isula/extend/resume/CMakeLists.txt +@@ -48,4 +48,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) +- ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cmd/isula/information/info/CMakeLists.txt b/test/cmd/isula/information/info/CMakeLists.txt +index 2f134986..d8d8ddb7 100644 +--- a/test/cmd/isula/information/info/CMakeLists.txt ++++ b/test/cmd/isula/information/info/CMakeLists.txt +@@ -49,3 +49,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cmd/isula/information/ps/CMakeLists.txt b/test/cmd/isula/information/ps/CMakeLists.txt +index 9659808a..ca04c25c 100644 +--- a/test/cmd/isula/information/ps/CMakeLists.txt ++++ b/test/cmd/isula/information/ps/CMakeLists.txt +@@ -49,3 +49,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cmd/isulad-shim/CMakeLists.txt b/test/cmd/isulad-shim/CMakeLists.txt +index 1c2de232..dc293f6d 100644 +--- a/test/cmd/isulad-shim/CMakeLists.txt ++++ b/test/cmd/isulad-shim/CMakeLists.txt +@@ -30,3 +30,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/console/CMakeLists.txt b/test/console/CMakeLists.txt +index acadc620..c6f2419c 100644 +--- a/test/console/CMakeLists.txt ++++ b/test/console/CMakeLists.txt +@@ -16,5 +16,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) +- +- ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/mainloop/CMakeLists.txt b/test/cutils/mainloop/CMakeLists.txt +index 78e3f18d..61ea7ffc 100644 +--- a/test/cutils/mainloop/CMakeLists.txt ++++ b/test/cutils/mainloop/CMakeLists.txt +@@ -25,3 +25,4 @@ target_link_libraries(${EXE} + libutils_ut -lcrypto -lyajl -lz) + + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/map/CMakeLists.txt b/test/cutils/map/CMakeLists.txt +index 4059559f..bd21ee3f 100644 +--- a/test/cutils/map/CMakeLists.txt ++++ b/test/cutils/map/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/path/CMakeLists.txt b/test/cutils/path/CMakeLists.txt +index 745258a1..aa0c6c6e 100644 +--- a/test/cutils/path/CMakeLists.txt ++++ b/test/cutils/path/CMakeLists.txt +@@ -15,3 +15,4 @@ target_include_directories(${EXE} PUBLIC + set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-Wl,--wrap,getcwd -Wl,--wrap,readlink") + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/util_atomic/CMakeLists.txt b/test/cutils/util_atomic/CMakeLists.txt +index 071b2a04..21b05c46 100644 +--- a/test/cutils/util_atomic/CMakeLists.txt ++++ b/test/cutils/util_atomic/CMakeLists.txt +@@ -16,3 +16,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_aes/CMakeLists.txt b/test/cutils/utils_aes/CMakeLists.txt +index f7535bb3..c4d175c8 100644 +--- a/test/cutils/utils_aes/CMakeLists.txt ++++ b/test/cutils/utils_aes/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_array/CMakeLists.txt b/test/cutils/utils_array/CMakeLists.txt +index 71733e31..afe564bf 100644 +--- a/test/cutils/utils_array/CMakeLists.txt ++++ b/test/cutils/utils_array/CMakeLists.txt +@@ -16,3 +16,4 @@ target_include_directories(${EXE} PUBLIC + set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-Wl,--wrap,calloc") + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_base64/CMakeLists.txt b/test/cutils/utils_base64/CMakeLists.txt +index d5b99361..35e6ba04 100644 +--- a/test/cutils/utils_base64/CMakeLists.txt ++++ b/test/cutils/utils_base64/CMakeLists.txt +@@ -15,3 +15,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_convert/CMakeLists.txt b/test/cutils/utils_convert/CMakeLists.txt +index 30068208..fcf70a7c 100644 +--- a/test/cutils/utils_convert/CMakeLists.txt ++++ b/test/cutils/utils_convert/CMakeLists.txt +@@ -15,3 +15,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_error/CMakeLists.txt b/test/cutils/utils_error/CMakeLists.txt +index 28016605..9607aeeb 100644 +--- a/test/cutils/utils_error/CMakeLists.txt ++++ b/test/cutils/utils_error/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_file/CMakeLists.txt b/test/cutils/utils_file/CMakeLists.txt +index 20317e15..01b2ff47 100644 +--- a/test/cutils/utils_file/CMakeLists.txt ++++ b/test/cutils/utils_file/CMakeLists.txt +@@ -16,3 +16,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_filters/CMakeLists.txt b/test/cutils/utils_filters/CMakeLists.txt +index 31d3ac25..561ff4ef 100644 +--- a/test/cutils/utils_filters/CMakeLists.txt ++++ b/test/cutils/utils_filters/CMakeLists.txt +@@ -16,3 +16,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_fs/CMakeLists.txt b/test/cutils/utils_fs/CMakeLists.txt +index 7ff3176a..e909aee6 100644 +--- a/test/cutils/utils_fs/CMakeLists.txt ++++ b/test/cutils/utils_fs/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_mount_spec/CMakeLists.txt b/test/cutils/utils_mount_spec/CMakeLists.txt +index 24fb5add..099805d2 100644 +--- a/test/cutils/utils_mount_spec/CMakeLists.txt ++++ b/test/cutils/utils_mount_spec/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_namespace/CMakeLists.txt b/test/cutils/utils_namespace/CMakeLists.txt +index 8add4a71..fb535e71 100644 +--- a/test/cutils/utils_namespace/CMakeLists.txt ++++ b/test/cutils/utils_namespace/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_network/CMakeLists.txt b/test/cutils/utils_network/CMakeLists.txt +index 7e2c84e7..d08a6fbd 100644 +--- a/test/cutils/utils_network/CMakeLists.txt ++++ b/test/cutils/utils_network/CMakeLists.txt +@@ -25,3 +25,4 @@ target_link_libraries(${EXE} + libutils_ut -lcrypto -lyajl -lz) + + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_pwgr/CMakeLists.txt b/test/cutils/utils_pwgr/CMakeLists.txt +index 5938991e..34acb92a 100644 +--- a/test/cutils/utils_pwgr/CMakeLists.txt ++++ b/test/cutils/utils_pwgr/CMakeLists.txt +@@ -15,3 +15,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_regex/CMakeLists.txt b/test/cutils/utils_regex/CMakeLists.txt +index 3f6410b2..45ba2604 100644 +--- a/test/cutils/utils_regex/CMakeLists.txt ++++ b/test/cutils/utils_regex/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_string/CMakeLists.txt b/test/cutils/utils_string/CMakeLists.txt +index 1343f4e6..b9968c43 100644 +--- a/test/cutils/utils_string/CMakeLists.txt ++++ b/test/cutils/utils_string/CMakeLists.txt +@@ -16,3 +16,4 @@ target_include_directories(${EXE} PUBLIC + set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-Wl,--wrap,util_strdup_s -Wl,--wrap,calloc -Wl,--wrap,strcat_s") + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_timestamp/CMakeLists.txt b/test/cutils/utils_timestamp/CMakeLists.txt +index 38aec640..6da3fcc9 100644 +--- a/test/cutils/utils_timestamp/CMakeLists.txt ++++ b/test/cutils/utils_timestamp/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_utils/CMakeLists.txt b/test/cutils/utils_utils/CMakeLists.txt +index 7b3bd546..99a83e7a 100644 +--- a/test/cutils/utils_utils/CMakeLists.txt ++++ b/test/cutils/utils_utils/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/cutils/utils_verify/CMakeLists.txt b/test/cutils/utils_verify/CMakeLists.txt +index abf9596f..dd9ef78b 100644 +--- a/test/cutils/utils_verify/CMakeLists.txt ++++ b/test/cutils/utils_verify/CMakeLists.txt +@@ -14,3 +14,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} libutils_ut -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/image/oci/oci_config_merge/CMakeLists.txt b/test/image/oci/oci_config_merge/CMakeLists.txt +index 88047fde..42cd2e78 100644 +--- a/test/image/oci/oci_config_merge/CMakeLists.txt ++++ b/test/image/oci/oci_config_merge/CMakeLists.txt +@@ -73,3 +73,4 @@ target_include_directories(${EXE} PUBLIC + set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-Wl,--wrap,util_common_calloc_s -Wl,--wrap,util_smart_calloc_s -Wl,--wrap,merge_env") + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/image/oci/registry/CMakeLists.txt b/test/image/oci/registry/CMakeLists.txt +index 9ff075db..31240ae0 100644 +--- a/test/image/oci/registry/CMakeLists.txt ++++ b/test/image/oci/registry/CMakeLists.txt +@@ -62,3 +62,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz libhttpclient) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/image/oci/storage/images/CMakeLists.txt b/test/image/oci/storage/images/CMakeLists.txt +index b00c5a0e..3e6b69a4 100644 +--- a/test/image/oci/storage/images/CMakeLists.txt ++++ b/test/image/oci/storage/images/CMakeLists.txt +@@ -45,3 +45,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/image/oci/storage/layers/CMakeLists.txt b/test/image/oci/storage/layers/CMakeLists.txt +index 3fe8ab7c..952e9483 100644 +--- a/test/image/oci/storage/layers/CMakeLists.txt ++++ b/test/image/oci/storage/layers/CMakeLists.txt +@@ -66,6 +66,7 @@ target_link_libraries(${DRIVER_EXE} + -lwebsockets -lcrypto -lyajl -larchive ${SELINUX_LIBRARY} -ldevmapper -lz) + + add_test(NAME ${DRIVER_EXE} COMMAND ${DRIVER_EXE} --gtest_output=xml:${DRIVER_EXE}-Results.xml) ++set_tests_properties(${DRIVER_EXE} PROPERTIES TIMEOUT 120) + + # storage_layers_ut + SET(LAYER_EXE storage_layers_ut) +@@ -141,3 +142,4 @@ target_link_libraries(${LAYER_EXE} + -lwebsockets -lcrypto -lyajl -larchive ${SELINUX_LIBRARY} -ldevmapper -lz) + + add_test(NAME ${LAYER_EXE} COMMAND ${LAYER_EXE} --gtest_output=xml:${LAYER_EXE}-Results.xml) ++set_tests_properties(${LAYER_EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/image/oci/storage/rootfs/CMakeLists.txt b/test/image/oci/storage/rootfs/CMakeLists.txt +index 5bf568f9..4d7d3533 100644 +--- a/test/image/oci/storage/rootfs/CMakeLists.txt ++++ b/test/image/oci/storage/rootfs/CMakeLists.txt +@@ -45,3 +45,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/runtime/isula/CMakeLists.txt b/test/runtime/isula/CMakeLists.txt +index 38a454b0..f5821953 100644 +--- a/test/runtime/isula/CMakeLists.txt ++++ b/test/runtime/isula/CMakeLists.txt +@@ -58,3 +58,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lpthread -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/runtime/lcr/CMakeLists.txt b/test/runtime/lcr/CMakeLists.txt +index 6f8f784c..979cbe5a 100644 +--- a/test/runtime/lcr/CMakeLists.txt ++++ b/test/runtime/lcr/CMakeLists.txt +@@ -58,3 +58,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/services/execution/execute/execution_extend/CMakeLists.txt b/test/services/execution/execute/execution_extend/CMakeLists.txt +index aaff39ef..8588fac3 100644 +--- a/test/services/execution/execute/execution_extend/CMakeLists.txt ++++ b/test/services/execution/execute/execution_extend/CMakeLists.txt +@@ -76,3 +76,4 @@ target_include_directories(${EXE} PUBLIC + ) + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/services/execution/spec/CMakeLists.txt b/test/services/execution/spec/CMakeLists.txt +index e1aa680e..d4a9d9b0 100644 +--- a/test/services/execution/spec/CMakeLists.txt ++++ b/test/services/execution/spec/CMakeLists.txt +@@ -74,4 +74,6 @@ target_include_directories(${MOCK_EXE} PUBLIC + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${SELINUX_LIBRARY} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz) + target_link_libraries(${MOCK_EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${SELINUX_LIBRARY} ${ISULA_LIBUTILS_LIBRARY} -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) + add_test(NAME ${MOCK_EXE} COMMAND ${MOCK_EXE} --gtest_output=xml:${MOCK_EXE}-Results.xml) ++set_tests_properties(${MOCK_EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/services/execution/spec/selinux_label_ut.cc b/test/services/execution/spec/selinux_label_ut.cc +index c0e9ab1c..f9a73cca 100644 +--- a/test/services/execution/spec/selinux_label_ut.cc ++++ b/test/services/execution/spec/selinux_label_ut.cc +@@ -179,11 +179,13 @@ protected: + void SetUp() override + { + CreateTestedObjects(); ++ selinux_state_init(); + } + + void TearDown() override + { + ClearTestedObjects(); ++ selinux_state_free(); + } + + private: +diff --git a/test/specs/specs/CMakeLists.txt b/test/specs/specs/CMakeLists.txt +index b730959c..c4b36c5f 100644 +--- a/test/specs/specs/CMakeLists.txt ++++ b/test/specs/specs/CMakeLists.txt +@@ -83,3 +83,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +diff --git a/test/specs/specs_extend/CMakeLists.txt b/test/specs/specs_extend/CMakeLists.txt +index 7d05deb4..06f46a37 100644 +--- a/test/specs/specs_extend/CMakeLists.txt ++++ b/test/specs/specs_extend/CMakeLists.txt +@@ -79,3 +79,4 @@ target_include_directories(${EXE} PUBLIC + + target_link_libraries(${EXE} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${ISULA_LIBUTILS_LIBRARY} -lgrpc++ -lprotobuf -lcrypto -lyajl -lz) + add_test(NAME ${EXE} COMMAND ${EXE} --gtest_output=xml:${EXE}-Results.xml) ++set_tests_properties(${EXE} PROPERTIES TIMEOUT 120) +-- +2.25.1 + diff --git a/0015-fix-cpu-rt-disable-after-reboot-machine.patch b/0015-fix-cpu-rt-disable-after-reboot-machine.patch new file mode 100644 index 0000000..23cf10e --- /dev/null +++ b/0015-fix-cpu-rt-disable-after-reboot-machine.patch @@ -0,0 +1,850 @@ +From adc75018f7eda4b205034999893634d1b98b2701 Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Thu, 16 Feb 2023 15:42:02 +0800 +Subject: [PATCH 15/19] fix cpu-rt disable after reboot machine + +1. ensure parent cgroup cpu-rt of container, should do in start container; +2. current do in create container, will cause failed of start container with cpu-rt after reboot machine + +Signed-off-by: haozi007 +--- + src/daemon/common/sysinfo.c | 48 ++++ + src/daemon/common/sysinfo.h | 2 + + src/daemon/executor/container_cb/execution.c | 177 +++++++++++++- + .../executor/container_cb/execution_create.c | 221 +----------------- + src/daemon/modules/api/specs_api.h | 2 +- + src/daemon/modules/spec/specs.c | 88 ++++--- + test/specs/specs/specs_ut.cc | 60 +++-- + 7 files changed, 306 insertions(+), 292 deletions(-) + +diff --git a/src/daemon/common/sysinfo.c b/src/daemon/common/sysinfo.c +index e7b3807b..8ad92b2a 100644 +--- a/src/daemon/common/sysinfo.c ++++ b/src/daemon/common/sysinfo.c +@@ -1627,3 +1627,51 @@ free_out: + } + return minfos; + } ++ ++char *sysinfo_cgroup_controller_cpurt_mnt_path(void) ++{ ++ char *res = NULL; ++ int nret = 0; ++ char *mnt = NULL; ++ char *root = NULL; ++ char fpath[PATH_MAX] = { 0 }; ++ sysinfo_t *sysinfo = NULL; ++ ++ sysinfo = get_sys_info(true); ++ if (sysinfo == NULL) { ++ ERROR("Can not get system info"); ++ return NULL; ++ } ++ ++ if (!(sysinfo->cgcpuinfo.cpu_rt_period)) { ++ ERROR("Daemon-scoped cpu-rt-period and cpu-rt-runtime are not supported by kernel"); ++ isulad_set_error_message("Daemon-scoped cpu-rt-period and cpu-rt-runtime are not supported by kernel"); ++ return NULL; ++ } ++ ++ nret = find_cgroup_mountpoint_and_root("cpu", &mnt, &root); ++ if (nret != 0 || mnt == NULL || root == NULL) { ++ ERROR("Can not find cgroup mnt and root path for subsystem 'cpu'"); ++ isulad_set_error_message("Can not find cgroup mnt and root path for subsystem 'cpu'"); ++ goto out; ++ } ++ ++ // When iSulad is run inside docker, the root is based of the host cgroup. ++ // Replace root to "/" ++ if (strncmp(root, "/docker/", strlen("/docker/")) == 0) { ++ root[1] = '\0'; ++ } ++ ++ nret = snprintf(fpath, sizeof(fpath), "%s/%s", mnt, root); ++ if (nret < 0 || (size_t)nret >= sizeof(fpath)) { ++ ERROR("Failed to print string"); ++ goto out; ++ } ++ ++ res = util_strdup_s(fpath); ++ ++out: ++ free(mnt); ++ free(root); ++ return res; ++} +\ No newline at end of file +diff --git a/src/daemon/common/sysinfo.h b/src/daemon/common/sysinfo.h +index 8468e00a..027cb1de 100644 +--- a/src/daemon/common/sysinfo.h ++++ b/src/daemon/common/sysinfo.h +@@ -139,6 +139,8 @@ mountinfo_t *find_mount_info(mountinfo_t **minfos, const char *dir); + + void free_mounts_info(mountinfo_t **minfos); + ++char *sysinfo_cgroup_controller_cpurt_mnt_path(void); ++ + #ifdef __cplusplus + } + #endif +diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c +index 68d0d8d6..4dd5f858 100644 +--- a/src/daemon/executor/container_cb/execution.c ++++ b/src/daemon/executor/container_cb/execution.c +@@ -17,7 +17,13 @@ + #include + #include + #include ++#include ++#include ++#include ++#include ++#include + #include ++ + #include + #include + #include +@@ -34,12 +40,11 @@ + #include + #include + #include +-#include +-#include +-#include +-#include ++#include + +-#include "isula_libutils/log.h" ++#include "sysinfo.h" ++#include "isulad_config.h" ++#include "specs_api.h" + #include "container_api.h" + #include "execution_extend.h" + #include "execution_information.h" +@@ -297,6 +302,155 @@ static void pack_start_response(container_start_response *response, uint32_t cc, + } + } + ++static int do_init_cpurt_cgroups_path(const char *path, int recursive_depth, const char *mnt_root, ++ int64_t cpu_rt_period, int64_t cpu_rt_runtime); ++ ++/* maybe create cpu realtime file */ ++static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const char *path) ++{ ++ int ret; ++ int fd = -1; ++ ssize_t nwrite; ++ char fpath[PATH_MAX] = { 0 }; ++ char buf[ISULAD_NUMSTRLEN64] = { 0 }; ++ ++ if (value == 0) { ++ return 0; ++ } ++ ++ ret = util_mkdir_p(path, CONFIG_DIRECTORY_MODE); ++ if (ret != 0) { ++ ERROR("Failed to mkdir: %s", path); ++ return -1; ++ } ++ ++ ret = snprintf(fpath, sizeof(fpath), "%s/%s", path, file); ++ if (ret < 0 || ret >= sizeof(fpath)) { ++ ERROR("Failed to print string"); ++ return -1; ++ } ++ ret = snprintf(buf, sizeof(buf), "%lld", (long long int)value); ++ if (ret < 0 || (size_t)ret >= sizeof(buf)) { ++ ERROR("Failed to print string"); ++ return -1; ++ } ++ ++ fd = util_open(fpath, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0700); ++ if (fd < 0) { ++ ERROR("Failed to open file: %s: %s", fpath, strerror(errno)); ++ isulad_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno)); ++ return -1; ++ } ++ nwrite = util_write_nointr(fd, buf, strlen(buf)); ++ if (nwrite < 0 || nwrite != strlen(buf)) { ++ ERROR("Failed to write %s to %s: %s", buf, fpath, strerror(errno)); ++ isulad_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ close(fd); ++ ++ return 0; ++} ++ ++static int recursively_create_cgroup(const char *path, const char *mnt_root, int recursive_depth, int64_t cpu_rt_period, ++ int64_t cpu_rt_runtime) ++{ ++ int nret; ++ char *dup = NULL; ++ char *dirpath = NULL; ++ char fpath[PATH_MAX] = { 0 }; ++ ++ dup = util_strdup_s(path); ++ dirpath = dirname(dup); ++ nret = do_init_cpurt_cgroups_path(dirpath, (recursive_depth + 1), mnt_root, cpu_rt_period, cpu_rt_runtime); ++ free(dup); ++ if (nret != 0) { ++ return -1; ++ } ++ ++ nret = snprintf(fpath, sizeof(fpath), "%s/%s", mnt_root, path); ++ if (nret < 0 || (size_t)nret >= sizeof(fpath)) { ++ ERROR("Failed to print string"); ++ return -1; ++ } ++ ++ nret = maybe_create_cpu_realtime_file(cpu_rt_period, "cpu.rt_period_us", fpath); ++ if (nret != 0) { ++ return -1; ++ } ++ ++ return maybe_create_cpu_realtime_file(cpu_rt_runtime, "cpu.rt_runtime_us", fpath); ++} ++ ++/* init cgroups path */ ++static int do_init_cpurt_cgroups_path(const char *path, int recursive_depth, const char *mnt_root, ++ int64_t cpu_rt_period, int64_t cpu_rt_runtime) ++{ ++ if ((recursive_depth + 1) > MAX_PATH_DEPTH) { ++ ERROR("Reach the max cgroup depth:%s", path); ++ return -1; ++ } ++ ++ if (path == NULL || strcmp(path, "/") == 0 || strcmp(path, ".") == 0) { ++ return 0; ++ } ++ ++ // Recursively create cgroup to ensure that the system and all parent cgroups have values set ++ // for the period and runtime as this limits what the children can be set to. ++ if (recursively_create_cgroup(path, mnt_root, recursive_depth, cpu_rt_period, cpu_rt_runtime)) { ++ return -1; ++ } ++ ++ return 0; ++} ++ ++// TODO: maybe we should adapt to cgroup v2 ++static int cpurt_controller_init(const char *id, const host_config *host_spec) ++{ ++ int ret = 0; ++ int64_t cpu_rt_period = 0; ++ int64_t cpu_rt_runtime = 0; ++ char *dirpath = NULL; ++ char *mnt_root = NULL; ++ char *cgroups_path = NULL; ++ ++ if (conf_get_cgroup_cpu_rt(&cpu_rt_period, &cpu_rt_runtime)) { ++ return -1; ++ } ++ ++ if (cpu_rt_period == 0 && cpu_rt_runtime == 0) { ++ return 0; ++ } ++ ++ cgroups_path = merge_container_cgroups_path(id, host_spec); ++ if (cgroups_path == NULL) { ++ ERROR("Merge cgroups path for container failed"); ++ ret = -1; ++ goto out; ++ } ++ if (strcmp(cgroups_path, "/") == 0 || strcmp(cgroups_path, ".") == 0) { ++ goto out; ++ } ++ ++ mnt_root = sysinfo_cgroup_controller_cpurt_mnt_path(); ++ if (mnt_root == NULL) { ++ ERROR("Failed to get cpu rt controller mnt root path"); ++ isulad_set_error_message("Failed to get cpu rt controller mnt root path"); ++ ret = -1; ++ goto out; ++ } ++ ++ dirpath = dirname(cgroups_path); ++ ++ ret = do_init_cpurt_cgroups_path(dirpath, 0, mnt_root, cpu_rt_period, cpu_rt_runtime); ++ ++out: ++ free(mnt_root); ++ free(cgroups_path); ++ return ret; ++} ++ + static int container_start_prepare(container_t *cont, const container_start_request *request, int stdinfd, + struct io_write_wrapper *stdout_handler, struct io_write_wrapper *stderr_handler, + char **fifopath, char *fifos[], int *sync_fd, pthread_t *thread_id) +@@ -309,6 +463,19 @@ static int container_start_prepare(container_t *cont, const container_start_requ + return -1; + } + ++ // init cgroup path for cpu_rt_runtime and cpu_rt_period ++ // we should do this in start container, not create container ++ // because it will fail after the following steps: ++ // 1. enable cpu-rt of isulad; ++ // 2. then run container with --cpu-rt-runtime ++ // 3. then reboot machine; ++ // 4. finally, start before container, it will failed... ++ // cause of no one to set value into cgroup/isulad/cpu-rt-runtime and cpu-rt-period. ++ if (cpurt_controller_init(id, cont->hostconfig) != 0) { ++ isulad_set_error_message("Failed to init controller of cpu-rt for container \"%s\".", id); ++ return -1; ++ } ++ + if (prepare_start_io(cont, request, fifopath, fifos, stdinfd, stdout_handler, stderr_handler, sync_fd, thread_id) != + 0) { + return -1; +diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c +index 0d03afcb..a039ba6b 100644 +--- a/src/daemon/executor/container_cb/execution_create.c ++++ b/src/daemon/executor/container_cb/execution_create.c +@@ -19,6 +19,13 @@ + #include + #include + #include ++#include ++#include ++#include ++#include ++#include ++ ++#include + #include + #include + #include +@@ -28,14 +35,7 @@ + #include + #include + #include +-#include +-#include +-#include +-#include +-#include +-#include + +-#include "isula_libutils/log.h" + #include "isulad_config.h" + #include "specs_api.h" + #include "verify.h" +@@ -61,9 +61,6 @@ + #include "opt_log.h" + #include "network_namespace_api.h" + +-static int do_init_cpurt_cgroups_path(const char *path, int recursive_depth, const char *mnt_root, +- int64_t cpu_rt_period, int64_t cpu_rt_runtime); +- + static int runtime_check(const char *name, bool *runtime_res) + { + int ret = 0; +@@ -1291,148 +1288,6 @@ static int save_container_config_before_create(const char *id, const char *runti + return 0; + } + +-/* maybe create cpu realtime file */ +-static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const char *path) +-{ +- int ret; +- int fd = -1; +- ssize_t nwrite; +- char fpath[PATH_MAX] = { 0 }; +- char buf[ISULAD_NUMSTRLEN64] = { 0 }; +- +- if (value == 0) { +- return 0; +- } +- +- ret = util_mkdir_p(path, CONFIG_DIRECTORY_MODE); +- if (ret != 0) { +- ERROR("Failed to mkdir: %s", path); +- return -1; +- } +- +- ret = snprintf(fpath, sizeof(fpath), "%s/%s", path, file); +- if (ret < 0 || ret >= sizeof(fpath)) { +- ERROR("Failed to print string"); +- return -1; +- } +- ret = snprintf(buf, sizeof(buf), "%lld", (long long int)value); +- if (ret < 0 || (size_t)ret >= sizeof(buf)) { +- ERROR("Failed to print string"); +- return -1; +- } +- +- fd = util_open(fpath, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0700); +- if (fd < 0) { +- ERROR("Failed to open file: %s: %s", fpath, strerror(errno)); +- isulad_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno)); +- return -1; +- } +- nwrite = util_write_nointr(fd, buf, strlen(buf)); +- if (nwrite < 0) { +- ERROR("Failed to write %s to %s: %s", buf, fpath, strerror(errno)); +- isulad_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno)); +- close(fd); +- return -1; +- } +- close(fd); +- +- return 0; +-} +- +-static int recursively_create_cgroup(const char *path, const char *mnt_root, int recursive_depth, int64_t cpu_rt_period, +- int64_t cpu_rt_runtime) +-{ +- int ret = 0; +- char *dup = NULL; +- char *dirpath = NULL; +- char fpath[PATH_MAX] = { 0 }; +- +- dup = util_strdup_s(path); +- dirpath = dirname(dup); +- ret = do_init_cpurt_cgroups_path(dirpath, (recursive_depth + 1), mnt_root, cpu_rt_period, cpu_rt_runtime); +- free(dup); +- if (ret != 0) { +- return ret; +- } +- +- int nret = snprintf(fpath, sizeof(fpath), "%s/%s", mnt_root, path); +- if (nret < 0 || (size_t)nret >= sizeof(fpath)) { +- ERROR("Failed to print string"); +- ret = -1; +- goto out; +- } +- +- ret = maybe_create_cpu_realtime_file(cpu_rt_period, "cpu.rt_period_us", fpath); +- if (ret != 0) { +- goto out; +- } +- +- ret = maybe_create_cpu_realtime_file(cpu_rt_runtime, "cpu.rt_runtime_us", fpath); +- if (ret != 0) { +- goto out; +- } +- +-out: +- return ret; +-} +- +-/* init cgroups path */ +-static int do_init_cpurt_cgroups_path(const char *path, int recursive_depth, const char *mnt_root, +- int64_t cpu_rt_period, int64_t cpu_rt_runtime) +-{ +- if ((recursive_depth + 1) > MAX_PATH_DEPTH) { +- ERROR("Reach the max cgroup depth:%s", path); +- return -1; +- } +- +- if (path == NULL || strcmp(path, "/") == 0 || strcmp(path, ".") == 0) { +- return 0; +- } +- +- // Recursively create cgroup to ensure that the system and all parent cgroups have values set +- // for the period and runtime as this limits what the children can be set to. +- if (recursively_create_cgroup(path, mnt_root, recursive_depth, cpu_rt_period, cpu_rt_runtime)) { +- return -1; +- } +- +- return 0; +-} +- +-static char *get_cpurt_controller_mnt_path() +-{ +- char *res = NULL; +- int nret = 0; +- char *mnt = NULL; +- char *root = NULL; +- char fpath[PATH_MAX] = { 0 }; +- +- nret = find_cgroup_mountpoint_and_root("cpu", &mnt, &root); +- if (nret != 0 || mnt == NULL || root == NULL) { +- ERROR("Can not find cgroup mnt and root path for subsystem 'cpu'"); +- isulad_set_error_message("Can not find cgroup mnt and root path for subsystem 'cpu'"); +- goto out; +- } +- +- // When iSulad is run inside docker, the root is based of the host cgroup. +- // Replace root to "/" +- if (strncmp(root, "/docker/", strlen("/docker/")) == 0) { +- root[1] = '\0'; +- } +- +- nret = snprintf(fpath, sizeof(fpath), "%s/%s", mnt, root); +- if (nret < 0 || (size_t)nret >= sizeof(fpath)) { +- ERROR("Failed to print string"); +- goto out; +- } +- +- res = util_strdup_s(fpath); +- +-out: +- free(mnt); +- free(root); +- return res; +-} +- + static char *new_pod_sandbox_key(void) + { + int nret = 0; +@@ -1495,61 +1350,6 @@ err_out: + return -1; + } + +-static int cpurt_controller_init(const char *cgroups_path) +-{ +- int ret = 0; +- char *dup = NULL; +- char *dirpath = NULL; +- int64_t cpu_rt_period = 0; +- int64_t cpu_rt_runtime = 0; +- sysinfo_t *sysinfo = NULL; +- char *mnt_root = NULL; +- +- if (cgroups_path == NULL || strcmp(cgroups_path, "/") == 0 || strcmp(cgroups_path, ".") == 0) { +- return 0; +- } +- +- if (conf_get_cgroup_cpu_rt(&cpu_rt_period, &cpu_rt_runtime)) { +- return -1; +- } +- +- if (cpu_rt_period == 0 && cpu_rt_runtime == 0) { +- return 0; +- } +- +- sysinfo = get_sys_info(true); +- if (sysinfo == NULL) { +- ERROR("Can not get system info"); +- ret = -1; +- goto out; +- } +- +- if (!(sysinfo->cgcpuinfo.cpu_rt_period)) { +- ERROR("Daemon-scoped cpu-rt-period and cpu-rt-runtime are not supported by kernel"); +- isulad_set_error_message("Daemon-scoped cpu-rt-period and cpu-rt-runtime are not supported by kernel"); +- ret = -1; +- goto out; +- } +- +- mnt_root = get_cpurt_controller_mnt_path(); +- if (mnt_root == NULL) { +- ERROR("Failed to get cpu rt controller mnt root path"); +- isulad_set_error_message("Failed to get cpu rt controller mnt root path"); +- ret = -1; +- goto out; +- } +- +- dup = util_strdup_s(cgroups_path); +- dirpath = dirname(dup); +- +- ret = do_init_cpurt_cgroups_path(dirpath, 0, mnt_root, cpu_rt_period, cpu_rt_runtime); +- +-out: +- free(mnt_root); +- free(dup); +- return ret; +-} +- + /* + * request -> host_spec + container_spec + * container_spec + image config +@@ -1707,13 +1507,6 @@ int container_create_cb(const container_create_request *request, container_creat + goto umount_channel; + } + +- // init cgroup path for cpu_rt_runtime and cpu_rt_period +- if (cpurt_controller_init(oci_spec->linux->cgroups_path) != 0) { +- ERROR("Unable to init CPU RT controller %s", oci_spec->linux->cgroups_path); +- cc = ISULAD_ERR_EXEC; +- goto umount_channel; +- } +- + if (container_v2_spec_merge_contaner_spec(v2_spec) != 0) { + ERROR("Failed to merge container settings"); + cc = ISULAD_ERR_EXEC; +diff --git a/src/daemon/modules/api/specs_api.h b/src/daemon/modules/api/specs_api.h +index c4ad79aa..0a594d81 100644 +--- a/src/daemon/modules/api/specs_api.h ++++ b/src/daemon/modules/api/specs_api.h +@@ -27,7 +27,7 @@ extern "C" { + + int merge_all_specs(host_config *host_spec, const char *real_rootfs, container_config_v2_common_config *v2_spec, + oci_runtime_spec *oci_spec); +-int merge_oci_cgroups_path(const char *id, oci_runtime_spec *oci_spec, const host_config *host_spec); ++char *merge_container_cgroups_path(const char *id, const host_config *host_spec); + int merge_global_config(oci_runtime_spec *oci_spec); + oci_runtime_spec *load_oci_config(const char *rootpath, const char *name); + oci_runtime_spec *default_spec(bool system_container); +diff --git a/src/daemon/modules/spec/specs.c b/src/daemon/modules/spec/specs.c +index 138a0989..f32ff911 100644 +--- a/src/daemon/modules/spec/specs.c ++++ b/src/daemon/modules/spec/specs.c +@@ -165,36 +165,45 @@ out: + return ret; + } + +-static int make_annotations_cgroup_dir(const container_config *container_spec, const host_config *host_spec) ++static char *do_get_container_cgroup_path(const host_config *host_spec) + { +- int ret = 0; +- char cleaned[PATH_MAX] = { 0 }; +- char *default_cgroup_parent = NULL; + char *path = NULL; + +- default_cgroup_parent = conf_get_isulad_cgroup_parent(); + if (host_spec->cgroup_parent != NULL) { +- path = host_spec->cgroup_parent; +- } else if (default_cgroup_parent != NULL) { +- path = default_cgroup_parent; ++ // first, use user setting ++ path = util_strdup_s(host_spec->cgroup_parent); ++ } else { ++ // second, if user donot set, use setting from daemon config ++ path = conf_get_isulad_cgroup_parent(); + } ++ + if (path == NULL) { +- path = "/isulad"; ++ // third, all faild, just use default '/isulad' ++ path = util_strdup_s("/isulad"); + } ++ ++ return path; ++} ++ ++static int make_annotations_cgroup_dir(const container_config *container_spec, const host_config *host_spec) ++{ ++ char cleaned[PATH_MAX] = { 0 }; ++ char *path = NULL; ++ ++ path = do_get_container_cgroup_path(host_spec); + if (util_clean_path(path, cleaned, sizeof(cleaned)) == NULL) { + ERROR("Failed to clean path: %s", path); +- ret = -1; +- goto out; ++ free(path); ++ return -1; + } ++ free(path); ++ + if (append_json_map_string_string(container_spec->annotations, "cgroup.dir", cleaned)) { + ERROR("Realloc annotations failed"); +- ret = -1; +- goto out; ++ return -1; + } + +-out: +- free(default_cgroup_parent); +- return ret; ++ return 0; + } + + static int make_annotations_oom_score_adj(const container_config *container_spec, const host_config *host_spec) +@@ -2048,42 +2057,45 @@ out: + return ret; + } + +-int merge_oci_cgroups_path(const char *id, oci_runtime_spec *oci_spec, const host_config *host_spec) ++char *merge_container_cgroups_path(const char *id, const host_config *host_spec) + { +- int ret = 0; +- char *default_cgroup_parent = NULL; + char *path = NULL; ++ char *ret = NULL; ++ ++ if (id == NULL || host_spec == NULL) { ++ ERROR("Invalid arguments"); ++ return NULL; ++ } ++ ++ path = do_get_container_cgroup_path(host_spec); ++ ++ ret = util_path_join(path, id); ++ free(path); ++ ++ return ret; ++} + ++static int merge_oci_cgroups_path(const char *id, oci_runtime_spec *oci_spec, const host_config *host_spec) ++{ + if (id == NULL || oci_spec == NULL || host_spec == NULL) { + ERROR("Invalid arguments"); +- ret = -1; +- goto out; ++ return -1; + } + + if (make_sure_oci_spec_linux(oci_spec) != 0) { + ERROR("Failed to make oci spec linux"); +- ret = -1; +- goto out; ++ return -1; + } + +- default_cgroup_parent = conf_get_isulad_cgroup_parent(); +- path = default_cgroup_parent; +- if (host_spec->cgroup_parent != NULL) { +- path = host_spec->cgroup_parent; +- } ++ free(oci_spec->linux->cgroups_path); + +- if (path == NULL) { +- free(oci_spec->linux->cgroups_path); +- oci_spec->linux->cgroups_path = util_path_join("/isulad", id); +- return 0; ++ oci_spec->linux->cgroups_path = merge_container_cgroups_path(id, host_spec); ++ if (oci_spec->linux->cgroups_path == NULL) { ++ ERROR("Failed to merge OCI spec cgroups path"); ++ return -1; + } + +- free(oci_spec->linux->cgroups_path); +- oci_spec->linux->cgroups_path = util_path_join(path, id); +- +-out: +- free(default_cgroup_parent); +- return ret; ++ return 0; + } + + int merge_all_specs(host_config *host_spec, const char *real_rootfs, container_config_v2_common_config *v2_spec, +diff --git a/test/specs/specs/specs_ut.cc b/test/specs/specs/specs_ut.cc +index c4014e2e..a2bd3890 100644 +--- a/test/specs/specs/specs_ut.cc ++++ b/test/specs/specs/specs_ut.cc +@@ -232,41 +232,36 @@ char *invoke_conf_get_isulad_cgroup_parent() + return util_strdup_s("/var/lib/isulad/engines/lcr"); + } + +-TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_1) ++TEST_F(SpecsUnitTest, test_merge_container_cgroups_path_1) + { +- ASSERT_EQ(merge_oci_cgroups_path(nullptr, nullptr, nullptr), -1); ++ ASSERT_EQ(merge_container_cgroups_path(nullptr, nullptr), nullptr); + } + +-TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_2) ++TEST_F(SpecsUnitTest, test_merge_container_cgroups_path_2) + { +- oci_runtime_spec *oci_spec = nullptr; + host_config *host_spec = nullptr; +- +- oci_spec = (oci_runtime_spec *)util_common_calloc_s(sizeof(oci_runtime_spec)); +- ASSERT_TRUE(oci_spec != nullptr); ++ char *merged_cp = nullptr; + + host_spec = (host_config *)util_common_calloc_s(sizeof(host_config)); + ASSERT_TRUE(host_spec != nullptr); + + EXPECT_CALL(m_isulad_conf, GetCgroupParent()).WillRepeatedly(Invoke(invoke_conf_get_isulad_cgroup_parent_null)); + +- ASSERT_EQ(merge_oci_cgroups_path("123", oci_spec, host_spec), 0); ++ merged_cp = merge_container_cgroups_path("123", host_spec); ++ ASSERT_NE(merged_cp, nullptr); + +- ASSERT_STREQ(oci_spec->linux->cgroups_path, "/isulad/123"); ++ ASSERT_STREQ(merged_cp, "/isulad/123"); + +- free_oci_runtime_spec(oci_spec); + free_host_config(host_spec); ++ free(merged_cp); + + testing::Mock::VerifyAndClearExpectations(&m_isulad_conf); + } + +-TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_3) ++TEST_F(SpecsUnitTest, test_merge_container_cgroups_path_3) + { +- oci_runtime_spec *oci_spec = nullptr; + host_config *host_spec = nullptr; +- +- oci_spec = (oci_runtime_spec *)util_common_calloc_s(sizeof(oci_runtime_spec)); +- ASSERT_TRUE(oci_spec != nullptr); ++ char *merged_cp = nullptr; + + host_spec = (host_config *)util_common_calloc_s(sizeof(host_config)); + ASSERT_TRUE(host_spec != nullptr); +@@ -275,46 +270,42 @@ TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_3) + + EXPECT_CALL(m_isulad_conf, GetCgroupParent()).WillRepeatedly(Invoke(invoke_conf_get_isulad_cgroup_parent_null)); + +- ASSERT_EQ(merge_oci_cgroups_path("123", oci_spec, host_spec), 0); ++ merged_cp = merge_container_cgroups_path("123", host_spec); ++ ASSERT_NE(merged_cp, nullptr); + +- ASSERT_STREQ(oci_spec->linux->cgroups_path, "/test/123"); ++ ASSERT_STREQ(merged_cp, "/test/123"); + +- free_oci_runtime_spec(oci_spec); + free_host_config(host_spec); ++ free(merged_cp); + + testing::Mock::VerifyAndClearExpectations(&m_isulad_conf); + } + +-TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_4) ++TEST_F(SpecsUnitTest, test_merge_container_cgroups_path_4) + { +- oci_runtime_spec *oci_spec = nullptr; + host_config *host_spec = nullptr; +- +- oci_spec = (oci_runtime_spec *)util_common_calloc_s(sizeof(oci_runtime_spec)); +- ASSERT_TRUE(oci_spec != nullptr); ++ char *merged_cp = nullptr; + + host_spec = (host_config *)util_common_calloc_s(sizeof(host_config)); + ASSERT_TRUE(host_spec != nullptr); + + EXPECT_CALL(m_isulad_conf, GetCgroupParent()).WillRepeatedly(Invoke(invoke_conf_get_isulad_cgroup_parent)); + +- ASSERT_EQ(merge_oci_cgroups_path("123", oci_spec, host_spec), 0); ++ merged_cp = merge_container_cgroups_path("123", host_spec); ++ ASSERT_NE(merged_cp, nullptr); + +- ASSERT_STREQ(oci_spec->linux->cgroups_path, "/var/lib/isulad/engines/lcr/123"); ++ ASSERT_STREQ(merged_cp, "/var/lib/isulad/engines/lcr/123"); + +- free_oci_runtime_spec(oci_spec); + free_host_config(host_spec); ++ free(merged_cp); + + testing::Mock::VerifyAndClearExpectations(&m_isulad_conf); + } + +-TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_5) ++TEST_F(SpecsUnitTest, test_merge_container_cgroups_path_5) + { +- oci_runtime_spec *oci_spec = nullptr; + host_config *host_spec = nullptr; +- +- oci_spec = (oci_runtime_spec *)util_common_calloc_s(sizeof(oci_runtime_spec)); +- ASSERT_TRUE(oci_spec != nullptr); ++ char *merged_cp = nullptr; + + host_spec = (host_config *)util_common_calloc_s(sizeof(host_config)); + ASSERT_TRUE(host_spec != nullptr); +@@ -323,12 +314,13 @@ TEST_F(SpecsUnitTest, test_merge_oci_cgroups_path_5) + + EXPECT_CALL(m_isulad_conf, GetCgroupParent()).WillRepeatedly(Invoke(invoke_conf_get_isulad_cgroup_parent)); + +- ASSERT_EQ(merge_oci_cgroups_path("123", oci_spec, host_spec), 0); ++ merged_cp = merge_container_cgroups_path("123", host_spec); ++ ASSERT_NE(merged_cp, nullptr); + +- ASSERT_STREQ(oci_spec->linux->cgroups_path, "/test/123"); ++ ASSERT_STREQ(merged_cp, "/test/123"); + +- free_oci_runtime_spec(oci_spec); + free_host_config(host_spec); ++ free(merged_cp); + + testing::Mock::VerifyAndClearExpectations(&m_isulad_conf); + } +-- +2.25.1 + diff --git a/0016-fix-code-style.patch b/0016-fix-code-style.patch new file mode 100644 index 0000000..bfdfc15 --- /dev/null +++ b/0016-fix-code-style.patch @@ -0,0 +1,681 @@ +From 549e22a9fb7f6e2c36a4a7422223c90fa7c44bd6 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Fri, 17 Feb 2023 09:34:14 +0800 +Subject: [PATCH 16/19] fix code style + +Signed-off-by: zhangxiaoyu +--- + src/client/connect/protocol_type.c | 2 +- + .../connect/rest/rest_containers_client.c | 2 +- + src/cmd/isula/base/run.h | 2 +- + src/cmd/isula/client_console.c | 2 +- + src/cmd/isula/stream/attach.c | 2 +- + src/cmd/isulad-shim/process.c | 5 +- + .../connect/grpc/grpc_containers_service.cc | 2 +- + .../grpc/grpc_containers_service_private.cc | 8 +-- + .../cri_pod_sandbox_manager_service_impl.cc | 10 ++-- + src/daemon/executor/container_cb/execution.c | 2 +- + .../modules/image/image_rootfs_handler.c | 12 ++--- + .../modules/runtime/isula/isula_rt_ops.c | 8 +-- + src/daemon/modules/runtime/shim/shim_rt_ops.c | 2 +- + .../modules/service/service_container.c | 4 +- + src/utils/cutils/filters.c | 2 +- + src/utils/cutils/utils_mount_spec.c | 6 +-- + test/cgroup/cpu/cgroup_cpu_ut.cc | 2 +- + test/console/console_ut.cc | 4 +- + test/cutils/utils_file/utils_file_ut.cc | 50 +++++++++---------- + .../utils_mount_spec/utils_mount_spec_ut.cc | 6 ++- + test/cutils/utils_pwgr/utils_pwgr_ut.cc | 4 +- + test/cutils/utils_utils/utils_utils_ut.cc | 5 +- + test/cutils/utils_verify/utils_verify_ut.cc | 2 +- + .../oci/storage/layers/storage_driver_ut.cc | 3 +- + test/sha256/sha256_ut.cc | 2 +- + 25 files changed, 78 insertions(+), 71 deletions(-) + +diff --git a/src/client/connect/protocol_type.c b/src/client/connect/protocol_type.c +index a3aabe0e..64576d1e 100644 +--- a/src/client/connect/protocol_type.c ++++ b/src/client/connect/protocol_type.c +@@ -660,7 +660,7 @@ void isula_kill_response_free(struct isula_kill_response *response) + } + free(response->id); + response->id = NULL; +- ++ + free(response->errmsg); + response->errmsg = NULL; + free(response); +diff --git a/src/client/connect/rest/rest_containers_client.c b/src/client/connect/rest/rest_containers_client.c +index 22aa1c9b..0a735a64 100644 +--- a/src/client/connect/rest/rest_containers_client.c ++++ b/src/client/connect/rest/rest_containers_client.c +@@ -1333,7 +1333,7 @@ static int unpack_kill_response(const struct parsed_http_message *message, void + if (cresponse->id != NULL) { + kill_response->id = util_strdup_s(cresponse->id); + } +- ++ + kill_response->server_errono = cresponse->cc; + if (cresponse->errmsg != NULL) { + kill_response->errmsg = util_strdup_s(cresponse->errmsg); +diff --git a/src/cmd/isula/base/run.h b/src/cmd/isula/base/run.h +index efca28a9..1084fae2 100644 +--- a/src/cmd/isula/base/run.h ++++ b/src/cmd/isula/base/run.h +@@ -34,7 +34,7 @@ extern "C" { + 'd', \ + &(cmdargs).detach, \ + "Run container in background and print container ID", \ +- NULL }, ++ NULL }, + + extern const char g_cmd_run_desc[]; + extern const char g_cmd_run_usage[]; +diff --git a/src/cmd/isula/client_console.c b/src/cmd/isula/client_console.c +index 8cba2047..1c087d24 100644 +--- a/src/cmd/isula/client_console.c ++++ b/src/cmd/isula/client_console.c +@@ -338,7 +338,7 @@ int delete_client_fifo_home_dir(const char *name) + WARN("Failed to delete client fifo home path:%s", client_fifo_home_dir); + } + free(client_fifo_home_dir); +- ++ + return 0; + } + +diff --git a/src/cmd/isula/stream/attach.c b/src/cmd/isula/stream/attach.c +index 8f60eb44..02c67e30 100644 +--- a/src/cmd/isula/stream/attach.c ++++ b/src/cmd/isula/stream/attach.c +@@ -49,7 +49,7 @@ sem_t g_attach_waitopen_sem; + sem_t g_attach_waitexit_sem; + #endif + +-struct client_arguments g_cmd_attach_args = { ++struct client_arguments g_cmd_attach_args = { + .time = INSPECT_TIMEOUT_SEC, + }; + +diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c +index 66c604f3..5222629c 100644 +--- a/src/cmd/isulad-shim/process.c ++++ b/src/cmd/isulad-shim/process.c +@@ -1203,7 +1203,8 @@ out: + return ret; + } + +-static int try_wait_all_child(void) { ++static int try_wait_all_child(void) ++{ + if (waitpid(-1, NULL, WNOHANG) == -1 && errno == ECHILD) { + // all child handled + return 0; +@@ -1243,7 +1244,7 @@ int process_signal_handle_routine(process_t *p, const pthread_t tid_accept) + } + if (exit_shim) { + process_kill_all(p); +- ++ + // wait atmost 120 seconds + DO_RETRY_CALL(120, 1000000, nret, try_wait_all_child); + if (nret != 0) { +diff --git a/src/daemon/entry/connect/grpc/grpc_containers_service.cc b/src/daemon/entry/connect/grpc/grpc_containers_service.cc +index d3b661a2..bc5c73f9 100644 +--- a/src/daemon/entry/connect/grpc/grpc_containers_service.cc ++++ b/src/daemon/entry/connect/grpc/grpc_containers_service.cc +@@ -465,7 +465,7 @@ Status ContainerServiceImpl::Stop(ServerContext *context, const StopRequest *req + } + + (void)cb->container.stop(container_req, &container_res); +- ++ + stop_response_to_grpc(container_res, reply); + + free_container_stop_request(container_req); +diff --git a/src/daemon/entry/connect/grpc/grpc_containers_service_private.cc b/src/daemon/entry/connect/grpc/grpc_containers_service_private.cc +index e934aa74..853336fe 100644 +--- a/src/daemon/entry/connect/grpc/grpc_containers_service_private.cc ++++ b/src/daemon/entry/connect/grpc/grpc_containers_service_private.cc +@@ -268,12 +268,12 @@ void ContainerServiceImpl::stop_response_to_grpc(const container_stop_response * + gresponse->set_cc(ISULAD_ERR_MEMOUT); + return; + } +- ++ + gresponse->set_cc(response->cc); + if (response->errmsg != nullptr) { + gresponse->set_errmsg(response->errmsg); + } +- ++ + if (response->id != nullptr) { + gresponse->set_id(response->id); + } +@@ -321,12 +321,12 @@ void ContainerServiceImpl::kill_response_to_grpc(const container_kill_response * + gresponse->set_cc(ISULAD_ERR_MEMOUT); + return; + } +- ++ + gresponse->set_cc(response->cc); + if (response->errmsg != nullptr) { + gresponse->set_errmsg(response->errmsg); + } +- ++ + if (response->id != nullptr) { + gresponse->set_id(response->id); + } +diff --git a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc +index 3e89008a..2ebd800e 100644 +--- a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc ++++ b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc +@@ -99,8 +99,8 @@ void PodSandboxManagerServiceImpl::ApplySandboxResources(const runtime::v1alpha2 + } + + +-void PodSandboxManagerServiceImpl::SetHostConfigDefaultValue(const google::protobuf::Map &annotations, +- host_config *hc) ++void PodSandboxManagerServiceImpl::SetHostConfigDefaultValue( ++ const google::protobuf::Map &annotations, host_config *hc) + { + free(hc->network_mode); + +@@ -525,7 +525,7 @@ void PodSandboxManagerServiceImpl::SetupSandboxNetwork(const runtime::v1alpha2:: + return; + } + stdAnnos.insert(std::pair(CRIHelpers::Constants::POD_SANDBOX_KEY, +- std::string(sandbox_key))); ++ std::string(sandbox_key))); + free(sandbox_key); + } + m_pluginManager->SetUpPod(config.metadata().namespace_(), config.metadata().name(), +@@ -775,12 +775,12 @@ auto PodSandboxManagerServiceImpl::ClearCniNetwork(const std::string &realSandbo + // not return and make sure teardown network + } else { + stdAnnos.insert(std::pair(CRIHelpers::Constants::POD_SANDBOX_KEY, +- std::string(netnsPath))); ++ std::string(netnsPath))); + } + } + + m_pluginManager->TearDownPod(ns, name, Network::DEFAULT_NETWORK_INTERFACE_NAME, realSandboxID, stdAnnos, +- pluginErr); ++ pluginErr); + if (pluginErr.NotEmpty()) { + WARN("TearDownPod cni network failed: %s", pluginErr.GetCMessage()); + errlist.push_back(pluginErr.GetMessage()); +diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c +index 4dd5f858..4ca2eb8b 100644 +--- a/src/daemon/executor/container_cb/execution.c ++++ b/src/daemon/executor/container_cb/execution.c +@@ -465,7 +465,7 @@ static int container_start_prepare(container_t *cont, const container_start_requ + + // init cgroup path for cpu_rt_runtime and cpu_rt_period + // we should do this in start container, not create container +- // because it will fail after the following steps: ++ // because it will fail after the following steps: + // 1. enable cpu-rt of isulad; + // 2. then run container with --cpu-rt-runtime + // 3. then reboot machine; +diff --git a/src/daemon/modules/image/image_rootfs_handler.c b/src/daemon/modules/image/image_rootfs_handler.c +index c3964b2c..1275658e 100644 +--- a/src/daemon/modules/image/image_rootfs_handler.c ++++ b/src/daemon/modules/image/image_rootfs_handler.c +@@ -87,7 +87,7 @@ static int proc_by_fpasswd(FILE *f_passwd, const char *user, defs_process_user * + struct passwd *pwbufp = NULL; + + if (f_passwd != NULL) { +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + errval = util_getpwent_r(f_passwd, &pw, buf, sizeof(buf), &pwbufp); + #else + errval = fgetpwent_r(f_passwd, &pw, buf, sizeof(buf), &pwbufp); +@@ -105,7 +105,7 @@ static int proc_by_fpasswd(FILE *f_passwd, const char *user, defs_process_user * + *matched_username = util_strdup_s(pwbufp->pw_name); + break; + } +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + errval = util_getpwent_r(f_passwd, &pw, buf, sizeof(buf), &pwbufp); + #else + errval = fgetpwent_r(f_passwd, &pw, buf, sizeof(buf), &pwbufp); +@@ -215,7 +215,7 @@ static int do_proc_by_froup(FILE *f_group, const char *group, defs_process_user + return 0; + } + +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + errval = util_getgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); + #else + errval = fgetgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); +@@ -226,7 +226,7 @@ static int do_proc_by_froup(FILE *f_group, const char *group, defs_process_user + if (search_group_list(gbufp, matched_username, puser) != 0) { + return -1; + } +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + errval = util_getgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); + #else + errval = fgetgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); +@@ -240,7 +240,7 @@ static int do_proc_by_froup(FILE *f_group, const char *group, defs_process_user + puser->gid = gbufp->gr_gid; + *groupcnt = 1; + } +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + errval = util_getgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); + #else + errval = fgetgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp); +@@ -378,7 +378,7 @@ static int get_additional_groups(char **additional_groups, size_t additional_gro + struct group *gbufp = NULL; + struct group *groups = NULL; + +-#if defined (__ANDROID__) || defined(__MUSL__) ++#if defined (__ANDROID__) || defined(__MUSL__) + while (f_group != NULL && util_getgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp) == 0) { + #else + while (f_group != NULL && fgetgrent_r(f_group, &grp, buf, sizeof(buf), &gbufp) == 0) { +diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c +index d198f92e..99f8be5e 100644 +--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c ++++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c +@@ -599,10 +599,10 @@ static int runtime_call_simple(const char *workdir, const char *runtime, const c + if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout, &stderr)) { + ERROR("call runtime %s failed stderr %s", subcmd, stderr); + ret = -1; +- // additional handler for the stderr, ++ // additional handler for the stderr, + // this intend to change the ret val of this function +- // for example, if output string contains some specific content, +- // we consider the runtime call simple succeeded, ++ // for example, if output string contains some specific content, ++ // we consider the runtime call simple succeeded, + // even if the process exit with failure. + if (stderr != NULL && cb != NULL) { + ret = cb(stderr); +@@ -636,7 +636,7 @@ static int kill_output_check(const char *output) + + // kill success or kill_output_check succeed return 0, DO_RETRY_CALL will break; + // if kill failed, recheck on shim alive, if not alive, kill succeed, still return 0; +-// else, return -1, DO_RETRY_CALL will call this again; ++// else, return -1, DO_RETRY_CALL will call this again; + static int runtime_call_kill_and_check(const char *workdir, const char *runtime, const char *id) + { + int ret = -1; +diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c +index 1b497358..9afb9ce7 100644 +--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c ++++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c +@@ -289,7 +289,7 @@ int rt_shim_create(const char *id, const char *runtime, const rt_create_params_t + goto out; + } + close(fd); +- ++ + if (shim_bin_v2_create(runtime, id, params->bundle, NULL, addr, state_path) != 0) { + ERROR("%s: failed to create v2 shim", id); + ret = -1; +diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c +index 340dea07..f30a3f8e 100644 +--- a/src/daemon/modules/service/service_container.c ++++ b/src/daemon/modules/service/service_container.c +@@ -1094,7 +1094,7 @@ static int delete_client_fifo_home_dir(const char *name) + WARN("Failed to delete client fifo home path:%s", client_fifo_home_dir); + } + free(client_fifo_home_dir); +- ++ + return 0; + } + +@@ -1199,7 +1199,7 @@ out: + // when container is auto-remove, it will be deleted when stopped. + // isula has no suitable time to delete fifo dir, so isulad delete it here. + // Whether the delete container operation fails or not, delete the client's fifo dir to avoid it residual. +- // When isula and isulad use tcp to connect, fifo files will not be created. ++ // When isula and isulad use tcp to connect, fifo files will not be created. + // Because restart will set auto_remove to false, using auto_remove_bak to ensure delete Policy. + if (cont->hostconfig != NULL && cont->hostconfig->auto_remove_bak && delete_client_fifo_home_dir(id) != 0) { + WARN("Failed to delete client fifo home dir"); +diff --git a/src/utils/cutils/filters.c b/src/utils/cutils/filters.c +index 21f5db7c..43ccde20 100644 +--- a/src/utils/cutils/filters.c ++++ b/src/utils/cutils/filters.c +@@ -318,7 +318,7 @@ bool filters_args_valid_key(const char **accepted, size_t len, const char *field + if (accepted == NULL || field == NULL) { + return false; + } +- ++ + for (i = 0; i < len; i++) { + if (accepted[i] != NULL && strcmp(accepted[i], field) == 0) { + return true; +diff --git a/src/utils/cutils/utils_mount_spec.c b/src/utils/cutils/utils_mount_spec.c +index e9b23cf2..6793f93b 100644 +--- a/src/utils/cutils/utils_mount_spec.c ++++ b/src/utils/cutils/utils_mount_spec.c +@@ -465,15 +465,15 @@ int util_parse_mount_spec(char *mount_str, mount_spec **spec, char **errmsg_out) + return -1; + } + +- if(spec == NULL){ ++ if (spec == NULL) { + CACHE_ERRMSG(errmsg, "Invalid spec: can't be NULL"); + return -1; + } + +- if(errmsg_out == NULL){ ++ if (errmsg_out == NULL) { + CACHE_ERRMSG(errmsg, "Invalid errmsg_out: can't be NULL"); + return -1; +- } ++ } + + m = util_common_calloc_s(sizeof(mount_spec)); + if (m == NULL) { +diff --git a/test/cgroup/cpu/cgroup_cpu_ut.cc b/test/cgroup/cpu/cgroup_cpu_ut.cc +index 1cfdf86f..8691db7c 100644 +--- a/test/cgroup/cpu/cgroup_cpu_ut.cc ++++ b/test/cgroup/cpu/cgroup_cpu_ut.cc +@@ -49,7 +49,7 @@ TEST(CgroupCpuUnitTest, test_conf_get_cgroup_cpu_rt) + ASSERT_EQ(conf_get_cgroup_cpu_rt(nullptr, nullptr), -1); + ASSERT_EQ(conf_get_cgroup_cpu_rt(&cpu_rt_period, nullptr), -1); + ASSERT_EQ(conf_get_cgroup_cpu_rt(nullptr, &cpu_rt_runtime), -1); +- ++ + struct service_arguments *args = new_args(cpu_rt_period, cpu_rt_runtime); + ASSERT_EQ(save_args_to_conf(args), 0); + ASSERT_EQ(conf_get_cgroup_cpu_rt(&cpu_rt_period, &cpu_rt_runtime), 0); +diff --git a/test/console/console_ut.cc b/test/console/console_ut.cc +index 73479000..a31083b3 100644 +--- a/test/console/console_ut.cc ++++ b/test/console/console_ut.cc +@@ -26,7 +26,7 @@ TEST(utils_console, test_console_fifo_create) + + ASSERT_EQ(S_ISFIFO(buf.st_mode), true); + +- ret = access(FIFO_NAME, R_OK|W_OK); ++ ret = access(FIFO_NAME, R_OK | W_OK); + ASSERT_EQ(ret, 0); + + remove(FIFO_NAME); +@@ -47,7 +47,7 @@ TEST(utils_console, test_console_fifo_delete) + + memset(path_buf, 'a', LONGER_PATH_MAX); + path_buf[LONGER_PATH_MAX - 1] = 0; +- ASSERT_EQ(strlen(path_buf), LONGER_PATH_MAX-1)<< "strlen is " << strlen(path_buf); ++ ASSERT_EQ(strlen(path_buf), LONGER_PATH_MAX - 1) << "strlen is " << strlen(path_buf); + + ret = console_fifo_create(FIFO_NAME); + if (ret != 0) { +diff --git a/test/cutils/utils_file/utils_file_ut.cc b/test/cutils/utils_file/utils_file_ut.cc +index ccd60ba4..78c07e60 100644 +--- a/test/cutils/utils_file/utils_file_ut.cc ++++ b/test/cutils/utils_file/utils_file_ut.cc +@@ -40,12 +40,12 @@ TEST(utils_file, test_util_dir_exists) + TEST(utils_file, test_util_fileself_exists) + { + ASSERT_EQ(util_fileself_exists(nullptr), false); +- ++ + std::string path = "/tmp/test"; + std::string path_link = "/tmp/test/link"; + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); + ASSERT_EQ(util_fileself_exists(path_link.c_str()), false); +- ASSERT_EQ(symlink(path.c_str(),path_link.c_str()), 0); ++ ASSERT_EQ(symlink(path.c_str(), path_link.c_str()), 0); + ASSERT_EQ(util_fileself_exists(path_link.c_str()), true); + ASSERT_EQ(util_path_remove(path_link.c_str()), 0); + ASSERT_EQ(util_path_remove(path.c_str()), 0); +@@ -54,7 +54,7 @@ TEST(utils_file, test_util_fileself_exists) + TEST(utils_file, test_util_file_exists) + { + ASSERT_EQ(util_file_exists(nullptr), false); +- ++ + std::string path = "/tmp/test"; + ASSERT_EQ(util_file_exists(path.c_str()), false); + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); +@@ -65,13 +65,13 @@ TEST(utils_file, test_util_file_exists) + + TEST(utils_file, test_util_recursive_rmdir) + { +- ASSERT_EQ(util_recursive_rmdir(nullptr,0), -1); +- ++ ASSERT_EQ(util_recursive_rmdir(nullptr, 0), -1); ++ + std::string path = "/tmp/test"; + std::string path_link = "/tmp/test/link"; + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); + ASSERT_EQ(util_mkdir_p(path_link.c_str(), FILE_PERMISSION_TEST), 0); +- ASSERT_EQ(util_recursive_rmdir(path.c_str(),1), 0); ++ ASSERT_EQ(util_recursive_rmdir(path.c_str(), 1), 0); + ASSERT_EQ(util_file_exists(path.c_str()), false); + ASSERT_EQ(util_file_exists(path_link.c_str()), false); + } +@@ -80,11 +80,11 @@ TEST(utils_file, test_util_ensure_path) + { + char *rpath = NULL; + std::string path = "/tmp/test"; +- ASSERT_EQ(util_ensure_path(nullptr,path.c_str()), -1); +- ASSERT_EQ(util_ensure_path(&rpath,nullptr), -1); ++ ASSERT_EQ(util_ensure_path(nullptr, path.c_str()), -1); ++ ASSERT_EQ(util_ensure_path(&rpath, nullptr), -1); + + ASSERT_EQ(util_file_exists(path.c_str()), false); +- ASSERT_EQ(util_ensure_path(&rpath,path.c_str()), 0); ++ ASSERT_EQ(util_ensure_path(&rpath, path.c_str()), 0); + ASSERT_EQ(util_file_exists(rpath), true); + ASSERT_EQ(util_path_remove(path.c_str()), 0); + } +@@ -130,12 +130,12 @@ TEST(utils_file, test_util_add_path) + std::string path = "/tmp/test/"; + std::string add_path = "add"; + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); +- ASSERT_STREQ(util_add_path(path.c_str(),add_path.c_str()), "/tmp/test/add"); ++ ASSERT_STREQ(util_add_path(path.c_str(), add_path.c_str()), "/tmp/test/add"); + ASSERT_EQ(util_path_remove(path.c_str()), 0); +- ++ + std::string path1 = "/tmp/test"; + ASSERT_EQ(util_mkdir_p(path1.c_str(), FILE_PERMISSION_TEST), 0); +- ASSERT_STREQ(util_add_path(path1.c_str(),add_path.c_str()), "/tmp/add"); ++ ASSERT_STREQ(util_add_path(path1.c_str(), add_path.c_str()), "/tmp/add"); + ASSERT_EQ(util_path_remove(path1.c_str()), 0); + } + +@@ -143,7 +143,7 @@ TEST(utils_file, test_verify_file_and_get_real_path) + { + std::string path = "/tmp/test"; + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); +- ASSERT_STREQ(verify_file_and_get_real_path(path.c_str()),"/tmp/test"); ++ ASSERT_STREQ(verify_file_and_get_real_path(path.c_str()), "/tmp/test"); + ASSERT_EQ(util_path_remove(path.c_str()), 0); + } + +@@ -151,17 +151,17 @@ TEST(utils_file, test_look_path) + { + std::string path = "/usr/bin/nsenter"; + char *err = NULL; +- ASSERT_STREQ(look_path("nsenter",&err),path.c_str()); ++ ASSERT_STREQ(look_path("nsenter", &err), path.c_str()); + } + + TEST(utils_file, test_util_copy_file) + { + std::string path = "/tmp/test"; +- ASSERT_EQ(util_copy_file("/etc/hosts",path.c_str(),NETWORK_MOUNT_FILE_MODE), 0); ++ ASSERT_EQ(util_copy_file("/etc/hosts", path.c_str(), NETWORK_MOUNT_FILE_MODE), 0); + ASSERT_EQ(util_path_remove(path.c_str()), 0); + + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); +- ASSERT_EQ(util_copy_file("/etc/hosts",path.c_str(),NETWORK_MOUNT_FILE_MODE), -1); ++ ASSERT_EQ(util_copy_file("/etc/hosts", path.c_str(), NETWORK_MOUNT_FILE_MODE), -1); + ASSERT_EQ(util_path_remove(path.c_str()), 0); + } + +@@ -169,10 +169,10 @@ TEST(utils_file, test_utils_calculate_dir_size_without_hardlink) + { + std::string path = "/tmp/test"; + std::string hosts = "/etc/hosts"; +- ASSERT_EQ(util_copy_file(hosts.c_str(),path.c_str(),NETWORK_MOUNT_FILE_MODE), 0); ++ ASSERT_EQ(util_copy_file(hosts.c_str(), path.c_str(), NETWORK_MOUNT_FILE_MODE), 0); + int64_t total_size = 0; + int64_t total_inodes = 0; +- utils_calculate_dir_size_without_hardlink("/tmp/", &total_size,&total_inodes); ++ utils_calculate_dir_size_without_hardlink("/tmp/", &total_size, &total_inodes); + ASSERT_NE(total_size, 0); + ASSERT_NE(total_inodes, 0); + ASSERT_EQ(util_path_remove(path.c_str()), 0); +@@ -191,12 +191,12 @@ TEST(utils_file, test_util_proc_file_line_by_line) + std::string content = "hello world"; + int fd; + fd = util_open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, DEFAULT_SECURE_FILE_MODE); +- ASSERT_EQ(util_write_nointr_in_total(fd, content.c_str(), strlen(content.c_str())),11); ++ ASSERT_EQ(util_write_nointr_in_total(fd, content.c_str(), strlen(content.c_str())), 11); + FILE *fp = NULL; +- map_t *checked_layers = NULL; ++ map_t *checked_layers = NULL; + fp = util_fopen(path.c_str(), "r"); + checked_layers = map_new(MAP_STR_BOOL, MAP_DEFAULT_CMP_FUNC, MAP_DEFAULT_FREE_FUNC); +- ASSERT_EQ(util_proc_file_line_by_line(fp, parse_checked_layer_cb, (void *)checked_layers),0); ++ ASSERT_EQ(util_proc_file_line_by_line(fp, parse_checked_layer_cb, (void *)checked_layers), 0); + fclose(fp); + ASSERT_EQ(util_path_remove(path.c_str()), 0); + } +@@ -204,7 +204,7 @@ TEST(utils_file, test_util_proc_file_line_by_line) + TEST(utils_file, test_util_recursive_remove_path) + { + ASSERT_EQ(util_recursive_remove_path(nullptr), -1); +- ++ + std::string path = "/tmp/test"; + std::string path_link = "/tmp/test/link"; + ASSERT_EQ(util_mkdir_p(path.c_str(), FILE_PERMISSION_TEST), 0); +@@ -212,16 +212,16 @@ TEST(utils_file, test_util_recursive_remove_path) + ASSERT_EQ(util_recursive_remove_path(path.c_str()), 0); + ASSERT_EQ(util_file_exists(path.c_str()), false); + ASSERT_EQ(util_file_exists(path_link.c_str()), false); +- ++ + } + + TEST(utils_file, test_util_copy_dir_recursive) + { +- char *path = (char*)"/tmp/test1/"; ++ char *path = (char*)"/tmp/test1/"; + char *src = (char*)"/tmp/test/"; + ASSERT_EQ(util_mkdir_p(path, FILE_PERMISSION_TEST), 0); + ASSERT_EQ(util_mkdir_p(src, FILE_PERMISSION_TEST), 0); +- ASSERT_EQ(util_copy_dir_recursive(path,src), 0); ++ ASSERT_EQ(util_copy_dir_recursive(path, src), 0); + ASSERT_EQ(util_recursive_remove_path(path), 0); + ASSERT_EQ(util_recursive_remove_path(src), 0); + } +diff --git a/test/cutils/utils_mount_spec/utils_mount_spec_ut.cc b/test/cutils/utils_mount_spec/utils_mount_spec_ut.cc +index 0f60d397..77b4752c 100644 +--- a/test/cutils/utils_mount_spec/utils_mount_spec_ut.cc ++++ b/test/cutils/utils_mount_spec/utils_mount_spec_ut.cc +@@ -18,7 +18,8 @@ + + TEST(utils_mount_spec, test_util_valid_mount_spec) + { +- char *base_valid = (char *)"type=bind,source=/home,target=/vol3,readonly=true,bind-selinux-opts=z,bind-propagation=rprivate"; ++ char *base_valid = (char *) ++ "type=bind,source=/home,target=/vol3,readonly=true,bind-selinux-opts=z,bind-propagation=rprivate"; + char *oci_valid = (char *)"type=tmpfs,dst=/tmpfs,tmpfs-size=1m,tmpfs-mode=1700"; + char *invalid1 = (char *)"type=volume,src=vol,dst=/vol,ro=true,red=false"; + char *invalid2 = (char *)"type,src,dst"; +@@ -35,7 +36,8 @@ TEST(utils_mount_spec, test_util_valid_mount_spec) + + TEST(utils_mount_spec, test_util_parse_mount_spec) + { +- char *base_valid = (char *)"type=bind,source=/home,target=/vol3,readonly=true,bind-selinux-opts=z,bind-propagation=rprivate"; ++ char *base_valid = (char *) ++ "type=bind,source=/home,target=/vol3,readonly=true,bind-selinux-opts=z,bind-propagation=rprivate"; + char *oci_valid = (char *)"type=tmpfs,dst=/tmpfs,tmpfs-size=1m,tmpfs-mode=1700"; + char *invalid1 = (char *)"type=volume,src=vol,dst=/vol,ro=true,red=false"; + char *invalid2 = (char *)"type,src,dst"; +diff --git a/test/cutils/utils_pwgr/utils_pwgr_ut.cc b/test/cutils/utils_pwgr/utils_pwgr_ut.cc +index 2a6b7e08..431372d3 100644 +--- a/test/cutils/utils_pwgr/utils_pwgr_ut.cc ++++ b/test/cutils/utils_pwgr/utils_pwgr_ut.cc +@@ -77,7 +77,9 @@ TEST(utils_pwgr, test_getgrent_r) + FILE *f_gr = fopen(path.c_str(), "r"); + ASSERT_NE(f_gr, nullptr); + +- struct group gr{0}; ++ struct group gr { ++ 0 ++ }; + struct group *pgr = nullptr; + struct group *pgr_alter = &gr; + char buf[BUFSIZ] = { 0 }; +diff --git a/test/cutils/utils_utils/utils_utils_ut.cc b/test/cutils/utils_utils/utils_utils_ut.cc +index c8f38717..6c7ece24 100644 +--- a/test/cutils/utils_utils/utils_utils_ut.cc ++++ b/test/cutils/utils_utils/utils_utils_ut.cc +@@ -134,7 +134,7 @@ TEST(utils_utils, test_util_env_ops) + ASSERT_EQ(ret_len, 2); + ASSERT_STREQ(ret[1], second_val.c_str()); + +- ++ + got = util_env_get_val(ret, ret_len, key1.c_str(), key1.size()); + ASSERT_STREQ(got, "world"); + free(got); +@@ -272,7 +272,8 @@ TEST(utils_utils, test_convert_v2_runtime) + } + + int global_total = 0; +-int retry_call_test(int success_idx) { ++int retry_call_test(int success_idx) ++{ + if (global_total == success_idx) { + return 0; + } +diff --git a/test/cutils/utils_verify/utils_verify_ut.cc b/test/cutils/utils_verify/utils_verify_ut.cc +index 9c4bf944..a68dfb66 100644 +--- a/test/cutils/utils_verify/utils_verify_ut.cc ++++ b/test/cutils/utils_verify/utils_verify_ut.cc +@@ -159,7 +159,7 @@ TEST(utils_verify, test_util_valid_file) + + ASSERT_EQ(util_path_remove(isulad_dir.c_str()), 0); + +- ASSERT_EQ(util_valid_file(nullptr, S_IFDIR),false); ++ ASSERT_EQ(util_valid_file(nullptr, S_IFDIR), false); + } + + TEST(utils_verify, test_util_valid_digest) +diff --git a/test/image/oci/storage/layers/storage_driver_ut.cc b/test/image/oci/storage/layers/storage_driver_ut.cc +index 650368d8..ae9f4df1 100644 +--- a/test/image/oci/storage/layers/storage_driver_ut.cc ++++ b/test/image/oci/storage/layers/storage_driver_ut.cc +@@ -144,7 +144,8 @@ protected: + + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/work "; + ASSERT_EQ(system(mkdir.c_str()), 0); + +- struct storage_module_init_options *opts = (struct storage_module_init_options *)util_common_calloc_s(sizeof(struct storage_module_init_options)); ++ struct storage_module_init_options *opts = (struct storage_module_init_options *)util_common_calloc_s(sizeof( ++ struct storage_module_init_options)); + opts->storage_root = strdup(root_dir.c_str()); + opts->storage_run_root = strdup(run_dir.c_str()); + opts->driver_name = strdup("overlay"); +diff --git a/test/sha256/sha256_ut.cc b/test/sha256/sha256_ut.cc +index 746220d7..2313ef0d 100644 +--- a/test/sha256/sha256_ut.cc ++++ b/test/sha256/sha256_ut.cc +@@ -67,7 +67,7 @@ TEST(sha256, test_sha256_digest_str) + EXPECT_STREQ(digest, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); + + digest = sha256_digest_str( +- "^cvdgfdgghaswere3575676y&*`~cx,xfdgdvcvdfd][';./?.,<>|\\!@#$%^&*()_+=-090wvvs3sdfel33cxvdf***$"); ++ "^cvdgfdgghaswere3575676y&*`~cx,xfdgdvcvdfd][';./?.,<>|\\!@#$%^&*()_+=-090wvvs3sdfel33cxvdf***$"); + EXPECT_STREQ(digest, "899a57a99c14c047eab26f8d6719da256a0737f6c28728ba5777b4fc5398c657"); + } + +-- +2.25.1 + diff --git a/0017-add-retry-for-read-write.patch b/0017-add-retry-for-read-write.patch new file mode 100644 index 0000000..eec3caa --- /dev/null +++ b/0017-add-retry-for-read-write.patch @@ -0,0 +1,337 @@ +From 82f9d555929be506738a2113bb0f0034e402ccd0 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Fri, 17 Feb 2023 16:07:53 +0800 +Subject: [PATCH 17/19] add retry for read/write + +Signed-off-by: zhangxiaoyu +--- + src/cmd/isulad-shim/common.c | 6 +++--- + src/cmd/isulad/main.c | 4 ++-- + src/daemon/common/selinux_label.c | 2 +- + src/daemon/entry/connect/grpc/grpc_containers_service.cc | 9 ++++++--- + src/daemon/entry/cri/sysctl_tools.c | 2 +- + src/daemon/executor/container_cb/execution.c | 2 +- + .../modules/container/container_gc/containers_gc.c | 3 ++- + src/daemon/modules/events_sender/event_sender.c | 2 +- + src/daemon/modules/image/oci/storage/storage.c | 4 +++- + src/daemon/modules/log/log_gather.c | 6 +++--- + src/daemon/modules/plugin/plugin.c | 2 +- + src/daemon/modules/runtime/isula/isula_rt_ops.c | 4 ++-- + src/daemon/modules/service/io_handler.c | 2 +- + src/daemon/modules/service/service_container.c | 2 +- + src/utils/cutils/utils.c | 2 +- + src/utils/cutils/utils_aes.c | 2 +- + src/utils/cutils/utils_file.c | 2 +- + src/utils/tar/util_archive.c | 4 ++-- + src/utils/tar/util_gzip.c | 2 +- + 19 files changed, 34 insertions(+), 28 deletions(-) + +diff --git a/src/cmd/isulad-shim/common.c b/src/cmd/isulad-shim/common.c +index bb8464bb..0c345187 100644 +--- a/src/cmd/isulad-shim/common.c ++++ b/src/cmd/isulad-shim/common.c +@@ -196,7 +196,7 @@ int generate_random_str(char *id, size_t len) + } + for (i = 0; i < len; i++) { + int nret; +- if (read(fd, &num, sizeof(int)) < 0) { ++ if (read_nointr(fd, &num, sizeof(int)) < 0) { + close(fd); + return SHIM_ERR; + } +@@ -232,8 +232,8 @@ void write_message(int fd, const char *level, const char *fmt, ...) + va_end(arg_list); + + snprintf(msg, MAX_MESSAGE_LEN - 1, "{\"level\": \"%s\", \"msg\": \"%s\"}\n", level, buf); +- nwrite = write(fd, msg, strlen(msg)); +- if (nwrite != strlen(msg)) { ++ nwrite = write_nointr_in_total(fd, msg, strlen(msg)); ++ if (nwrite < 0 || (size_t)nwrite != strlen(msg)) { + return; + } + } +diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c +index d22ab407..6d121f33 100644 +--- a/src/cmd/isulad/main.c ++++ b/src/cmd/isulad/main.c +@@ -478,8 +478,8 @@ int check_and_save_pid(const char *fn) + goto out; + } + +- len = (int)write(fd, pidbuf, strlen(pidbuf)); +- if (len < 0) { ++ len = util_write_nointr(fd, pidbuf, strlen(pidbuf)); ++ if (len < 0 || (size_t)len != strlen(pidbuf)) { + ERROR("Failed to write pid to file:%s: %s", fn, strerror(errno)); + ret = -1; + } +diff --git a/src/daemon/common/selinux_label.c b/src/daemon/common/selinux_label.c +index 24294780..173f3acb 100644 +--- a/src/daemon/common/selinux_label.c ++++ b/src/daemon/common/selinux_label.c +@@ -310,7 +310,7 @@ static int get_random_value(unsigned int range, unsigned int *val) + return -1; + } + +- if (read(fd, &num, sizeof(int)) < 0) { ++ if (util_read_nointr(fd, &num, sizeof(int)) < 0) { + ERROR("Failed to read urandom value\n"); + ret = -1; + goto out; +diff --git a/src/daemon/entry/connect/grpc/grpc_containers_service.cc b/src/daemon/entry/connect/grpc/grpc_containers_service.cc +index bc5c73f9..f69613ce 100644 +--- a/src/daemon/entry/connect/grpc/grpc_containers_service.cc ++++ b/src/daemon/entry/connect/grpc/grpc_containers_service.cc +@@ -384,7 +384,8 @@ Status ContainerServiceImpl::RemoteStart(ServerContext *context, + break; + } + const std::string &command = request.stdin(); +- if (write(read_pipe_fd[1], (void *)(command.c_str()), command.length()) < 0) { ++ int nret = util_write_nointr_in_total(read_pipe_fd[1], command.c_str(), command.length()); ++ if (nret < 0 || (size_t)nret != command.length()) { + ERROR("sub write over!"); + break; + } +@@ -668,7 +669,8 @@ public: + } + for (int i = 0; i < request.cmd_size(); i++) { + std::string command = request.cmd(i); +- if (write(m_read_pipe_fd, (void *)(command.c_str()), command.length()) < 0) { ++ int nret = util_write_nointr_in_total(m_read_pipe_fd, command.c_str(), command.length()); ++ if (nret < 0 || (size_t)nret != command.length()) { + ERROR("sub write over!"); + return; + } +@@ -946,7 +948,8 @@ Status ContainerServiceImpl::Attach(ServerContext *context, ServerReaderWriter= PATH_MAX - 1) { + ERROR("Invalid layer id: %s", lid); +@@ -1438,7 +1439,8 @@ static int do_add_checked_layer(const char *lid, int fd, map_t *checked_layers) + (void)memcpy(buf, lid, strlen(lid)); + buf[strlen(lid)] = '\n'; + // save checked layer ids into file +- if (util_write_nointr(fd, buf, strlen(lid) + 1) < 0) { ++ nret = util_write_nointr(fd, buf, strlen(lid) + 1); ++ if (nret < 0 || (size_t)nret != strlen(lid) + 1) { + ERROR("Write checked layer data failed: %s", strerror(errno)); + ret = -1; + goto out; +diff --git a/src/daemon/modules/log/log_gather.c b/src/daemon/modules/log/log_gather.c +index 49facaa2..414c9ad1 100644 +--- a/src/daemon/modules/log/log_gather.c ++++ b/src/daemon/modules/log/log_gather.c +@@ -183,9 +183,9 @@ static int write_into_file(const void *buf, size_t g_log_size) + return -1; + } + } +- ret = (int)write(g_log_fd, buf, g_log_size); +- if (ret <= 0) { +- return ret; ++ ret = util_write_nointr_in_total(g_log_fd, buf, g_log_size); ++ if (ret < 0 || (size_t)ret != g_log_size) { ++ return -1; + } + + write_size += ret; +diff --git a/src/daemon/modules/plugin/plugin.c b/src/daemon/modules/plugin/plugin.c +index 53afeeaf..1c0af368 100644 +--- a/src/daemon/modules/plugin/plugin.c ++++ b/src/daemon/modules/plugin/plugin.c +@@ -618,7 +618,7 @@ static int process_plugin_events(int inotify_fd, const char *plugin_dir) + struct inotify_event *plugin_event = NULL; + char buffer[8192 + 1] = { 0 }; + int action = 0; +- events_length = read(inotify_fd, buffer, 8192); ++ events_length = util_read_nointr(inotify_fd, buffer, 8192); + + if (events_length <= 0) { + ERROR("Failed to wait events"); +diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c +index 99f8be5e..e80aa9a4 100644 +--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c ++++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c +@@ -1355,8 +1355,8 @@ int rt_isula_exec_resize(const char *id, const char *runtime, const rt_exec_resi + goto out; + } + +- count = write(fd, data, RESIZE_DATA_SIZE); +- if (count <= 0) { ++ count = util_write_nointr(fd, data, strlen(data)); ++ if (count < 0 || (size_t)count != strlen(data)) { + ERROR("write exec resize data error"); + ret = -1; + goto out; +diff --git a/src/daemon/modules/service/io_handler.c b/src/daemon/modules/service/io_handler.c +index 893733bc..98c763a4 100644 +--- a/src/daemon/modules/service/io_handler.c ++++ b/src/daemon/modules/service/io_handler.c +@@ -340,7 +340,7 @@ static ssize_t write_to_fd(void *context, const void *data, size_t len) + { + ssize_t ret; + ret = util_write_nointr(*(int *)context, data, len); +- if ((ret <= 0) || (ret != (ssize_t)len)) { ++ if (ret < 0 || (size_t)ret != len) { + ERROR("Failed to write: %s", strerror(errno)); + return -1; + } +diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c +index f30a3f8e..6dc06c83 100644 +--- a/src/daemon/modules/service/service_container.c ++++ b/src/daemon/modules/service/service_container.c +@@ -340,7 +340,7 @@ static int write_env_content(const char *env_path, const char **env, size_t env_ + goto out; + } + nret = util_write_nointr(fd, env_content, strlen(env_content)); +- if (nret < 0 || nret != len - 1) { ++ if (nret < 0 || (size_t)nret != strlen(env_content)) { + SYSERROR("Write env file failed"); + free(env_content); + ret = -1; +diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c +index b1db045a..2c3709ad 100644 +--- a/src/utils/cutils/utils.c ++++ b/src/utils/cutils/utils.c +@@ -1237,7 +1237,7 @@ int util_generate_random_str(char *id, size_t len) + } + for (i = 0; i < len; i++) { + int nret; +- if (read(fd, &num, sizeof(int)) < 0) { ++ if (util_read_nointr(fd, &num, sizeof(int)) < 0) { + ERROR("Failed to read urandom value"); + close(fd); + return -1; +diff --git a/src/utils/cutils/utils_aes.c b/src/utils/cutils/utils_aes.c +index 1e25ecd3..055a9538 100644 +--- a/src/utils/cutils/utils_aes.c ++++ b/src/utils/cutils/utils_aes.c +@@ -77,7 +77,7 @@ int util_aes_key(const char *key_file, bool create, unsigned char *aeskey) + goto out; + } + +- if (read(fd, aeskey, AES_256_CFB_KEY_LEN) != AES_256_CFB_KEY_LEN) { ++ if (util_read_nointr(fd, aeskey, AES_256_CFB_KEY_LEN) != AES_256_CFB_KEY_LEN) { + ERROR("read key file %s failed: %s", key_file, strerror(errno)); + ret = -1; + goto out; +diff --git a/src/utils/cutils/utils_file.c b/src/utils/cutils/utils_file.c +index 7b1d5cb6..4c62aaa6 100644 +--- a/src/utils/cutils/utils_file.c ++++ b/src/utils/cutils/utils_file.c +@@ -1012,7 +1012,7 @@ int util_file2str(const char *filename, char *buf, size_t len) + if (fd == -1) { + return -1; + } +- num_read = (int)read(fd, buf, len - 1); ++ num_read = (int)util_read_nointr(fd, buf, len - 1); + if (num_read <= 0) { + num_read = -1; + } else { +diff --git a/src/utils/tar/util_archive.c b/src/utils/tar/util_archive.c +index da814c94..630ad8f8 100644 +--- a/src/utils/tar/util_archive.c ++++ b/src/utils/tar/util_archive.c +@@ -659,7 +659,7 @@ child_out: + if (ret != 0) { + ERROR("Wait archive_untar_handler failed with error:%s", strerror(errno)); + fcntl(pipe_stderr[0], F_SETFL, O_NONBLOCK); +- if (read(pipe_stderr[0], errbuf, BUFSIZ) < 0) { ++ if (util_read_nointr(pipe_stderr[0], errbuf, BUFSIZ) < 0) { + ERROR("read error message from child failed"); + } + } +@@ -1054,7 +1054,7 @@ child_out: + if (ret != 0) { + ERROR("tar failed"); + fcntl(pipe_for_read[0], F_SETFL, O_NONBLOCK); +- if (read(pipe_for_read[0], errbuf, BUFSIZ) < 0) { ++ if (util_read_nointr(pipe_for_read[0], errbuf, BUFSIZ) < 0) { + ERROR("read error message from child failed"); + } + } +diff --git a/src/utils/tar/util_gzip.c b/src/utils/tar/util_gzip.c +index 5c34d719..2f4750be 100644 +--- a/src/utils/tar/util_gzip.c ++++ b/src/utils/tar/util_gzip.c +@@ -212,7 +212,7 @@ int gzip(const char *filename, size_t len) + return -1; + } + +- size_read = read(pipefd[0], buffer, BUFSIZ); ++ size_read = util_read_nointr(pipefd[0], buffer, BUFSIZ); + close(pipefd[0]); + + if (size_read) { +-- +2.25.1 + diff --git a/0018-add-crictl-timeout-and-sync-for-CI.patch b/0018-add-crictl-timeout-and-sync-for-CI.patch new file mode 100644 index 0000000..50b7226 --- /dev/null +++ b/0018-add-crictl-timeout-and-sync-for-CI.patch @@ -0,0 +1,127 @@ +From 4ca7a67fc6f9304239224e92d0ab15180cf48a10 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Mon, 20 Feb 2023 15:42:40 +0800 +Subject: [PATCH 18/19] add crictl timeout and sync for CI + +Signed-off-by: zhangxiaoyu +--- + CI/test_cases/container_cases/bigdata_stream.sh | 7 +++++++ + CI/test_cases/container_cases/bigdata_stream_runc.sh | 4 ++++ + CI/test_cases/helpers.sh | 5 ++++- + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/CI/test_cases/container_cases/bigdata_stream.sh b/CI/test_cases/container_cases/bigdata_stream.sh +index 6c669503..4b2022af 100755 +--- a/CI/test_cases/container_cases/bigdata_stream.sh ++++ b/CI/test_cases/container_cases/bigdata_stream.sh +@@ -124,6 +124,7 @@ function test_concurrent_bigdata_stream() + pids[${#pids[@]}]=$! + done + wait ${pids[*]// /|} ++ sync && sync + + for index in $(seq 1 5); do + ls -l /home/iocopy_stream_data_500M_$index +@@ -151,6 +152,7 @@ function test_concurrent_bigdata_stream_without_pty() + pids[${#pids[@]}]=$! + done + wait ${pids[*]// /|} ++ sync && sync + + for index in $(seq 1 5); do + ls -l /home/iocopy_stream_data_500M_$index +@@ -209,6 +211,7 @@ function test_stream_with_stop_client() + kill -18 $pid + + wait $pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +@@ -254,6 +257,7 @@ function test_stream_with_stop_attach() + kill -18 $pid + + wait $exec_pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +@@ -299,6 +303,7 @@ function test_stream_with_stop_lxc_monitor() + kill -18 $pid + + wait $exec_pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +@@ -348,6 +353,7 @@ function test_stream_with_stop_isulad() + kill -18 $(cat /var/run/isulad.pid) + + wait $pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +@@ -398,6 +404,7 @@ function test_stream_with_runc() + isula exec -it $RUNCID cat test_500M > /home/iocopy_stream_data_500M + [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to cat bigdata" && ((ret++)) + ++ sync && sync + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) + [[ $total_size -ne 524288000 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - stream iocopy loss data" && ((ret++)) + +diff --git a/CI/test_cases/container_cases/bigdata_stream_runc.sh b/CI/test_cases/container_cases/bigdata_stream_runc.sh +index 6933bef0..3a384cd8 100755 +--- a/CI/test_cases/container_cases/bigdata_stream_runc.sh ++++ b/CI/test_cases/container_cases/bigdata_stream_runc.sh +@@ -117,6 +117,7 @@ function test_cat_bigdata() + pids[${#pids[@]}]=$! + done + wait ${pids[*]// /|} ++ sync && sync + + for index in $(seq 1 5); do + ls -l /home/iocopy_stream_data_500M_$index +@@ -144,6 +145,7 @@ function test_cat_bigdata_without_pty() + pids[${#pids[@]}]=$! + done + wait ${pids[*]// /|} ++ sync && sync + + for index in $(seq 1 5); do + ls -l /home/iocopy_stream_data_500M_$index +@@ -173,6 +175,7 @@ function test_stream_with_stop_client() + kill -18 $pid + + wait $pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +@@ -217,6 +220,7 @@ function test_stream_with_stop_isulad() + kill -18 $(cat /var/run/isulad.pid) + + wait $pid ++ sync && sync + + ls -l /home/iocopy_stream_data_500M + total_size=$(stat -c"%s" /home/iocopy_stream_data_500M) +diff --git a/CI/test_cases/helpers.sh b/CI/test_cases/helpers.sh +index 5097217c..a11e676c 100755 +--- a/CI/test_cases/helpers.sh ++++ b/CI/test_cases/helpers.sh +@@ -80,7 +80,10 @@ function wait_container() { + + function crictl() { + CRICTL=$(which crictl) +- "$CRICTL" -i unix:///var/run/isulad.sock -r unix:///var/run/isulad.sock "$@" ++ # Default timeout is 2s. ++ # In some high IO testcase, isulad handle CRI request time maybe more than 2s. ++ # And the crictl will print error message "context deadline exceeded" ++ "$CRICTL" -i unix:///var/run/isulad.sock -r unix:///var/run/isulad.sock --timeout 5s "$@" + } + + function msg_ok() +-- +2.25.1 + diff --git a/0019-unlock-m_podsLock-if-new-failed.patch b/0019-unlock-m_podsLock-if-new-failed.patch new file mode 100644 index 0000000..b332e39 --- /dev/null +++ b/0019-unlock-m_podsLock-if-new-failed.patch @@ -0,0 +1,27 @@ +From d7c76d137f60b4adf0eba46e0db67182fca04e69 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Wed, 22 Feb 2023 10:43:52 +0800 +Subject: [PATCH 19/19] unlock m_podsLock if new failed + +Signed-off-by: zhangxiaoyu +--- + src/daemon/entry/cri/network_plugin.cc | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/daemon/entry/cri/network_plugin.cc b/src/daemon/entry/cri/network_plugin.cc +index 00be975e..7a957de3 100644 +--- a/src/daemon/entry/cri/network_plugin.cc ++++ b/src/daemon/entry/cri/network_plugin.cc +@@ -347,6 +347,9 @@ void PluginManager::Lock(const std::string &fullPodName, Errors &error) + auto tmpLock = std::unique_ptr(new (std::nothrow) PodLock()); + if (tmpLock == nullptr) { + error.SetError("Out of memory"); ++ if (pthread_mutex_unlock(&m_podsLock) != 0) { ++ error.SetError("plugin manager unlock failed"); ++ } + return; + } + lock = tmpLock.get(); +-- +2.25.1 + diff --git a/iSulad.spec b/iSulad.spec index ebb3ce7..686ee2c 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 2.0.18 -%global _release 2 +%global _release 3 %global is_systemd 1 %global enable_shimv2 1 %global is_embedded 1 @@ -13,6 +13,26 @@ URL: https://gitee.com/openeuler/iSulad Source: https://gitee.com/openeuler/iSulad/repository/archive/v%{version}.tar.gz BuildRoot: {_tmppath}/iSulad-%{version} +Patch0001: 0001-add-omitted-musl-adaption-code.patch +Patch0002: 0002-add-cpu-rt-CI.patch +Patch0003: 0003-add-cpu-rt-ut.patch +Patch0004: 0004-add-info-log-when-isulad-shutdown.patch +Patch0005: 0005-create-a-log-file-for-shim-v2-and-remove-10-229-devi.patch +Patch0006: 0006-ensure-isula-exec-inherits-the-config-of-create.patch +Patch0007: 0007-Delete-meaningless-thread-creation-and-ensure-the-ta.patch +Patch0008: 0008-fix-cpu-rt-review-comments.patch +Patch0009: 0009-fix-inspect.sh-failed.patch +Patch0010: 0010-ensure-list-name-is-not-null.patch +Patch0011: 0011-Bugfix-in-config-and-executor.patch +Patch0012: 0012-fix-isula-cpu-rt-CI.patch +Patch0013: 0013-add-CRI-ContainerStats-Service.patch +Patch0014: 0014-fix-selinux_label_ut-timeout-and-add-timeout-for-all.patch +Patch0015: 0015-fix-cpu-rt-disable-after-reboot-machine.patch +Patch0016: 0016-fix-code-style.patch +Patch0017: 0017-add-retry-for-read-write.patch +Patch0018: 0018-add-crictl-timeout-and-sync-for-CI.patch +Patch0019: 0019-unlock-m_podsLock-if-new-failed.patch + %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) Provides: libisula.so()(64bit) @@ -256,6 +276,12 @@ fi %endif %changelog +* Wed Feb 22 2023 zhangxiaoyu - 2.0.18-3 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: upgrade from upstream + * Thu Feb 16 2023 zhangxiaoyu - 2.0.18-2 - Type: bugfix - ID: NA