From 96970d781852054e8734c2f14383bfe5c9a1d134 Mon Sep 17 00:00:00 2001 From: lifeng68 Date: Wed, 30 Dec 2020 16:00:53 +0800 Subject: [PATCH] iSulad: update to v2.0.8 Signed-off-by: lifeng68 --- ...Add-a-solution-to-the-gpgkey-problem.patch | 45 - ...mp-directory-from-var-tmp-to-var-lib.patch | 606 -------- ...roto-to-v1.19.3-according-to-kubelet.patch | 102 -- 0004-adapt-CI-ISULAD_TMPDIR-testcases.patch | 50 - ...0.1-port-in-cri-stream-websocket-ser.patch | 75 - ...que-token-in-CRI-websockets-server-R.patch | 50 - ...t_use_decrypted_key_flag-and-setup-a.patch | 56 - 0008-show-all-mutl-network-ips.patch | 26 - ...Sulad-only-qsort-the-configed-mounts.patch | 554 ------- ...d-testcases-for-bind-proc-and-sys-fs.patch | 76 - ...-verify-peer-if-it-s-secure-registry.patch | 29 - ...l-certs-load-success-if-any-provided.patch | 239 --- 0013-add-ch-docs-for-install-iSulad.patch | 305 ---- 0014-error-out-if-unpack-layer-failed.patch | 34 - ...-ignore-get-ip-error-for-mutlnetwork.patch | 27 - ...upport-default-container-log-options.patch | 1303 ----------------- ...se-for-default-container-log-configs.patch | 231 --- ...an-code-ignore-list-containers-error.patch | 136 -- ...mage_module_data-in-oci-image-module.patch | 638 -------- ...te-path-to-relative-path-when-unpack.patch | 31 - ...heck-error-in-terminal.c-and-volume_.patch | 44 - ...-args-use_decrypted_key-is-a-pointer.patch | 31 - 0023-verify-peer-only-if-CA-configed.patch | 29 - iSulad.spec | 34 +- v2.0.7.tar.gz => v2.0.8.tar.gz | Bin 3343121 -> 3367710 bytes 25 files changed, 8 insertions(+), 4743 deletions(-) delete mode 100644 0001-Add-a-solution-to-the-gpgkey-problem.patch delete mode 100644 0002-change-default-tmp-directory-from-var-tmp-to-var-lib.patch delete mode 100644 0003-update-api.proto-to-v1.19.3-according-to-kubelet.patch delete mode 100644 0004-adapt-CI-ISULAD_TMPDIR-testcases.patch delete mode 100644 0005-listening-127.0.0.1-port-in-cri-stream-websocket-ser.patch delete mode 100644 0006-using-64-bit-unique-token-in-CRI-websockets-server-R.patch delete mode 100644 0007-add-mock-conf_get_use_decrypted_key_flag-and-setup-a.patch delete mode 100644 0008-show-all-mutl-network-ips.patch delete mode 100644 0009-iSulad-only-qsort-the-configed-mounts.patch delete mode 100644 0010-CI-add-testcases-for-bind-proc-and-sys-fs.patch delete mode 100644 0011-verify-peer-if-it-s-secure-registry.patch delete mode 100644 0012-make-sure-all-certs-load-success-if-any-provided.patch delete mode 100644 0013-add-ch-docs-for-install-iSulad.patch delete mode 100644 0014-error-out-if-unpack-layer-failed.patch delete mode 100644 0015-ignore-get-ip-error-for-mutlnetwork.patch delete mode 100644 0016-support-default-container-log-options.patch delete mode 100644 0017-add-testcase-for-default-container-log-configs.patch delete mode 100644 0018-clean-code-ignore-list-containers-error.patch delete mode 100644 0019-add-g_oci_image_module_data-in-oci-image-module.patch delete mode 100644 0020-translate-absolute-path-to-relative-path-when-unpack.patch delete mode 100644 0021-clean-code-fix-check-error-in-terminal.c-and-volume_.patch delete mode 100644 0022-iSulad-bugfix-args-use_decrypted_key-is-a-pointer.patch delete mode 100644 0023-verify-peer-only-if-CA-configed.patch rename v2.0.7.tar.gz => v2.0.8.tar.gz (52%) diff --git a/0001-Add-a-solution-to-the-gpgkey-problem.patch b/0001-Add-a-solution-to-the-gpgkey-problem.patch deleted file mode 100644 index 0766079..0000000 --- a/0001-Add-a-solution-to-the-gpgkey-problem.patch +++ /dev/null @@ -1,45 +0,0 @@ -From a46546cd6c9d3e085beac143eb3b7dcff7f118e5 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=E5=A4=A7=E7=BD=97=E9=A9=AC=E7=9A=84=E5=A4=AA=E9=98=B3?= - -Date: Mon, 23 Nov 2020 22:55:24 +0800 -Subject: [PATCH 01/17] Add a solution to the gpgkey problem - ---- - README.md | 21 +++++++++++++++++++++ - 1 file changed, 21 insertions(+) - -diff --git a/README.md b/README.md -index 08467ddc..9b34d615 100644 ---- a/README.md -+++ b/README.md -@@ -25,6 +25,27 @@ Install iSulad with yum: - yum install -y iSulad - ``` - -+if you found this error -+``` -+Repository 'openEuler' is missing name in configuration, using id. -+ -+You have enabled checking of packages via GPG keys. This is a good thing. -+However, you do not have any GPG public keys installed. You need to download -+the keys for packages you wish to install and install them. -+You can do that by running the command: -+ rpm --import public.gpg.key -+ -+ -+Alternatively you can specify the url to the key you would like to use -+for a repository in the 'gpgkey' option in a repository section and YUM -+will install it for you. -+ -+For more information contact your distribution or package provider. -+ -+``` -+ -+you should run `rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-openEuler` first -+ - ### Run - We provide `systemd` service to start `iSulad`: - ```sh --- -2.25.1 - diff --git a/0002-change-default-tmp-directory-from-var-tmp-to-var-lib.patch b/0002-change-default-tmp-directory-from-var-tmp-to-var-lib.patch deleted file mode 100644 index 3e97c7b..0000000 --- a/0002-change-default-tmp-directory-from-var-tmp-to-var-lib.patch +++ /dev/null @@ -1,606 +0,0 @@ -From e17d4ea9e2e6ec5555429cbc0363748e33170dea Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Mon, 23 Nov 2020 16:52:56 +0800 -Subject: [PATCH 02/17] change default tmp directory from /var/tmp to - /var/lib/isulad/tmp - -Signed-off-by: WangFengTu ---- - src/daemon/modules/image/oci/oci_image.c | 21 +++- - src/daemon/modules/image/oci/oci_load.c | 20 ++-- - .../modules/image/oci/registry/registry.c | 20 ++-- - .../modules/image/oci/storage/storage.c | 34 ------ - .../modules/image/oci/storage/storage.h | 2 - - src/daemon/modules/image/oci/utils_images.c | 102 ++++++++++++++---- - src/daemon/modules/image/oci/utils_images.h | 3 +- - test/image/oci/registry/CMakeLists.txt | 2 +- - test/image/oci/registry/registry_ut.cc | 22 +++- - test/image/oci/storage/images/CMakeLists.txt | 2 + - .../oci/storage/images/storage_images_ut.cc | 1 + - test/image/oci/storage/rootfs/CMakeLists.txt | 4 +- - .../oci/storage/rootfs/storage_rootfs_ut.cc | 1 + - test/mocks/isulad_config_mock.cc | 16 +++ - test/mocks/isulad_config_mock.h | 2 + - 15 files changed, 160 insertions(+), 92 deletions(-) - -diff --git a/src/daemon/modules/image/oci/oci_image.c b/src/daemon/modules/image/oci/oci_image.c -index f0ba19cb..f4fa1e88 100644 ---- a/src/daemon/modules/image/oci/oci_image.c -+++ b/src/daemon/modules/image/oci/oci_image.c -@@ -150,26 +150,34 @@ out: - return ret; - } - --static void cleanup_image_tmpdir() -+static int recreate_image_tmpdir() - { - char *image_tmp_path = NULL; -+ int ret = 0; - -- image_tmp_path = get_image_tmp_path(); -+ image_tmp_path = oci_get_isulad_tmpdir(); - if (image_tmp_path == NULL) { - ERROR("failed to get image tmp path"); -- return; -+ ret = -1; -+ goto out; - } - - if (util_recursive_rmdir(image_tmp_path, 0)) { - ERROR("failed to remove directory %s", image_tmp_path); -+ ret = -1; -+ goto out; - } - - if (util_mkdir_p(image_tmp_path, TEMP_DIRECTORY_MODE)) { - ERROR("failed to create directory %s", image_tmp_path); -+ ret = -1; -+ goto out; - } -+ -+out: - free(image_tmp_path); - -- return; -+ return ret; - } - - int oci_init(const isulad_daemon_configs *args) -@@ -181,7 +189,10 @@ int oci_init(const isulad_daemon_configs *args) - return ret; - } - -- cleanup_image_tmpdir(); -+ ret = recreate_image_tmpdir(); -+ if (ret != 0) { -+ goto out; -+ } - - ret = registry_init(NULL, NULL); - if (ret != 0) { -diff --git a/src/daemon/modules/image/oci/oci_load.c b/src/daemon/modules/image/oci/oci_load.c -index 073ad55b..97cff34b 100644 ---- a/src/daemon/modules/image/oci/oci_load.c -+++ b/src/daemon/modules/image/oci/oci_load.c -@@ -1011,25 +1011,23 @@ static char *oci_load_path_create() - { - int ret = 0; - int nret = 0; -- char *oci_load_work_dir = NULL; -+ char *image_tmp_path = NULL; - char tmp_dir[PATH_MAX] = { 0 }; - -- oci_load_work_dir = storage_oci_load_work_dir(); -- if (oci_load_work_dir == NULL) { -- ERROR("Failed to get oci load work dir"); -- isulad_try_set_error_message("Failed to get oci load work dir"); -- ret = -1; -+ ret = makesure_isulad_tmpdir_perm_right(); -+ if (ret != 0) { -+ ERROR("failed to make sure permission of image tmp work dir"); - goto out; - } - -- if (util_mkdir_p(oci_load_work_dir, TEMP_DIRECTORY_MODE) != 0) { -- ERROR("Unable to create oci image load tmp work dir:%s", oci_load_work_dir); -- isulad_try_set_error_message("Unable to create oci image load tmp work dir:%s", oci_load_work_dir); -+ image_tmp_path = oci_get_isulad_tmpdir(); -+ if (image_tmp_path == NULL) { -+ ERROR("failed to get image tmp work dir"); - ret = -1; - goto out; - } - -- nret = snprintf(tmp_dir, PATH_MAX, "%s/oci-image-load-XXXXXX", oci_load_work_dir); -+ nret = snprintf(tmp_dir, PATH_MAX, "%s/oci-image-load-XXXXXX", image_tmp_path); - if (nret < 0 || (size_t)nret >= sizeof(tmp_dir)) { - ERROR("Path is too long"); - ret = -1; -@@ -1044,7 +1042,7 @@ static char *oci_load_path_create() - } - - out: -- free(oci_load_work_dir); -+ free(image_tmp_path); - return ret == 0 ? util_strdup_s(tmp_dir) : NULL; - } - -diff --git a/src/daemon/modules/image/oci/registry/registry.c b/src/daemon/modules/image/oci/registry/registry.c -index 2656b9b2..a94d10b1 100644 ---- a/src/daemon/modules/image/oci/registry/registry.c -+++ b/src/daemon/modules/image/oci/registry/registry.c -@@ -1718,7 +1718,13 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio - - update_host(desc); - -- image_tmp_path = get_image_tmp_path(); -+ ret = makesure_isulad_tmpdir_perm_right(); -+ if (ret != 0) { -+ ERROR("failed to make sure permission of image tmp work dir"); -+ goto out; -+ } -+ -+ image_tmp_path = oci_get_isulad_tmpdir(); - if (image_tmp_path == NULL) { - ERROR("failed to get image tmp work dir"); - ret = -1; -@@ -1859,18 +1865,6 @@ static void cached_layers_kvfree(void *key, void *value) - int registry_init(char *auths_dir, char *certs_dir) - { - int ret = 0; -- char *image_tmp_path = NULL; -- -- image_tmp_path = get_image_tmp_path(); -- if (image_tmp_path == NULL) { -- ERROR("failed to get image tmp path"); -- return -1; -- } -- -- if (util_mkdir_p(image_tmp_path, TEMP_DIRECTORY_MODE)) { -- ERROR("failed to create directory %s", image_tmp_path); -- } -- free(image_tmp_path); - - auths_set_dir(auths_dir); - certs_set_dir(certs_dir); -diff --git a/src/daemon/modules/image/oci/storage/storage.c b/src/daemon/modules/image/oci/storage/storage.c -index f15531be..0d837079 100644 ---- a/src/daemon/modules/image/oci/storage/storage.c -+++ b/src/daemon/modules/image/oci/storage/storage.c -@@ -1715,20 +1715,6 @@ out: - int storage_module_init(struct storage_module_init_options *opts) - { - int ret = 0; -- char *oci_load_work_dir = NULL; -- -- oci_load_work_dir = storage_oci_load_work_dir(); -- if (oci_load_work_dir == NULL) { -- ERROR("Get oci load work dir failed"); -- ret = -1; -- goto out; -- } -- -- ret = util_recursive_rmdir(oci_load_work_dir, 0); -- if (ret != 0) { -- ERROR("failed to remove dir %s", oci_load_work_dir); -- goto out; -- } - - if (check_module_init_opt(opts) != 0) { - ret = -1; -@@ -1783,25 +1769,5 @@ int storage_module_init(struct storage_module_init_options *opts) - } - - out: -- free(oci_load_work_dir); - return ret; - } -- -- --char *storage_oci_load_work_dir() --{ -- char *isulad_tmp = NULL; -- char *oci_load_work_dir = NULL; -- -- isulad_tmp = oci_get_isulad_tmpdir(); -- if (isulad_tmp == NULL) { -- ERROR("Failed to get isulad tmp dir"); -- goto out; -- } -- -- oci_load_work_dir = util_path_join(isulad_tmp, "isulad-oci-load"); -- --out: -- free(isulad_tmp); -- return oci_load_work_dir; --} -\ No newline at end of file -diff --git a/src/daemon/modules/image/oci/storage/storage.h b/src/daemon/modules/image/oci/storage/storage.h -index b030a3a5..f2141924 100644 ---- a/src/daemon/modules/image/oci/storage/storage.h -+++ b/src/daemon/modules/image/oci/storage/storage.h -@@ -179,8 +179,6 @@ int storage_rootfs_umount(const char *container_id, bool force); - - container_inspect_graph_driver *storage_get_metadata_by_container_id(const char *id); - --char *storage_oci_load_work_dir(); -- - #ifdef __cplusplus - } - #endif -diff --git a/src/daemon/modules/image/oci/utils_images.c b/src/daemon/modules/image/oci/utils_images.c -index de0eb324..7eddd25c 100644 ---- a/src/daemon/modules/image/oci/utils_images.c -+++ b/src/daemon/modules/image/oci/utils_images.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - #include "isula_libutils/log.h" - #include "utils.h" -@@ -36,10 +37,10 @@ - #include "utils_file.h" - #include "utils_string.h" - #include "utils_verify.h" -+#include "isulad_config.h" - - // nanos of 2038-01-19T03:14:07, the max valid linux time - #define MAX_NANOS 2147483647000000000 --#define ISULAD_DEFAULT_TMP_DIR "/var/tmp" - - char *get_last_part(char **parts) - { -@@ -488,36 +489,101 @@ bool oci_valid_time(char *time) - return true; - } - -+static int makesure_path_is_dir(char *path) -+{ -+ struct stat st = {0}; -+ -+ if (lstat(path, &st) != 0) { -+ if (errno == ENOENT) { -+ return util_mkdir_p(path, TEMP_DIRECTORY_MODE); -+ } -+ ERROR("lstat %s failed: %s", path, strerror(errno)); -+ return -1; -+ } -+ -+ if (!S_ISDIR(st.st_mode)) { -+ if (util_recursive_rmdir(path, 0)) { -+ ERROR("failed to remove directory %s", path); -+ return -1; -+ } -+ } -+ -+ if (util_mkdir_p(path, TEMP_DIRECTORY_MODE) != 0) { -+ ERROR("make dir:%s failed", path); -+ return -1; -+ } -+ -+ return 0; -+} - - char *oci_get_isulad_tmpdir() - { -- char *isula_tmp = NULL; -+ char *isulad_tmpdir = NULL; -+ char *isulad_root_dir = NULL; -+ char *env_dir = NULL; -+ int ret = 0; - -- isula_tmp = getenv("ISULAD_TMPDIR"); -- if (util_valid_str(isula_tmp) && !util_dir_exists(isula_tmp)) { -- if (util_mkdir_p(isula_tmp, TEMP_DIRECTORY_MODE) != 0) { -- ERROR("make dir:%s failed", isula_tmp); -- return NULL; -- } -+ isulad_root_dir = conf_get_isulad_rootdir(); -+ if (isulad_root_dir == NULL) { -+ ERROR("get isulad root dir failed"); -+ return NULL; - } - -- return util_valid_str(isula_tmp) ? util_strdup_s(isula_tmp) : util_strdup_s(ISULAD_DEFAULT_TMP_DIR); -+ env_dir = getenv("ISULAD_TMPDIR"); -+ if (util_valid_str(env_dir)) { -+ isulad_tmpdir = util_path_join(env_dir, "isulad_tmpdir"); -+ } else { -+ isulad_tmpdir = util_path_join(isulad_root_dir, "isulad_tmpdir"); -+ } -+ if (isulad_tmpdir == NULL) { -+ ERROR("join temporary directory failed"); -+ ret = -1; -+ goto out; -+ } -+ -+out: -+ free(isulad_root_dir); -+ if (ret != 0) { -+ free(isulad_tmpdir); -+ isulad_tmpdir = NULL; -+ } -+ -+ return isulad_tmpdir; - } - --char *get_image_tmp_path() -+int makesure_isulad_tmpdir_perm_right() - { -- char *isulad_tmp = NULL; -- char *isula_image = NULL; -+ struct stat st = {0}; -+ char *isulad_tmpdir = NULL; -+ int ret = 0; -+ -+ isulad_tmpdir = oci_get_isulad_tmpdir(); -+ if (isulad_tmpdir == NULL) { -+ return -1; -+ } - -- isulad_tmp = oci_get_isulad_tmpdir(); -- if (isulad_tmp == NULL) { -- ERROR("Failed to get isulad tmp dir"); -+ ret = makesure_path_is_dir(isulad_tmpdir); -+ if (ret != 0) { -+ goto out; -+ } -+ -+ if (lstat(isulad_tmpdir, &st) != 0) { -+ ERROR("lstat %s failed: %s", isulad_tmpdir, strerror(errno)); -+ ret = -1; - goto out; - } - -- isula_image = util_path_join(isulad_tmp, "isula-image"); -+ // chown to root -+ ret = lchown(isulad_tmpdir, 0, 0); -+ if (ret == 0 || (ret == EPERM && st.st_uid == 0 && st.st_gid == 0)) { -+ ret = 0; -+ goto out; -+ } else { -+ ERROR("lchown %s failed: %s", isulad_tmpdir, strerror(errno)); -+ } - - out: -- free(isulad_tmp); -- return isula_image; -+ free(isulad_tmpdir); -+ -+ return ret; - } -diff --git a/src/daemon/modules/image/oci/utils_images.h b/src/daemon/modules/image/oci/utils_images.h -index 5dedd569..cebcc796 100644 ---- a/src/daemon/modules/image/oci/utils_images.h -+++ b/src/daemon/modules/image/oci/utils_images.h -@@ -55,8 +55,7 @@ int add_rootfs_and_history(const layer_blob *layers, size_t layers_len, const re - bool oci_valid_time(char *time); - - char *oci_get_isulad_tmpdir(); -- --char *get_image_tmp_path(); -+int makesure_isulad_tmpdir_perm_right(); - - #ifdef __cplusplus - } -diff --git a/test/image/oci/registry/CMakeLists.txt b/test/image/oci/registry/CMakeLists.txt -index 9e34103c..36e7cab8 100644 ---- a/test/image/oci/registry/CMakeLists.txt -+++ b/test/image/oci/registry/CMakeLists.txt -@@ -24,7 +24,6 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/buffer/buffer.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/cutils/utils_aes.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/modules/image/oci/storage/image_store/image_type.c -- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/config/isulad_config.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/modules/image/oci/registry_type.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/sysinfo.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/modules/image/oci/storage/image_store/image_store.c -@@ -37,6 +36,7 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/storage_mock.cc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/oci_image_mock.cc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/http_mock.cc -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/isulad_config_mock.cc - registry_ut.cc) - - target_include_directories(${EXE} PUBLIC -diff --git a/test/image/oci/registry/registry_ut.cc b/test/image/oci/registry/registry_ut.cc -index f656a49d..25ddf694 100644 ---- a/test/image/oci/registry/registry_ut.cc -+++ b/test/image/oci/registry/registry_ut.cc -@@ -43,6 +43,7 @@ - #include "aes.h" - #include "auths.h" - #include "oci_image_mock.h" -+#include "isulad_config_mock.h" - - using ::testing::Args; - using ::testing::ByRef; -@@ -79,17 +80,21 @@ protected: - MockHttp_SetMock(&m_http_mock); - MockStorage_SetMock(&m_storage_mock); - MockOciImage_SetMock(&m_oci_image_mock); -+ MockIsuladConf_SetMock(&m_isulad_conf_mock); - } - - void TearDown() override - { - MockHttp_SetMock(nullptr); - MockStorage_SetMock(nullptr); -+ MockOciImage_SetMock(nullptr); -+ MockIsuladConf_SetMock(nullptr); - } - - NiceMock m_http_mock; - NiceMock m_storage_mock; - NiceMock m_oci_image_mock; -+ NiceMock m_isulad_conf_mock; - }; - - int invokeHttpRequestV1(const char *url, struct http_get_options *options, long *response_code, int recursive_len) -@@ -497,7 +502,12 @@ static int init_log() - return 0; - } - --void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock) -+static char *invokeConfGetISuladRootDir() -+{ -+ return util_strdup_s(get_dir().c_str()); -+} -+ -+void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladConf *isulad_conf_mock) - { - EXPECT_CALL(*mock, StorageImgCreate(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeStorageImgCreate)); -@@ -531,6 +541,8 @@ void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock) - .WillRepeatedly(Invoke(invokeFreeLayer)); - EXPECT_CALL(*oci_image_mock, OciValidTime(::testing::_)) - .WillRepeatedly(Invoke(invokeOciValidTime)); -+ EXPECT_CALL(*isulad_conf_mock, ConfGetISuladRootDir()) -+ .WillRepeatedly(Invoke(invokeConfGetISuladRootDir)); - return; - } - -@@ -588,7 +600,7 @@ TEST_F(RegistryUnitTest, test_pull_v1_image) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV1)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); - ASSERT_EQ(registry_pull(&options), 0); - - ASSERT_EQ(registry_pull(&options), 0); -@@ -648,7 +660,7 @@ TEST_F(RegistryUnitTest, test_pull_v2_image) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV2)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); - - // test retry success - ASSERT_EQ(registry_pull(&options), 0); -@@ -682,7 +694,7 @@ TEST_F(RegistryUnitTest, test_pull_oci_image) - options->insecure_registry = false; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestOCI)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); - ASSERT_EQ(registry_pull(options), 0); - - free_registry_pull_options(options); -@@ -700,7 +712,7 @@ TEST_F(RegistryUnitTest, test_pull_already_exist) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV2)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); - EXPECT_CALL(m_storage_mock, StorageLayerGet(::testing::_)) - .WillRepeatedly(Invoke(invokeStorageLayerGet1)); - ASSERT_EQ(registry_pull(&options), 0); -diff --git a/test/image/oci/storage/images/CMakeLists.txt b/test/image/oci/storage/images/CMakeLists.txt -index 82ad4680..b00c5a0e 100644 ---- a/test/image/oci/storage/images/CMakeLists.txt -+++ b/test/image/oci/storage/images/CMakeLists.txt -@@ -22,6 +22,7 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/registry_type.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/image_store/image_store.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/storage_mock.cc -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/isulad_config_mock.cc - storage_images_ut.cc) - - target_include_directories(${EXE} PUBLIC -@@ -34,6 +35,7 @@ target_include_directories(${EXE} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/cutils/map - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/sha256 - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/http -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/image_store -diff --git a/test/image/oci/storage/images/storage_images_ut.cc b/test/image/oci/storage/images/storage_images_ut.cc -index 4115e911..234ab742 100644 ---- a/test/image/oci/storage/images/storage_images_ut.cc -+++ b/test/image/oci/storage/images/storage_images_ut.cc -@@ -33,6 +33,7 @@ - #include "isula_libutils/imagetool_images_list.h" - #include "isula_libutils/imagetool_image.h" - #include "storage_mock.h" -+#include "isulad_config_mock.h" - - using ::testing::Args; - using ::testing::ByRef; -diff --git a/test/image/oci/storage/rootfs/CMakeLists.txt b/test/image/oci/storage/rootfs/CMakeLists.txt -index 3ba56bb9..8da8196b 100644 ---- a/test/image/oci/storage/rootfs/CMakeLists.txt -+++ b/test/image/oci/storage/rootfs/CMakeLists.txt -@@ -21,6 +21,7 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/rootfs_store/rootfs.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/storage_mock.cc -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/isulad_config_mock.cc - storage_rootfs_ut.cc) - - target_include_directories(${EXE} PUBLIC -@@ -33,7 +34,8 @@ target_include_directories(${EXE} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/sha256 - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/json/schema/src - ${CMAKE_BINARY_DIR}/conf -- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../test/mocks -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../test/mocks -+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/rootfs_store -diff --git a/test/image/oci/storage/rootfs/storage_rootfs_ut.cc b/test/image/oci/storage/rootfs/storage_rootfs_ut.cc -index a4864dad..9cf91fa9 100644 ---- a/test/image/oci/storage/rootfs/storage_rootfs_ut.cc -+++ b/test/image/oci/storage/rootfs/storage_rootfs_ut.cc -@@ -30,6 +30,7 @@ - #include "utils.h" - #include "path.h" - #include "storage.h" -+#include "isulad_config_mock.h" - - std::string META_DATA_CONTENT = "metadata test"; - -diff --git a/test/mocks/isulad_config_mock.cc b/test/mocks/isulad_config_mock.cc -index 9d993157..88a74a41 100644 ---- a/test/mocks/isulad_config_mock.cc -+++ b/test/mocks/isulad_config_mock.cc -@@ -136,3 +136,19 @@ char *conf_get_isulad_storage_driver_backing_fs() - } - return nullptr; - } -+ -+char *conf_get_isulad_rootdir() -+{ -+ if (g_isulad_conf_mock != nullptr) { -+ return g_isulad_conf_mock->ConfGetISuladRootDir(); -+ } -+ return nullptr; -+} -+ -+bool conf_get_use_decrypted_key_flag() -+{ -+ if (g_isulad_conf_mock != nullptr) { -+ return g_isulad_conf_mock->ConfGetUseDecryptedKeyFlag(); -+ } -+ return true; -+} -diff --git a/test/mocks/isulad_config_mock.h b/test/mocks/isulad_config_mock.h -index fdf27cdb..03af3cc9 100644 ---- a/test/mocks/isulad_config_mock.h -+++ b/test/mocks/isulad_config_mock.h -@@ -34,6 +34,8 @@ public: - MOCK_METHOD1(GetSystemCpuUsage, int(uint64_t *val)); - MOCK_METHOD0(ConfGetIsuladStorageDriverBackingFs, char *()); - MOCK_METHOD0(GetMonitordPath, char *(void)); -+ MOCK_METHOD0(ConfGetISuladRootDir, char *(void)); -+ MOCK_METHOD0(ConfGetUseDecryptedKeyFlag, bool (void)); - }; - - void MockIsuladConf_SetMock(MockIsuladConf *mock); --- -2.25.1 - diff --git a/0003-update-api.proto-to-v1.19.3-according-to-kubelet.patch b/0003-update-api.proto-to-v1.19.3-according-to-kubelet.patch deleted file mode 100644 index f5142a9..0000000 --- a/0003-update-api.proto-to-v1.19.3-according-to-kubelet.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 5720b90e9515a698b5f9cde21a99194848f2c66a Mon Sep 17 00:00:00 2001 -From: gaohuatao -Date: Fri, 13 Nov 2020 03:21:16 -0500 -Subject: [PATCH 03/17] update api.proto to v1.19.3 according to kubelet - -Signed-off-by: gaohuatao ---- - src/api/services/cri/api.proto | 31 ++++++++++++++++++++ - src/daemon/entry/cri/cri_security_context.cc | 7 +++++ - 2 files changed, 38 insertions(+) - -diff --git a/src/api/services/cri/api.proto b/src/api/services/cri/api.proto -index 67e5527e..dc0cfeb9 100644 ---- a/src/api/services/cri/api.proto -+++ b/src/api/services/cri/api.proto -@@ -219,6 +219,13 @@ enum NamespaceMode { - // For example, a container with a PID namespace of NODE expects to view - // all of the processes on the host running the kubelet. - NODE = 2; -+ // TARGET targets the namespace of another container. When this is specified, -+ // a target_id must be specified in NamespaceOption and refer to a container -+ // previously created with NamespaceMode CONTAINER. This containers namespace -+ // will be made to match that of container target_id. -+ // For example, a container with a PID namespace of TARGET expects to view -+ // all of the processes that container target_id can view. -+ TARGET = 3; - } - - // NamespaceOption provides options for Linux namespaces. -@@ -236,6 +243,10 @@ message NamespaceOption { - // Note: There is currently no way to set CONTAINER scoped IPC in the Kubernetes API. - // Namespaces currently set by the kubelet: POD, NODE - NamespaceMode ipc = 3; -+ // Target Container ID for NamespaceMode of TARGET. This container must have been -+ // previously created in the same pod. It is not possible to specify different targets -+ // for each namespace. -+ string target_id = 4; - } - - // Int64Value is the wrapper of int64. -@@ -519,6 +530,10 @@ message ListPodSandboxResponse { - // future it will include more detailed information about the different image types. - message ImageSpec { - string image = 1; -+ // Unstructured key-value map holding arbitrary metadata. -+ // ImageSpec Annotations can be used to help the runtime target specific -+ // images in multi-arch images. -+ map annotations = 2; - } - - message KeyValue { -@@ -545,6 +560,19 @@ message LinuxContainerResources { - string cpuset_cpus = 6; - // CpusetMems constrains the allowed set of memory nodes. Default: "" (not specified). - string cpuset_mems = 7; -+ // List of HugepageLimits to limit the HugeTLB usage of container per page size. Default: nil (not specified). -+ repeated HugepageLimit hugepage_limits = 8; -+} -+ -+// HugepageLimit corresponds to the file`hugetlb..limit_in_byte` in container level cgroup. -+// For example, `PageSize=1GB`, `Limit=1073741824` means setting `1073741824` bytes to hugetlb.1GB.limit_in_bytes. -+message HugepageLimit { -+ // The value of PageSize has the format B (2MB, 1GB), -+ // and must match the of the corresponding control file found in `hugetlb..limit_in_bytes`. -+ // The values of are intended to be parsed using base 1024("1KB" = 1024, "1MB" = 1048576, etc). -+ string page_size = 1; -+ // limit in bytes of hugepagesize HugeTLB usage. -+ uint64 limit = 2; - } - - // SELinuxOption are the labels to be applied to the container. -@@ -1040,6 +1068,9 @@ message Image { - // User name that will run the command(s). This is used if UID is not set - // and no user is specified when creating container. - string username = 6; -+ // ImageSpec for image which includes annotations -+ ImageSpec spec = 7; -+ - } - - message ListImagesResponse { -diff --git a/src/daemon/entry/cri/cri_security_context.cc b/src/daemon/entry/cri/cri_security_context.cc -index 634e53ad..1d332261 100644 ---- a/src/daemon/entry/cri/cri_security_context.cc -+++ b/src/daemon/entry/cri/cri_security_context.cc -@@ -179,6 +179,13 @@ static void ModifyContainerNamespaceOptions(const runtime::v1alpha2::NamespaceOp - hostConfig->pid_mode = util_strdup_s(sandboxNSMode.c_str()); - } - -+ -+ if (nsOpts.pid() == runtime::v1alpha2::NamespaceMode::TARGET) { -+ std::string targetPidNsMode = "container:" + nsOpts.target_id(); -+ free(hostConfig->pid_mode); -+ hostConfig->pid_mode = util_strdup_s(targetPidNsMode.c_str()); -+ } -+ - /* set common Namespace options */ - ModifyCommonNamespaceOptions(nsOpts, hostConfig); - /* modify host network option for container */ --- -2.25.1 - diff --git a/0004-adapt-CI-ISULAD_TMPDIR-testcases.patch b/0004-adapt-CI-ISULAD_TMPDIR-testcases.patch deleted file mode 100644 index 6029b4e..0000000 --- a/0004-adapt-CI-ISULAD_TMPDIR-testcases.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 3a15d0174b16207915ab5736ee45f5018472b251 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Tue, 24 Nov 2020 14:51:57 +0800 -Subject: [PATCH 04/17] adapt CI ISULAD_TMPDIR testcases - -Signed-off-by: WangFengTu ---- - CI/test_cases/image_cases/isulad_tmpdir.sh | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/CI/test_cases/image_cases/isulad_tmpdir.sh b/CI/test_cases/image_cases/isulad_tmpdir.sh -index 22a6ad42..46849ae7 100644 ---- a/CI/test_cases/image_cases/isulad_tmpdir.sh -+++ b/CI/test_cases/image_cases/isulad_tmpdir.sh -@@ -58,8 +58,8 @@ function test_isulad_tmpdir() - export ISULAD_TMPDIR="/var/isula/tmp" - restart_isulad - load_pull_test -- test -d /var/isula/tmp/isula-image -- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isula-image not exist in ISULAD_TMPDIR" && ((ret++)) -+ test -d /var/isula/tmp/isulad_tmpdir -+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isulad_tmpdir not exist in ISULAD_TMPDIR" && ((ret++)) - - # The scene of ISULAD_TMPDIR dir is symbol link that it refers to dir exists - rm -rf /var/isula/tmp -@@ -69,8 +69,8 @@ function test_isulad_tmpdir() - export ISULAD_TMPDIR="/var/isula/tmpdir" - restart_isulad - load_pull_test -- test -d /var/isula/tmpdir/isula-image -- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isula-image not exist in ISULAD_TMPDIR" && ((ret++)) -+ test -d /var/isula/tmpdir/isulad_tmpdir -+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isulad_tmpdir not exist in ISULAD_TMPDIR" && ((ret++)) - - # rm dest dir of symbol link - rm -rf /var/tmpdir -@@ -86,8 +86,8 @@ function test_isulad_tmpdir() - [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - start isulad failed" && ((ret++)) - - load_pull_test -- test -d /var/tmp/isula-image -- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isula-image not exist in /var/tmp" && ((ret++)) -+ test -d /var/lib/isulad/isulad_tmpdir -+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isulad_tmpdir not exist in /var/lib/isulad" && ((ret++)) - - msg_info "${test} finished with return ${ret}..." - return ${ret} --- -2.25.1 - diff --git a/0005-listening-127.0.0.1-port-in-cri-stream-websocket-ser.patch b/0005-listening-127.0.0.1-port-in-cri-stream-websocket-ser.patch deleted file mode 100644 index 69e946a..0000000 --- a/0005-listening-127.0.0.1-port-in-cri-stream-websocket-ser.patch +++ /dev/null @@ -1,75 +0,0 @@ -From f3f2765e074a489ceeb2364fbb941a40d3232ff5 Mon Sep 17 00:00:00 2001 -From: wujing -Date: Tue, 24 Nov 2020 15:13:05 +0800 -Subject: [PATCH 05/17] listening 127.0.0.1:port in cri stream websocket server - -Signed-off-by: wujing ---- - src/daemon/entry/cri/websocket/service/ws_server.cc | 6 ++---- - .../modules/image/oci/storage/image_store/image_store.c | 8 ++++---- - 2 files changed, 6 insertions(+), 8 deletions(-) - -diff --git a/src/daemon/entry/cri/websocket/service/ws_server.cc b/src/daemon/entry/cri/websocket/service/ws_server.cc -index 43cecb88..735f2780 100644 ---- a/src/daemon/entry/cri/websocket/service/ws_server.cc -+++ b/src/daemon/entry/cri/websocket/service/ws_server.cc -@@ -106,12 +106,10 @@ void WebsocketServer::EmitLog(int level, const char *line) - - int WebsocketServer::CreateContext() - { -- unsigned int opts = 0; - int limited; - struct lws_context_creation_info info; - struct rlimit oldLimit, newLimit; - const size_t WS_ULIMIT_FDS = 1024; -- char interface[] = "127.0.0.1"; - - m_url.SetScheme("ws"); - m_url.SetHost("localhost:" + std::to_string(m_listenPort)); -@@ -120,13 +118,13 @@ int WebsocketServer::CreateContext() - lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG, WebsocketServer::EmitLog); - - info.port = m_listenPort; -- info.iface = interface; -+ info.iface = "127.0.0.1"; - info.protocols = m_protocols; - info.ssl_cert_filepath = nullptr; - info.ssl_private_key_filepath = nullptr; - info.gid = -1; - info.uid = -1; -- info.options = opts | LWS_SERVER_OPTION_VALIDATE_UTF8; -+ info.options = LWS_SERVER_OPTION_VALIDATE_UTF8 | LWS_SERVER_OPTION_DISABLE_IPV6; - info.max_http_header_pool = MAX_HTTP_HEADER_POOL; - info.extensions = nullptr; - -diff --git a/src/daemon/modules/image/oci/storage/image_store/image_store.c b/src/daemon/modules/image/oci/storage/image_store/image_store.c -index 0f613dd2..af8573ad 100644 ---- a/src/daemon/modules/image/oci/storage/image_store/image_store.c -+++ b/src/daemon/modules/image/oci/storage/image_store/image_store.c -@@ -59,8 +59,8 @@ - #define IMAGE_JSON "images.json" - - #define MAX_IMAGE_NAME_LENGTH 72 --#define DIGIST_PREFIX "@sha256:" --#define MAX_IMAGE_DIGST_LENGTH 64 -+#define DIGEST_PREFIX "@sha256:" -+#define MAX_IMAGE_DIGEST_LENGTH 64 - - typedef struct digest_image { - struct linked_list images_list; -@@ -2757,10 +2757,10 @@ static int resort_image_names(const char **names, size_t names_len, char **first - size_t len = strlen(names[i]); - if (strlen(names[i]) > MAX_IMAGE_NAME_LENGTH) { - prefix = util_sub_string(names[i], len - MAX_IMAGE_NAME_LENGTH, -- MAX_IMAGE_NAME_LENGTH - MAX_IMAGE_DIGST_LENGTH); -+ MAX_IMAGE_NAME_LENGTH - MAX_IMAGE_DIGEST_LENGTH); - } - -- if (prefix != NULL && strcmp(prefix, DIGIST_PREFIX) == 0) { -+ if (prefix != NULL && strcmp(prefix, DIGEST_PREFIX) == 0) { - if (util_array_append(image_digests, names[i]) != 0) { - ERROR("Failed to append image to digest: %s", names[i]); - ret = -1; --- -2.25.1 - diff --git a/0006-using-64-bit-unique-token-in-CRI-websockets-server-R.patch b/0006-using-64-bit-unique-token-in-CRI-websockets-server-R.patch deleted file mode 100644 index dee9543..0000000 --- a/0006-using-64-bit-unique-token-in-CRI-websockets-server-R.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 7b59f3cead750d00bafe406ab2150f3abd189acb Mon Sep 17 00:00:00 2001 -From: wujing -Date: Tue, 24 Nov 2020 17:09:08 +0800 -Subject: [PATCH 06/17] using 64 bit unique token in CRI websockets server - Request Cache - -Signed-off-by: wujing ---- - src/daemon/entry/cri/request_cache.cc | 10 ++++++---- - src/daemon/entry/cri/request_cache.h | 2 +- - 2 files changed, 7 insertions(+), 5 deletions(-) - -diff --git a/src/daemon/entry/cri/request_cache.cc b/src/daemon/entry/cri/request_cache.cc -index 5209bcaf..a3cb3771 100644 ---- a/src/daemon/entry/cri/request_cache.cc -+++ b/src/daemon/entry/cri/request_cache.cc -@@ -86,11 +86,13 @@ std::string RequestCache::UniqueToken() - std::default_random_engine e1(r()); - std::uniform_int_distribution uniform_dist(1, 254); - // Number of bytes to be TokenLen when base64 encoded. -- const int tokenSize { 16 }; -- char rawToken[tokenSize + 1] { 0 }; -+ const int tokenSize = ceil(static_cast(TokenLen) * 6 / 8); -+ char rawToken[tokenSize + 1]; -+ (void)memset(rawToken, 0, sizeof(rawToken)); - for (int i {}; i < maxTries; ++i) { -- char buf[40] { 0 }; -- for (size_t j {}; j < tokenSize; ++j) { -+ char buf[TokenLen + 1]; -+ (void)memset(buf, 0, sizeof(buf)); -+ for (int j {}; j < tokenSize; ++j) { - rawToken[j] = (char)uniform_dist(e1); - } - lws_b64_encode_string(rawToken, (int)strlen(rawToken), buf, (int)sizeof(buf)); -diff --git a/src/daemon/entry/cri/request_cache.h b/src/daemon/entry/cri/request_cache.h -index b0b7f491..024f3ba7 100644 ---- a/src/daemon/entry/cri/request_cache.h -+++ b/src/daemon/entry/cri/request_cache.h -@@ -52,7 +52,7 @@ private: - static std::mutex m_mutex; - static std::atomic m_instance; - const size_t MaxInFlight { 1000 }; -- const size_t TokenLen { 8 }; -+ const size_t TokenLen { 64 }; - }; - - #endif // DAEMON_ENTRY_CRI_REQUEST_CACHE_H --- -2.25.1 - diff --git a/0007-add-mock-conf_get_use_decrypted_key_flag-and-setup-a.patch b/0007-add-mock-conf_get_use_decrypted_key_flag-and-setup-a.patch deleted file mode 100644 index e1bddd2..0000000 --- a/0007-add-mock-conf_get_use_decrypted_key_flag-and-setup-a.patch +++ /dev/null @@ -1,56 +0,0 @@ -From c84953295a615da574aa1b42348a6f60105d5482 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Tue, 24 Nov 2020 20:00:42 +0800 -Subject: [PATCH 07/17] add mock conf_get_use_decrypted_key_flag and setup all - common mocks - -Signed-off-by: WangFengTu ---- - test/image/oci/registry/registry_ut.cc | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/test/image/oci/registry/registry_ut.cc b/test/image/oci/registry/registry_ut.cc -index 25ddf694..4b264424 100644 ---- a/test/image/oci/registry/registry_ut.cc -+++ b/test/image/oci/registry/registry_ut.cc -@@ -73,6 +73,8 @@ std::string get_dir() - return static_cast(abs_path) + "../../../../../test/image/oci/registry"; - } - -+void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladConf *isulad_conf_mock); -+ - class RegistryUnitTest : public testing::Test { - protected: - void SetUp() override -@@ -81,6 +83,7 @@ protected: - MockStorage_SetMock(&m_storage_mock); - MockOciImage_SetMock(&m_oci_image_mock); - MockIsuladConf_SetMock(&m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); - } - - void TearDown() override -@@ -507,6 +510,11 @@ static char *invokeConfGetISuladRootDir() - return util_strdup_s(get_dir().c_str()); - } - -+static bool invokeConfGetUseDecryptedKeyFlag() -+{ -+ return true; -+} -+ - void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladConf *isulad_conf_mock) - { - EXPECT_CALL(*mock, StorageImgCreate(::testing::_, ::testing::_, ::testing::_, ::testing::_)) -@@ -543,6 +551,8 @@ void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladCo - .WillRepeatedly(Invoke(invokeOciValidTime)); - EXPECT_CALL(*isulad_conf_mock, ConfGetISuladRootDir()) - .WillRepeatedly(Invoke(invokeConfGetISuladRootDir)); -+ EXPECT_CALL(*isulad_conf_mock, ConfGetUseDecryptedKeyFlag()) -+ .WillRepeatedly(Invoke(invokeConfGetUseDecryptedKeyFlag)); - return; - } - --- -2.25.1 - diff --git a/0008-show-all-mutl-network-ips.patch b/0008-show-all-mutl-network-ips.patch deleted file mode 100644 index 38719de..0000000 --- a/0008-show-all-mutl-network-ips.patch +++ /dev/null @@ -1,26 +0,0 @@ -From cd9d3524c53ee2090f6d3c8f079ad7905ca4bd41 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 26 Nov 2020 09:30:05 +0800 -Subject: [PATCH 08/17] show all mutl network ips - -Signed-off-by: haozi007 ---- - src/daemon/entry/cri/cri_sandbox.cc | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/daemon/entry/cri/cri_sandbox.cc b/src/daemon/entry/cri/cri_sandbox.cc -index b44c86c1..772638a1 100644 ---- a/src/daemon/entry/cri/cri_sandbox.cc -+++ b/src/daemon/entry/cri/cri_sandbox.cc -@@ -978,7 +978,7 @@ void CRIRuntimeServiceImpl::GetFormatIPsForMultNet(container_inspect *inspect, c - } - - for (size_t i = 0; i < len; i++) { -- if (elems[i]->interface == nullptr || strcmp(elems[i]->interface, defaultInterface.c_str()) == 0) { -+ if (elems[i]->interface == nullptr) { - continue; - } - Network::PodNetworkStatus status; --- -2.25.1 - diff --git a/0009-iSulad-only-qsort-the-configed-mounts.patch b/0009-iSulad-only-qsort-the-configed-mounts.patch deleted file mode 100644 index 980142b..0000000 --- a/0009-iSulad-only-qsort-the-configed-mounts.patch +++ /dev/null @@ -1,554 +0,0 @@ -From 25465336f77be1332c4536f90eb6ebd8edfd71de Mon Sep 17 00:00:00 2001 -From: lifeng68 -Date: Fri, 27 Nov 2020 11:29:58 +0800 -Subject: [PATCH 09/17] iSulad: only qsort the configed mounts - -Signed-off-by: lifeng68 ---- - src/daemon/entry/cri/cri_security_context.cc | 1 - - src/daemon/modules/spec/specs_mount.c | 216 ++++++++++--------- - 2 files changed, 114 insertions(+), 103 deletions(-) - -diff --git a/src/daemon/entry/cri/cri_security_context.cc b/src/daemon/entry/cri/cri_security_context.cc -index 1d332261..cf5b300e 100644 ---- a/src/daemon/entry/cri/cri_security_context.cc -+++ b/src/daemon/entry/cri/cri_security_context.cc -@@ -179,7 +179,6 @@ static void ModifyContainerNamespaceOptions(const runtime::v1alpha2::NamespaceOp - hostConfig->pid_mode = util_strdup_s(sandboxNSMode.c_str()); - } - -- - if (nsOpts.pid() == runtime::v1alpha2::NamespaceMode::TARGET) { - std::string targetPidNsMode = "container:" + nsOpts.target_id(); - free(hostConfig->pid_mode); -diff --git a/src/daemon/modules/spec/specs_mount.c b/src/daemon/modules/spec/specs_mount.c -index db7e4fd8..6099a918 100644 ---- a/src/daemon/modules/spec/specs_mount.c -+++ b/src/daemon/modules/spec/specs_mount.c -@@ -372,7 +372,8 @@ static defs_mount *mount_point_to_defs_mnt(container_config_v2_common_config_mou - ERROR("Out of memory"); - return NULL; - } -- mnt->options = util_common_calloc_s(sizeof(char *) * (options_len + 3)); // +2 for readonly/propagation/selinux_relabel -+ mnt->options = -+ util_common_calloc_s(sizeof(char *) * (options_len + 3)); // +2 for readonly/propagation/selinux_relabel - if (mnt->options == NULL) { - ERROR("Out of memory"); - ret = -1; -@@ -647,10 +648,10 @@ out: - return m; - } - --static defs_mount * parse_anonymous_volume(char *volume) -+static defs_mount *parse_anonymous_volume(char *volume) - { - int ret = 0; -- char path[PATH_MAX] = {0}; -+ char path[PATH_MAX] = { 0 }; - defs_mount *mount_element = NULL; - - if (!util_clean_path(volume, path, sizeof(path))) { -@@ -1378,17 +1379,12 @@ out: - } - #endif - --static int merge_fs_mounts_to_oci_and_spec(oci_runtime_spec *oci_spec, defs_mount **mounts, size_t mounts_len, -- container_config_v2_common_config *common_config) -+static int merge_fs_mounts_to_oci_spec(oci_runtime_spec *oci_spec, defs_mount **mounts, size_t mounts_len) - { - int ret = 0; - size_t new_size = 0, old_size = 0; -- size_t new_mp_key_size, new_mp_val_size, old_mp_key_size, old_mp_val_size; - size_t i = 0; -- char **mp_key = NULL; -- container_config_v2_common_config_mount_points_element **mp_val = NULL; - defs_mount **mounts_temp = NULL; -- struct volume *vol = NULL; - - if (mounts_len == 0) { - return 0; -@@ -1414,42 +1410,66 @@ static int merge_fs_mounts_to_oci_and_spec(oci_runtime_spec *oci_spec, defs_moun - } - oci_spec->mounts = mounts_temp; - -- if (common_config != NULL) { -- if (common_config->mount_points == NULL) { -- common_config->mount_points = util_common_calloc_s(sizeof(container_config_v2_common_config_mount_points)); -- if (common_config->mount_points == NULL) { -+ for (i = 0; i < mounts_len; i++) { -+ defs_mount *mnt = mounts[i]; -+ oci_spec->mounts[oci_spec->mounts_len] = mnt; -+ oci_spec->mounts_len++; -+ mounts[i] = NULL; -+ } -+ -+out: -+ return ret; -+} -+ -+static int merge_fs_mounts_to_v2_spec(defs_mount **mounts, size_t mounts_len, -+ container_config_v2_common_config *v2_spec) -+{ -+ int ret = 0; -+ size_t new_mp_key_size, new_mp_val_size, old_mp_key_size, old_mp_val_size; -+ size_t i = 0; -+ char **mp_key = NULL; -+ container_config_v2_common_config_mount_points_element **mp_val = NULL; -+ struct volume *vol = NULL; -+ -+ if (mounts_len == 0) { -+ return 0; -+ } -+ -+ if (v2_spec != NULL) { -+ if (v2_spec->mount_points == NULL) { -+ v2_spec->mount_points = util_common_calloc_s(sizeof(container_config_v2_common_config_mount_points)); -+ if (v2_spec->mount_points == NULL) { - ERROR("Out of memory"); - ret = -1; - goto out; - } - } -- new_mp_key_size = (common_config->mount_points->len + mounts_len) * sizeof(char *); -- old_mp_key_size = common_config->mount_points->len * sizeof(char *); -- new_mp_val_size = (common_config->mount_points->len + mounts_len) * -+ new_mp_key_size = (v2_spec->mount_points->len + mounts_len) * sizeof(char *); -+ old_mp_key_size = v2_spec->mount_points->len * sizeof(char *); -+ new_mp_val_size = (v2_spec->mount_points->len + mounts_len) * - sizeof(container_config_v2_common_config_mount_points_element *); -- old_mp_val_size = -- common_config->mount_points->len * sizeof(container_config_v2_common_config_mount_points_element *); -+ old_mp_val_size = v2_spec->mount_points->len * sizeof(container_config_v2_common_config_mount_points_element *); - -- ret = util_mem_realloc((void **)&mp_key, new_mp_key_size, common_config->mount_points->keys, old_mp_key_size); -+ ret = util_mem_realloc((void **)&mp_key, new_mp_key_size, v2_spec->mount_points->keys, old_mp_key_size); - if (ret != 0) { - ERROR("Failed to realloc memory mount point"); - ret = -1; - goto out; - } -- common_config->mount_points->keys = mp_key; -- ret = util_mem_realloc((void **)&mp_val, new_mp_val_size, common_config->mount_points->values, old_mp_val_size); -+ v2_spec->mount_points->keys = mp_key; -+ ret = util_mem_realloc((void **)&mp_val, new_mp_val_size, v2_spec->mount_points->values, old_mp_val_size); - if (ret != 0) { - ERROR("Failed to realloc memory mount point"); - ret = -1; - goto out; - } -- common_config->mount_points->values = mp_val; -+ v2_spec->mount_points->values = mp_val; - } - - for (i = 0; i < mounts_len; i++) { - defs_mount *mnt = mounts[i]; - if (strcmp(mnt->type, "volume") == 0) { -- struct volume_options opts = {.ref = common_config->id}; -+ struct volume_options opts = { .ref = v2_spec->id }; - // support local volume only currently. - vol = volume_create(VOLUME_DEFAULT_DRIVER_NAME, mnt->source, &opts); - if (vol == NULL) { -@@ -1461,8 +1481,8 @@ static int merge_fs_mounts_to_oci_and_spec(oci_runtime_spec *oci_spec, defs_moun - mnt->source = util_strdup_s(vol->path); - - #ifdef ENABLE_SELINUX -- if (oci_spec->linux != NULL) { -- ret = relabel_volume(vol, mnt, oci_spec->linux->mount_label); -+ if (v2_spec->mount_label != NULL) { -+ ret = relabel_volume(vol, mnt, v2_spec->mount_label); - if (ret != 0) { - ERROR("Failed to relabel volume"); - ret = -1; -@@ -1472,41 +1492,37 @@ static int merge_fs_mounts_to_oci_and_spec(oci_runtime_spec *oci_spec, defs_moun - #endif - } - -- if (common_config != NULL) { -- common_config->mount_points->values[common_config->mount_points->len] = defs_mnt_to_mount_point(mnt); -- if (common_config->mount_points->values[common_config->mount_points->len] == NULL) { -+ if (v2_spec != NULL) { -+ v2_spec->mount_points->values[v2_spec->mount_points->len] = defs_mnt_to_mount_point(mnt); -+ if (v2_spec->mount_points->values[v2_spec->mount_points->len] == NULL) { - ERROR("Failed to transform to mount point"); - ret = -1; - goto out; - } - if (vol != NULL) { -- common_config->mount_points->values[common_config->mount_points->len]->name = util_strdup_s(vol->name); -- common_config->mount_points->values[common_config->mount_points->len]->driver = util_strdup_s(vol->driver); -+ v2_spec->mount_points->values[v2_spec->mount_points->len]->name = util_strdup_s(vol->name); -+ v2_spec->mount_points->values[v2_spec->mount_points->len]->driver = util_strdup_s(vol->driver); - } -- common_config->mount_points->values[common_config->mount_points->len]->named = mnt->named; -- common_config->mount_points->keys[common_config->mount_points->len] = util_strdup_s(mnt->destination); -- common_config->mount_points->len++; -+ v2_spec->mount_points->values[v2_spec->mount_points->len]->named = mnt->named; -+ v2_spec->mount_points->keys[v2_spec->mount_points->len] = util_strdup_s(mnt->destination); -+ v2_spec->mount_points->len++; - } - - if (vol != NULL && !have_nocopy(mnt)) { - /* if mount point have data and it's mounted from volume, - * we need to copy data from destination mount point to volume */ -- ret = copy_data_to_volume(common_config->base_fs, mnt); -+ ret = copy_data_to_volume(v2_spec->base_fs, mnt); - if (ret != 0) { - ERROR("Failed to copy data to volume"); - goto out; - } - } - -- // mount -t have no type volume, use bind in oci spec -+ // mount -t have no type volume, trans volume to bind - if (strcmp(mnt->type, "volume") == 0) { - free(mnt->type); - mnt->type = util_strdup_s("bind"); - } -- oci_spec->mounts[oci_spec->mounts_len] = mnt; -- oci_spec->mounts_len++; -- mounts[i] = NULL; -- - free_volume(vol); - vol = NULL; - } -@@ -2137,39 +2153,36 @@ out: - return ret; - } - --static bool mounts_expand(oci_runtime_spec *container, size_t add_len) -+static bool mounts_expand(defs_mount ***all_mounts, size_t *all_mounts_len, size_t add_len) - { - defs_mount **tmp_mount = NULL; - int ret = 0; -- size_t old_len = container->mounts_len; -+ defs_mount **old_mount = *all_mounts; -+ size_t old_len = *all_mounts_len; -+ - if (add_len > SIZE_MAX / sizeof(defs_mount *) - old_len) { - ERROR("Too many mount elements!"); - return false; - } -- ret = util_mem_realloc((void **)&tmp_mount, (old_len + add_len) * sizeof(defs_mount *), container->mounts, -+ ret = util_mem_realloc((void **)&tmp_mount, (old_len + add_len) * sizeof(defs_mount *), old_mount, - old_len * sizeof(defs_mount *)); - if (ret < 0) { - ERROR("memory realloc failed for mount array expand"); - return false; - } -- container->mounts = tmp_mount; -- container->mounts_len = old_len + add_len; -+ *all_mounts = tmp_mount; -+ *all_mounts_len = old_len + add_len; - - return true; - } - --static bool mount_file(oci_runtime_spec *container, const char *src_path, const char *dst_path) -+static bool mount_file(defs_mount ***all_mounts, size_t *all_mounts_len, const char *src_path, const char *dst_path) - { - char **options = NULL; - size_t options_len = 2; - bool ret = false; - defs_mount *tmp_mounts = NULL; - -- /* mount options */ -- if (options_len > SIZE_MAX / sizeof(char *)) { -- ERROR("Options len is too long!"); -- goto out_free; -- } - options = util_common_calloc_s(options_len * sizeof(char *)); - if (options == NULL) { - ERROR("Out of memory"); -@@ -2192,11 +2205,12 @@ static bool mount_file(oci_runtime_spec *container, const char *src_path, const - options = NULL; - - /* expand mount array */ -- if (!mounts_expand(container, 1)) { -+ if (!mounts_expand(all_mounts, all_mounts_len, 1)) { - goto out_free; - } -+ - /* add a new mount node */ -- container->mounts[container->mounts_len - 1] = tmp_mounts; -+ (*all_mounts)[(*all_mounts_len) - 1] = tmp_mounts; - - ret = true; - out_free: -@@ -2208,17 +2222,14 @@ out_free: - return ret; - } - --static bool add_host_channel_mount(oci_runtime_spec *container, const host_config_host_channel *host_channel) -+static bool add_host_channel_mount(defs_mount ***all_mounts, size_t *all_mounts_len, -+ const host_config_host_channel *host_channel) - { - char **options = NULL; - size_t options_len = 3; - bool ret = false; - defs_mount *tmp_mounts = NULL; - -- if (options_len > SIZE_MAX / sizeof(char *)) { -- ERROR("Invalid option size"); -- return ret; -- } - options = util_common_calloc_s(options_len * sizeof(char *)); - if (options == NULL) { - ERROR("Out of memory"); -@@ -2242,15 +2253,14 @@ static bool add_host_channel_mount(oci_runtime_spec *container, const host_confi - options = NULL; - - /* expand mount array */ -- if (!mounts_expand(container, 1)) { -+ if (!mounts_expand(all_mounts, all_mounts_len, 1)) { - goto out_free; - } -- /* add a new mount node */ -- container->mounts[container->mounts_len - 1] = tmp_mounts; -+ -+ (*all_mounts)[(*all_mounts_len) - 1] = tmp_mounts; - - ret = true; - out_free: -- - if (!ret) { - util_free_array_by_len(options, options_len); - free_defs_mount(tmp_mounts); -@@ -2319,7 +2329,7 @@ static inline bool is_mount_destination_hostname(const char *destination) - * if not exists: append mounts to ocispec by v2_spec - * if exists: replace the source in v2_spec - */ --static int append_network_files_mounts(oci_runtime_spec *oci_spec, host_config *host_spec, -+static int append_network_files_mounts(defs_mount ***all_mounts, size_t *all_mounts_len, host_config *host_spec, - container_config_v2_common_config *v2_spec) - { - int ret = 0; -@@ -2327,25 +2337,27 @@ static int append_network_files_mounts(oci_runtime_spec *oci_spec, host_config * - bool has_hosts_mount = false; - bool has_resolv_mount = false; - bool has_hostname_mount = false; -+ defs_mount **old_mounts = *all_mounts; -+ size_t old_mounts_len = *all_mounts_len; - #ifdef ENABLE_SELINUX - bool share = namespace_is_container(host_spec->network_mode); - #endif - -- for (i = 0; i < oci_spec->mounts_len; i++) { -- if (is_mount_destination_hosts(oci_spec->mounts[i]->destination)) { -+ for (i = 0; i < old_mounts_len; i++) { -+ if (is_mount_destination_hosts(old_mounts[i]->destination)) { - has_hosts_mount = true; - free(v2_spec->hosts_path); -- v2_spec->hosts_path = util_strdup_s(oci_spec->mounts[i]->source); -+ v2_spec->hosts_path = util_strdup_s(old_mounts[i]->source); - } -- if (is_mount_destination_resolv(oci_spec->mounts[i]->destination)) { -+ if (is_mount_destination_resolv(old_mounts[i]->destination)) { - has_resolv_mount = true; - free(v2_spec->resolv_conf_path); -- v2_spec->resolv_conf_path = util_strdup_s(oci_spec->mounts[i]->source); -+ v2_spec->resolv_conf_path = util_strdup_s(old_mounts[i]->source); - } -- if (is_mount_destination_hostname(oci_spec->mounts[i]->destination)) { -+ if (is_mount_destination_hostname(old_mounts[i]->destination)) { - has_hostname_mount = true; - free(v2_spec->hostname_path); -- v2_spec->hostname_path = util_strdup_s(oci_spec->mounts[i]->source); -+ v2_spec->hostname_path = util_strdup_s(old_mounts[i]->source); - } - } - -@@ -2361,7 +2373,7 @@ static int append_network_files_mounts(oci_runtime_spec *oci_spec, host_config * - goto out; - } - #endif -- if (!mount_file(oci_spec, v2_spec->hosts_path, ETC_HOSTS)) { -+ if (!mount_file(all_mounts, all_mounts_len, v2_spec->hosts_path, ETC_HOSTS)) { - ERROR("Merge hosts mount failed"); - ret = -1; - goto out; -@@ -2379,7 +2391,7 @@ static int append_network_files_mounts(oci_runtime_spec *oci_spec, host_config * - goto out; - } - #endif -- if (!mount_file(oci_spec, v2_spec->resolv_conf_path, RESOLV_CONF_PATH)) { -+ if (!mount_file(all_mounts, all_mounts_len, v2_spec->resolv_conf_path, RESOLV_CONF_PATH)) { - ERROR("Merge resolv.conf mount failed"); - ret = -1; - goto out; -@@ -2397,7 +2409,7 @@ static int append_network_files_mounts(oci_runtime_spec *oci_spec, host_config * - return -1; - } - #endif -- if (!mount_file(oci_spec, v2_spec->hostname_path, ETC_HOSTNAME)) { -+ if (!mount_file(all_mounts, all_mounts_len, v2_spec->hostname_path, ETC_HOSTNAME)) { - ERROR("Merge hostname mount failed"); - ret = -1; - goto out; -@@ -2497,8 +2509,7 @@ out: - return ret; - } - --static int prepare_share_shm(oci_runtime_spec *oci_spec, host_config *host_spec, -- container_config_v2_common_config *v2_spec) -+static int prepare_share_shm(host_config *host_spec, container_config_v2_common_config *v2_spec) - { - #define MAX_PROPERTY_LEN 64 - char shmproperty[MAX_PROPERTY_LEN] = { 0 }; -@@ -2551,17 +2562,13 @@ out: - return ret; - } - --static bool add_shm_mount(oci_runtime_spec *container, const char *shm_path) -+static bool add_shm_mount(defs_mount ***all_mounts, size_t *all_mounts_len, const char *shm_path) - { - char **options = NULL; - size_t options_len = 3; - bool ret = false; - defs_mount *tmp_mounts = NULL; - -- if (options_len > SIZE_MAX / sizeof(char *)) { -- ERROR("Invalid option size"); -- return ret; -- } - options = util_common_calloc_s(options_len * sizeof(char *)); - if (options == NULL) { - ERROR("Out of memory"); -@@ -2586,11 +2593,11 @@ static bool add_shm_mount(oci_runtime_spec *container, const char *shm_path) - options = NULL; - - /* expand mount array */ -- if (!mounts_expand(container, 1)) { -+ if (!mounts_expand(all_mounts, all_mounts_len, 1)) { - goto out_free; - } -- /* add a new mount node */ -- container->mounts[container->mounts_len - 1] = tmp_mounts; -+ -+ (*all_mounts)[(*all_mounts_len) - 1] = tmp_mounts; - - ret = true; - out_free: -@@ -2603,8 +2610,7 @@ out_free: - } - - #define SHM_MOUNT_POINT "/dev/shm" --static int setup_ipc_dirs(oci_runtime_spec *oci_spec, host_config *host_spec, -- container_config_v2_common_config *v2_spec) -+static int setup_ipc_dirs(host_config *host_spec, container_config_v2_common_config *v2_spec) - { - int ret = 0; - container_t *cont = NULL; -@@ -2617,7 +2623,7 @@ static int setup_ipc_dirs(oci_runtime_spec *oci_spec, host_config *host_spec, - } - // setup shareable dirs - if (host_spec->ipc_mode == NULL || namespace_is_shareable(host_spec->ipc_mode)) { -- return prepare_share_shm(oci_spec, host_spec, v2_spec); -+ return prepare_share_shm(host_spec, v2_spec); - } - - if (namespace_is_container(host_spec->ipc_mode)) { -@@ -2654,7 +2660,7 @@ int destination_compare(const void *p1, const void *p2) - return strcmp(mount_1->destination, mount_2->destination); - } - --static defs_mount * get_conflict_mount_point(defs_mount **mounts, size_t mounts_len, defs_mount *mnt) -+static defs_mount *get_conflict_mount_point(defs_mount **mounts, size_t mounts_len, defs_mount *mnt) - { - size_t i = 0; - -@@ -2832,7 +2838,7 @@ static int add_image_config_volumes(container_config *container_spec, defs_mount - defs_mount *mnt = NULL; - defs_mount *conflict = NULL; - -- for (i = 0; container_spec->volumes != 0 && i < container_spec->volumes->len; i++) { -+ for (i = 0; container_spec->volumes != 0 && i < container_spec->volumes->len; i++) { - mnt = parse_anonymous_volume(container_spec->volumes->keys[i]); - if (mnt == NULL) { - ERROR("parse binds %s failed", container_spec->volumes->keys[i]); -@@ -2863,8 +2869,8 @@ out: - // 2. if --volumes-from conflict with -v/--mount, drop the mount of --volumes-from - // 3. if anonymous volumes in image config conflict with -v/--mount/--volumes-from, - // drop the anonymous volumes in image config --static int merge_all_fs_mounts(host_config *host_spec, container_config *container_spec, -- defs_mount ***all_mounts, size_t *all_mounts_len) -+static int merge_all_fs_mounts(host_config *host_spec, container_config *container_spec, defs_mount ***all_mounts, -+ size_t *all_mounts_len) - { - int ret = 0; - defs_mount **merged_mounts = NULL; -@@ -2943,9 +2949,9 @@ int merge_conf_mounts(oci_runtime_spec *oci_spec, host_config *host_spec, contai - } - - /* mounts to mount filesystem */ -- ret = merge_fs_mounts_to_oci_and_spec(oci_spec, all_fs_mounts, all_fs_mounts_len, v2_spec); -+ ret = merge_fs_mounts_to_v2_spec(all_fs_mounts, all_fs_mounts_len, v2_spec); - if (ret) { -- ERROR("Failed to merge mounts"); -+ ERROR("Failed to merge mounts in to v2 spec"); - goto out; - } - -@@ -2954,7 +2960,7 @@ int merge_conf_mounts(oci_runtime_spec *oci_spec, host_config *host_spec, contai - - /* host channel to mount */ - if (host_spec->host_channel != NULL) { -- if (!add_host_channel_mount(oci_spec, host_spec->host_channel)) { -+ if (!add_host_channel_mount(&all_fs_mounts, &all_fs_mounts_len, host_spec->host_channel)) { - ERROR("Failed to merge host channel mount"); - goto out; - } -@@ -2965,7 +2971,7 @@ int merge_conf_mounts(oci_runtime_spec *oci_spec, host_config *host_spec, contai - } - - /* setup ipc dir */ -- if (setup_ipc_dirs(oci_spec, host_spec, v2_spec) != 0) { -+ if (setup_ipc_dirs(host_spec, v2_spec) != 0) { - ret = -1; - goto out; - } -@@ -2973,27 +2979,33 @@ int merge_conf_mounts(oci_runtime_spec *oci_spec, host_config *host_spec, contai - /* add ipc mount */ - if (v2_spec->shm_path != NULL) { - // check whether duplication -- add_shm_mount(oci_spec, v2_spec->shm_path); -+ add_shm_mount(&all_fs_mounts, &all_fs_mounts_len, v2_spec->shm_path); - } - -- if (!has_mount_shm(host_spec, v2_spec) && host_spec->shm_size > 0) { -- ret = change_dev_shm_size(oci_spec, host_spec); -+ if (!host_spec->system_container) { -+ ret = append_network_files_mounts(&all_fs_mounts, &all_fs_mounts_len, host_spec, v2_spec); - if (ret) { -- ERROR("Failed to set dev shm size"); -+ ERROR("Failed to append network mounts"); - goto out; - } - } - -- if (!host_spec->system_container) { -- ret = append_network_files_mounts(oci_spec, host_spec, v2_spec); -+ qsort(all_fs_mounts, all_fs_mounts_len, sizeof(all_fs_mounts[0]), destination_compare); -+ -+ ret = merge_fs_mounts_to_oci_spec(oci_spec, all_fs_mounts, all_fs_mounts_len); -+ if (ret) { -+ ERROR("Failed to merge all mounts in to oci spec"); -+ goto out; -+ } -+ -+ if (!has_mount_shm(host_spec, v2_spec) && host_spec->shm_size > 0) { -+ ret = change_dev_shm_size(oci_spec, host_spec); - if (ret) { -- ERROR("Failed to append network mounts"); -+ ERROR("Failed to set dev shm size"); - goto out; - } - } - -- qsort(oci_spec->mounts, oci_spec->mounts_len, sizeof(oci_spec->mounts[0]), destination_compare); -- - out: - if (mounted) { - (void)im_umount_container_rootfs(v2_spec->image_type, v2_spec->image, v2_spec->id); --- -2.25.1 - diff --git a/0010-CI-add-testcases-for-bind-proc-and-sys-fs.patch b/0010-CI-add-testcases-for-bind-proc-and-sys-fs.patch deleted file mode 100644 index a7919da..0000000 --- a/0010-CI-add-testcases-for-bind-proc-and-sys-fs.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 9ad5a2da26efc2a1a15564ddbb72059a1142ec85 Mon Sep 17 00:00:00 2001 -From: lifeng68 -Date: Fri, 27 Nov 2020 16:57:00 +0800 -Subject: [PATCH 10/17] CI: add testcases for bind /proc and /sys/fs - -Signed-off-by: lifeng68 ---- - .../container_cases/bind_special_dir.sh | 56 +++++++++++++++++++ - 1 file changed, 56 insertions(+) - create mode 100644 CI/test_cases/container_cases/bind_special_dir.sh - -diff --git a/CI/test_cases/container_cases/bind_special_dir.sh b/CI/test_cases/container_cases/bind_special_dir.sh -new file mode 100644 -index 00000000..0e61e348 ---- /dev/null -+++ b/CI/test_cases/container_cases/bind_special_dir.sh -@@ -0,0 +1,56 @@ -+#!/bin/bash -+# -+# attributes: isulad bind special directory -+# concurrent: NA -+# spend time: 5 -+ -+####################################################################### -+##- @Copyright (C) Huawei Technologies., Ltd. 2020. 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: lifeng -+##- @Create: 2020-11-27 -+####################################################################### -+ -+declare -r curr_path=$(dirname $(readlink -f "$0")) -+source ../helpers.sh -+ -+function test_bind_special_dir() -+{ -+ local ret=0 -+ local image="busybox" -+ local test="container bind special directory test => (${FUNCNAME[@]})" -+ -+ msg_info "${test} starting..." -+ -+ 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++)) -+ -+ c_id=`isula run -itd -v -itd -v /sys/fs:/sys/fs:rw,rshared -v /proc:/proc -v /dev:/dev:ro -v /dev/pts:/dev/pts:rw busybox sh` -+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to run container with image: ${image}" && ((ret++)) -+ -+ isula exec -it $c_id sh -c "ls -al /sys/fs" | grep "cgroup" -+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to check container with image: ${image}" && ((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} -+} -+ -+declare -i ans=0 -+ -+test_bind_special_dir || ((ans++)) -+ -+show_result ${ans} "${curr_path}/${0}" --- -2.25.1 - diff --git a/0011-verify-peer-if-it-s-secure-registry.patch b/0011-verify-peer-if-it-s-secure-registry.patch deleted file mode 100644 index aaf9c53..0000000 --- a/0011-verify-peer-if-it-s-secure-registry.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 1f8f03ebc44a763a7686eda8cbf6341b9c057a6f Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Sat, 28 Nov 2020 10:45:59 +0800 -Subject: [PATCH 11/17] verify peer if it's secure registry - -we verify peer only when CA file is provided before, -now we verify peer if it's secure registry - -Signed-off-by: WangFengTu ---- - src/daemon/modules/image/oci/registry/http_request.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/daemon/modules/image/oci/registry/http_request.c b/src/daemon/modules/image/oci/registry/http_request.c -index 60644ed5..fb44a7b6 100644 ---- a/src/daemon/modules/image/oci/registry/http_request.c -+++ b/src/daemon/modules/image/oci/registry/http_request.c -@@ -118,7 +118,7 @@ static int setup_ssl_config(pull_descriptor *desc, struct http_get_options *opti - } - } - -- if (options->ca_file != NULL) { -+ if (!desc->insecure_registry) { - options->ssl_verify_peer = true; - } - --- -2.25.1 - diff --git a/0012-make-sure-all-certs-load-success-if-any-provided.patch b/0012-make-sure-all-certs-load-success-if-any-provided.patch deleted file mode 100644 index 6a80d7d..0000000 --- a/0012-make-sure-all-certs-load-success-if-any-provided.patch +++ /dev/null @@ -1,239 +0,0 @@ -From a242455ecf86e4766ecb8989f8a5c62059c02e7c Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Sat, 28 Nov 2020 11:37:09 +0800 -Subject: [PATCH 12/17] make sure all certs load success if any provided - -Signed-off-by: WangFengTu ---- - src/daemon/modules/image/oci/registry/certs.c | 161 ++++++++++++++++-- - 1 file changed, 149 insertions(+), 12 deletions(-) - -diff --git a/src/daemon/modules/image/oci/registry/certs.c b/src/daemon/modules/image/oci/registry/certs.c -index 6574d2bf..f9ef63c9 100644 ---- a/src/daemon/modules/image/oci/registry/certs.c -+++ b/src/daemon/modules/image/oci/registry/certs.c -@@ -26,9 +26,11 @@ - #include "utils.h" - #include "utils_file.h" - #include "utils_string.h" -+#include "err_msg.h" - - #define DEFAULT_ISULAD_CERTD "/etc/isulad/certs.d" - #define CLIENT_CERT_SUFFIX ".cert" -+#define CLIENT_KEY_SUFFIX ".key" - #define CA_SUFFIX ".crt" - - static char *g_certs_dir = DEFAULT_ISULAD_CERTD; -@@ -68,18 +70,117 @@ static char *corresponding_key_name(const char *cert_name) - return key_name; - } - -+static char *corresponding_cert_name(const char *key_name) -+{ -+ char cert_name[PATH_MAX] = {0}; -+ char *tmp_key_name = NULL; -+ int sret = 0; -+ -+ if (key_name == NULL) { -+ ERROR("Invalid NULL pointer"); -+ return NULL; -+ } -+ -+ if (strlen(key_name) <= strlen(CLIENT_KEY_SUFFIX)) { -+ ERROR("Invalid key name too short"); -+ return NULL; -+ } -+ -+ tmp_key_name = util_strdup_s(key_name); -+ tmp_key_name[strlen(tmp_key_name) - strlen(CLIENT_KEY_SUFFIX)] = 0; // strip suffix .key -+ -+ sret = snprintf(cert_name, sizeof(cert_name), "%s.cert", tmp_key_name); -+ if (sret < 0 || (size_t)sret >= sizeof(cert_name)) { -+ ERROR("Failed to sprintf cert name"); -+ free(tmp_key_name); -+ return NULL; -+ } -+ -+ return util_strdup_s(cert_name); -+} -+ -+static int get_path_by_cert_name(const char *path, const char *cert_name, char **cert_path, char **key_path) -+{ -+ int ret = 0; -+ char *key_name = NULL; -+ char *tmp_key_path = NULL; -+ char *tmp_cert_path = NULL; -+ -+ key_name = corresponding_key_name(cert_name); -+ if (key_name == NULL) { -+ ERROR("find corresponding key name for cert failed"); -+ ret = -1; -+ goto out; -+ } -+ tmp_key_path = util_path_join(path, key_name); -+ tmp_cert_path = util_path_join(path, cert_name); -+ if (tmp_cert_path == NULL || tmp_key_path == NULL) { -+ ret = -1; -+ ERROR("error join path"); -+ goto out; -+ } -+ -+ *cert_path = util_strdup_s(tmp_cert_path); -+ *key_path = util_strdup_s(tmp_key_path); -+ -+out: -+ free(key_name); -+ free(tmp_cert_path); -+ free(tmp_key_path); -+ -+ return ret; -+} -+ -+static int get_path_by_key_name(const char *path, const char *key_name, char **cert_path, char **key_path) -+{ -+ int ret = 0; -+ char *cert_name = NULL; -+ char *tmp_key_path = NULL; -+ char *tmp_cert_path = NULL; -+ -+ cert_name = corresponding_cert_name(key_name); -+ if (cert_name == NULL) { -+ ERROR("find corresponding key name for cert failed"); -+ ret = -1; -+ goto out; -+ } -+ tmp_key_path = util_path_join(path, key_name); -+ tmp_cert_path = util_path_join(path, cert_name); -+ if (tmp_cert_path == NULL || tmp_key_path == NULL) { -+ ret = -1; -+ ERROR("error join path"); -+ goto out; -+ } -+ -+ *cert_path = util_strdup_s(tmp_cert_path); -+ *key_path = util_strdup_s(tmp_key_path); -+ -+out: -+ free(cert_name); -+ free(tmp_cert_path); -+ free(tmp_key_path); -+ -+ return ret; -+} -+ - static int load_certs(const char *path, const char *name, bool use_decrypted_key, char **ca_file, char **cert_file, - char **key_file) - { - int ret = 0; - char *key_name = NULL; -+ char *tmp_key_file = NULL; -+ char *tmp_cert_file = NULL; - -- if (path == NULL || ca_file == NULL || cert_file == NULL || key_file == NULL) { -+ if (path == NULL || ca_file == NULL || cert_file == NULL || key_file == NULL || name == NULL) { - ERROR("Invalid NULL pointer"); - return -1; - } - -- if (*ca_file == NULL && util_has_suffix(name, CA_SUFFIX)) { -+ if (util_has_suffix(name, CA_SUFFIX)) { -+ if (*ca_file != NULL) { -+ ERROR("more than one ca file found, support only one ca file currently, continue to try"); -+ goto out; -+ } - *ca_file = util_path_join(path, name); - if (*ca_file == NULL) { - ret = -1; -@@ -87,20 +188,43 @@ static int load_certs(const char *path, const char *name, bool use_decrypted_key - goto out; - } - goto out; -- } else if (*cert_file == NULL && *key_file == NULL && util_has_suffix(name, CLIENT_CERT_SUFFIX)) { -- key_name = corresponding_key_name(name); -- if (key_name == NULL) { -- ERROR("find corresponding key name for cert failed"); -+ } else if (util_has_suffix(name, CLIENT_CERT_SUFFIX)) { -+ ret = get_path_by_cert_name(path, name, &tmp_cert_file, &tmp_key_file); -+ if (ret != 0) { -+ ERROR("get path of cert and key by cert name failed"); -+ isulad_try_set_error_message("get path of cert and key by cert name failed"); -+ goto out; -+ } -+ if (!util_file_exists(tmp_key_file)) { - ret = -1; -+ ERROR("lack corresponding key file for tls cert"); -+ isulad_try_set_error_message("lack corresponding key file for tls cert"); - goto out; - } -- *key_file = util_path_join(path, key_name); -- *cert_file = util_path_join(path, name); -- if (*cert_file == NULL || *key_file == NULL) { -+ if (*cert_file != NULL) { -+ ERROR("more than one cert file found, support only one cert file currently, continue to try"); -+ goto out; -+ } -+ *cert_file = util_strdup_s(tmp_cert_file); -+ goto out; -+ } else if (util_has_suffix(name, CLIENT_KEY_SUFFIX)) { -+ ret = get_path_by_key_name(path, name, &tmp_cert_file, &tmp_key_file); -+ if (ret != 0) { -+ ERROR("get path of cert and key by key name failed"); -+ isulad_try_set_error_message("get path of cert and key by key name failed"); -+ goto out; -+ } -+ if (!util_file_exists(tmp_cert_file)) { - ret = -1; -- ERROR("error join key name"); -+ ERROR("lack corresponding cert file for tls key"); -+ isulad_try_set_error_message("lack corresponding cert file for tls key"); -+ goto out; -+ } -+ if (*key_file != NULL) { -+ ERROR("more than one key file found, support only one key file currently, continue to try"); - goto out; - } -+ *key_file = util_strdup_s(tmp_key_file); - goto out; - } else { - goto out; -@@ -109,6 +233,8 @@ static int load_certs(const char *path, const char *name, bool use_decrypted_key - out: - free(key_name); - key_name = NULL; -+ free(tmp_cert_file); -+ free(tmp_key_file); - - if (ret != 0) { - free(*ca_file); -@@ -122,6 +248,15 @@ out: - return ret; - } - -+static bool valid_certs(char *ca_file, char *cert_file, char *key_file) -+{ -+ if ((ca_file == NULL && cert_file == NULL && key_file == NULL) || -+ (ca_file != NULL && cert_file != NULL && key_file != NULL)) { -+ return true; -+ } -+ return false; -+} -+ - int certs_load(char *host, bool use_decrypted_key, char **ca_file, char **cert_file, char **key_file) - { - int ret = 0; -@@ -170,8 +305,10 @@ int certs_load(char *host, bool use_decrypted_key, char **ca_file, char **cert_f - entry = readdir(dir); - } - -- if (*ca_file == NULL || *cert_file == NULL || *key_file == NULL) { -- ERROR("Loaded only part of certs, continue to try"); -+ if (!valid_certs(*ca_file, *cert_file, *key_file)) { -+ ERROR("failed to load all certs"); -+ isulad_try_set_error_message("failed to load all certs"); -+ ret = -1; - } - - out: --- -2.25.1 - diff --git a/0013-add-ch-docs-for-install-iSulad.patch b/0013-add-ch-docs-for-install-iSulad.patch deleted file mode 100644 index 4a9a4d2..0000000 --- a/0013-add-ch-docs-for-install-iSulad.patch +++ /dev/null @@ -1,305 +0,0 @@ -From da5ab167ebc5765c91630846cd0850acd6ce8814 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 26 Nov 2020 14:58:05 +0800 -Subject: [PATCH 13/17] add ch docs for install iSulad - -Signed-off-by: haozi007 ---- - README.md | 7 ++ - docs/build_guide.md | 22 +++--- - docs/build_guide_zh.md | 164 +++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 182 insertions(+), 11 deletions(-) - create mode 100644 docs/build_guide_zh.md - -diff --git a/README.md b/README.md -index 9b34d615..1dd3cf1a 100644 ---- a/README.md -+++ b/README.md -@@ -4,9 +4,16 @@ - - `iSulad` is a lightweight container runtime daemon which is designed for IOT and Cloud infrastructure.`iSulad` has the characteristics of light, fast and not limited by hardware specifications and architecture, and can be applied more widely. - -+## Documentation -+ -+- [en build guide](./docs/build_guide.md) -+- [cn build guide](./docs/build_guide_zh.md) -+- [more usage guide](https://openeuler.org/zh/docs/20.09/docs/Container/iSula%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8E.html) -+ - ## Getting Started - - ### Installing -+ - To install iSulad, you can use `rpm` or `yum` package manager command with `openEuler` repository. - - Or write repository file by hand: -diff --git a/docs/build_guide.md b/docs/build_guide.md -index 912139fa..2ee12c39 100644 ---- a/docs/build_guide.md -+++ b/docs/build_guide.md -@@ -7,12 +7,12 @@ If you intend to contribute on iSulad. Thanks for your effort. Every contributio - These dependencies are required for build: - - ### install basic dependencies based on Centos distribution --```sh -+```bash - $ sudo yum --enablerepo='*' install -y automake autoconf libtool cmake make libcap libcap-devel libselinux libselinux-devel libseccomp libseccomp-devel yajl-devel git libcgroup tar python3 python3-pip device-mapper-devel libarchive libarchive-devel libcurl-devel zlib-devel glibc-headers openssl-devel gcc gcc-c++ systemd-devel systemd-libs golang libtar libtar-devel - ``` - - ### install basic dependencies based on Ubuntu distribution --```sh -+```bash - $ sudo apt install -y libtool automake autoconf cmake make pkg-config libyajl-dev zlib1g-dev libselinux-dev libseccomp-dev libcap-dev libsystemd-dev git libcurl4-gnutls-dev openssl libdevmapper-dev golang python3 libtar libtar-dev - ``` - -@@ -24,13 +24,13 @@ Please use the protobuf and grpc came with your distribution, if not exists then - Note: grpc-1.22 can not support GCC 9+. - - ### set ldconfig and pkgconfig --``` -+```bash - $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH - $ export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH - $ sudo -E echo "/usr/local/lib" >> /etc/ld.so.conf - ``` - ### build and install protobuf --``` -+```bash - $ git clone https://gitee.com/src-openeuler/protobuf.git - $ cd protobuf - $ git checkout openEuler-20.03-LTS-tag -@@ -44,7 +44,7 @@ $ sudo -E ldconfig - ``` - - ### build and install c-ares --``` -+```bash - $ git clone https://gitee.com/src-openeuler/c-ares.git - $ cd c-ares - $ git checkout openEuler-20.03-LTS-tag -@@ -58,7 +58,7 @@ $ sudo -E ldconfig - ``` - - ### build and install grpc --``` -+```bash - $ git clone https://gitee.com/src-openeuler/grpc.git - $ cd grpc - $ git checkout openEuler-20.03-LTS-tag -@@ -70,7 +70,7 @@ $ sudo -E ldconfig - ``` - - ### build and install http-parser --``` -+```bash - $ git clone https://gitee.com/src-openeuler/http-parser.git - $ cd http-parser - $ git checkout openEuler-20.03-LTS-tag -@@ -82,7 +82,7 @@ $ sudo -E ldconfig - ``` - - ### build and install libwebsockets --``` -+```bash - $ git clone https://gitee.com/src-openeuler/libwebsockets.git - $ cd libwebsockets - $ git checkout openEuler-20.03-LTS-tag -@@ -101,7 +101,7 @@ $ sudo -E ldconfig - iSulad depend on some specific versions dependencies. - - ### build and install lxc --``` -+```bash - $ git clone https://gitee.com/src-openeuler/lxc.git - $ cd lxc - $ tar -zxf lxc-4.0.3.tar.gz -@@ -114,7 +114,7 @@ $ sudo -E make install - ``` - - ### build and install lcr --``` -+```bash - $ git clone https://gitee.com/openeuler/lcr.git - $ cd lcr - $ mkdir build -@@ -125,7 +125,7 @@ $ sudo -E make install - ``` - - ### build and install clibcni --``` -+```bash - $ git clone https://gitee.com/openeuler/clibcni.git - $ cd clibcni - $ mkdir build -diff --git a/docs/build_guide_zh.md b/docs/build_guide_zh.md -new file mode 100644 -index 00000000..182d6fec ---- /dev/null -+++ b/docs/build_guide_zh.md -@@ -0,0 +1,164 @@ -+# 源码编译iSulad -+ -+我们感谢为iSulad做的任何贡献。 -+ -+## 各发行版本的基本依赖安装 -+ -+这些依赖是编译依赖的基础组件: -+ -+### openEuler的安装命令 -+ -+openEuler可以直接通过编译依赖自动安装的方式(其他rpm的发行版本也可以参考,但是存在部分包名不一致的情况),具体如下: -+ -+```bash -+dnf builddep iSulad.spec -+``` -+ -+注:iSulad.spec直接用源码中的文件即可。 -+ -+### Centos的安装命令 -+ -+```bash -+$ sudo yum --enablerepo='*' install -y automake autoconf libtool cmake make libcap libcap-devel libselinux libselinux-devel libseccomp libseccomp-devel yajl-devel git libcgroup tar python3 python3-pip device-mapper-devel libarchive libarchive-devel libcurl-devel zlib-devel glibc-headers openssl-devel gcc gcc-c++ systemd-devel systemd-libs libtar libtar-devel -+``` -+ -+### Ubuntu的安装命令 -+```bash -+$ sudo apt install -y libtool automake autoconf cmake make pkg-config libyajl-dev zlib1g-dev libselinux-dev libseccomp-dev libcap-dev libsystemd-dev git libcurl4-gnutls-dev openssl libdevmapper-dev python3 libtar libtar-dev -+``` -+ -+## 从源码构建和安装关键依赖 -+下面的依赖组件,你的包管理中可能不存在,或者版本不满足要求。因此,需要从源码编译安装。protobuf和grpc建议直接通过包管理安装,除非没有或者版本太老。 -+ -+***注意:grpc-1.22不支持GCC 9+。*** -+ -+### 设置ldconfig和pkgconfig的路径 -+ -+编译安装的默认路径为`/usr/local/lib/`,因此需要把该路径添加到`PKG_CONFIG_PATH`和`LD_LIBRARY_PATH`,从而系统能找到我们编译安装的软件包和lib库。如果安装的`/usr/lib/`,可以忽略这一步。 -+ -+```bash -+$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH -+$ export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH -+$ sudo -E echo "/usr/local/lib" >> /etc/ld.so.conf -+``` -+### 编译安装protobuf -+```bash -+$ git clone https://gitee.com/src-openeuler/protobuf.git -+$ cd protobuf -+$ git checkout openEuler-20.03-LTS-tag -+$ tar -xzvf protobuf-all-3.9.0.tar.gz -+$ cd protobuf-3.9.0 -+$ sudo -E ./autogen.sh -+$ sudo -E ./configure -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+$ sudo -E ldconfig -+``` -+ -+### 编译安装c-ares -+```bash -+$ git clone https://gitee.com/src-openeuler/c-ares.git -+$ cd c-ares -+$ git checkout openEuler-20.03-LTS-tag -+$ tar -xzvf c-ares-1.15.0.tar.gz -+$ cd c-ares-1.15.0 -+$ sudo -E autoreconf -if -+$ sudo -E ./configure --enable-shared --disable-dependency-tracking -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+$ sudo -E ldconfig -+``` -+ -+### 编译安装grpc -+```bash -+$ git clone https://gitee.com/src-openeuler/grpc.git -+$ cd grpc -+$ git checkout openEuler-20.03-LTS-tag -+$ tar -xzvf grpc-1.22.0.tar.gz -+$ cd grpc-1.22.0 -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+$ sudo -E ldconfig -+``` -+ -+### 编译安装http-parser -+```bash -+$ git clone https://gitee.com/src-openeuler/http-parser.git -+$ cd http-parser -+$ git checkout openEuler-20.03-LTS-tag -+$ tar -xzvf http-parser-2.9.2.tar.gz -+$ cd http-parser-2.9.2 -+$ sudo -E make -j CFLAGS="-Wno-error" -+$ sudo -E make CFLAGS="-Wno-error" install -+$ sudo -E ldconfig -+``` -+ -+### 编译安装libwebsockets -+```bash -+$ git clone https://gitee.com/src-openeuler/libwebsockets.git -+$ cd libwebsockets -+$ git checkout openEuler-20.03-LTS-tag -+$ tar -xzvf libwebsockets-2.4.2.tar.gz -+$ cd libwebsockets-2.4.2 -+$ patch -p1 -F1 -s < ../libwebsockets-fix-coredump.patch -+$ mkdir build -+$ cd build -+$ sudo -E cmake -DLWS_WITH_SSL=0 -DLWS_MAX_SMP=32 -DCMAKE_BUILD_TYPE=Debug ../ -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+$ sudo -E ldconfig -+``` -+ -+## 编译安装特定依赖版本 -+iSulad依赖一些特定版本的组件,由于各组件是通过函数接口使用,因此,**必须保证各组件版本一致**。例如: -+ -+- 统一使用各组件的master分支的代码进行构建; -+- 后续的releases版本会增加依赖的组件的版本号; -+- 也统一可以从[openEuler](https://openeuler.org/zh/download/)的特定OS版本,通过包管理工具获取各组件的`src.rpm`包的方式获取源码; -+- 也可以到[src-openeuler](https://gitee.com/src-openeuler)社区获取各组件相同分支的代码; -+ -+### 编译安装lxc -+```bash -+$ git clone https://gitee.com/src-openeuler/lxc.git -+$ cd lxc -+$ tar -zxf lxc-4.0.3.tar.gz -+$ ./apply-patches -+$ cd lxc-4.0.3 -+$ sudo -E ./autogen.sh -+$ sudo -E ./configure -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+``` -+ -+### 编译安装lcr -+```bash -+$ git clone https://gitee.com/openeuler/lcr.git -+$ cd lcr -+$ mkdir build -+$ cd build -+$ sudo -E cmake .. -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+``` -+ -+### 编译安装clibcni -+```bash -+$ git clone https://gitee.com/openeuler/clibcni.git -+$ cd clibcni -+$ mkdir build -+$ cd build -+$ sudo -E cmake .. -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+``` -+ -+### 编译安装iSulad -+```bash -+$ git clone https://gitee.com/openeuler/iSulad.git -+$ cd iSulad -+$ mkdir build -+$ cd build -+$ sudo -E cmake .. -+$ sudo -E make -j $(nproc) -+$ sudo -E make install -+``` --- -2.25.1 - diff --git a/0014-error-out-if-unpack-layer-failed.patch b/0014-error-out-if-unpack-layer-failed.patch deleted file mode 100644 index cafa9cf..0000000 --- a/0014-error-out-if-unpack-layer-failed.patch +++ /dev/null @@ -1,34 +0,0 @@ -From ff793d00c408810e2f434800fa3811f5ba2501a7 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Thu, 3 Dec 2020 10:32:57 +0800 -Subject: [PATCH 14/17] error out if unpack layer failed - -Signed-off-by: WangFengTu ---- - .../modules/image/oci/storage/layer_store/layer_store.c | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c -index 704dbd63..87e49d07 100644 ---- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c -+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c -@@ -1061,14 +1061,13 @@ static int apply_diff(layer_t *l, const struct io_read_wrapper *diff) - { - int64_t size = 0; - int ret = 0; -- int nret = 0; - - if (diff == NULL) { - return 0; - } - -- nret = graphdriver_apply_diff(l->slayer->id, diff); -- if (nret != 0) { -+ ret = graphdriver_apply_diff(l->slayer->id, diff); -+ if (ret != 0) { - goto out; - } - --- -2.25.1 - diff --git a/0015-ignore-get-ip-error-for-mutlnetwork.patch b/0015-ignore-get-ip-error-for-mutlnetwork.patch deleted file mode 100644 index c51ddde..0000000 --- a/0015-ignore-get-ip-error-for-mutlnetwork.patch +++ /dev/null @@ -1,27 +0,0 @@ -From b0b1bc36bf4672ce45c0dd2be877083894b62350 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 3 Dec 2020 15:44:27 +0800 -Subject: [PATCH 15/17] ignore get ip error for mutlnetwork - -Signed-off-by: haozi007 ---- - src/daemon/entry/cri/cri_sandbox.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/daemon/entry/cri/cri_sandbox.cc b/src/daemon/entry/cri/cri_sandbox.cc -index 772638a1..2d623097 100644 ---- a/src/daemon/entry/cri/cri_sandbox.cc -+++ b/src/daemon/entry/cri/cri_sandbox.cc -@@ -985,7 +985,8 @@ void CRIRuntimeServiceImpl::GetFormatIPsForMultNet(container_inspect *inspect, c - m_pluginManager->GetPodNetworkStatus(metadata.namespace_(), metadata.name(), elems[i]->interface, inspect->id, status, - error); - if (error.NotEmpty()) { -- goto out; -+ WARN("get status for network: %s failed: %s", elems[i]->name, error.GetCMessage()); -+ error.Clear(); - } - // add a sentry to make ips of mutlnetwork store from position 2 - if (result.size() < 2) { --- -2.25.1 - diff --git a/0016-support-default-container-log-options.patch b/0016-support-default-container-log-options.patch deleted file mode 100644 index 4980c12..0000000 --- a/0016-support-default-container-log-options.patch +++ /dev/null @@ -1,1303 +0,0 @@ -From f4c5700bcf82bacc85e4e25b7afe94d65d3e54f4 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Sat, 14 Nov 2020 18:44:08 +0800 -Subject: [PATCH 16/17] support default container log options - -Signed-off-by: haozi007 ---- - src/cmd/isula/base/create.c | 141 +-------- - src/cmd/isula/client_arguments.c | 1 - - src/cmd/isulad/isulad_commands.c | 84 ++++++ - src/cmd/isulad/isulad_commands.h | 38 ++- - src/cmd/isulad/main.c | 73 +++++ - src/cmd/options/opt_log.c | 276 ++++++++++++++++++ - src/cmd/options/opt_log.h | 39 +++ - src/common/constants.h | 4 + - src/contrib/config/daemon.json | 3 + - src/daemon/config/daemon_arguments.c | 12 +- - src/daemon/config/daemon_arguments.h | 54 ++-- - src/daemon/config/isulad_config.c | 84 +++++- - src/daemon/config/isulad_config.h | 2 + - .../executor/container_cb/execution_create.c | 150 +++++++--- - .../modules/service/service_container.c | 1 + - 15 files changed, 750 insertions(+), 212 deletions(-) - create mode 100644 src/cmd/options/opt_log.c - create mode 100644 src/cmd/options/opt_log.h - -diff --git a/src/cmd/isula/base/create.c b/src/cmd/isula/base/create.c -index a79b18b9..87c1086b 100644 ---- a/src/cmd/isula/base/create.c -+++ b/src/cmd/isula/base/create.c -@@ -38,6 +38,7 @@ - #include "pull.h" - #include "constants.h" - #include "connect.h" -+#include "opt_log.h" - - #include "utils_array.h" - #include "utils_convert.h" -@@ -1348,120 +1349,6 @@ static int add_new_annotation(const char *key, const char *value, struct client_ - return 0; - } - --typedef int (*log_opt_callback_t)(const char *key, const char *value, struct client_arguments *args); -- --typedef struct log_opt_parse { -- const char *key; -- const char *anno_key; -- log_opt_callback_t cb; --} log_opt_parse_t; -- --static int log_opt_common_cb(const char *key, const char *value, struct client_arguments *args) --{ -- return add_new_annotation(key, value, args); --} -- --static int log_opt_max_file_cb(const char *key, const char *value, struct client_arguments *args) --{ -- unsigned int ptr = 0; -- int ret = -1; -- -- if (util_safe_uint(value, &ptr)) { -- return ret; -- } -- if (ptr == 0) { -- COMMAND_ERROR("Invalid option 'max-file', value:%s", value); -- return ret; -- } -- -- return add_new_annotation(key, value, args); --} -- --static int log_opt_syslog_facility(const char *key, const char *value, struct client_arguments *args) --{ --#define FACILITIES_LEN 20 -- const char *facility_keys[FACILITIES_LEN] = { "kern", "user", "mail", "daemon", "auth", -- "syslog", "lpr", "news", "uucp", "cron", -- "authpriv", "ftp", "local0", "local1", "local2", -- "local3", "local4", "local5", "local6", "local7" -- }; -- int i; -- -- for (i = 0; i < FACILITIES_LEN; i++) { -- if (strcmp(facility_keys[i], value) == 0) { -- break; -- } -- } -- -- if (i == FACILITIES_LEN) { -- return -1; -- } -- -- return add_new_annotation(key, value, args); --} -- --static int log_opt_disable_log_cb(const char *key, const char *value, struct client_arguments *args) --{ -- int ret = -1; -- -- if (strcmp(value, "true") == 0) { -- ret = add_new_annotation(key, "none", args); -- } else if (strcmp(value, "false") == 0) { -- ret = 0; -- } else { -- COMMAND_ERROR("Invalid option 'disable-log', value:%s", value); -- } -- -- return ret; --} -- --static int log_opt_parse_options(struct client_arguments *args, const char *optkey, const char *value) --{ --#define OPTIONS_MAX 5 -- log_opt_parse_t log_opts[OPTIONS_MAX] = { -- { -- .key = "max-size", -- .anno_key = CONTAINER_LOG_CONFIG_KEY_SIZE, -- .cb = &log_opt_common_cb, -- }, -- { -- .key = "max-file", -- .anno_key = CONTAINER_LOG_CONFIG_KEY_ROTATE, -- .cb = &log_opt_max_file_cb, -- }, -- { -- .key = "disable-log", -- .anno_key = CONTAINER_LOG_CONFIG_KEY_FILE, -- .cb = &log_opt_disable_log_cb, -- }, -- { -- .key = "syslog-tag", -- .anno_key = CONTAINER_LOG_CONFIG_KEY_SYSLOG_TAG, -- .cb = &log_opt_common_cb, -- }, -- { -- .key = "syslog-facility", -- .anno_key = CONTAINER_LOG_CONFIG_KEY_SYSLOG_FACILITY, -- .cb = &log_opt_syslog_facility, -- }, -- }; -- int ret = -1; -- int i; -- -- for (i = 0; i < OPTIONS_MAX; i++) { -- if (strcmp(optkey, log_opts[i].key) == 0) { -- ret = log_opts[i].cb(log_opts[i].anno_key, value, args); -- break; -- } -- } -- -- if (i == OPTIONS_MAX) { -- COMMAND_ERROR("Unsupported log opt: %s", optkey); -- } -- -- return ret; --} -- - int log_opt_parser(struct client_arguments *args, const char *option) - { - int ret = -1; -@@ -1504,10 +1391,22 @@ int log_opt_parser(struct client_arguments *args, const char *option) - tmp[len] = '\0'; - value += 1; - -- ret = log_opt_parse_options(args, optkey, value); -+ if (args->annotations == NULL) { -+ args->annotations = util_common_calloc_s(sizeof(json_map_string_string)); -+ if (args->annotations == NULL) { -+ COMMAND_ERROR("Out of Memory"); -+ goto out; -+ } -+ } - -+ if (!parse_container_log_opt(optkey, value, args->annotations)) { -+ ret = -1; -+ goto out; -+ } -+ -+ ret = 0; - out: -- if (ret < 0) { -+ if (ret != 0) { - COMMAND_ERROR("Invalid option: %s", option); - } - free(tmp); -@@ -1523,21 +1422,13 @@ int callback_log_opt(command_option_t *option, const char *value) - - int callback_log_driver(command_option_t *option, const char *value) - { --#define DRIVER_MAX 2 -- const char *drivers[] = { CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER, CONTAINER_LOG_CONFIG_SYSLOG_DRIVER }; -- int i = 0; - struct client_arguments *args = (struct client_arguments *)option->data; - - if (value == NULL) { - return -1; - } - -- for (; i < DRIVER_MAX; i++) { -- if (strcmp(value, drivers[i]) == 0) { -- break; -- } -- } -- if (i == DRIVER_MAX) { -+ if (!check_opt_container_log_driver(value)) { - return -1; - } - -diff --git a/src/cmd/isula/client_arguments.c b/src/cmd/isula/client_arguments.c -index ad6ba40c..ffe40c2e 100644 ---- a/src/cmd/isula/client_arguments.c -+++ b/src/cmd/isula/client_arguments.c -@@ -123,7 +123,6 @@ int client_arguments_init(struct client_arguments *args) - } else { - args->socket = util_strdup_s(DEFAULT_UNIX_SOCKET); - } -- args->log_driver = util_strdup_s("json-file"); - - (void)memset(&args->custom_conf, 0, sizeof(struct custom_configs)); - (void)memset(&args->cr, 0, sizeof(struct args_cgroup_resources)); -diff --git a/src/cmd/isulad/isulad_commands.c b/src/cmd/isulad/isulad_commands.c -index 11e166fc..d0ab029c 100644 ---- a/src/cmd/isulad/isulad_commands.c -+++ b/src/cmd/isulad/isulad_commands.c -@@ -32,6 +32,7 @@ - #include "utils_string.h" - #include "utils_verify.h" - #include "opt_ulimit.h" -+#include "opt_log.h" - - const char isulad_desc[] = "GLOBAL OPTIONS:"; - const char isulad_usage[] = "[global options]"; -@@ -103,6 +104,89 @@ out: - return ret; - } - -+int server_callback_container_log_driver(command_option_t *option, const char *value) -+{ -+ int ret = 0; -+ struct service_arguments *args = NULL; -+ -+ if (option == NULL || value == NULL) { -+ COMMAND_ERROR("Invalid input arguments"); -+ ret = -1; -+ goto out; -+ } -+ if (!check_opt_container_log_driver(value)) { -+ ret = -1; -+ goto out; -+ } -+ -+ args = (struct service_arguments *)option->data; -+ -+ free(args->json_confs->container_log->driver); -+ args->json_confs->container_log->driver = util_strdup_s(value); -+ -+out: -+ return ret; -+} -+ -+int server_callback_container_log(command_option_t *option, const char *value) -+{ -+ int ret = 0; -+ struct service_arguments *args = NULL; -+ json_map_string_string *log_opts = NULL; -+ char **split_opts = NULL; -+ size_t i; -+ -+ if (option == NULL || value == NULL) { -+ COMMAND_ERROR("Invalid input arguments"); -+ ret = -1; -+ goto out; -+ } -+ split_opts = util_string_split_multi(value, '='); -+ // value must be format of 'key = value' -+ if (util_array_len((const char **)split_opts) != 2) { -+ COMMAND_ERROR("Invalid input arguments: %s", value); -+ ret = -1; -+ goto out; -+ } -+ -+ if (!check_raw_log_opt(split_opts[0])) { -+ COMMAND_ERROR("Unsupport container log key: %s", split_opts[0]); -+ ret = -1; -+ goto out; -+ } -+ -+ args = (struct service_arguments *)option->data; -+ if (args->json_confs->container_log->opts == NULL) { -+ args->json_confs->container_log->opts = util_common_calloc_s(sizeof(json_map_string_string)); -+ } -+ log_opts = args->json_confs->container_log->opts; -+ if (log_opts == NULL) { -+ COMMAND_ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ -+ for (i = 0; i < log_opts->len; i++) { -+ // just update found key-value -+ if (strcmp(split_opts[0], log_opts->keys[i]) == 0) { -+ free(log_opts->values[i]); -+ log_opts->values[i] = util_strdup_s(split_opts[1]); -+ goto out; -+ } -+ } -+ -+ ret = append_json_map_string_string(log_opts, split_opts[0], split_opts[1]); -+ if (ret != 0) { -+ COMMAND_ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ -+out: -+ util_free_array(split_opts); -+ return ret; -+} -+ - static void command_init_isulad(command_t *self, command_option_t *options, int options_len, int argc, - const char **argv, const char *description, const char *usage) - { -diff --git a/src/cmd/isulad/isulad_commands.h b/src/cmd/isulad/isulad_commands.h -index 78ec5846..02007f3c 100644 ---- a/src/cmd/isulad/isulad_commands.h -+++ b/src/cmd/isulad/isulad_commands.h -@@ -37,14 +37,14 @@ int update_hosts(struct service_arguments *args); - int update_default_ulimit(struct service_arguments *args); - int command_default_ulimit_append(command_option_t *option, const char *arg); - --#define ISULAD_OPTIONS(cmdargs) \ -- { CMD_OPT_TYPE_CALLBACK, \ -- false, \ -- "host", \ -- 'H', \ -- &(cmdargs)->hosts, \ -- "The socket name used to create gRPC server", \ -- command_valid_socket_append_array }, \ -+#define ISULAD_OPTIONS(cmdargs) \ -+ { CMD_OPT_TYPE_CALLBACK, \ -+ false, \ -+ "host", \ -+ 'H', \ -+ &(cmdargs)->hosts, \ -+ "The socket name used to create gRPC server", \ -+ command_valid_socket_append_array }, \ - { CMD_OPT_TYPE_STRING_DUP, false, "pidfile", 'p', &(cmdargs)->json_confs->pidfile, \ - "Save pid into this file", NULL }, \ - { CMD_OPT_TYPE_BOOL, false, "help", 0, &(cmdargs)->help, "Show help", NULL }, \ -@@ -99,13 +99,27 @@ int command_default_ulimit_append(command_option_t *option, const char *arg); - (cmdargs), \ - "Set daemon log driver options, such as: log-path=/tmp/logs/ to set directory where to store daemon logs", \ - server_callback_log_opt }, \ -+ { CMD_OPT_TYPE_CALLBACK, \ -+ false, \ -+ "container-log-driver", \ -+ 0, \ -+ (cmdargs), \ -+ "Set default container log driver, such as: json-file", \ -+ server_callback_container_log_driver }, \ -+ { CMD_OPT_TYPE_CALLBACK, \ -+ false, \ -+ "container-log-opts", \ -+ 0, \ -+ (cmdargs), \ -+ "Set default container log driver options, such as: max-file=7 to set max number of container log files", \ -+ server_callback_container_log }, \ - { CMD_OPT_TYPE_BOOL, false, "version", 'V', &(cmdargs)->version, "Print the version", NULL }, \ - { CMD_OPT_TYPE_STRING_DUP, \ - false, \ - "group", \ - 'G', \ - &(cmdargs)->json_confs->group, \ -- "Group for the unix socket(default is isula)", \ -+ "Group for the unix socket(default is isula)", \ - NULL }, \ - { CMD_OPT_TYPE_STRING_DUP, \ - false, \ -@@ -249,9 +263,9 @@ int command_default_ulimit_append(command_option_t *option, const char *arg); - &(cmdargs)->json_confs->websocket_server_listening_port, \ - "CRI websocket streaming service listening port (default 10350)", \ - command_convert_uint }, \ -- { \ -- CMD_OPT_TYPE_BOOL, false, "selinux-enabled", 0, &(cmdargs)->json_confs->selinux_enabled, \ -- "Enable selinux support", NULL \ -+ { CMD_OPT_TYPE_BOOL, \ -+ false, "selinux-enabled", 0, &(cmdargs)->json_confs->selinux_enabled, \ -+ "Enable selinux support", NULL \ - } - - #ifdef __cplusplus -diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c -index bef78f87..ce93eaa0 100644 ---- a/src/cmd/isulad/main.c -+++ b/src/cmd/isulad/main.c -@@ -70,6 +70,7 @@ - #include "utils_string.h" - #include "utils_verify.h" - #include "volume_api.h" -+#include "opt_log.h" - - #ifdef GRPC_CONNECTOR - #include "clibcni/api.h" -@@ -836,6 +837,73 @@ static int configure_kernel_security_support(const struct service_arguments *arg - } - #endif - -+static int use_default_log_opts_for_json_file(bool rotate_found, bool size_found, -+ isulad_daemon_configs_container_log *conf) -+{ -+ int nret = 0; -+ -+ if (conf->opts == NULL) { -+ conf->opts = util_common_calloc_s(sizeof(json_map_string_string)); -+ } -+ if (conf->opts == NULL) { -+ ERROR("Out of memory"); -+ return -1; -+ } -+ -+ if (!rotate_found) { -+ nret = append_json_map_string_string(conf->opts, CONTAINER_LOG_CONFIG_KEY_ROTATE, "7"); -+ if (nret != 0) { -+ ERROR("Out of memory"); -+ return -1; -+ } -+ } -+ -+ if (!size_found) { -+ nret = append_json_map_string_string(conf->opts, CONTAINER_LOG_CONFIG_KEY_SIZE, "1MB"); -+ if (nret != 0) { -+ ERROR("Out of memory"); -+ return -1; -+ } -+ } -+ -+ return 0; -+} -+ -+static int update_container_log_configs(isulad_daemon_configs_container_log *conf) -+{ -+ bool rotate_found = false; -+ bool size_found = false; -+ size_t i; -+ -+ if (conf->driver == NULL) { -+ conf->driver = util_strdup_s(CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER); -+ } -+ -+ if (!parse_container_log_opts(&conf->opts)) { -+ return -1; -+ } -+ -+ /* validate daemon container log configs */ -+ for (i = 0; conf->opts != NULL && i < conf->opts->len; i++) { -+ if (!check_opt_container_log_opt(conf->driver, conf->opts->keys[i])) { -+ return -1; -+ } -+ -+ if (strcmp(CONTAINER_LOG_CONFIG_KEY_ROTATE, conf->opts->keys[i]) == 0) { -+ rotate_found = true; -+ } else if (strcmp(CONTAINER_LOG_CONFIG_KEY_SIZE, conf->opts->keys[i]) == 0) { -+ size_found = true; -+ } -+ } -+ -+ // set default log opts for json file driver -+ if (strcmp(conf->driver, CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER) == 0) { -+ return use_default_log_opts_for_json_file(rotate_found, size_found, conf); -+ } -+ -+ return 0; -+} -+ - static int update_server_args(struct service_arguments *args) - { - int ret = 0; -@@ -860,6 +928,11 @@ static int update_server_args(struct service_arguments *args) - goto out; - } - -+ if (update_container_log_configs(args->json_confs->container_log) != 0) { -+ ret = -1; -+ goto out; -+ } -+ - /* check args */ - if (check_args(args)) { - ret = -1; -diff --git a/src/cmd/options/opt_log.c b/src/cmd/options/opt_log.c -new file mode 100644 -index 00000000..f6c18b23 ---- /dev/null -+++ b/src/cmd/options/opt_log.c -@@ -0,0 +1,276 @@ -+/****************************************************************************** -+ * Copyright (c) Huawei Technologies Co., Ltd. 2020. 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. -+ * Author: haozi007 -+ * Create: 2020-11-16 -+ * Description: provide log options parse function -+ ******************************************************************************/ -+#include "opt_log.h" -+ -+#include -+#include -+#include -+ -+#include -+ -+#include "constants.h" -+#include "utils.h" -+#include "utils_array.h" -+#include "utils_convert.h" -+#include "utils_string.h" -+ -+#define DRIVER_MAX 2 -+ -+typedef int (*log_opt_callback_t)(const char *key, const char *value, char **parsed_val); -+ -+typedef struct log_opt_parse { -+ const char *key; -+ const char *real_key; -+ log_opt_callback_t cb; -+} log_opt_parse_t; -+ -+static int log_opt_common_cb(const char *key, const char *value, char **parsed_val) -+{ -+ *parsed_val = util_strdup_s(value); -+ return 0; -+} -+ -+static int log_opt_max_file_cb(const char *key, const char *value, char **parsed_val) -+{ -+ unsigned int ptr = 0; -+ int ret = -1; -+ -+ if (util_safe_uint(value, &ptr)) { -+ return ret; -+ } -+ if (ptr == 0) { -+ ERROR("Invalid option 'max-file', value:%s", value); -+ return ret; -+ } -+ -+ *parsed_val = util_strdup_s(value); -+ return 0; -+} -+ -+static int log_opt_syslog_facility(const char *key, const char *value, char **parsed_val) -+{ -+ const char *facility_values[] = { "kern", "user", "mail", "daemon", "auth", -+ "syslog", "lpr", "news", "uucp", "cron", -+ "authpriv", "ftp", "local0", "local1", "local2", -+ "local3", "local4", "local5", "local6", "local7" -+ }; -+ int i; -+ size_t f_len = sizeof(facility_values) / sizeof(const char *); -+ -+ for (i = 0; i < f_len; i++) { -+ if (strcmp(facility_values[i], value) == 0) { -+ break; -+ } -+ } -+ -+ if (i == f_len) { -+ ERROR("Invalid option 'syslog-facility', value:%s", value); -+ return -1; -+ } -+ -+ *parsed_val = util_strdup_s(value); -+ return 0; -+} -+ -+static int log_opt_disable_log_cb(const char *key, const char *value, char **parsed_val) -+{ -+ int ret = -1; -+ -+ if (strcmp(value, "true") == 0) { -+ *parsed_val = util_strdup_s("none"); -+ ret = 0; -+ } else if (strcmp(value, "false") == 0) { -+ ret = 0; -+ } -+ -+ if (ret != 0) { -+ ERROR("Invalid option 'disable-log', value:%s", value); -+ } -+ -+ return ret; -+} -+ -+bool parse_container_log_opt(const char *key, const char *val, json_map_string_string *opts) -+{ -+#define LOG_PARSER_MAX 5 -+ size_t i, j; -+ log_opt_parse_t support_parsers[LOG_PARSER_MAX] = { -+ { -+ .key = "max-size", -+ .real_key = CONTAINER_LOG_CONFIG_KEY_SIZE, -+ .cb = &log_opt_common_cb, -+ }, -+ { -+ .key = "max-file", -+ .real_key = CONTAINER_LOG_CONFIG_KEY_ROTATE, -+ .cb = &log_opt_max_file_cb, -+ }, -+ { -+ .key = "disable-log", -+ .real_key = CONTAINER_LOG_CONFIG_KEY_FILE, -+ .cb = &log_opt_disable_log_cb, -+ }, -+ { -+ .key = "syslog-tag", -+ .real_key = CONTAINER_LOG_CONFIG_KEY_SYSLOG_TAG, -+ .cb = &log_opt_common_cb, -+ }, -+ { -+ .key = "syslog-facility", -+ .real_key = CONTAINER_LOG_CONFIG_KEY_SYSLOG_FACILITY, -+ .cb = &log_opt_syslog_facility, -+ }, -+ }; -+ -+ if (key == NULL || opts == NULL) { -+ return false; -+ } -+ -+ for (i = 0; i < LOG_PARSER_MAX; i++) { -+ if (strcmp(key, support_parsers[i].key) == 0) { -+ char *parsed_val = NULL; -+ int nret; -+ -+ nret = support_parsers[i].cb(support_parsers[i].real_key, val, &parsed_val); -+ if (nret != 0) { -+ return false; -+ } -+ if (parsed_val == NULL) { -+ return true; -+ } -+ -+ // check whether seted option, if setted, ust replace -+ for (j = 0; j < opts->len; j++) { -+ if (strcmp(opts->keys[j], support_parsers[i].real_key) == 0) { -+ free(opts->values[j]); -+ opts->values[j] = parsed_val; -+ return true; -+ } -+ } -+ nret = append_json_map_string_string(opts, support_parsers[i].real_key, parsed_val); -+ return true; -+ } -+ } -+ ERROR("Unknow log opts: %s = %s", key, val); -+ return false; -+} -+ -+bool parse_container_log_opts(json_map_string_string **opts) -+{ -+ size_t i; -+ json_map_string_string *result = NULL; -+ -+ if (opts == NULL || *opts == NULL) { -+ return true; -+ } -+ result = util_common_calloc_s(sizeof(json_map_string_string)); -+ if (result == NULL) { -+ ERROR("Out of memory"); -+ return false; -+ } -+ -+ for (i = 0; i < (*opts)->len; i++) { -+ if ((*opts)->values[i] == NULL || strlen((*opts)->values[i]) > OPT_MAX_LEN) { -+ ERROR("Too large value: %s for key:%s", (*opts)->values[i], (*opts)->keys[i]); -+ free_json_map_string_string(result); -+ return false; -+ } -+ -+ if (!parse_container_log_opt((*opts)->keys[i], (*opts)->values[i], result)) { -+ free_json_map_string_string(result); -+ return false; -+ } -+ } -+ -+ free_json_map_string_string(*opts); -+ *opts = result; -+ return true; -+} -+ -+bool check_opt_container_log_opt(const char *driver, const char *opt_key) -+{ -+#define DRIVER_MAX 2 -+#define MAX_SUPPORT_KEY_LEN 3 -+ const char *support_keys[][MAX_SUPPORT_KEY_LEN] = { -+ { CONTAINER_LOG_CONFIG_KEY_FILE, CONTAINER_LOG_CONFIG_KEY_ROTATE, CONTAINER_LOG_CONFIG_KEY_SIZE }, -+ { CONTAINER_LOG_CONFIG_KEY_SYSLOG_TAG, CONTAINER_LOG_CONFIG_KEY_SYSLOG_FACILITY, NULL} -+ }; -+ const char *driver_idx[] = { CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER, CONTAINER_LOG_CONFIG_SYSLOG_DRIVER }; -+ size_t i, idx; -+ -+ if (driver == NULL || opt_key == NULL) { -+ return false; -+ } -+ for (idx = 0; idx < DRIVER_MAX; idx++) { -+ if (strcmp(driver_idx[idx], driver) == 0) { -+ break; -+ } -+ } -+ if (idx == DRIVER_MAX) { -+ ERROR("Unsupport driver: %s", driver); -+ return false; -+ } -+ -+ for (i = 0; i < MAX_SUPPORT_KEY_LEN; i++) { -+ if (support_keys[idx][i] == NULL) { -+ break; -+ } -+ if (strcmp(support_keys[idx][i], opt_key) == 0) { -+ return true; -+ } -+ } -+ -+ ERROR("driver: %s, unsupport opts: %s", driver, opt_key); -+ return false; -+} -+ -+bool check_raw_log_opt(const char *key) -+{ -+ size_t i; -+ const char *support_keys[] = { -+ "max-size", "max-file", "disable-log", "syslog-tag", "syslog-facility" -+ }; -+ -+ if (key == NULL) { -+ return false; -+ } -+ -+ for (i = 0; i < sizeof(support_keys) / sizeof(const char *); i++) { -+ if (strcmp(key, support_keys[i]) == 0) { -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -+bool check_opt_container_log_driver(const char *driver) -+{ -+ const char *supported_drivers[] = { CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER, CONTAINER_LOG_CONFIG_SYSLOG_DRIVER }; -+ int i = 0; -+ -+ if (driver == NULL) { -+ return false; -+ } -+ -+ for (; i < DRIVER_MAX; i++) { -+ if (strcmp(driver, supported_drivers[i]) == 0) { -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -diff --git a/src/cmd/options/opt_log.h b/src/cmd/options/opt_log.h -new file mode 100644 -index 00000000..f9daa02d ---- /dev/null -+++ b/src/cmd/options/opt_log.h -@@ -0,0 +1,39 @@ -+/****************************************************************************** -+ * Copyright (c) Huawei Technologies Co., Ltd. 2020. 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. -+ * Author: haozi007 -+ * Create: 2020-11-13 -+ * Description: provide log options parse function -+ ******************************************************************************/ -+#ifndef CMD_OPTIONS_LOG_H -+#define CMD_OPTIONS_LOG_H -+ -+#include -+#include -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+bool check_raw_log_opt(const char *key); -+ -+bool check_opt_container_log_opt(const char *driver, const char *opt); -+ -+bool check_opt_container_log_driver(const char *driver); -+ -+bool parse_container_log_opt(const char *key, const char *val, json_map_string_string *opts); -+ -+bool parse_container_log_opts(json_map_string_string **opts); -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif -diff --git a/src/common/constants.h b/src/common/constants.h -index 457e2423..dd2f3e5e 100644 ---- a/src/common/constants.h -+++ b/src/common/constants.h -@@ -82,6 +82,8 @@ extern "C" { - - #define CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER "json-file" - #define CONTAINER_LOG_CONFIG_SYSLOG_DRIVER "syslog" -+ -+#define CONTAINER_LOG_CONFIG_KEY_PREFIX "log.console." - #define CONTAINER_LOG_CONFIG_KEY_DRIVER "log.console.driver" - #define CONTAINER_LOG_CONFIG_KEY_FILE "log.console.file" - #define CONTAINER_LOG_CONFIG_KEY_ROTATE "log.console.filerotate" -@@ -121,6 +123,8 @@ extern "C" { - - #define MAX_HOSTS 10 - -+#define OPT_MAX_LEN 255 -+ - #define EVENT_ARGS_MAX 255 - #define EVENT_EXTRA_ANNOTATION_MAX 255 - -diff --git a/src/contrib/config/daemon.json b/src/contrib/config/daemon.json -index 9ffb08ef..d2ce4d02 100644 ---- a/src/contrib/config/daemon.json -+++ b/src/contrib/config/daemon.json -@@ -13,6 +13,9 @@ - "max-size": "30KB" - }, - "log-driver": "stdout", -+ "container-log": { -+ "driver": "json-file" -+ }, - "hook-spec": "/etc/default/isulad/hooks/default.json", - "start-timeout": "2m", - "storage-driver": "overlay2", -diff --git a/src/daemon/config/daemon_arguments.c b/src/daemon/config/daemon_arguments.c -index ef287645..ba41a9a5 100644 ---- a/src/daemon/config/daemon_arguments.c -+++ b/src/daemon/config/daemon_arguments.c -@@ -137,6 +137,14 @@ int service_arguments_init(struct service_arguments *args) - args->max_file = 7; - args->max_size = 1024 * 1024; - -+ // init container log configs -+ args->json_confs->container_log = (isulad_daemon_configs_container_log *)util_common_calloc_s(sizeof( -+ isulad_daemon_configs_container_log)); -+ if (args->json_confs->container_log == NULL) { -+ ERROR("Out of memory"); -+ goto free_out; -+ } -+ - args->json_confs->pidfile = util_strdup_s("/var/run/isulad.pid"); - args->json_confs->storage_driver = util_strdup_s("overlay2"); - args->json_confs->native_umask = util_strdup_s(UMASK_SECURE); -@@ -149,7 +157,6 @@ int service_arguments_init(struct service_arguments *args) - *(args->json_confs->use_decrypted_key) = true; - args->json_confs->insecure_skip_verify_enforce = false; - -- args->image_opt_timeout = 5 * 60; // default image operation timeout 300s - if (set_daemon_default_tls_options(args) != 0) { - goto free_out; - } -@@ -241,6 +248,7 @@ int server_log_opt_parser(struct service_arguments *args, const char *option) - ret = append_json_map_string_string(args->json_confs->log_opts, key, value); - } - -+ tmp[len] = '='; - out: - free(tmp); - return ret; -@@ -310,4 +318,4 @@ void free_default_ulimit(host_config_ulimits_element **default_ulimit) - free_host_config_ulimits_element(*p); - } - free(default_ulimit); --} -\ No newline at end of file -+} -diff --git a/src/daemon/config/daemon_arguments.h b/src/daemon/config/daemon_arguments.h -index 77feb4d1..54099c81 100644 ---- a/src/daemon/config/daemon_arguments.h -+++ b/src/daemon/config/daemon_arguments.h -@@ -31,38 +31,40 @@ extern "C" { - typedef void (*service_arguments_help_t)(void); - - struct service_arguments { -- char *progname; - service_arguments_help_t print_help; - -- bool quiet; -- bool help; -- bool version; -- char **hosts; -- size_t hosts_len; -- -- // struct service_arguments *server_conf; -+ struct { /* common args */ -+ char *progname; -+ bool quiet; -+ bool help; -+ bool version; -+ char **hosts; -+ size_t hosts_len; -+ unsigned int websocket_server_listening_port; -+ }; -+ -+ struct { /* default configs for container */ -+ // daemon hooks config -+ oci_runtime_spec_hooks *hooks; -+ -+ host_config_ulimits_element **default_ulimit; -+ size_t default_ulimit_len; -+ -+ unsigned int start_timeout; -+ }; -+ -+ struct { /* daemon log configs */ -+ unsigned int log_file_mode; -+ char *logpath; -+ int64_t max_size; -+ int max_file; -+ }; -+ -+ // store all daemon.json configs - isulad_daemon_configs *json_confs; - -- /* parsed configs */ -- oci_runtime_spec_hooks *hooks; -- -- unsigned int start_timeout; -- unsigned int image_opt_timeout; -- -- /* log-opts */ -- unsigned int log_file_mode; -- char *logpath; -- int64_t max_size; -- int max_file; -- -- /* default configs */ -- host_config_ulimits_element **default_ulimit; -- size_t default_ulimit_len; -- unsigned int websocket_server_listening_port; -- - // remaining arguments - char * const *argv; -- - int argc; - }; - -diff --git a/src/daemon/config/isulad_config.c b/src/daemon/config/isulad_config.c -index f6e5ffdb..314545fa 100644 ---- a/src/daemon/config/isulad_config.c -+++ b/src/daemon/config/isulad_config.c -@@ -27,9 +27,9 @@ - #include - #include - #include -+#include - - #include "constants.h" --#include "isula_libutils/log.h" - #include "utils.h" - #include "sysinfo.h" - #include "err_msg.h" -@@ -815,6 +815,61 @@ out: - return logdriver; - } - -+/* conf get default container log opts */ -+int conf_get_container_log_opts(isulad_daemon_configs_container_log **opts) -+{ -+ struct service_arguments *conf = NULL; -+ isulad_daemon_configs_container_log *result = NULL; -+ isulad_daemon_configs_container_log *work = NULL; -+ size_t i; -+ int ret = 0; -+ -+ if (isulad_server_conf_rdlock() != 0) { -+ return -1; -+ } -+ -+ conf = conf_get_server_conf(); -+ if (conf == NULL || conf->json_confs->container_log == NULL) { -+ goto out; -+ } -+ work = conf->json_confs->container_log; -+ -+ result = util_common_calloc_s(sizeof(isulad_daemon_configs_container_log)); -+ if (result == NULL) { -+ ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ result->driver = util_strdup_s(work->driver); -+ if (work->opts == NULL) { -+ *opts = result; -+ result = NULL; -+ goto out; -+ } -+ if (work->opts->len > 0) { -+ result->opts = util_common_calloc_s(sizeof(json_map_string_string)); -+ if (result->opts == NULL) { -+ ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ } -+ for (i = 0; i < work->opts->len; i++) { -+ if (append_json_map_string_string(result->opts, work->opts->keys[i], work->opts->values[i]) != 0) { -+ ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ } -+ -+ *opts = result; -+ result = NULL; -+out: -+ (void)isulad_server_conf_unlock(); -+ free_isulad_daemon_configs_container_log(result); -+ return ret; -+} -+ - /* conf get image layer check flag */ - bool conf_get_image_layer_check_flag() - { -@@ -1311,7 +1366,7 @@ static int merge_hosts_conf_into_global(struct service_arguments *args, const is - return 0; - } - --static int merge_logs_conf_into_global(struct service_arguments *args, isulad_daemon_configs *tmp_json_confs) -+static int do_merge_daemon_logs_conf(struct service_arguments *args, isulad_daemon_configs *tmp_json_confs) - { - size_t i; - -@@ -1334,6 +1389,31 @@ static int merge_logs_conf_into_global(struct service_arguments *args, isulad_da - return 0; - } - -+// just mask isulad config to args -+static int do_merge_container_logs_conf(struct service_arguments *args, isulad_daemon_configs *tmp_json_confs) -+{ -+ if (tmp_json_confs->container_log == NULL) { -+ return 0; -+ } -+ -+ // do not check valid of json log opts at here; -+ // while all config ready to do check. -+ free_isulad_daemon_configs_container_log(args->json_confs->container_log); -+ args->json_confs->container_log = tmp_json_confs->container_log; -+ tmp_json_confs->container_log = NULL; -+ -+ return 0; -+} -+ -+static int merge_logs_conf_into_global(struct service_arguments *args, isulad_daemon_configs *tmp_json_confs) -+{ -+ if (do_merge_daemon_logs_conf(args, tmp_json_confs)) { -+ return -1; -+ } -+ -+ return do_merge_container_logs_conf(args, tmp_json_confs); -+} -+ - static int merge_authorization_conf_into_global(struct service_arguments *args, isulad_daemon_configs *tmp_json_confs) - { - args->json_confs->tls = tmp_json_confs->tls; -diff --git a/src/daemon/config/isulad_config.h b/src/daemon/config/isulad_config.h -index b5c64c54..fb523e5d 100644 ---- a/src/daemon/config/isulad_config.h -+++ b/src/daemon/config/isulad_config.h -@@ -51,6 +51,8 @@ char *conf_get_isulad_log_gather_fifo_path(); - - int conf_get_cgroup_cpu_rt(int64_t *cpu_rt_period, int64_t *cpu_rt_runtime); - -+int conf_get_container_log_opts(isulad_daemon_configs_container_log **opts); -+ - char *conf_get_isulad_log_file(); - char *conf_get_engine_log_file(); - char *conf_get_enable_plugins(); -diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c -index 188d58b2..c2ddf88b 100644 ---- a/src/daemon/executor/container_cb/execution_create.c -+++ b/src/daemon/executor/container_cb/execution_create.c -@@ -57,6 +57,7 @@ - #include "utils_timestamp.h" - #include "utils_verify.h" - #include "selinux_label.h" -+#include "opt_log.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); -@@ -213,67 +214,128 @@ static container_config *get_container_spec_from_request(const container_create_ - return container_spec; - } - --static int add_default_log_config_to_container_spec(const char *id, const char *runtime_root, -- container_config *container_spec) -+static void set_container_log_config_driver(isulad_daemon_configs_container_log *opts, container_config *container_spec) - { -- int ret = 0; -- int i = 0; -- bool file_found = false; -- bool rotate_found = false; -- bool size_found = false; -+ if (container_spec->log_driver != NULL) { -+ return; -+ } -+ -+ // use daemon container log driver -+ container_spec->log_driver = util_strdup_s(opts->driver); -+ if (container_spec->log_driver != NULL) { -+ return; -+ } -+ -+ // use default container log driver -+ container_spec->log_driver = util_strdup_s(CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER); -+} - -- /* generate default log path */ -- if (container_spec->log_driver != NULL && -- strcmp(CONTAINER_LOG_CONFIG_SYSLOG_DRIVER, container_spec->log_driver) == 0) { -+static int merge_container_log_config_opts(const char *daemon_driver, const json_map_string_string *daemon_opts, -+ container_config *spec) -+{ -+ size_t i, j; -+ -+ if (daemon_driver == NULL || strcmp(daemon_driver, spec->log_driver) != 0) { -+ // daemon driver different with spec, just ignore log opts of daemon - return 0; - } - -- if (container_spec->annotations == NULL) { -- container_spec->annotations = util_common_calloc_s(sizeof(json_map_string_string)); -+ // merge daemon container log opts into spec -+ for (i = 0; daemon_opts != NULL && i < daemon_opts->len; i++) { -+ for (j = 0; j < spec->annotations->len; j++) { -+ if (strcmp(spec->annotations->keys[j], daemon_opts->keys[i]) == 0) { -+ break; -+ } -+ } -+ if (j == spec->annotations->len && -+ append_json_map_string_string(spec->annotations, daemon_opts->keys[i], daemon_opts->values[i]) != 0) { -+ ERROR("Out of memory"); -+ return -1; -+ } - } -- if (container_spec->annotations == NULL) { -+ -+ return 0; -+} -+ -+static int do_set_default_log_path_for_json_file(const char *id, const char *root, bool file_found, -+ container_config *spec) -+{ -+ int nret = 0; -+ char default_path[PATH_MAX] = { 0 }; -+ -+ nret = snprintf(default_path, PATH_MAX, "%s/%s/console.log", root, id); -+ if (nret < 0 || nret >= PATH_MAX) { -+ ERROR("Create default log path for container %s failed", id); -+ return -1; -+ } -+ nret = append_json_map_string_string(spec->annotations, CONTAINER_LOG_CONFIG_KEY_FILE, default_path); -+ if (nret != 0) { - ERROR("Out of memory"); -- ret = -1; -- goto out; -+ return -1; - } - -- for (; i < container_spec->annotations->len; i++) { -- const char *tmp_key = container_spec->annotations->keys[i]; -+ return 0; -+} -+ -+static int do_check_container_log_config_opts(const char *id, const char *root, container_config *spec) -+{ -+ size_t i; -+ bool file_found = false; -+ -+ // check log opts is support by driver -+ for (i = 0; i < spec->annotations->len; i++) { -+ const char *tmp_key = spec->annotations->keys[i]; -+ if (strncmp(tmp_key, CONTAINER_LOG_CONFIG_KEY_PREFIX, strlen(CONTAINER_LOG_CONFIG_KEY_PREFIX)) != 0) { -+ // ignore other configs -+ continue; -+ } -+ DEBUG("check log opt key: %s for driver: %s", tmp_key, spec->log_driver); -+ if (!check_opt_container_log_opt(spec->log_driver, tmp_key)) { -+ isulad_set_error_message("container log driver: %s, unsupport: %s", spec->log_driver, tmp_key); -+ return -1; -+ } -+ - if (strcmp(CONTAINER_LOG_CONFIG_KEY_FILE, tmp_key) == 0) { - file_found = true; -- } else if (strcmp(CONTAINER_LOG_CONFIG_KEY_ROTATE, tmp_key) == 0) { -- rotate_found = true; -- } else if (strcmp(CONTAINER_LOG_CONFIG_KEY_SIZE, tmp_key) == 0) { -- size_found = true; - } - } -- if (!file_found) { -- char default_path[PATH_MAX] = { 0 }; -- int nret = snprintf(default_path, PATH_MAX, "%s/%s/console.log", runtime_root, id); -- if (nret < 0 || nret >= PATH_MAX) { -- ERROR("Create default log path for container %s failed", id); -- ret = -1; -- goto out; -- } -- ret = append_json_map_string_string(container_spec->annotations, CONTAINER_LOG_CONFIG_KEY_FILE, default_path); -- if (ret != 0) { -- goto out; -- } -+ -+ if (!file_found && strcmp(spec->log_driver, CONTAINER_LOG_CONFIG_JSON_FILE_DRIVER) == 0) { -+ return do_set_default_log_path_for_json_file(id, root, file_found, spec); - } -- if (!rotate_found) { -- ret = append_json_map_string_string(container_spec->annotations, CONTAINER_LOG_CONFIG_KEY_ROTATE, "7"); -- if (ret != 0) { -- goto out; -- } -+ -+ return 0; -+} -+ -+static int set_container_log_config_to_container_spec(const char *id, const char *runtime_root, -+ container_config *container_spec) -+{ -+ int ret = 0; -+ isulad_daemon_configs_container_log *daemon_container_opts = NULL; -+ -+ if (conf_get_container_log_opts(&daemon_container_opts) != 0) { -+ return -1; - } -- if (!size_found) { -- ret = append_json_map_string_string(container_spec->annotations, CONTAINER_LOG_CONFIG_KEY_SIZE, "30KB"); -- if (ret != 0) { -- goto out; -- } -+ -+ set_container_log_config_driver(daemon_container_opts, container_spec); -+ -+ if (container_spec->annotations == NULL) { -+ container_spec->annotations = util_common_calloc_s(sizeof(json_map_string_string)); -+ } -+ if (container_spec->annotations == NULL) { -+ ERROR("Out of memory"); -+ ret = -1; -+ goto out; -+ } -+ -+ ret = merge_container_log_config_opts(daemon_container_opts->driver, daemon_container_opts->opts, container_spec); -+ if (ret != 0) { -+ goto out; - } -+ ret = do_check_container_log_config_opts(id, runtime_root, container_spec); - - out: -+ free_isulad_daemon_configs_container_log(daemon_container_opts); - return ret; - } - -@@ -287,7 +349,7 @@ static container_config *get_container_spec(const char *id, const char *runtime_ - return NULL; - } - -- if (add_default_log_config_to_container_spec(id, runtime_root, container_spec)) { -+ if (set_container_log_config_to_container_spec(id, runtime_root, container_spec)) { - goto error_out; - } - -diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c -index 529a68de..ae5db17d 100644 ---- a/src/daemon/modules/service/service_container.c -+++ b/src/daemon/modules/service/service_container.c -@@ -770,6 +770,7 @@ static int do_start_container(container_t *cont, const char *console_fifos[], bo - goto close_exit_fd; - } - -+ - create_params.bundle = bundle; - create_params.state = cont->state_path; - create_params.oci_config_data = oci_spec; --- -2.25.1 - diff --git a/0017-add-testcase-for-default-container-log-configs.patch b/0017-add-testcase-for-default-container-log-configs.patch deleted file mode 100644 index 42856a0..0000000 --- a/0017-add-testcase-for-default-container-log-configs.patch +++ /dev/null @@ -1,231 +0,0 @@ -From acbcd786e29a9d3764d69db02ad485d94da1315c Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 3 Dec 2020 10:36:07 +0800 -Subject: [PATCH 17/17] add testcase for default container log configs - -Signed-off-by: haozi007 ---- - CI/test_cases/container_cases/log_test.sh | 166 ++++++++++++++++++ - .../container_cases/test_data/daemon.json | 37 ++++ - 2 files changed, 203 insertions(+) - create mode 100755 CI/test_cases/container_cases/log_test.sh - create mode 100644 CI/test_cases/container_cases/test_data/daemon.json - -diff --git a/CI/test_cases/container_cases/log_test.sh b/CI/test_cases/container_cases/log_test.sh -new file mode 100755 -index 00000000..08abf212 ---- /dev/null -+++ b/CI/test_cases/container_cases/log_test.sh -@@ -0,0 +1,166 @@ -+#!/bin/bash -+# -+# attributes: isulad container log -+# concurrent: NA -+# spend time: 46 -+ -+curr_path=$(dirname $(readlink -f "$0")) -+data_path=$(realpath $curr_path/test_data) -+source ../helpers.sh -+ -+function do_pre() -+{ -+ mv /etc/isulad/daemon.json /etc/isulad/daemon.bak -+ cp ${data_path}/daemon.json /etc/isulad/daemon.json -+} -+ -+function do_post() -+{ -+ cp -f /etc/isulad/daemon.bak /etc/isulad/daemon.json -+ check_valgrind_log -+ start_isulad_with_valgrind -+} -+ -+function do_check_item() -+{ -+ cat ${ISULAD_ROOT_PATH}/engine/lcr/$1/config | grep console | grep "$2" -+ if [ $? -ne 0 ]; then -+ msg_err "expect $2" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+} -+ -+function do_test_syslog_helper() -+{ -+ msg_info "this is $0 do_test" -+ -+ crictl pull busybox -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to pull busybox image" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ cid=`isula run -tid busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ do_check_item ${cid} "logdriver = syslog" -+ -+ if [ "x$1" != "x" ]; then -+ do_check_item ${cid} "syslog_tag = $1" -+ fi -+ -+ isula rm -f ${cid} -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to remove container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ return $TC_RET_T -+} -+ -+function do_test_json_file_helper() -+{ -+ msg_info "this is $0 do_test" -+ local file_cnt=7 -+ local file_size=1MB -+ -+ if [ "x$1" != "x" ]; then -+ file_cnt=$1 -+ fi -+ if [ "x$2" != "x" ]; then -+ file_size=$2 -+ fi -+ -+ cid=`isula run -tid busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ do_check_item ${cid} "logdriver = json-file" -+ do_check_item ${cid} "rotate = $file_cnt" -+ do_check_item ${cid} "size = $file_size" -+ -+ isula rm -f ${cid} -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to remove container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ return $TC_RET_T -+} -+ -+function do_test_container_log() -+{ -+ msg_info "this is $0 do_test" -+ -+ cid=`isula run -tid --log-driver=json-file busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ do_check_item ${cid} "logdriver = json-file" -+ do_check_item ${cid} "rotate = 7" -+ do_check_item ${cid} "size = 1MB" -+ -+ cid=`isula run -tid --log-driver=json-file --log-opt="max-file=8" busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ do_check_item ${cid} "logdriver = json-file" -+ do_check_item ${cid} "rotate = 8" -+ do_check_item ${cid} "size = 1MB" -+ -+ cid=`isula run -tid --log-driver=json-file --log-opt="max-size=128KB" busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ do_check_item ${cid} "logdriver = json-file" -+ do_check_item ${cid} "rotate = 7" -+ do_check_item ${cid} "size = 128KB" -+ -+ cid=`isula run -tid --log-driver=json-file --log-opt="disable-log=true" busybox sh` -+ if [ $? -ne 0 ]; then -+ msg_err "Failed to run container" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ cat ${ISULAD_ROOT_PATH}/engine/lcr/${cid}/config | grep console | grep "logfile =" -+ if [ $? -eq 0 ]; then -+ msg_err "Failed to disable log" -+ TC_RET_T=$(($TC_RET_T+1)) -+ fi -+ -+ isula rm -f `isula ps -aq` -+ return $TC_RET_T -+} -+ -+function do_test() { -+ check_valgrind_log -+ start_isulad_with_valgrind --log-opts="syslog-tag=xxxx" -+ -+ do_test_syslog_helper "xxxx" -+ -+ check_valgrind_log -+ start_isulad_with_valgrind --log-driver=json-file --log-opts="max-size=10MB" --log-opts="max-file=3" -+ do_test_json_file_helper "3" "10MB" -+ -+ check_valgrind_log -+ start_isulad_with_valgrind -+ do_test_container_log -+} -+ -+ret=0 -+ -+do_pre -+if [ $? -ne 0 ];then -+ let "ret=$ret + 1" -+fi -+ -+do_post -+ -+show_result $ret "cni base test" -diff --git a/CI/test_cases/container_cases/test_data/daemon.json b/CI/test_cases/container_cases/test_data/daemon.json -new file mode 100644 -index 00000000..f8914ed4 ---- /dev/null -+++ b/CI/test_cases/container_cases/test_data/daemon.json -@@ -0,0 +1,37 @@ -+{ -+ "group": "isula", -+ "default-runtime": "lcr", -+ "graph": "/var/lib/isulad", -+ "state": "/var/run/isulad", -+ "engine": "lcr", -+ "log-level": "ERROR", -+ "pidfile": "/var/run/isulad.pid", -+ "log-opts": { -+ "log-file-mode": "0600", -+ "log-path": "/var/lib/isulad", -+ "max-file": "1", -+ "max-size": "30KB" -+ }, -+ "log-driver": "stdout", -+ "container-log": { -+ "driver": "syslog" -+ }, -+ "hook-spec": "/etc/default/isulad/hooks/default.json", -+ "start-timeout": "2m", -+ "storage-driver": "overlay2", -+ "storage-opts": [ -+ "overlay2.override_kernel_check=true" -+ ], -+ "registry-mirrors": [ -+ ], -+ "insecure-registries": [ -+ ], -+ "pod-sandbox-image": "", -+ "native.umask": "secure", -+ "network-plugin": "", -+ "cni-bin-dir": "", -+ "cni-conf-dir": "", -+ "image-layer-check": false, -+ "use-decrypted-key": true, -+ "insecure-skip-verify-enforce": false -+} --- -2.25.1 - diff --git a/0018-clean-code-ignore-list-containers-error.patch b/0018-clean-code-ignore-list-containers-error.patch deleted file mode 100644 index e11d1c2..0000000 --- a/0018-clean-code-ignore-list-containers-error.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 051be757db25c8ac7e6c4beb1ec219b4fde3641c Mon Sep 17 00:00:00 2001 -From: lifeng68 -Date: Sat, 5 Dec 2020 10:24:58 +0800 -Subject: [PATCH 18/18] clean code: ignore list containers error - -Signed-off-by: lifeng68 ---- - src/daemon/executor/container_cb/list.c | 82 +++++++++++++++---------- - 1 file changed, 51 insertions(+), 31 deletions(-) - -diff --git a/src/daemon/executor/container_cb/list.c b/src/daemon/executor/container_cb/list.c -index 4c9c9ed..3dea940 100644 ---- a/src/daemon/executor/container_cb/list.c -+++ b/src/daemon/executor/container_cb/list.c -@@ -311,44 +311,73 @@ static void dup_id_name(const container_config_v2_common_config *common_config, - } - } - --static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config, -- container_container *isuladinfo) -+static void dup_container_labels(const map_t *map_labels, const container_config_v2_common_config *common_config, -+ container_container *isuladinfo) - { - int ret = 0; -- bool args_err = false; -- -- if (map_labels == NULL || common_config == NULL || isuladinfo == NULL) { -- return -1; -- } - - if (common_config->config == NULL) { -- return 0; -+ return; - } -- args_err = (common_config->config->labels != NULL && common_config->config->labels->len != 0); -- if (args_err) { -+ -+ if (common_config->config->labels != NULL && common_config->config->labels->len != 0) { - json_map_string_string *labels = common_config->config->labels; - - ret = replace_labels(isuladinfo, labels, map_labels); -- if (ret == -1) { -- goto out; -+ if (ret != 0) { -+ ERROR("Failed to dup container %s labels", common_config->id); - } - } - -+ return; -+} -+ -+static void dup_container_annotations(const container_config_v2_common_config *common_config, -+ container_container *isuladinfo) -+{ -+ int ret = 0; -+ -+ if (common_config->config == NULL) { -+ return; -+ } -+ - ret = replace_annotations(common_config, isuladinfo); -- if (ret == -1) { -- goto out; -+ if (ret != 0) { -+ ERROR("Failed to dup container %s annotations", common_config->id); - } - -- dup_id_name(common_config, isuladinfo); -- args_err = (common_config->created != NULL && -- util_to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0); -- if (args_err) { -- ret = -1; -- goto out; -+ return; -+} -+ -+static void dup_container_created_time(const container_config_v2_common_config *common_config, -+ container_container *isuladinfo) -+{ -+ if (common_config->created != NULL && -+ util_to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0) { -+ ERROR("Failed to dup container %s created time", common_config->id); -+ } -+ -+ return; -+} -+ -+static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config, -+ container_container *isuladinfo) -+{ -+ if (map_labels == NULL || common_config == NULL || isuladinfo == NULL) { -+ return -1; - } -+ -+ dup_id_name(common_config, isuladinfo); -+ - isuladinfo->restartcount = (uint64_t)common_config->restart_count; --out: -- return ret; -+ -+ dup_container_labels(map_labels, common_config, isuladinfo); -+ -+ dup_container_annotations(common_config, isuladinfo); -+ -+ dup_container_created_time(common_config, isuladinfo); -+ -+ return 0; - } - - static int container_info_match(const struct list_context *ctx, const map_t *map_labels, -@@ -413,7 +442,6 @@ static int fill_isuladinfo(container_container *isuladinfo, const container_conf - char *image = NULL; - char *timestr = NULL; - char *defvalue = "-"; -- int64_t created_nanos = 0; - - ret = convert_common_config_info(map_labels, cont->common_config, isuladinfo); - if (ret != 0) { -@@ -438,14 +466,6 @@ static int fill_isuladinfo(container_container *isuladinfo, const container_conf - isuladinfo->runtime = cont->runtime ? util_strdup_s(cont->runtime) : util_strdup_s("none"); - - isuladinfo->health_state = container_get_health_state(cont_state); -- if (cont->common_config->created != NULL) { -- ret = util_to_unix_nanos_from_str(cont->common_config->created, &created_nanos); -- if (ret != 0) { -- goto out; -- } -- } -- -- isuladinfo->created = created_nanos; - - out: - return ret; --- -2.25.1 - diff --git a/0019-add-g_oci_image_module_data-in-oci-image-module.patch b/0019-add-g_oci_image_module_data-in-oci-image-module.patch deleted file mode 100644 index 33d260c..0000000 --- a/0019-add-g_oci_image_module_data-in-oci-image-module.patch +++ /dev/null @@ -1,638 +0,0 @@ -From 0f4d5658caf7e3870b126c3e2314cfc1edc35419 Mon Sep 17 00:00:00 2001 -From: zhangxiaoyu -Date: Tue, 1 Dec 2020 14:39:59 +0800 -Subject: [PATCH] add g_oci_image_module_data in oci image module - -Signed-off-by: zhangxiaoyu ---- - src/daemon/modules/image/CMakeLists.txt | 2 - - src/daemon/modules/image/oci/oci_image.c | 93 ++++++++++++++++++- - src/daemon/modules/image/oci/oci_image.h | 13 +++ - src/daemon/modules/image/oci/oci_load.c | 7 +- - src/daemon/modules/image/oci/oci_login.c | 10 +- - src/daemon/modules/image/oci/oci_pull.c | 13 ++- - .../modules/image/oci/registry/registry.c | 14 ++- - src/daemon/modules/image/oci/utils_images.c | 25 ++--- - src/daemon/modules/image/oci/utils_images.h | 5 +- - test/image/oci/registry/CMakeLists.txt | 2 - - test/image/oci/registry/registry_ut.cc | 56 ++++++----- - test/mocks/oci_image_mock.cc | 8 ++ - test/mocks/oci_image_mock.h | 1 + - 13 files changed, 182 insertions(+), 67 deletions(-) - -diff --git a/src/daemon/modules/image/CMakeLists.txt b/src/daemon/modules/image/CMakeLists.txt -index a92799a0..00a096e3 100644 ---- a/src/daemon/modules/image/CMakeLists.txt -+++ b/src/daemon/modules/image/CMakeLists.txt -@@ -67,8 +67,6 @@ add_library(${LIB_ISULAD_IMG} ${LIBTYPE} - ${CMAKE_SOURCE_DIR}/src/utils/buffer/buffer.c - ${CMAKE_SOURCE_DIR}/src/daemon/common/err_msg.c - ${CMAKE_SOURCE_DIR}/src/daemon/common/selinux_label.c -- ${CMAKE_SOURCE_DIR}/src/daemon/config/isulad_config.c -- ${CMAKE_SOURCE_DIR}/src/daemon/config/daemon_arguments.c - ${CMAKE_SOURCE_DIR}/src/daemon/common/sysinfo.c - ${CMAKE_SOURCE_DIR}/src/utils/tar/isulad_tar.c - ${CMAKE_SOURCE_DIR}/src/utils/tar/util_archive.c -diff --git a/src/daemon/modules/image/oci/oci_image.c b/src/daemon/modules/image/oci/oci_image.c -index f4fa1e88..461fbf10 100644 ---- a/src/daemon/modules/image/oci/oci_image.c -+++ b/src/daemon/modules/image/oci/oci_image.c -@@ -39,6 +39,90 @@ - - #define IMAGE_NOT_KNOWN_ERR "image not known" - -+struct oci_image_module_data g_oci_image_module_data = { 0 }; -+ -+static void free_oci_image_data(void) -+{ -+ free(g_oci_image_module_data.root_dir); -+ g_oci_image_module_data.root_dir = NULL; -+ -+ g_oci_image_module_data.use_decrypted_key = false; -+ g_oci_image_module_data.insecure_skip_verify_enforce = false; -+ -+ util_free_array_by_len(g_oci_image_module_data.registry_mirrors, g_oci_image_module_data.registry_mirrors_len); -+ g_oci_image_module_data.registry_mirrors = NULL; -+ g_oci_image_module_data.registry_mirrors_len = 0; -+ -+ util_free_array_by_len(g_oci_image_module_data.insecure_registries, g_oci_image_module_data.insecure_registries_len); -+ g_oci_image_module_data.insecure_registries = NULL; -+ g_oci_image_module_data.insecure_registries_len = 0; -+} -+ -+static int oci_image_data_init(const isulad_daemon_configs *args) -+{ -+ int nret = 0; -+ size_t i; -+ char *p = NULL; -+ -+ if (args->graph == NULL) { -+ ERROR("args graph NULL"); -+ return -1; -+ } -+ g_oci_image_module_data.root_dir = util_strdup_s(args->graph); -+ -+ g_oci_image_module_data.use_decrypted_key = args->use_decrypted_key; -+ g_oci_image_module_data.insecure_skip_verify_enforce = args->insecure_skip_verify_enforce; -+ -+ if (util_array_len((const char **)args->registry_mirrors) != args->registry_mirrors_len) { -+ ERROR("registry_mirrors_len is not the length of registry_mirrors"); -+ goto free_out; -+ } -+ if (args->registry_mirrors_len != 0) { -+ for (i = 0; i < args->registry_mirrors_len; i++) { -+ p = args->registry_mirrors[i]; -+ if (p == NULL) { -+ break; -+ } -+ nret = util_array_append(&g_oci_image_module_data.registry_mirrors, p); -+ if (nret != 0) { -+ ERROR("Out of memory"); -+ goto free_out; -+ } -+ g_oci_image_module_data.registry_mirrors_len++; -+ } -+ } -+ -+ if (util_array_len((const char **)args->insecure_registries) != args->insecure_registries_len) { -+ ERROR("insecure_registries_len is not the length of insecure_registries"); -+ goto free_out; -+ } -+ if (args->insecure_registries_len != 0) { -+ for (i = 0; i < args->insecure_registries_len; i++) { -+ p = args->insecure_registries[i]; -+ if (p == NULL) { -+ break; -+ } -+ nret = util_array_append(&g_oci_image_module_data.insecure_registries, p); -+ if (nret != 0) { -+ ERROR("Out of memory"); -+ goto free_out; -+ } -+ g_oci_image_module_data.insecure_registries_len++; -+ } -+ } -+ -+ return 0; -+ -+free_out: -+ free_oci_image_data(); -+ return -1; -+} -+ -+struct oci_image_module_data *get_oci_image_data(void) -+{ -+ return &g_oci_image_module_data; -+} -+ - // only use overlay as the driver name if specify overlay2 or overlay - static char *format_driver_name(const char *driver) - { -@@ -155,7 +239,7 @@ static int recreate_image_tmpdir() - char *image_tmp_path = NULL; - int ret = 0; - -- image_tmp_path = oci_get_isulad_tmpdir(); -+ image_tmp_path = oci_get_isulad_tmpdir(g_oci_image_module_data.root_dir); - if (image_tmp_path == NULL) { - ERROR("failed to get image tmp path"); - ret = -1; -@@ -189,6 +273,12 @@ int oci_init(const isulad_daemon_configs *args) - return ret; - } - -+ ret = oci_image_data_init(args); -+ if (ret != 0) { -+ ERROR("Failed to init oci image"); -+ goto out; -+ } -+ - ret = recreate_image_tmpdir(); - if (ret != 0) { - goto out; -@@ -213,6 +303,7 @@ out: - void oci_exit() - { - storage_module_exit(); -+ free_oci_image_data(); - } - - int oci_pull_rf(const im_pull_request *request, im_pull_response *response) -diff --git a/src/daemon/modules/image/oci/oci_image.h b/src/daemon/modules/image/oci/oci_image.h -index a452213d..64a4d8e8 100644 ---- a/src/daemon/modules/image/oci/oci_image.h -+++ b/src/daemon/modules/image/oci/oci_image.h -@@ -27,6 +27,19 @@ - extern "C" { - #endif - -+struct oci_image_module_data { -+ char *root_dir; -+ bool use_decrypted_key; -+ bool insecure_skip_verify_enforce; -+ -+ char **registry_mirrors; -+ size_t registry_mirrors_len; -+ -+ char **insecure_registries; -+ size_t insecure_registries_len; -+}; -+struct oci_image_module_data *get_oci_image_data(void); -+ - int oci_init(const isulad_daemon_configs *args); - void oci_exit(); - -diff --git a/src/daemon/modules/image/oci/oci_load.c b/src/daemon/modules/image/oci/oci_load.c -index 97cff34b..80647253 100644 ---- a/src/daemon/modules/image/oci/oci_load.c -+++ b/src/daemon/modules/image/oci/oci_load.c -@@ -41,6 +41,7 @@ - #include "utils_array.h" - #include "utils_file.h" - #include "utils_verify.h" -+#include "oci_image.h" - - #define MANIFEST_BIG_DATA_KEY "manifest" - #define OCI_SCHEMA_VERSION 2 -@@ -1013,14 +1014,16 @@ static char *oci_load_path_create() - int nret = 0; - char *image_tmp_path = NULL; - char tmp_dir[PATH_MAX] = { 0 }; -+ struct oci_image_module_data *oci_image_data = NULL; - -- ret = makesure_isulad_tmpdir_perm_right(); -+ oci_image_data = get_oci_image_data(); -+ ret = makesure_isulad_tmpdir_perm_right(oci_image_data->root_dir); - if (ret != 0) { - ERROR("failed to make sure permission of image tmp work dir"); - goto out; - } - -- image_tmp_path = oci_get_isulad_tmpdir(); -+ image_tmp_path = oci_get_isulad_tmpdir(oci_image_data->root_dir); - if (image_tmp_path == NULL) { - ERROR("failed to get image tmp work dir"); - ret = -1; -diff --git a/src/daemon/modules/image/oci/oci_login.c b/src/daemon/modules/image/oci/oci_login.c -index b95e00e8..547bfc69 100644 ---- a/src/daemon/modules/image/oci/oci_login.c -+++ b/src/daemon/modules/image/oci/oci_login.c -@@ -23,6 +23,7 @@ - #include "isulad_config.h" - #include "utils_array.h" - #include "utils_string.h" -+#include "oci_image.h" - - static int is_valid_arguments(const char *server, const char *username, const char *password) - { -@@ -47,6 +48,7 @@ int oci_do_login(const char *server, const char *username, const char *password) - char **registry = NULL; - char *host = NULL; - char **parts = NULL; -+ struct oci_image_module_data *oci_image_data = NULL; - - if (is_valid_arguments(server, username, password) != 0) { - ERROR("Invalid arguments"); -@@ -60,8 +62,10 @@ int oci_do_login(const char *server, const char *username, const char *password) - } - host = parts[0]; - -- options.skip_tls_verify = conf_get_skip_insecure_verify_flag(); -- insecure_registries = conf_get_insecure_registry_list(); -+ oci_image_data = get_oci_image_data(); -+ options.skip_tls_verify = oci_image_data->insecure_skip_verify_enforce; -+ -+ insecure_registries = oci_image_data->insecure_registries; - for (registry = insecure_registries; (registry != NULL) && (*registry != NULL); registry++) { - if (!strcmp(*registry, host)) { - options.insecure_registry = true; -@@ -81,8 +85,6 @@ int oci_do_login(const char *server, const char *username, const char *password) - out: - util_free_array(parts); - parts = NULL; -- util_free_array(insecure_registries); -- insecure_registries = NULL; - - return ret; - } -diff --git a/src/daemon/modules/image/oci/oci_pull.c b/src/daemon/modules/image/oci/oci_pull.c -index 9d94b663..71807553 100644 ---- a/src/daemon/modules/image/oci/oci_pull.c -+++ b/src/daemon/modules/image/oci/oci_pull.c -@@ -29,6 +29,7 @@ - #include "utils_array.h" - #include "utils_base64.h" - #include "utils_string.h" -+#include "oci_image.h" - - static int decode_auth(const char *auth, char **username, char **password) - { -@@ -95,6 +96,7 @@ static int pull_image(const im_pull_request *request, char **name) - char **mirror = NULL; - char *host = NULL; - char *with_tag = NULL; -+ struct oci_image_module_data *oci_image_data = NULL; - - options = (registry_pull_options *)util_common_calloc_s(sizeof(registry_pull_options)); - if (options == NULL) { -@@ -113,8 +115,9 @@ static int pull_image(const im_pull_request *request, char **name) - options->auth.password = util_strdup_s(request->password); - } - -- options->skip_tls_verify = conf_get_skip_insecure_verify_flag(); -- insecure_registries = conf_get_insecure_registry_list(); -+ oci_image_data = get_oci_image_data(); -+ options->skip_tls_verify = oci_image_data->insecure_skip_verify_enforce; -+ insecure_registries = oci_image_data->insecure_registries; - - host = oci_get_host(request->image); - if (host != NULL) { -@@ -127,7 +130,7 @@ static int pull_image(const im_pull_request *request, char **name) - goto out; - } - } else { -- registry_mirrors = conf_get_registry_list(); -+ registry_mirrors = oci_image_data->registry_mirrors; - if (registry_mirrors == NULL) { - ERROR("Invalid image name %s, no host found", request->image); - isulad_try_set_error_message("Invalid image name, no host found"); -@@ -160,10 +163,6 @@ static int pull_image(const im_pull_request *request, char **name) - out: - free(host); - host = NULL; -- util_free_array(registry_mirrors); -- registry_mirrors = NULL; -- util_free_array(insecure_registries); -- insecure_registries = NULL; - free_registry_pull_options(options); - options = NULL; - -diff --git a/src/daemon/modules/image/oci/registry/registry.c b/src/daemon/modules/image/oci/registry/registry.c -index a94d10b1..b280f96b 100644 ---- a/src/daemon/modules/image/oci/registry/registry.c -+++ b/src/daemon/modules/image/oci/registry/registry.c -@@ -52,6 +52,7 @@ - #include "utils_string.h" - #include "utils_timestamp.h" - #include "utils_verify.h" -+#include "oci_image.h" - - #define MANIFEST_BIG_DATA_KEY "manifest" - #define MAX_CONCURRENT_DOWNLOAD_NUM 5 -@@ -1685,6 +1686,7 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio - char blobpath[PATH_MAX] = { 0 }; - char scope[PATH_MAX] = { 0 }; - char *image_tmp_path = NULL; -+ struct oci_image_module_data *oci_image_data = NULL; - - if (desc == NULL || options == NULL) { - ERROR("Invalid NULL param"); -@@ -1718,13 +1720,14 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio - - update_host(desc); - -- ret = makesure_isulad_tmpdir_perm_right(); -+ oci_image_data = get_oci_image_data(); -+ ret = makesure_isulad_tmpdir_perm_right(oci_image_data->root_dir); - if (ret != 0) { - ERROR("failed to make sure permission of image tmp work dir"); - goto out; - } - -- image_tmp_path = oci_get_isulad_tmpdir(); -+ image_tmp_path = oci_get_isulad_tmpdir(oci_image_data->root_dir); - if (image_tmp_path == NULL) { - ERROR("failed to get image tmp work dir"); - ret = -1; -@@ -1755,7 +1758,7 @@ static int prepare_pull_desc(pull_descriptor *desc, registry_pull_options *optio - desc->dest_image_name = util_strdup_s(options->dest_image_name); - desc->scope = util_strdup_s(scope); - desc->blobpath = util_strdup_s(blobpath); -- desc->use_decrypted_key = conf_get_use_decrypted_key_flag(); -+ desc->use_decrypted_key = oci_image_data->use_decrypted_key; - desc->skip_tls_verify = options->skip_tls_verify; - desc->insecure_registry = options->insecure_registry; - desc->cancel = false; -@@ -1928,6 +1931,7 @@ int registry_login(registry_login_options *options) - { - int ret = 0; - pull_descriptor *desc = NULL; -+ struct oci_image_module_data *oci_image_data = NULL; - - if (options == NULL || options->host == NULL || options->auth.username == NULL || options->auth.password == NULL || - strlen(options->auth.username) == 0 || strlen(options->auth.password) == 0) { -@@ -1942,9 +1946,11 @@ int registry_login(registry_login_options *options) - goto out; - } - -+ oci_image_data = get_oci_image_data(); -+ - desc->host = util_strdup_s(options->host); - update_host(desc); -- desc->use_decrypted_key = conf_get_use_decrypted_key_flag(); -+ desc->use_decrypted_key = oci_image_data->use_decrypted_key; - desc->skip_tls_verify = options->skip_tls_verify; - desc->insecure_registry = options->insecure_registry; - desc->username = util_strdup_s(options->auth.username); -diff --git a/src/daemon/modules/image/oci/utils_images.c b/src/daemon/modules/image/oci/utils_images.c -index 7eddd25c..a909b0f3 100644 ---- a/src/daemon/modules/image/oci/utils_images.c -+++ b/src/daemon/modules/image/oci/utils_images.c -@@ -516,16 +516,13 @@ static int makesure_path_is_dir(char *path) - return 0; - } - --char *oci_get_isulad_tmpdir() -+char *oci_get_isulad_tmpdir(const char *root_dir) - { - char *isulad_tmpdir = NULL; -- char *isulad_root_dir = NULL; - char *env_dir = NULL; -- int ret = 0; - -- isulad_root_dir = conf_get_isulad_rootdir(); -- if (isulad_root_dir == NULL) { -- ERROR("get isulad root dir failed"); -+ if (root_dir == NULL) { -+ ERROR("root dir is NULL"); - return NULL; - } - -@@ -533,31 +530,23 @@ char *oci_get_isulad_tmpdir() - if (util_valid_str(env_dir)) { - isulad_tmpdir = util_path_join(env_dir, "isulad_tmpdir"); - } else { -- isulad_tmpdir = util_path_join(isulad_root_dir, "isulad_tmpdir"); -+ isulad_tmpdir = util_path_join(root_dir, "isulad_tmpdir"); - } - if (isulad_tmpdir == NULL) { - ERROR("join temporary directory failed"); -- ret = -1; -- goto out; -- } -- --out: -- free(isulad_root_dir); -- if (ret != 0) { -- free(isulad_tmpdir); -- isulad_tmpdir = NULL; -+ return NULL; - } - - return isulad_tmpdir; - } - --int makesure_isulad_tmpdir_perm_right() -+int makesure_isulad_tmpdir_perm_right(const char *root_dir) - { - struct stat st = {0}; - char *isulad_tmpdir = NULL; - int ret = 0; - -- isulad_tmpdir = oci_get_isulad_tmpdir(); -+ isulad_tmpdir = oci_get_isulad_tmpdir(root_dir); - if (isulad_tmpdir == NULL) { - return -1; - } -diff --git a/src/daemon/modules/image/oci/utils_images.h b/src/daemon/modules/image/oci/utils_images.h -index cebcc796..4e13c76c 100644 ---- a/src/daemon/modules/image/oci/utils_images.h -+++ b/src/daemon/modules/image/oci/utils_images.h -@@ -39,7 +39,6 @@ extern "C" { - #define REPO_PREFIX_TO_STRIP "library/" - #define MAX_ID_BUF_LEN 256 - -- - char *oci_get_host(const char *name); - char *oci_host_from_mirror(const char *mirror); - char *oci_default_tag(const char *name); -@@ -54,8 +53,8 @@ int add_rootfs_and_history(const layer_blob *layers, size_t layers_len, const re - docker_image_config_v2 *config); - bool oci_valid_time(char *time); - --char *oci_get_isulad_tmpdir(); --int makesure_isulad_tmpdir_perm_right(); -+char *oci_get_isulad_tmpdir(const char *root_dir); -+int makesure_isulad_tmpdir_perm_right(const char *root_dir); - - #ifdef __cplusplus - } -diff --git a/test/image/oci/registry/CMakeLists.txt b/test/image/oci/registry/CMakeLists.txt -index 36e7cab8..cfc7da87 100644 ---- a/test/image/oci/registry/CMakeLists.txt -+++ b/test/image/oci/registry/CMakeLists.txt -@@ -19,7 +19,6 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/cutils/utils_timestamp.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/modules/image/oci/utils_images.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/err_msg.c -- ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/http/parser.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/buffer/buffer.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/cutils/utils_aes.c -@@ -36,7 +35,6 @@ add_executable(${EXE} - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/storage_mock.cc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/oci_image_mock.cc - ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/http_mock.cc -- ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/isulad_config_mock.cc - registry_ut.cc) - - target_include_directories(${EXE} PUBLIC -diff --git a/test/image/oci/registry/registry_ut.cc b/test/image/oci/registry/registry_ut.cc -index 4b264424..f0e35dc0 100644 ---- a/test/image/oci/registry/registry_ut.cc -+++ b/test/image/oci/registry/registry_ut.cc -@@ -73,7 +73,28 @@ std::string get_dir() - return static_cast(abs_path) + "../../../../../test/image/oci/registry"; - } - --void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladConf *isulad_conf_mock); -+void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock); -+ -+static struct oci_image_module_data g_oci_image_registry = { 0 }; -+ -+static void oci_image_registry_init() -+{ -+ g_oci_image_registry.root_dir = util_strdup_s(get_dir().c_str()); -+ g_oci_image_registry.use_decrypted_key = true; -+} -+ -+static struct oci_image_module_data *invokeGetOciImageData() -+{ -+ return &g_oci_image_registry; -+} -+ -+static void oci_image_registry_exit() -+{ -+ free(g_oci_image_registry.root_dir); -+ g_oci_image_registry.root_dir = NULL; -+ -+ g_oci_image_registry.use_decrypted_key = false; -+} - - class RegistryUnitTest : public testing::Test { - protected: -@@ -82,8 +103,8 @@ protected: - MockHttp_SetMock(&m_http_mock); - MockStorage_SetMock(&m_storage_mock); - MockOciImage_SetMock(&m_oci_image_mock); -- MockIsuladConf_SetMock(&m_isulad_conf_mock); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock); -+ oci_image_registry_init(); - } - - void TearDown() override -@@ -91,13 +112,12 @@ protected: - MockHttp_SetMock(nullptr); - MockStorage_SetMock(nullptr); - MockOciImage_SetMock(nullptr); -- MockIsuladConf_SetMock(nullptr); -+ oci_image_registry_exit(); - } - - NiceMock m_http_mock; - NiceMock m_storage_mock; - NiceMock m_oci_image_mock; -- NiceMock m_isulad_conf_mock; - }; - - int invokeHttpRequestV1(const char *url, struct http_get_options *options, long *response_code, int recursive_len) -@@ -505,17 +525,7 @@ static int init_log() - return 0; - } - --static char *invokeConfGetISuladRootDir() --{ -- return util_strdup_s(get_dir().c_str()); --} -- --static bool invokeConfGetUseDecryptedKeyFlag() --{ -- return true; --} -- --void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladConf *isulad_conf_mock) -+void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock) - { - EXPECT_CALL(*mock, StorageImgCreate(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeStorageImgCreate)); -@@ -549,10 +559,8 @@ void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock, MockIsuladCo - .WillRepeatedly(Invoke(invokeFreeLayer)); - EXPECT_CALL(*oci_image_mock, OciValidTime(::testing::_)) - .WillRepeatedly(Invoke(invokeOciValidTime)); -- EXPECT_CALL(*isulad_conf_mock, ConfGetISuladRootDir()) -- .WillRepeatedly(Invoke(invokeConfGetISuladRootDir)); -- EXPECT_CALL(*isulad_conf_mock, ConfGetUseDecryptedKeyFlag()) -- .WillRepeatedly(Invoke(invokeConfGetUseDecryptedKeyFlag)); -+ EXPECT_CALL(*oci_image_mock, GetOciImageData()) -+ .WillRepeatedly(Invoke(invokeGetOciImageData)); - return; - } - -@@ -610,7 +618,7 @@ TEST_F(RegistryUnitTest, test_pull_v1_image) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV1)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock); - ASSERT_EQ(registry_pull(&options), 0); - - ASSERT_EQ(registry_pull(&options), 0); -@@ -670,7 +678,7 @@ TEST_F(RegistryUnitTest, test_pull_v2_image) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV2)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock); - - // test retry success - ASSERT_EQ(registry_pull(&options), 0); -@@ -704,7 +712,7 @@ TEST_F(RegistryUnitTest, test_pull_oci_image) - options->insecure_registry = false; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestOCI)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock); - ASSERT_EQ(registry_pull(options), 0); - - free_registry_pull_options(options); -@@ -722,7 +730,7 @@ TEST_F(RegistryUnitTest, test_pull_already_exist) - - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) - .WillRepeatedly(Invoke(invokeHttpRequestV2)); -- mockCommonAll(&m_storage_mock, &m_oci_image_mock, &m_isulad_conf_mock); -+ mockCommonAll(&m_storage_mock, &m_oci_image_mock); - EXPECT_CALL(m_storage_mock, StorageLayerGet(::testing::_)) - .WillRepeatedly(Invoke(invokeStorageLayerGet1)); - ASSERT_EQ(registry_pull(&options), 0); -diff --git a/test/mocks/oci_image_mock.cc b/test/mocks/oci_image_mock.cc -index 51987f62..c6451005 100644 ---- a/test/mocks/oci_image_mock.cc -+++ b/test/mocks/oci_image_mock.cc -@@ -31,3 +31,11 @@ bool oci_valid_time(char *time) - } - return false; - } -+ -+struct oci_image_module_data *get_oci_image_data(void) -+{ -+ if (g_oci_image_mock != nullptr) { -+ return g_oci_image_mock->GetOciImageData(); -+ } -+ return { 0 }; -+} -diff --git a/test/mocks/oci_image_mock.h b/test/mocks/oci_image_mock.h -index 16b2a3c5..cd1db1fd 100644 ---- a/test/mocks/oci_image_mock.h -+++ b/test/mocks/oci_image_mock.h -@@ -23,6 +23,7 @@ class MockOciImage { - public: - virtual ~MockOciImage() = default; - MOCK_METHOD1(OciValidTime, bool(char *time)); -+ MOCK_METHOD0(GetOciImageData, struct oci_image_module_data * ()); - }; - - void MockOciImage_SetMock(MockOciImage *mock); --- -2.25.1 - diff --git a/0020-translate-absolute-path-to-relative-path-when-unpack.patch b/0020-translate-absolute-path-to-relative-path-when-unpack.patch deleted file mode 100644 index 34854ba..0000000 --- a/0020-translate-absolute-path-to-relative-path-when-unpack.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 8dca81df2e93e7b91b53213adfcd469d4fbb84e8 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Mon, 7 Dec 2020 14:49:34 +0800 -Subject: [PATCH] translate absolute path to relative path when unpack - -Signed-off-by: WangFengTu ---- - src/utils/tar/util_archive.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/src/utils/tar/util_archive.c b/src/utils/tar/util_archive.c -index 85f75c7f..581503fd 100644 ---- a/src/utils/tar/util_archive.c -+++ b/src/utils/tar/util_archive.c -@@ -375,6 +375,13 @@ int archive_unpack_handler(const struct io_read_wrapper *content, const char *ds - continue; - } - -+ // if path in archive is absolute, we need to translate it to relative because -+ // libarchive can not support absolute path when unpack -+ pathname = archive_entry_pathname(entry); -+ if (pathname != NULL && pathname[0] == '/') { -+ archive_entry_set_pathname(entry, pathname + 1); -+ } -+ - ret = archive_write_header(ext, entry); - if (ret != ARCHIVE_OK) { - ERROR("Fail to handle tar header: %s", archive_error_string(ext)); --- -2.25.1 - diff --git a/0021-clean-code-fix-check-error-in-terminal.c-and-volume_.patch b/0021-clean-code-fix-check-error-in-terminal.c-and-volume_.patch deleted file mode 100644 index 250beb6..0000000 --- a/0021-clean-code-fix-check-error-in-terminal.c-and-volume_.patch +++ /dev/null @@ -1,44 +0,0 @@ -From f28afb0aeea9ff6465400825a64a3d28f83f187a Mon Sep 17 00:00:00 2001 -From: lifeng68 -Date: Mon, 7 Dec 2020 14:48:05 +0800 -Subject: [PATCH] clean code: fix check error in terminal.c and volume_cb.c - -Signed-off-by: lifeng68 ---- - src/cmd/isulad-shim/terminal.c | 5 +++-- - src/daemon/executor/volume_cb/volume_cb.c | 2 +- - 2 files changed, 4 insertions(+), 3 deletions(-) - -diff --git a/src/cmd/isulad-shim/terminal.c b/src/cmd/isulad-shim/terminal.c -index 9b7d55e6..f803b634 100644 ---- a/src/cmd/isulad-shim/terminal.c -+++ b/src/cmd/isulad-shim/terminal.c -@@ -268,9 +268,10 @@ void shim_write_container_log_file(log_terminal *terminal, const char *type, cha - } - - if (buf != NULL && read_count > 0) { -- upto = size + read_count; -- if (upto > BUF_CACHE_SIZE) { -+ if (read_count > (BUF_CACHE_SIZE - size)) { - upto = BUF_CACHE_SIZE; -+ } else { -+ upto = size + read_count; - } - - if (upto > size) { -diff --git a/src/daemon/executor/volume_cb/volume_cb.c b/src/daemon/executor/volume_cb/volume_cb.c -index 8efddad9..13f99517 100644 ---- a/src/daemon/executor/volume_cb/volume_cb.c -+++ b/src/daemon/executor/volume_cb/volume_cb.c -@@ -70,7 +70,7 @@ static int volume_list_cb(const volume_list_volume_request *request, volume_list - goto out; - } - -- (*response)->volumes = util_common_calloc_s(sizeof(volume_volume *) * list->vols_len); -+ (*response)->volumes = util_smart_calloc_s(sizeof(volume_volume *), list->vols_len); - if ((*response)->volumes == NULL) { - ERROR("out of memory"); - cc = ISULAD_ERR_MEMOUT; --- -2.25.1 - diff --git a/0022-iSulad-bugfix-args-use_decrypted_key-is-a-pointer.patch b/0022-iSulad-bugfix-args-use_decrypted_key-is-a-pointer.patch deleted file mode 100644 index a055523..0000000 --- a/0022-iSulad-bugfix-args-use_decrypted_key-is-a-pointer.patch +++ /dev/null @@ -1,31 +0,0 @@ -From e744a909cdb3a88ca4cbbe92385e70bf29c690a0 Mon Sep 17 00:00:00 2001 -From: zhangxiaoyu -Date: Mon, 7 Dec 2020 16:28:19 +0800 -Subject: [PATCH] iSulad: bugfix, args->use_decrypted_key is a pointer - -Signed-off-by: zhangxiaoyu ---- - src/daemon/modules/image/oci/oci_image.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/src/daemon/modules/image/oci/oci_image.c b/src/daemon/modules/image/oci/oci_image.c -index 461fbf10..773803fa 100644 ---- a/src/daemon/modules/image/oci/oci_image.c -+++ b/src/daemon/modules/image/oci/oci_image.c -@@ -70,7 +70,12 @@ static int oci_image_data_init(const isulad_daemon_configs *args) - } - g_oci_image_module_data.root_dir = util_strdup_s(args->graph); - -- g_oci_image_module_data.use_decrypted_key = args->use_decrypted_key; -+ if (args->use_decrypted_key == NULL) { -+ g_oci_image_module_data.use_decrypted_key = true; -+ } else { -+ g_oci_image_module_data.use_decrypted_key = *(args->use_decrypted_key); -+ } -+ - g_oci_image_module_data.insecure_skip_verify_enforce = args->insecure_skip_verify_enforce; - - if (util_array_len((const char **)args->registry_mirrors) != args->registry_mirrors_len) { --- -2.25.1 - diff --git a/0023-verify-peer-only-if-CA-configed.patch b/0023-verify-peer-only-if-CA-configed.patch deleted file mode 100644 index ec8edc6..0000000 --- a/0023-verify-peer-only-if-CA-configed.patch +++ /dev/null @@ -1,29 +0,0 @@ -From b09d3c39641e66160f588b66ac8c3b88cfd726a8 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Mon, 7 Dec 2020 16:26:42 +0800 -Subject: [PATCH] verify peer only if CA configed - -rollback ssl verify check condition because some system -do not have certs configed by default. - -Signed-off-by: WangFengTu ---- - src/daemon/modules/image/oci/registry/http_request.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/daemon/modules/image/oci/registry/http_request.c b/src/daemon/modules/image/oci/registry/http_request.c -index fb44a7b6..60644ed5 100644 ---- a/src/daemon/modules/image/oci/registry/http_request.c -+++ b/src/daemon/modules/image/oci/registry/http_request.c -@@ -118,7 +118,7 @@ static int setup_ssl_config(pull_descriptor *desc, struct http_get_options *opti - } - } - -- if (!desc->insecure_registry) { -+ if (options->ca_file != NULL) { - options->ssl_verify_peer = true; - } - --- -2.25.1 - diff --git a/iSulad.spec b/iSulad.spec index 72e1e76..be2df4c 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ -%global _version 2.0.7 -%global _release 20201207.151847.gita1fce123 +%global _version 2.0.8 +%global _release 20201230.155843.git6557a6eb %global is_systemd 1 Name: iSulad @@ -12,30 +12,6 @@ Source: https://gitee.com/openeuler/iSulad/repository/archive/v%{version}.tar BuildRoot: {_tmppath}/iSulad-%{version} ExclusiveArch: x86_64 aarch64 -Patch0001: 0001-Add-a-solution-to-the-gpgkey-problem.patch -Patch0002: 0002-change-default-tmp-directory-from-var-tmp-to-var-lib.patch -Patch0003: 0003-update-api.proto-to-v1.19.3-according-to-kubelet.patch -Patch0004: 0004-adapt-CI-ISULAD_TMPDIR-testcases.patch -Patch0005: 0005-listening-127.0.0.1-port-in-cri-stream-websocket-ser.patch -Patch0006: 0006-using-64-bit-unique-token-in-CRI-websockets-server-R.patch -Patch0007: 0007-add-mock-conf_get_use_decrypted_key_flag-and-setup-a.patch -Patch0008: 0008-show-all-mutl-network-ips.patch -Patch0009: 0009-iSulad-only-qsort-the-configed-mounts.patch -Patch0010: 0010-CI-add-testcases-for-bind-proc-and-sys-fs.patch -Patch0011: 0011-verify-peer-if-it-s-secure-registry.patch -Patch0012: 0012-make-sure-all-certs-load-success-if-any-provided.patch -Patch0013: 0013-add-ch-docs-for-install-iSulad.patch -Patch0014: 0014-error-out-if-unpack-layer-failed.patch -Patch0015: 0015-ignore-get-ip-error-for-mutlnetwork.patch -Patch0016: 0016-support-default-container-log-options.patch -Patch0017: 0017-add-testcase-for-default-container-log-configs.patch -Patch0018: 0018-clean-code-ignore-list-containers-error.patch -Patch0019: 0019-add-g_oci_image_module_data-in-oci-image-module.patch -Patch0020: 0020-translate-absolute-path-to-relative-path-when-unpack.patch -Patch0021: 0021-clean-code-fix-check-error-in-terminal.c-and-volume_.patch -Patch0022: 0022-iSulad-bugfix-args-use_decrypted_key-is-a-pointer.patch -Patch0023: 0023-verify-peer-only-if-CA-configed.patch - %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) Provides: libisula.so()(64bit) @@ -237,6 +213,12 @@ fi %endif %changelog +* Wed Dec 30 2020 lifeng - 2.0.8-20201230.155843.git6557a6eb +- Type: update to v2.0.8 +- ID: NA +- SUG: NA +- DESC: update from master + * Mon Dec 7 2020 zhangxiaoyu - 2.0.7-20201207.151847.gita1fce123 - Type: update - ID: NA diff --git a/v2.0.7.tar.gz b/v2.0.8.tar.gz similarity index 52% rename from v2.0.7.tar.gz rename to v2.0.8.tar.gz index dd880178a837a5a55107ed33a6468af9f95a445d..a804420bd30646ee0304bb815aa20b71cd9312d4 100644 GIT binary patch delta 2033534 zcmV(?K-a&KhRgw;#?1kLABzY80000000Zni{d3#KmHE~9EB0hh{Sg5aDOqxqswqWL zHqI2ul2jaz<1$NNNg@IP1Pe%_o7^~a{Y);}xC6={w%xW#Q=`$A>=3CjtCAxGmt9{!tKe>+Ya_X^5 z?aYbxf&Q?xbn#$+|A+fA|If|OEk1SeM5R*KWA6V-|AysKucNp9utyIa=GVDo{9iao z|BH*+#fkX8xRiV9p-kdqu76$EwN=WQUGeHs-(}0hb+>y&%Uc%Xe8ab$w!^|oyUkg& zO!NgU?>ZeX-;MwnFmE-a))ux1uxu>&9%oh@IomAHIRG$!yYOYwrY>g_C~FK%FQkzJ zpb?xRw`joZGTU(-k3n0BwIkUCJ%`k@0TzX^LT`lB0mM#0X0rjW(;%Ab@4%mY*oj3` z#VfPjs03UG3?xPs1nDst8n3ida!ue5dE!6-WJP{xdQRj}*SUq{Q+ud){V-Z}eQOI4 z@^ui_WfCWU8FqqH0F9Jri@8T3uE(Awrfv+c?0ac6vt5s9#MJ1ga8x4_$R*lq*>oJQ z*bAb5ie<_7gM*~op?$s@GP)(~WR0~QoEzV(u_z9`Mn4!zIEs20!YYI4#5Q6#LOrv3 z6hhB@N~aCh3tSlOsAXMeTw8U#D%k755R`Hhc&Pn<1P;c{u7xxRpr>Vx5SS&Da-f~0 zbE4ob<$N6Gdr|1SgXte@E_!iq43wx;38A265RC^Q&nURkdbyAq=NPNHFwHUGrZ