upgrade from upstream

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
This commit is contained in:
zhangxiaoyu 2023-05-11 19:23:02 +08:00
parent 4a0d72b9cc
commit b92e3211b3
8 changed files with 415 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From cd4ce196a2b144327f050269a14d8391a88e9920 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 6 Mar 2023 15:28:43 +0800
Subject: [PATCH 09/15] adapt to repo of openeuler url changed
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
CI/pr-gateway.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CI/pr-gateway.sh b/CI/pr-gateway.sh
index df345bd..66c2074 100755
--- a/CI/pr-gateway.sh
+++ b/CI/pr-gateway.sh
@@ -14,7 +14,15 @@
##- @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 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
+fi
cd ~
--
2.25.1

View File

@ -0,0 +1,97 @@
From edb2ec1336f59ad8ca093f8cf2b2e092ff62575e Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
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 <liuhao27@huawei.com>
---
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

View File

@ -0,0 +1,37 @@
From de9dad87ccd54bd2beceb0d8dbb6bd5c442270ff Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sat, 8 Apr 2023 11:38:50 +0800
Subject: [PATCH 11/15] add files_limit to oci spec
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/defs.json | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index cfbaa19..58c56fe 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -989,6 +989,19 @@
"limit"
]
},
+ "files": {
+ "id": "https://opencontainers.org/schema/bundle/linux/resources/files",
+ "type": "object",
+ "properties": {
+ "limit": {
+ "id": "https://opencontainers.org/schema/bundle/linux/resources/files/limit",
+ "$ref": "#/definitions/int64"
+ }
+ },
+ "required": [
+ "limit"
+ ]
+ },
"blockIO": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO",
"type": "object",
--
2.25.1

View File

@ -0,0 +1,76 @@
From 85a5823c87f8b0e5d5b2172aa5e4564f50fbc011 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Fri, 21 Apr 2023 09:51:16 +0800
Subject: [PATCH 12/15] add memory info from runtime
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
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

View File

@ -0,0 +1,59 @@
From 1839c09872b1e5a19109992c6ab52d9b45655ac6 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 26 Apr 2023 17:08:04 +0800
Subject: [PATCH 13/15] add unified resources and remove useless
MemorySwapLimitInBytes
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
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

View File

@ -0,0 +1,61 @@
From e76e5dec8ca66102fc883e1f4a9a1a4d9b102ada Mon Sep 17 00:00:00 2001
From: xuepeng <xuxuepeng1@huawei.com>
Date: Fri, 28 Apr 2023 04:58:21 +0800
Subject: [PATCH 14/15] Add resources info to pod inspection
Signed-off-by: xuepeng <xuxuepeng1@huawei.com>
---
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

View File

@ -0,0 +1,38 @@
From 9335aa89a00618814ca957dd2617d502a955f598 Mon Sep 17 00:00:00 2001
From: xuepeng <xuxuepeng1@huawei.com>
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 <xuxuepeng1@huawei.com>
---
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

View File

@ -1,5 +1,5 @@
%global _version 2.1.1
%global _release 5
%global _release 6
%global _inner_name isula_libutils
Name: lcr
@ -20,6 +20,13 @@ 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
@ -138,6 +145,12 @@ rm -rf %{buildroot}
%{_includedir}/%{_inner_name}/*.h
%changelog
* Thu May 11 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-6
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:upgrade from upstream
* Tue Feb 21 2023 wangrunze <wangrunze13@loongson.cn> - 2.1.1-5
- Type:bugfix
- CVE:NA