diff --git a/0001-add-libisula.pc.patch b/0001-add-libisula.pc.patch new file mode 100644 index 0000000..c16bbcc --- /dev/null +++ b/0001-add-libisula.pc.patch @@ -0,0 +1,71 @@ +From 83b3f2f2b114915c250bdc4500138a8531750192 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Mon, 6 Feb 2023 20:36:17 +0800 +Subject: [PATCH] add libisula.pc + +Signed-off-by: zhangxiaoyu +--- + CMakeLists.txt | 7 +++++++ + lcr.pc.in | 2 +- + libisula.pc.in | 12 ++++++++++++ + 3 files changed, 20 insertions(+), 1 deletion(-) + create mode 100644 libisula.pc.in + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c1acbab..8ee67c1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -75,6 +75,11 @@ configure_file( + "${CMAKE_BINARY_DIR}/conf/lcr.pc" + ) + ++configure_file( ++ "${CMAKE_CURRENT_SOURCE_DIR}/libisula.pc.in" ++ "${CMAKE_BINARY_DIR}/conf/libisula.pc" ++) ++ + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party) + + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +@@ -112,6 +117,8 @@ endif() + # install all files + install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc + DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE) ++install(FILES ${CMAKE_BINARY_DIR}/conf/libisula.pc ++ DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE) + install(FILES src/lcrcontainer.h + DESTINATION include/lcr) + +diff --git a/lcr.pc.in b/lcr.pc.in +index e102dbb..419e187 100644 +--- a/lcr.pc.in ++++ b/lcr.pc.in +@@ -7,6 +7,6 @@ Name: liblcr + Description: light-weighted container runtime library + Version: @LCR_VERSION@ + URL: liblcr +-Libs: -L@CMAKE_INSTALL_PREFIX@/lib -llcr -lisula_libutils ++Libs: -L@CMAKE_INSTALL_PREFIX@/lib -llcr + Cflags: -I@CMAKE_INSTALL_PREFIX@/include + +diff --git a/libisula.pc.in b/libisula.pc.in +new file mode 100644 +index 0000000..2738dd3 +--- /dev/null ++++ b/libisula.pc.in +@@ -0,0 +1,12 @@ ++prefix=@CMAKE_INSTALL_PREFIX@ ++libdir=@CMAKE_INSTALL_PREFIX@/lib ++localstatedir=@CMAKE_INSTALL_PREFIX@/var ++includedir=@CMAKE_INSTALL_PREFIX@/include ++ ++Name: libisula ++Description: light-weighted container json and log libraries ++Version: @LCR_VERSION@ ++URL: libisula ++Libs: -L@CMAKE_INSTALL_PREFIX@/lib -lisula_libutils ++Cflags: -I@CMAKE_INSTALL_PREFIX@/include ++ +-- +2.25.1 + diff --git a/0002-add-unified-and-memory_swap_limit_in_bytes-into-host.patch b/0002-add-unified-and-memory_swap_limit_in_bytes-into-host.patch new file mode 100644 index 0000000..e5ba946 --- /dev/null +++ b/0002-add-unified-and-memory_swap_limit_in_bytes-into-host.patch @@ -0,0 +1,51 @@ +From 9bd736bc14da91bfc6ca8bf38f05218e5703adf5 Mon Sep 17 00:00:00 2001 +From: "ilya.kuksenok" +Date: Tue, 7 Feb 2023 13:51:44 +0300 +Subject: [PATCH 2/4] add unified and memory_swap_limit_in_bytes into + host-config + +--- + .gitignore | 2 ++ + src/json/schema/host-config.json | 8 +++++++- + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/.gitignore b/.gitignore +index 0995486..973ceef 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -1,3 +1,5 @@ + *.pyc + build + .vscode ++.idea ++cmake-build-debug +diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json +index c308558..0367a76 100644 +--- a/src/json/schema/host-config.json ++++ b/src/json/schema/host-config.json +@@ -139,9 +139,15 @@ + "Memory": { + "type": "int64" + }, ++ "Unified": { ++ "$ref": "defs.json#/definitions/mapStringString" ++ }, + "OomScoreAdj": { + "type": "integer" + }, ++ "MemorySwapLimitInBytes":{ ++ "type": "int64" ++ }, + "BlkioWeight": { + "type": "uint16" + }, +@@ -292,4 +298,4 @@ + "type": "string" + } + } +-} +\ No newline at end of file ++} +-- +2.25.1 + diff --git a/0002-fix-layer-size-type-as-int64.patch b/0002-fix-layer-size-type-as-int64.patch deleted file mode 100644 index 35f55af..0000000 --- a/0002-fix-layer-size-type-as-int64.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 9e9fbc213ce485a53b8dee07ad923369096ae899 Mon Sep 17 00:00:00 2001 -From: "Neil.wrz" -Date: Mon, 20 Feb 2023 22:24:30 -0800 -Subject: [PATCH 2/2] fix layer size type as int64 - -Signed-off-by: Neil.wrz ---- - src/json/schema/registry/manifest_schema2.json | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/json/schema/registry/manifest_schema2.json b/src/json/schema/registry/manifest_schema2.json -index 44f31db..78cc68c 100644 ---- a/src/json/schema/registry/manifest_schema2.json -+++ b/src/json/schema/registry/manifest_schema2.json -@@ -44,7 +44,7 @@ - "type": "string" - }, - "size": { -- "type": "integer" -+ "type": "int64" - }, - "digest": { - "$ref": "../defs.json#/definitions/digest" --- -2.25.1 - diff --git a/0001-fix-update-cpu-rt-period-failed.patch b/0003-fix-update-cpu-rt-period-failed.patch similarity index 61% rename from 0001-fix-update-cpu-rt-period-failed.patch rename to 0003-fix-update-cpu-rt-period-failed.patch index 6fcfa18..fdc15b9 100644 --- a/0001-fix-update-cpu-rt-period-failed.patch +++ b/0003-fix-update-cpu-rt-period-failed.patch @@ -1,26 +1,24 @@ -From 42cf57e75e50457c1a4ee28d286aa4644c9c266a Mon Sep 17 00:00:00 2001 +From d332dbb9050510f91445625b56952fd533ec530a Mon Sep 17 00:00:00 2001 From: songbuhuang <544824346@qq.com> -Date: Wed, 8 Feb 2023 10:40:20 +0800 -Subject: [PATCH 1/2] fix update cpu-rt period failed +Date: Wed, 8 Feb 2023 10:53:25 +0800 +Subject: [PATCH 3/4] fix update cpu-rt period failed Signed-off-by: songbuhuang <544824346@qq.com> --- - src/lcrcontainer_execute.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) + src/lcrcontainer_execute.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c -index ac49c50..4c49a28 100644 +index 3f5860f..ff4685b 100644 --- a/src/lcrcontainer_execute.c +++ b/src/lcrcontainer_execute.c -@@ -363,14 +363,15 @@ static bool update_resources_cpu_v1(struct lxc_container *c, const struct lcr_cg - if (!update_resources_cpuset_mems(c, cr)) { +@@ -360,13 +360,14 @@ static bool update_resources_cpu_v1(struct lxc_container *c, const struct lcr_cg goto err_out; } -- + - if (update_resources_cpu_rt_period(c, cr) != 0) { - goto err_out; - } -+ if (update_resources_cpu_rt_runtime(c, cr) != 0) { goto err_out; } diff --git a/0004-fix-writing-config-line-with-wrong-length.patch b/0004-fix-writing-config-line-with-wrong-length.patch new file mode 100644 index 0000000..641b948 --- /dev/null +++ b/0004-fix-writing-config-line-with-wrong-length.patch @@ -0,0 +1,40 @@ +From 4df2c0f530bfa62b98e22ea87a01fa567cf01ef3 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Thu, 9 Feb 2023 10:18:01 +0800 +Subject: [PATCH 4/4] fix writing config line with wrong length + +Signed-off-by: zhangxiaoyu +--- + src/lcrcontainer_extend.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/lcrcontainer_extend.c b/src/lcrcontainer_extend.c +index f6d1465..fb43b22 100644 +--- a/src/lcrcontainer_extend.c ++++ b/src/lcrcontainer_extend.c +@@ -841,7 +841,6 @@ static int lcr_spec_write_config(FILE *fp, const struct lcr_list *lcr_conf) + } + + nret = snprintf(line, len, "%s = %s", item->name, item->value); +- + if (nret < 0 || (size_t)nret >= len) { + ERROR("Sprintf failed"); + goto cleanup; +@@ -853,11 +852,10 @@ static int lcr_spec_write_config(FILE *fp, const struct lcr_list *lcr_conf) + goto cleanup; + } + +- nret = strlen(line_encode); +- +- line_encode[nret] = '\n'; ++ len = strlen(line_encode); ++ line_encode[len] = '\n'; + +- if (fwrite(line_encode, 1, len, fp) != len) { ++ if (fwrite(line_encode, 1, len + 1, fp) != len + 1) { + ERROR("Write file failed: %s", strerror(errno)); + goto cleanup; + } +-- +2.25.1 + diff --git a/0005-Add-memory-related-fields.patch b/0005-Add-memory-related-fields.patch new file mode 100644 index 0000000..3326e9a --- /dev/null +++ b/0005-Add-memory-related-fields.patch @@ -0,0 +1,38 @@ +From 3acca1f09f56d871fe38c741917822b96636b540 Mon Sep 17 00:00:00 2001 +From: "ilya.kuksenok" +Date: Wed, 8 Feb 2023 15:59:18 +0300 +Subject: [PATCH 5/8] Add memory related fields + +--- + src/json/schema/container/info.json | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json +index 8ce10af5..1db0ccf4 100644 +--- a/src/json/schema/container/info.json ++++ b/src/json/schema/container/info.json +@@ -17,6 +17,21 @@ + "cpu_use_user": { + "type": "uint64" + }, ++ "avaliable_bytes": { ++ "type": "uint64" ++ }, ++ "usage_bytes": { ++ "type": "uint64" ++ }, ++ "rss_bytes": { ++ "type": "uint64" ++ }, ++ "page_faults": { ++ "type": "uint64" ++ }, ++ "major_page_faults": { ++ "type": "uint64" ++ }, + "cpu_use_kernel": { + "type": "uint64" + }, +-- +2.25.1 + diff --git a/0006-mod-headers.patch b/0006-mod-headers.patch new file mode 100644 index 0000000..0e3024d --- /dev/null +++ b/0006-mod-headers.patch @@ -0,0 +1,28 @@ +From aa7af4993648e2d1fe002fabf2c103ae728d5888 Mon Sep 17 00:00:00 2001 +From: "ilya.kuksenok" +Date: Tue, 14 Feb 2023 14:01:46 +0300 +Subject: [PATCH 6/8] mod headers + +--- + src/lcrcontainer.h | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h +index 5134b59d..a222ac97 100644 +--- a/src/lcrcontainer.h ++++ b/src/lcrcontainer.h +@@ -90,6 +90,11 @@ struct lcr_container_state { + /* Memory usage */ + uint64_t mem_used; + uint64_t mem_limit; ++ uint64_t avaliable_bytes; ++ uint64_t usage_bytes; ++ uint64_t rss_bytes; ++ uint64_t page_faults; ++ uint64_t major_page_faults; + /* Kernel Memory usage */ + uint64_t kmem_used; + uint64_t kmem_limit; +-- +2.25.1 + diff --git a/0004-add-cgroup-resources-json-schema-for-isula-update.patch b/0007-add-cgroup-resources-json-schema-for-isula-update.patch similarity index 93% rename from 0004-add-cgroup-resources-json-schema-for-isula-update.patch rename to 0007-add-cgroup-resources-json-schema-for-isula-update.patch index 338a27c..fb52360 100644 --- a/0004-add-cgroup-resources-json-schema-for-isula-update.patch +++ b/0007-add-cgroup-resources-json-schema-for-isula-update.patch @@ -1,7 +1,7 @@ -From 3f1ef0eeb7fe469bfc42e1ea6726ec91a97e165d Mon Sep 17 00:00:00 2001 +From 6ca6e250fc0cc10290c6e495168b29e09e2a70e9 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Wed, 15 Feb 2023 16:05:39 +0800 -Subject: [PATCH 4/6] add cgroup resources json schema for isula update +Subject: [PATCH 7/8] add cgroup resources json schema for isula update Signed-off-by: zhongtao --- @@ -13,7 +13,7 @@ Signed-off-by: zhongtao diff --git a/src/json/schema/shim/client/cgroup-resources.json b/src/json/schema/shim/client/cgroup-resources.json new file mode 100644 -index 0000000..1031071 +index 00000000..10310710 --- /dev/null +++ b/src/json/schema/shim/client/cgroup-resources.json @@ -0,0 +1,58 @@ @@ -76,7 +76,7 @@ index 0000000..1031071 + } +} diff --git a/src/json/schema/shim/client/process-state.json b/src/json/schema/shim/client/process-state.json -index 05f55fc..f07d14f 100644 +index 05f55fc5..f07d14f1 100644 --- a/src/json/schema/shim/client/process-state.json +++ b/src/json/schema/shim/client/process-state.json @@ -1,4 +1,5 @@ @@ -86,7 +86,7 @@ index 05f55fc..f07d14f 100644 "type": "object", "required": [ diff --git a/src/json/schema/shim/client/runtime-stats.json b/src/json/schema/shim/client/runtime-stats.json -index 6ed9473..ae77e9d 100644 +index 6ed9473d..ae77e9db 100644 --- a/src/json/schema/shim/client/runtime-stats.json +++ b/src/json/schema/shim/client/runtime-stats.json @@ -1,4 +1,5 @@ diff --git a/0005-add-field-for-isulad-daemon-configs.patch b/0008-add-field-for-isulad-daemon-configs.patch similarity index 81% rename from 0005-add-field-for-isulad-daemon-configs.patch rename to 0008-add-field-for-isulad-daemon-configs.patch index 6e07a7b..7f0e9b7 100644 --- a/0005-add-field-for-isulad-daemon-configs.patch +++ b/0008-add-field-for-isulad-daemon-configs.patch @@ -1,7 +1,7 @@ -From 558723cf5f1506538822e716b5b9ae7ee84736f6 Mon Sep 17 00:00:00 2001 +From 825554c1318b94edd29d4f22a9c5cbc3270cf277 Mon Sep 17 00:00:00 2001 From: "Neil.wrz" Date: Wed, 15 Feb 2023 19:11:45 -0800 -Subject: [PATCH 5/6] add field for isulad daemon configs +Subject: [PATCH 8/8] add field for isulad daemon configs Signed-off-by: Neil.wrz --- @@ -9,7 +9,7 @@ Signed-off-by: Neil.wrz 1 file changed, 3 insertions(+) diff --git a/src/json/schema/isulad-daemon-configs.json b/src/json/schema/isulad-daemon-configs.json -index 1332a73..b75e929 100644 +index b1f60cf1..9ac8ee04 100644 --- a/src/json/schema/isulad-daemon-configs.json +++ b/src/json/schema/isulad-daemon-configs.json @@ -46,6 +46,9 @@ diff --git a/0003-adapt-to-repo-of-openeuler-url-changed.patch b/0009-adapt-to-repo-of-openeuler-url-changed.patch similarity index 50% rename from 0003-adapt-to-repo-of-openeuler-url-changed.patch rename to 0009-adapt-to-repo-of-openeuler-url-changed.patch index 7a5e112..819356c 100644 --- a/0003-adapt-to-repo-of-openeuler-url-changed.patch +++ b/0009-adapt-to-repo-of-openeuler-url-changed.patch @@ -1,7 +1,7 @@ -From 2e6991000d0e1e42db9f054400949543a1a44520 Mon Sep 17 00:00:00 2001 +From cd4ce196a2b144327f050269a14d8391a88e9920 Mon Sep 17 00:00:00 2001 From: zhongtao -Date: Mon, 6 Mar 2023 15:24:59 +0800 -Subject: [PATCH 3/6] adapt to repo of openeuler url changed +Date: Mon, 6 Mar 2023 15:28:43 +0800 +Subject: [PATCH 09/15] adapt to repo of openeuler url changed Signed-off-by: zhongtao --- @@ -9,18 +9,18 @@ Signed-off-by: zhongtao 1 file changed, 8 insertions(+) diff --git a/CI/pr-gateway.sh b/CI/pr-gateway.sh -index ae1e8ef..1a15461 100755 +index df345bd..66c2074 100755 --- a/CI/pr-gateway.sh +++ b/CI/pr-gateway.sh @@ -14,7 +14,15 @@ - ##- @Create: 2022-02-22 + ##- @Create: 2021-12-20 ####################################################################### +sed -i "s#http://repo.openeuler.org#https://repo.huaweicloud.com/openeuler#g" /etc/yum.repos.d/openEuler.repo + +dnf update -y + - dnf install -y gtest-devel gmock-devel gtest gmock diffutils cmake gcc-c++ yajl-devel patch make libtool git chrpath zlib-devel + dnf install -y gtest-devel gmock-devel diffutils cmake gcc-c++ yajl-devel patch make libtool libevent-devel libevhtp-devel grpc grpc-plugins grpc-devel protobuf-devel libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel http-parser-devel libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel systemd-devel git chrpath +if [ $? -ne 0 ]; then + echo "install dependences failed" + exit 1 diff --git a/0010-add-call-timeout-check-macro.patch b/0010-add-call-timeout-check-macro.patch new file mode 100644 index 0000000..43b947f --- /dev/null +++ b/0010-add-call-timeout-check-macro.patch @@ -0,0 +1,97 @@ +From edb2ec1336f59ad8ca093f8cf2b2e092ff62575e Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Wed, 8 Mar 2023 10:33:40 +0800 +Subject: [PATCH 10/15] add call timeout check macro + +1. add macro for check call function timeout, and output a log; +2. add testcase for call timeout check macro; + +Signed-off-by: haozi007 +--- + tests/log_ut.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ + third_party/log.h | 11 +++++++++++ + 2 files changed, 51 insertions(+) + +diff --git a/tests/log_ut.cpp b/tests/log_ut.cpp +index 8cf6599..2638e85 100644 +--- a/tests/log_ut.cpp ++++ b/tests/log_ut.cpp +@@ -166,6 +166,8 @@ TEST(log_testcases, test_isula_libutils_log_enable) + DEBUG("debug log"); + check_log(fd, false, false, "debug log"); + isula_libutils_log_disable(); ++ ++ unlink(fname); + } + + TEST(log_testcases, test_isula_libutils_log_prefix) +@@ -202,5 +204,43 @@ TEST(log_testcases, test_isula_libutils_log_prefix) + isula_libutils_set_log_prefix(""); + INFO("fake log"); + check_log(fd, true, true, default_prefix); ++ ++ isula_libutils_log_disable(); ++ unlink(fname); ++} ++ ++static int do_sleep(int time) ++{ ++ sleep(time); ++ return 1; + } + ++TEST(log_testcases, test_call_check_timeout) ++{ ++ struct isula_libutils_log_config tconf = {0}; ++ const char *default_prefix = "iSula"; ++ const char *prio = "INFO"; ++ const char *fname = "/tmp/fake.fifo"; ++ int fd = -1; ++ int nret; ++ ++ tconf.driver = ISULA_LOG_DRIVER_FIFO; ++ tconf.priority = prio; ++ tconf.file = fname; ++ isula_libutils_log_enable(&tconf); ++ ++ fd = isula_libutils_get_log_fd(); ++ ASSERT_GE(fd, 0); ++ ++ // not timeout, will no log ++ CALL_CHECK_TIMEOUT(2, do_sleep(1)); ++ check_log(fd, false, false, default_prefix); ++ ++ // timeout, should have log ++ CALL_CHECK_TIMEOUT(1, nret = do_sleep(2)); ++ check_log(fd, true, true, "use 1 sec, timeout!!"); ++ ASSERT_EQ(nret, 1); ++ ++ isula_libutils_log_disable(); ++ unlink(fname); ++} +\ No newline at end of file +diff --git a/third_party/log.h b/third_party/log.h +index 2db0d98..fad04a1 100644 +--- a/third_party/log.h ++++ b/third_party/log.h +@@ -452,6 +452,17 @@ void isula_libutils_log_disable(); + + int isula_libutils_get_log_fd(void); + ++#define CALL_CHECK_TIMEOUT(timeout, caller) \ ++ do { \ ++ struct timespec tbeg, tend; \ ++ (void)clock_gettime(CLOCK_REALTIME, &tbeg); \ ++ caller; \ ++ (void)clock_gettime(CLOCK_REALTIME, &tend); \ ++ if (tend.tv_sec - tbeg.tv_sec >= (timeout)) { \ ++ ERROR("Call: "#caller" use %d sec, timeout!!", timeout); \ ++ } \ ++ } while (0) ++ + #ifdef __cplusplus + } + #endif +-- +2.25.1 + diff --git a/0006-add-files_limit-to-oci-spec.patch b/0011-add-files_limit-to-oci-spec.patch similarity index 87% rename from 0006-add-files_limit-to-oci-spec.patch rename to 0011-add-files_limit-to-oci-spec.patch index de03a8c..9789867 100644 --- a/0006-add-files_limit-to-oci-spec.patch +++ b/0011-add-files_limit-to-oci-spec.patch @@ -1,7 +1,7 @@ -From fe5de86ac3df1ba26f50f0eacdfb525e52f33573 Mon Sep 17 00:00:00 2001 +From de9dad87ccd54bd2beceb0d8dbb6bd5c442270ff Mon Sep 17 00:00:00 2001 From: zhongtao Date: Sat, 8 Apr 2023 11:38:50 +0800 -Subject: [PATCH 6/6] add files_limit to oci spec +Subject: [PATCH 11/15] add files_limit to oci spec Signed-off-by: zhongtao --- @@ -9,10 +9,10 @@ Signed-off-by: zhongtao 1 file changed, 13 insertions(+) diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json -index 317cab4..27b2de2 100644 +index cfbaa19..58c56fe 100644 --- a/src/json/schema/defs.json +++ b/src/json/schema/defs.json -@@ -920,6 +920,19 @@ +@@ -989,6 +989,19 @@ "limit" ] }, diff --git a/0012-add-memory-info-from-runtime.patch b/0012-add-memory-info-from-runtime.patch new file mode 100644 index 0000000..302ae7c --- /dev/null +++ b/0012-add-memory-info-from-runtime.patch @@ -0,0 +1,76 @@ +From 85a5823c87f8b0e5d5b2172aa5e4564f50fbc011 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Fri, 21 Apr 2023 09:51:16 +0800 +Subject: [PATCH 12/15] add memory info from runtime + +Signed-off-by: zhangxiaoyu +--- + src/json/schema/container/info.json | 2 +- + src/json/schema/shim/client/runtime-stats.json | 9 +++++++++ + src/lcrcontainer.h | 2 -- + src/lcrcontainer_execute.c | 3 +++ + 4 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json +index 1db0ccf..19107a1 100644 +--- a/src/json/schema/container/info.json ++++ b/src/json/schema/container/info.json +@@ -20,7 +20,7 @@ + "avaliable_bytes": { + "type": "uint64" + }, +- "usage_bytes": { ++ "workingset_bytes": { + "type": "uint64" + }, + "rss_bytes": { +diff --git a/src/json/schema/shim/client/runtime-stats.json b/src/json/schema/shim/client/runtime-stats.json +index ae77e9d..6fdc579 100644 +--- a/src/json/schema/shim/client/runtime-stats.json ++++ b/src/json/schema/shim/client/runtime-stats.json +@@ -52,6 +52,15 @@ + "properties": { + "total_inactive_file": { + "$ref": "../../defs.json#/definitions/uint64" ++ }, ++ "rss": { ++ "$ref": "../../defs.json#/definitions/uint64" ++ }, ++ "pgfault": { ++ "$ref": "../../defs.json#/definitions/uint64" ++ }, ++ "pgmajfault": { ++ "$ref": "../../defs.json#/definitions/uint64" + } + } + } +diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h +index a222ac9..edfc869 100644 +--- a/src/lcrcontainer.h ++++ b/src/lcrcontainer.h +@@ -90,8 +90,6 @@ struct lcr_container_state { + /* Memory usage */ + uint64_t mem_used; + uint64_t mem_limit; +- uint64_t avaliable_bytes; +- uint64_t usage_bytes; + uint64_t rss_bytes; + uint64_t page_faults; + uint64_t major_page_faults; +diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c +index ff4685b..4d72050 100644 +--- a/src/lcrcontainer_execute.c ++++ b/src/lcrcontainer_execute.c +@@ -789,6 +789,9 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs) + lcs->mem_limit = lxc_metrics.mem_limit; + lcs->kmem_used = lxc_metrics.kmem_used; + lcs->kmem_limit = lxc_metrics.kmem_limit; ++ lcs->rss_bytes = lxc_metrics.rss_bytes; ++ lcs->page_faults = lxc_metrics.page_faults; ++ lcs->major_page_faults = lxc_metrics.major_page_faults; + + lcs->cache = lxc_metrics.cache; + lcs->cache_total = lxc_metrics.cache_total; +-- +2.25.1 + diff --git a/0013-add-unified-resources-and-remove-useless-MemorySwapL.patch b/0013-add-unified-resources-and-remove-useless-MemorySwapL.patch new file mode 100644 index 0000000..563e4b4 --- /dev/null +++ b/0013-add-unified-resources-and-remove-useless-MemorySwapL.patch @@ -0,0 +1,59 @@ +From 1839c09872b1e5a19109992c6ab52d9b45655ac6 Mon Sep 17 00:00:00 2001 +From: zhangxiaoyu +Date: Wed, 26 Apr 2023 17:08:04 +0800 +Subject: [PATCH 13/15] add unified resources and remove useless + MemorySwapLimitInBytes + +Signed-off-by: zhangxiaoyu +--- + src/json/schema/defs.json | 4 ++++ + src/json/schema/host-config.json | 3 --- + src/json/schema/shim/client/cgroup-resources.json | 3 +++ + 3 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json +index 58c56fe..d96ac4c 100644 +--- a/src/json/schema/defs.json ++++ b/src/json/schema/defs.json +@@ -969,6 +969,10 @@ + "id": "https://opencontainers.org/schema/bundle/linux/resources", + "type": "object", + "properties": { ++ "unified": { ++ "id": "https://opencontainers.org/schema/bundle/linux/resources/unified", ++ "$ref": "#/definitions/mapStringString" ++ }, + "devices": { + "id": "https://opencontainers.org/schema/bundle/linux/resources/devices", + "type": "array", +diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json +index 0367a76..302a537 100644 +--- a/src/json/schema/host-config.json ++++ b/src/json/schema/host-config.json +@@ -145,9 +145,6 @@ + "OomScoreAdj": { + "type": "integer" + }, +- "MemorySwapLimitInBytes":{ +- "type": "int64" +- }, + "BlkioWeight": { + "type": "uint16" + }, +diff --git a/src/json/schema/shim/client/cgroup-resources.json b/src/json/schema/shim/client/cgroup-resources.json +index 1031071..693bcf0 100644 +--- a/src/json/schema/shim/client/cgroup-resources.json ++++ b/src/json/schema/shim/client/cgroup-resources.json +@@ -53,6 +53,9 @@ + "$ref": "../../defs.json#/definitions/uint64" + } + } ++ }, ++ "unified": { ++ "$ref": "../../defs.json#/definitions/mapStringString" + } + } + } +-- +2.25.1 + diff --git a/0014-Add-resources-info-to-pod-inspection.patch b/0014-Add-resources-info-to-pod-inspection.patch new file mode 100644 index 0000000..43fe982 --- /dev/null +++ b/0014-Add-resources-info-to-pod-inspection.patch @@ -0,0 +1,61 @@ +From e76e5dec8ca66102fc883e1f4a9a1a4d9b102ada Mon Sep 17 00:00:00 2001 +From: xuepeng +Date: Fri, 28 Apr 2023 04:58:21 +0800 +Subject: [PATCH 14/15] Add resources info to pod inspection + +Signed-off-by: xuepeng +--- + src/json/schema/container/inspect.json | 37 ++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/src/json/schema/container/inspect.json b/src/json/schema/container/inspect.json +index d6dc8c3..9c76c33 100644 +--- a/src/json/schema/container/inspect.json ++++ b/src/json/schema/container/inspect.json +@@ -54,6 +54,43 @@ + } + } + }, ++ "Resources": { ++ "type": "object", ++ "properties": { ++ "CPUPeriod": { ++ "type": "int64" ++ }, ++ "CPUQuota": { ++ "type": "int64" ++ }, ++ "CPUShares": { ++ "type": "int64" ++ }, ++ "Memory": { ++ "type": "int64" ++ }, ++ "MemorySwap": { ++ "type": "int64" ++ }, ++ "Hugetlbs": { ++ "type": "array", ++ "items": { ++ "type": "object", ++ "properties": { ++ "PageSize": { ++ "type": "string" ++ }, ++ "Limit": { ++ "type": "uint64" ++ } ++ } ++ } ++ }, ++ "unified": { ++ "$ref": "../defs.json#/definitions/mapStringString" ++ } ++ } ++ }, + "Image": { + "type": "string" + }, +-- +2.25.1 + diff --git a/0015-Add-timestamp-and-calculated-cpu-usage-for-cpu-usage.patch b/0015-Add-timestamp-and-calculated-cpu-usage-for-cpu-usage.patch new file mode 100644 index 0000000..f9d86a3 --- /dev/null +++ b/0015-Add-timestamp-and-calculated-cpu-usage-for-cpu-usage.patch @@ -0,0 +1,38 @@ +From 9335aa89a00618814ca957dd2617d502a955f598 Mon Sep 17 00:00:00 2001 +From: xuepeng +Date: Fri, 5 May 2023 08:06:22 +0800 +Subject: [PATCH 15/15] Add timestamp and calculated cpu usage for cpu usage + support + +Signed-off-by: xuepeng +--- + src/json/schema/container/info.json | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json +index 19107a1..53d8a91 100644 +--- a/src/json/schema/container/info.json ++++ b/src/json/schema/container/info.json +@@ -14,6 +14,9 @@ + "cpu_use_nanos": { + "type": "uint64" + }, ++ "cpu_use_nanos_per_second": { ++ "type": "uint64" ++ }, + "cpu_use_user": { + "type": "uint64" + }, +@@ -73,6 +76,9 @@ + }, + "inactive_file_total": { + "type": "uint64" ++ }, ++ "timestamp": { ++ "type": "uint64" + } + } + } +-- +2.25.1 + diff --git a/lcr.spec b/lcr.spec index 4a3c629..a6b1cfc 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ -%global _version 2.0.9 -%global _release 4 +%global _version 2.1.1 +%global _release 6 %global _inner_name isula_libutils Name: lcr @@ -12,12 +12,21 @@ Group: Applications/System License: LGPLv2.1+ BuildRoot: %{_tmppath}/lcr-%{version} -Patch0001: 0001-fix-update-cpu-rt-period-failed.patch -Patch0002: 0002-fix-layer-size-type-as-int64.patch -Patch0003: 0003-adapt-to-repo-of-openeuler-url-changed.patch -Patch0004: 0004-add-cgroup-resources-json-schema-for-isula-update.patch -Patch0005: 0005-add-field-for-isulad-daemon-configs.patch -Patch0006: 0006-add-files_limit-to-oci-spec.patch +Patch0001: 0001-add-libisula.pc.patch +Patch0002: 0002-add-unified-and-memory_swap_limit_in_bytes-into-host.patch +Patch0003: 0003-fix-update-cpu-rt-period-failed.patch +Patch0004: 0004-fix-writing-config-line-with-wrong-length.patch +Patch0005: 0005-Add-memory-related-fields.patch +Patch0006: 0006-mod-headers.patch +Patch0007: 0007-add-cgroup-resources-json-schema-for-isula-update.patch +Patch0008: 0008-add-field-for-isulad-daemon-configs.patch +Patch0009: 0009-adapt-to-repo-of-openeuler-url-changed.patch +Patch0010: 0010-add-call-timeout-check-macro.patch +Patch0011: 0011-add-files_limit-to-oci-spec.patch +Patch0012: 0012-add-memory-info-from-runtime.patch +Patch0013: 0013-add-unified-resources-and-remove-useless-MemorySwapL.patch +Patch0014: 0014-Add-resources-info-to-pod-inspection.patch +Patch0015: 0015-Add-timestamp-and-calculated-cpu-usage-for-cpu-usage.patch %define lxcver_lower 4.0.3-2022102400 %define lxcver_upper 4.0.3-2022102500 @@ -27,7 +36,6 @@ BuildRequires: lxc > %{lxcver_lower} lxc < %{lxcver_upper} BuildRequires: lxc-devel > %{lxcver_lower} lxc-devel < %{lxcver_upper} BuildRequires: zlib-devel yajl-devel gtest-devel Requires: lxc > %{lxcver_lower} lxc < %{lxcver_upper} yajl zlib -ExclusiveArch: x86_64 aarch64 loongarch64 %ifarch x86_64 Provides: liblcr.so()(64bit) @@ -54,14 +62,30 @@ This package provides the lightweight container tools and library to control lxc-based containers. %package devel -Summary: Huawei container runtime, json and log C Library +Summary: Huawei container runtime headers for developing programs Group: Libraries -ExclusiveArch: x86_64 aarch64 sw_64 +ExclusiveArch: x86_64 aarch64 sw_64 loongarch64 Requires: %{name} = %{version}-%{release} -%description devel -the %{name}-libs package contains libraries for running iSula applications. +%package -n libisula +Summary: Huawei container json, log and utils C Library +Group: Libraries +ExclusiveArch: x86_64 aarch64 sw_64 loongarch64 +%package -n libisula-devel +Summary: Huawei container json, log and utils C headers +Group: Libraries +ExclusiveArch: x86_64 aarch64 sw_64 loongarch64 +Requires: libisula = %{version}-%{release} + +%description devel +the %{name}-devel package contains runtime headers for developing programs. + +%description -n libisula +the libisula package contains json, log and utils libraries for running iSula applications. + +%description -n libisula-devel +the libisula-devel package contains json, log and utils headers for developing programs. %prep %autosetup -n lcr-v%{_version} -Sgit -p1 @@ -82,11 +106,11 @@ install -m 0644 ../src/lcrcontainer.h %{buildroot}/%{_includedir}/lcr/lcrcontai chmod +x %{buildroot}/%{_libdir}/liblcr.so install -m 0644 ./src/libisula_libutils.so %{buildroot}/%{_libdir}/libisula_libutils.so +install -m 0644 ./conf/libisula.pc %{buildroot}/%{_libdir}/pkgconfig/libisula.pc install -d $RPM_BUILD_ROOT/%{_includedir}/%{_inner_name} install -m 0644 ../build/json/*.h %{buildroot}/%{_includedir}/%{_inner_name}/ install -m 0644 ../src/json/*.h %{buildroot}/%{_includedir}/%{_inner_name}/ -install -m 0644 ../third_party/log.h %{buildroot}/%{_includedir}/%{_inner_name}/log.h -install -m 0644 ../third_party/go_crc64.h %{buildroot}/%{_includedir}/%{_inner_name}/go_crc64.h +install -m 0644 ../third_party/*.h %{buildroot}/%{_includedir}/%{_inner_name}/ chmod +x %{buildroot}/%{_libdir}/libisula_libutils.so find %{buildroot} -type f -name '*.la' -exec rm -f {} ';' @@ -104,15 +128,29 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) -%{_libdir}/* +%{_libdir}/liblcr.so %{_libdir}/pkgconfig/lcr.pc %files devel %defattr(-,root,root,-) %{_includedir}/lcr/lcrcontainer.h + +%files -n libisula +%defattr(-,root,root,-) +%{_libdir}/libisula_libutils.so +%{_libdir}/pkgconfig/libisula.pc + +%files -n libisula-devel +%defattr(-,root,root,-) %{_includedir}/%{_inner_name}/*.h %changelog +* Thu May 11 2023 zhangxiaoyu - 2.1.1-6 +- Type:enhancement +- CVE:NA +- SUG:NA +- DESC:upgrade to 2.1.1 + * Mon Apr 24 2023 zhangxiaoyu - 2.0.9-4 - Type:bugfix - CVE:NA diff --git a/v2.0.9.tar.gz b/v2.0.9.tar.gz deleted file mode 100644 index 12544f8..0000000 Binary files a/v2.0.9.tar.gz and /dev/null differ diff --git a/v2.1.1.tar.gz b/v2.1.1.tar.gz new file mode 100644 index 0000000..321666b Binary files /dev/null and b/v2.1.1.tar.gz differ