!611 Upgrade to v2.1.3

* Upgrade to v2.1.3
This commit is contained in:
xuxuepeng 2023-08-29 11:40:21 +00:00 committed by haozi007
parent 6605ba0772
commit cff876a2c9
18 changed files with 58 additions and 3124 deletions

View File

@ -0,0 +1,26 @@
From 3f949cbfe601de10d813fd08a5ca58cdc5a7258e Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Tue, 29 Aug 2023 19:21:27 +0800
Subject: [PATCH] Use reference in loop in listpodsandbox
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
index 33b700f3..687f4e6d 100644
--- a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc
@@ -739,7 +739,7 @@ void PodSandboxManagerService::ListPodSandbox(const runtime::v1::PodSandboxFilte
sandbox::SandboxManager::GetInstance()->ListAllSandboxes(filter, sandboxes);
- for (const auto sandbox : sandboxes) {
+ for (const auto &sandbox : sandboxes) {
std::unique_ptr<runtime::v1::PodSandbox> pod(new runtime::v1::PodSandbox);
pod->set_id(sandbox->GetId());
--
2.40.1

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
From b20af14432e3befcae1c40de91a4dfb579ccd03b Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sat, 13 May 2023 11:05:35 +0800
Subject: [PATCH 2/9] restore ping head
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
test/image/oci/registry/data/v2/ping_head | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/image/oci/registry/data/v2/ping_head b/test/image/oci/registry/data/v2/ping_head
index d9456e50..93742901 100644
--- a/test/image/oci/registry/data/v2/ping_head
+++ b/test/image/oci/registry/data/v2/ping_head
@@ -4,6 +4,6 @@ Date: Thu, 02 Jul 2020 09:14:14 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 2
Connection: keep-alive
-Docker-Distribution-Api-Version: registry/2.0
-
+Docker-Distribution-Api-Version: registry/2.0
+
{"errors":[{"code":"UNAUTHORIZED","message":"Unauthorized access."}]}
--
2.40.1

View File

@ -1,42 +0,0 @@
From 5bfde56d1130572e9bf76dd0fc40a5f0a34923d2 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sun, 14 May 2023 14:02:48 +0800
Subject: [PATCH 3/9] fix health_check.sh
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
CI/test_cases/container_cases/health_check.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/CI/test_cases/container_cases/health_check.sh b/CI/test_cases/container_cases/health_check.sh
index 621574cd..1542bd09 100755
--- a/CI/test_cases/container_cases/health_check.sh
+++ b/CI/test_cases/container_cases/health_check.sh
@@ -103,7 +103,7 @@ function test_health_check_normally()
[[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "healthy" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not healthy" && ((ret++))
- kill -9 $(isula inspect -f '{{.State.Pid}}' ${container_name}) && sleep 1 # Wait for the container to be killed
+ kill -9 $(isula inspect -f '{{.State.Pid}}' ${container_name}) && sleep 2 # Wait for the container to be killed
# The container process exits abnormally and the health check status becomes unhealthy
[[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
@@ -139,13 +139,13 @@ function test_health_check_timeout()
[[ $(isula inspect -f '{{.State.Status}}' ${container_name}) == "running" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container status: not running" && ((ret++))
- sleep 1 # Health check has been performed yet
+ sleep 2 # Health check has been performed yet
# Initial status when the container is still starting
[[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
- sleep 7 # finish first health check
+ sleep 10 # finish first health check
# The container process exits and the health check status becomes unhealthy
[[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
--
2.40.1

View File

@ -1,62 +0,0 @@
From 2c651d3ed5e7d7d78338ce542e66ee9fb36a9275 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sun, 14 May 2023 14:25:22 +0800
Subject: [PATCH 4/9] ensure isulad_io not NULL before close fd
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/cmd/isulad-shim/process.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index 7716c288..6ad50c53 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -194,6 +194,10 @@ static int stdin_cb(int fd, uint32_t events, void *cbdata, struct epoll_descr *d
} else {
fd_to = &(p->shim_io->in);
}
+
+ if (fd_to == NULL || *fd_to == -1) {
+ return EPOLL_LOOP_HANDLE_CONTINUE;
+ }
w_count = write_nointr_in_total(*fd_to, p->buf, r_count);
if (w_count < 0) {
/* When any error occurs, set the write fd -1 */
@@ -797,21 +801,21 @@ static int init_isulad_stdio(process_t *p)
return SHIM_OK;
failure:
if (p->isulad_io != NULL) {
+ if (p->isulad_io->in > 0) {
+ close(p->isulad_io->in);
+ }
+ if (p->isulad_io->out > 0) {
+ close(p->isulad_io->out);
+ }
+ if (p->isulad_io->err > 0) {
+ close(p->isulad_io->err);
+ }
+ if (p->isulad_io->resize > 0) {
+ close(p->isulad_io->resize);
+ }
free(p->isulad_io);
p->isulad_io = NULL;
}
- if (p->isulad_io->in > 0) {
- close(p->isulad_io->in);
- }
- if (p->isulad_io->out > 0) {
- close(p->isulad_io->out);
- }
- if (p->isulad_io->err > 0) {
- close(p->isulad_io->err);
- }
- if (p->isulad_io->resize > 0) {
- close(p->isulad_io->resize);
- }
return SHIM_ERR;
}
--
2.40.1

View File

@ -1,75 +0,0 @@
From 57921deef3849f519b3fffdcf76184144ba54fb3 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 16 May 2023 15:16:13 +0800
Subject: [PATCH 5/9] recheck delete command exit status
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
.../modules/runtime/isula/isula_rt_ops.c | 24 ++++++++++++-------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 9008c5c7..07f714f0 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -635,9 +635,9 @@ static int runtime_call_simple(const char *workdir, const char *runtime, const c
}
// oci runtime return -1 if the container 'does not exist'
-// if output contains 'does not exist', means nothing to kill, return 0
-// this will change the exit status of kill command
-static int kill_output_check(const char *output)
+// if output contains 'does not exist', means nothing to kill or delete, return 0
+// this will change the exit status of kill or delete command
+static int non_existent_output_check(const char *output)
{
char *pattern = "does not exist";
@@ -645,24 +645,24 @@ static int kill_output_check(const char *output)
return -1;
}
- // container not exist, kill success, return 0
+ // container not exist, kill or delete success, return 0
if (util_strings_contains_word(output, pattern)) {
return 0;
}
- // kill failed, return -1
+ // kill or delete failed, return -1
return -1;
}
-// kill success or kill_output_check succeed return 0, DO_RETRY_CALL will break;
+// kill success or non_existent_output_check succeed return 0, DO_RETRY_CALL will break;
// if kill failed, recheck on shim alive, if not alive, kill succeed, still return 0;
// else, return -1, DO_RETRY_CALL will call this again;
static int runtime_call_kill_and_check(const char *workdir, const char *runtime, const char *id)
{
int ret = -1;
- // kill succeed, return 0; kill_output_check succeed, return 0;
- ret = runtime_call_simple(workdir, runtime, "kill", NULL, 0, id, kill_output_check);
+ // kill succeed, return 0; non_existent_output_check succeed, return 0;
+ ret = runtime_call_simple(workdir, runtime, "kill", NULL, 0, id, non_existent_output_check);
if (ret == 0) {
return 0;
}
@@ -677,7 +677,13 @@ static int runtime_call_kill_and_check(const char *workdir, const char *runtime,
static int runtime_call_delete_force(const char *workdir, const char *runtime, const char *id)
{
const char *opts[1] = { "--force" };
- return runtime_call_simple(workdir, runtime, "delete", opts, 1, id, NULL);
+ // delete succeed, return 0;
+ // When the runc version is less than or equal to v1.0.0-rc3,
+ // if the container does not exist when force deleting it,
+ // runc will report an error and isulad does not need to retry the deletion again.
+ // related PR ID:d1a743674a98e23d348b29f52c43436356f56b79
+ // non_existent_output_check succeed, return 0;
+ return runtime_call_simple(workdir, runtime, "delete", opts, 1, id, non_existent_output_check);
}
#define ExitSignalOffset 128
--
2.40.1

View File

@ -1,31 +0,0 @@
From f591197fc150e9a137d869b518cda4cecbf70363 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Thu, 18 May 2023 19:07:13 +0800
Subject: [PATCH 6/9] restore execSync return value
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/daemon/entry/connect/grpc/runtime_runtime_service.cc | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
index 63a780cb..354b220e 100644
--- a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
+++ b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
@@ -279,13 +279,6 @@ grpc::Status RuntimeRuntimeServiceImpl::ExecSync(grpc::ServerContext *context,
return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
}
- if (reply->exit_code() != 0) {
- ERROR("Object: CRI, Type: Sync exec in container: %s with exit code: %d", request->container_id().c_str(),
- reply->exit_code());
- error.SetError(reply->stderr());
- return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
- }
-
WARN("Event: {Object: CRI, Type: sync execed Container: %s}", request->container_id().c_str());
return grpc::Status::OK;
--
2.40.1

View File

@ -1,131 +0,0 @@
From e04d2f1d8382e7b3e81ab4725a21562147ad1727 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 22 May 2023 12:50:32 +0800
Subject: [PATCH 7/9] reinforce cri_stream.sh and health_check.sh
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
CI/test_cases/container_cases/cri_stream.sh | 30 ++++++++++++----
CI/test_cases/container_cases/health_check.sh | 34 ++++++++++++++-----
2 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/CI/test_cases/container_cases/cri_stream.sh b/CI/test_cases/container_cases/cri_stream.sh
index 8b5440d3..bfe90208 100755
--- a/CI/test_cases/container_cases/cri_stream.sh
+++ b/CI/test_cases/container_cases/cri_stream.sh
@@ -58,6 +58,9 @@ function set_up()
function test_cri_exec_fun()
{
local ret=0
+ local retry_limit=20
+ local retry_interval=1
+ local success=1
local test="test_cri_exec_fun => (${FUNCNAME[@]})"
msg_info "${test} starting..."
declare -a fun_pids
@@ -74,9 +77,15 @@ function test_cri_exec_fun()
done
wait ${abn_pids[*]// /|}
- sleep 2
- ps -T -p $(cat /var/run/isulad.pid) | grep IoCopy
- [[ $? -eq 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual IO copy thread in CRI exec operation" && ((ret++))
+ for i in $(seq 1 "$retry_limit"); do
+ ps -T -p $(cat /var/run/isulad.pid) | grep IoCopy
+ if [ $? -ne 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual IO copy thread in CRI exec operation" && ((ret++))
msg_info "${test} finished with return ${ret}..."
return ${ret}
@@ -85,6 +94,9 @@ function test_cri_exec_fun()
function test_cri_exec_abn
{
local ret=0
+ local retry_limit=20
+ local retry_interval=1
+ local success=1
local test="test_cri_exec_abn => (${FUNCNAME[@]})"
msg_info "${test} starting..."
@@ -92,10 +104,16 @@ function test_cri_exec_abn
pid=$!
sleep 3
kill -9 $pid
- sleep 2
- ps -T -p $(cat /var/run/isulad.pid) | grep IoCopy
- [[ $? -eq 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual IO copy thread in CRI exec operation" && ((ret++))
+ for i in $(seq 1 "$retry_limit"); do
+ ps -T -p $(cat /var/run/isulad.pid) | grep IoCopy
+ if [ $? -ne 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - residual IO copy thread in CRI exec operation" && ((ret++))
msg_info "${test} finished with return ${ret}..."
return ${ret}
diff --git a/CI/test_cases/container_cases/health_check.sh b/CI/test_cases/container_cases/health_check.sh
index 1542bd09..28af6149 100755
--- a/CI/test_cases/container_cases/health_check.sh
+++ b/CI/test_cases/container_cases/health_check.sh
@@ -123,6 +123,9 @@ function test_health_check_timeout()
{
local ret=0
local image="busybox"
+ local retry_limit=10
+ local retry_interval=1
+ local success=1
local test="list && inspect image info test => (${FUNCNAME[@]})"
msg_info "${test} starting..."
@@ -139,16 +142,31 @@ function test_health_check_timeout()
[[ $(isula inspect -f '{{.State.Status}}' ${container_name}) == "running" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container status: not running" && ((ret++))
- sleep 2 # Health check has been performed yet
-
+ # Health check has been performed yet
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# Initial status when the container is still starting
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
-
- sleep 10 # finish first health check
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
+
+ sleep 7 # finish first health check
+
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# The container process exits and the health check status becomes unhealthy
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
[[ $(isula inspect -f '{{.State.ExitCode}}' ${container_name}) == "137" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container exit code: not 137" && ((ret++))
--
2.40.1

View File

@ -1,166 +0,0 @@
From ab3d902b09ace8d69172a4ea6cf9771a21540ffb Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 22 May 2023 19:37:23 +0800
Subject: [PATCH 8/9] reinforce omit health_check.sh
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
CI/test_cases/container_cases/health_check.sh | 100 +++++++++++++++---
1 file changed, 83 insertions(+), 17 deletions(-)
diff --git a/CI/test_cases/container_cases/health_check.sh b/CI/test_cases/container_cases/health_check.sh
index 28af6149..0bbad16e 100755
--- a/CI/test_cases/container_cases/health_check.sh
+++ b/CI/test_cases/container_cases/health_check.sh
@@ -29,6 +29,9 @@ isula pull ${image}
function test_health_check_paraments()
{
local ret=0
+ local retry_limit=10
+ local retry_interval=1
+ local success=1
local test="list && inspect image info test => (${FUNCNAME[@]})"
msg_info "${test} starting..."
@@ -45,16 +48,33 @@ function test_health_check_paraments()
[[ $(isula inspect -f '{{.State.Status}}' ${container_name}) == "running" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container status: not running" && ((ret++))
- sleep 13 # finish first health check
+ # finish first health check
+ sleep 10
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# keep starting status with health check return non-zero at always until status change to unhealthy
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
sleep 6 # finish second health check
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
+
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
# validate --health-retries option
[[ $(isula inspect -f '{{.State.Health.FailingStreak}}' ${container_name}) == "2" ]]
@@ -77,6 +97,9 @@ function test_health_check_normally()
{
local ret=0
local image="busybox"
+ local retry_limit=10
+ local retry_interval=1
+ local success=1
local test="list && inspect image info test => (${FUNCNAME[@]})"
msg_info "${test} starting..."
@@ -92,25 +115,60 @@ function test_health_check_normally()
[[ $(isula inspect -f '{{.State.Status}}' ${container_name}) == "running" ]]
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container status: not running" && ((ret++))
- sleep 2 # Health check has been performed yet
+ # Health check has been performed yet
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# Initial status when the container is still starting
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "starting" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not starting" && ((ret++))
sleep 8 # finish first health check
+
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "healthy" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# When the health check returns successfully, status immediately becomes healthy
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "healthy" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not healthy" && ((ret++))
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not healthy" && ((ret++))
- kill -9 $(isula inspect -f '{{.State.Pid}}' ${container_name}) && sleep 2 # Wait for the container to be killed
+ kill -9 $(isula inspect -f '{{.State.Pid}}' ${container_name})
+
+ # Wait for the container to be killed
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
# The container process exits abnormally and the health check status becomes unhealthy
- [[ $(isula inspect -f '{{.State.Health.Status}}' ${container_name}) == "unhealthy" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
- [[ $(isula inspect -f '{{.State.ExitCode}}' ${container_name}) == "137" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container exit code: not 137" && ((ret++))
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.ExitCode}}' ${container_name}) == "137" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
+
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container exit code: not 137" && ((ret++))
isula rm -f ${container_name}
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to remove container: ${container_name}" && ((ret++))
@@ -168,8 +226,16 @@ function test_health_check_timeout()
# The container process exits and the health check status becomes unhealthy
[[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container health check status: not unhealthy" && ((ret++))
- [[ $(isula inspect -f '{{.State.ExitCode}}' ${container_name}) == "137" ]]
- [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container exit code: not 137" && ((ret++))
+ success=1
+ for i in $(seq 1 "$retry_limit"); do
+ [[ $(isula inspect -f '{{.State.ExitCode}}' ${container_name}) == "137" ]]
+ if [ $? -eq 0 ]; then
+ success=0
+ break;
+ fi
+ sleep $retry_interval
+ done
+ [[ $success -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - incorrent container exit code: not 137" && ((ret++))
isula rm -f ${container_name}
[[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - failed to remove container: ${container_name}" && ((ret++))
--
2.40.1

View File

@ -1,75 +0,0 @@
From ab1f394910103615d015077d538cb71c363397fc Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Tue, 23 May 2023 19:01:40 -0700
Subject: [PATCH 9/9] fix memory leak and array access out of range
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
.../oci/storage/remote_layer_support/remote_support.c | 4 ++--
.../storage/remote_layer_support/ro_symlink_maintain.c | 2 +-
src/utils/http/parser.c | 10 ++++++++++
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c b/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
index 748298cb..400678c4 100644
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/remote_support.c
@@ -105,12 +105,12 @@ int remote_start_refresh_thread(pthread_rwlock_t *remote_lock)
res = pthread_create(&a_thread, NULL, remote_refresh_ro_symbol_link, (void *)&supporters);
if (res != 0) {
CRIT("Thread creation failed");
- return -1;
+ goto free_out;
}
if (pthread_detach(a_thread) != 0) {
SYSERROR("Failed to detach 0x%lx", a_thread);
- return -1;
+ goto free_out;
}
return 0;
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
index 0e2b671b..2bcc43e6 100644
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
@@ -136,7 +136,7 @@ static int do_build_ro_dir(const char *home, const char *id)
nret = asprintf(&ro_layer_dir, "%s/%s/%s", home, REMOTE_RO_LAYER_DIR, id);
if (nret < 0 || nret > PATH_MAX) {
SYSERROR("Failed to create ro layer dir path");
- return -1;
+ goto out;
}
if (util_mkdir_p(ro_layer_dir, IMAGE_STORE_PATH_MODE) != 0) {
diff --git a/src/utils/http/parser.c b/src/utils/http/parser.c
index 12df2435..a79893ba 100644
--- a/src/utils/http/parser.c
+++ b/src/utils/http/parser.c
@@ -88,6 +88,11 @@ static int parser_cb_header_field(http_parser *parser, const char *buf,
m->num_headers++;
}
+ if (m->num_headers == 0) {
+ ERROR("Failed to parse header field because headers num is 0");
+ return -1;
+ }
+
strlncat(m->headers[m->num_headers - 1][0], sizeof(m->headers[m->num_headers - 1][0]), buf, len);
m->last_header_element = FIELD;
@@ -100,6 +105,11 @@ static int parser_cb_header_value(http_parser *parser, const char *buf,
size_t len)
{
struct parsed_http_message *m = parser->data;
+
+ if (m->num_headers == 0) {
+ ERROR("Failed to parse header value because headers num is 0");
+ return -1;
+ }
strlncat(m->headers[m->num_headers - 1][1], sizeof(m->headers[m->num_headers - 1][1]), buf, len);
m->last_header_element = VALUE;
--
2.40.1

View File

@ -1,130 +0,0 @@
From 10d3f420735925bcc747384198fdc07bb8faf0c2 Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Wed, 24 May 2023 18:35:33 -0700
Subject: [PATCH 10/15] fix memory leak of top_layer
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
.../oci/storage/image_store/image_store.c | 3 +-
.../remote_layer_support/image_remote_impl.c | 50 +++++++++++++------
.../overlay_remote_impl.c | 4 +-
3 files changed, 38 insertions(+), 19 deletions(-)
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 473ba3c8..65b90832 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
@@ -3681,7 +3681,8 @@ int remote_append_image_by_directory_with_lock(const char *id)
nret = snprintf(image_path, sizeof(image_path), "%s/%s", g_image_store->dir, id);
if (nret < 0 || (size_t)nret >= sizeof(image_path)) {
ERROR("Failed to get image path");
- return -1;
+ ret = -1;
+ goto out;
}
ret = append_image_by_directory(image_path);
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c b/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
index 92bf901d..b4a53ec1 100644
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/image_remote_impl.c
@@ -126,11 +126,43 @@ out:
return ret;
}
+static int check_top_layer_and_add_image(const char *id)
+{
+ char *top_layer = NULL;
+ int ret = 0;
+
+ top_layer = remote_image_get_top_layer_from_json(id);
+ if (top_layer == NULL) {
+ WARN("Can't get top layer id for image: %s, image not add", id);
+ return 0;
+ }
+
+ if (!remote_layer_layer_valid(top_layer)) {
+ WARN("Current not find valid under layer, remote image:%s not add", id);
+ if (!map_remove(image_byid_new, (void *)id)) {
+ WARN("image %s will not be loaded from remote.", id);
+ }
+ goto out;
+ }
+
+ if (remote_append_image_by_directory_with_lock(id) != 0) {
+ ERROR("Failed to load image into memrory: %s", id);
+ if (!map_remove(image_byid_new, (void *)id)) {
+ WARN("image %s will not be loaded from remote", id);
+ }
+ ret = -1;
+ }
+
+out:
+ free(top_layer);
+
+ return ret;
+}
+
static int remote_image_add(void *data)
{
char **array_added = NULL;
char **array_deleted = NULL;
- char *top_layer = NULL;
map_t *tmp_map = NULL;
bool exist = true;
size_t i = 0;
@@ -144,20 +176,7 @@ static int remote_image_add(void *data)
array_deleted = remote_deleted_layers(image_byid_old, image_byid_new);
for (i = 0; i < util_array_len((const char **)array_added); i++) {
- top_layer = remote_image_get_top_layer_from_json(array_added[i]);
- if (top_layer != NULL && !remote_layer_layer_valid(top_layer)) {
- WARN("Current not find valid under layer, remoet image:%s not added", array_added[i]);
- if (!map_remove(image_byid_new, (void *)array_added[i])) {
- WARN("image %s will not be loaded from remote.", array_added[i]);
- }
- continue;
- }
-
- if (remote_append_image_by_directory_with_lock(array_added[i]) != 0) {
- ERROR("Failed to load image into memrory: %s", array_added[i]);
- if (!map_remove(image_byid_new, (void *)array_added[i])) {
- WARN("image %s will not be loaded from remote", array_added[i]);
- }
+ if (check_top_layer_and_add_image(array_added[i]) != 0) {
ret = -1;
}
}
@@ -179,7 +198,6 @@ static int remote_image_add(void *data)
util_free_array(array_added);
util_free_array(array_deleted);
- free(top_layer);
return ret;
}
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c b/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
index 30caf175..238506c2 100644
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/overlay_remote_impl.c
@@ -292,7 +292,7 @@ free_out:
return ret;
}
-static int remote_image_add(struct remote_overlay_data *data)
+static int remote_overlay_add(struct remote_overlay_data *data)
{
int ret = 0;
char **array_added = NULL;
@@ -346,7 +346,7 @@ void remote_overlay_refresh(struct remote_overlay_data *data)
return;
}
- if (remote_image_add(data) != 0) {
+ if (remote_overlay_add(data) != 0) {
ERROR("refresh overlay failed");
}
}
--
2.25.1

View File

@ -1,223 +0,0 @@
From b878dde993c8da90788fae5c2a463812001bff30 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 24 May 2023 09:35:35 +0800
Subject: [PATCH 11/15] distinguishing exit codes between shim and container
processes
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/cmd/isulad-shim/main.c | 10 ++-
src/cmd/isulad-shim/process.c | 8 ++-
.../modules/runtime/isula/isula_rt_ops.c | 63 +++++++++++++++----
3 files changed, 64 insertions(+), 17 deletions(-)
diff --git a/src/cmd/isulad-shim/main.c b/src/cmd/isulad-shim/main.c
index ed55805c..e2625aac 100644
--- a/src/cmd/isulad-shim/main.c
+++ b/src/cmd/isulad-shim/main.c
@@ -160,5 +160,13 @@ int main(int argc, char **argv)
released_timeout_exit();
- return process_signal_handle_routine(p, tid_epoll, timeout);
+ ret = process_signal_handle_routine(p, tid_epoll, timeout);
+ if (ret == SHIM_ERR) {
+ exit(EXIT_FAILURE);
+ }
+ if (ret == SHIM_ERR_TIMEOUT) {
+ exit(SHIM_EXIT_TIMEOUT);
+ }
+
+ exit(EXIT_SUCCESS);
}
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index 6ad50c53..1d070f83 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -1269,7 +1269,7 @@ int process_signal_handle_routine(process_t *p, const pthread_t tid_epoll, const
nret = kill(p->ctr_pid, SIGKILL);
if (nret < 0 && errno != ESRCH) {
write_message(g_log_fd, ERR_MSG, "Can not kill process (pid=%d) with SIGKILL", p->ctr_pid);
- exit(EXIT_FAILURE);
+ return SHIM_ERR;
}
}
@@ -1307,8 +1307,10 @@ int process_signal_handle_routine(process_t *p, const pthread_t tid_epoll, const
if (ret == SHIM_ERR_TIMEOUT) {
write_message(g_log_fd, INFO_MSG, "Wait %d timeout", p->ctr_pid);
- exit(SHIM_EXIT_TIMEOUT);
+ return SHIM_ERR_TIMEOUT;
}
- return status;
+ // write container process exit_code in stdout
+ (void)write_nointr(STDOUT_FILENO, &status, sizeof(int));
+ return SHIM_OK;
}
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 07f714f0..84a081c1 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -677,9 +677,9 @@ static int runtime_call_kill_and_check(const char *workdir, const char *runtime,
static int runtime_call_delete_force(const char *workdir, const char *runtime, const char *id)
{
const char *opts[1] = { "--force" };
- // delete succeed, return 0;
- // When the runc version is less than or equal to v1.0.0-rc3,
- // if the container does not exist when force deleting it,
+ // delete succeed, return 0;
+ // When the runc version is less than or equal to v1.0.0-rc3,
+ // if the container does not exist when force deleting it,
// runc will report an error and isulad does not need to retry the deletion again.
// related PR ID:d1a743674a98e23d348b29f52c43436356f56b79
// non_existent_output_check succeed, return 0;
@@ -704,11 +704,16 @@ static int status_to_exit_code(int status)
return exit_code;
}
+/*
+ exit_code records the exit code of the container, obtained by reading the stdout of isulad-shim;
+ shim_exit_code records the exit code of isulad-shim, obtained through waitpid;
+*/
static int shim_create(bool fg, const char *id, const char *workdir, const char *bundle, const char *runtime_cmd,
- int *exit_code, const char* timeout)
+ int *exit_code, const char* timeout, int* shim_exit_code)
{
pid_t pid = 0;
int exec_fd[2] = { -1, -1 };
+ int shim_stdout_pipe[2] = { -1, -1 };
int num = 0;
int ret = 0;
char exec_buff[BUFSIZ + 1] = { 0 };
@@ -738,11 +743,18 @@ static int shim_create(bool fg, const char *id, const char *workdir, const char
return -1;
}
+ if (pipe2(shim_stdout_pipe, O_CLOEXEC) != 0) {
+ ERROR("Failed to create pipe for shim exit code");
+ return -1;
+ }
+
pid = fork();
if (pid < 0) {
ERROR("Failed fork for shim parent %s", strerror(errno));
close(exec_fd[0]);
close(exec_fd[1]);
+ close(shim_stdout_pipe[0]);
+ close(shim_stdout_pipe[1]);
return -1;
}
@@ -777,12 +789,21 @@ static int shim_create(bool fg, const char *id, const char *workdir, const char
realexec:
/* real shim process. */
close(exec_fd[0]);
+ close(shim_stdout_pipe[0]);
+ // child process, dup2 shim_stdout_pipe[1] to STDOUT
+ if (dup2(shim_stdout_pipe[1], STDOUT_FILENO) < 0) {
+ (void)dprintf(exec_fd[1], "Dup fd error: %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
if (setsid() < 0) {
(void)dprintf(exec_fd[1], "%s: failed setsid for process %d", id, getpid());
exit(EXIT_FAILURE);
}
-
- if (util_check_inherited(true, exec_fd[1]) != 0) {
+ int ignore_fd[2] = {-1, -1};
+ ignore_fd[0] = exec_fd[1];
+ ignore_fd[1] = shim_stdout_pipe[1];
+ if (util_check_inherited_exclude_fds(true, ignore_fd, 2) != 0) {
(void)dprintf(exec_fd[1], "close inherited fds failed");
}
@@ -791,24 +812,38 @@ realexec:
}
close(exec_fd[1]);
+ close(shim_stdout_pipe[1]);
num = util_read_nointr(exec_fd[0], exec_buff, sizeof(exec_buff) - 1);
close(exec_fd[0]);
if (num > 0) {
- ERROR("exec failed: %s", exec_buff);
+ ERROR("Exec failed: %s", exec_buff);
ret = -1;
goto out;
}
status = util_wait_for_pid_status(pid);
if (status < 0) {
- ERROR("failed wait shim-parent %d exit %s", pid, strerror(errno));
+ ERROR("Failed wait shim-parent %d exit %s", pid, strerror(errno));
ret = -1;
goto out;
}
- if (exit_code != NULL) {
- *exit_code = status_to_exit_code(status);
+ *shim_exit_code = status_to_exit_code(status);
+ if (*shim_exit_code != 0) {
+ ERROR("Isulad-shim exit error");
+ ret = -1;
+ goto out;
+ }
+
+ if (exit_code == NULL) {
+ goto out;
+ }
+ ret = util_read_nointr(shim_stdout_pipe[0], exit_code, sizeof(int));
+ close(shim_stdout_pipe[0]);
+ if (ret <= 0) {
+ *exit_code = 137;
}
+ ret = 0;
out:
if (ret != 0) {
@@ -892,6 +927,7 @@ int rt_isula_create(const char *id, const char *runtime, const rt_create_params_
int ret = 0;
char workdir[PATH_MAX] = { 0 };
shim_client_process_state p = { 0 };
+ int shim_exit_code = 0;
if (id == NULL || runtime == NULL || params == NULL) {
ERROR("nullptr arguments not allowed");
@@ -924,7 +960,7 @@ int rt_isula_create(const char *id, const char *runtime, const rt_create_params_
}
get_runtime_cmd(runtime, &cmd);
- ret = shim_create(false, id, workdir, params->bundle, cmd, NULL, NULL);
+ ret = shim_create(false, id, workdir, params->bundle, cmd, NULL, NULL, &shim_exit_code);
if (ret != 0) {
runtime_call_delete_force(workdir, runtime, id);
ERROR("%s: failed create shim process", id);
@@ -1125,6 +1161,7 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
int pid = 0;
shim_client_process_state p = { 0 };
char *timeout = NULL;
+ int shim_exit_code = 0;
if (id == NULL || runtime == NULL || params == NULL || exit_code == NULL) {
ERROR("nullptr arguments not allowed");
@@ -1199,13 +1236,13 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
}
}
- ret = shim_create(fg_exec(params), id, workdir, bundle, cmd, exit_code, timeout);
+ ret = shim_create(fg_exec(params), id, workdir, bundle, cmd, exit_code, timeout, &shim_exit_code);
if (ret != 0) {
ERROR("%s: failed create shim process for exec %s", id, exec_id);
goto errlog_out;
}
- if (*exit_code == SHIM_EXIT_TIMEOUT) {
+ if (shim_exit_code == SHIM_EXIT_TIMEOUT) {
ret = -1;
isulad_set_error_message("Exec container error;exec timeout");
ERROR("isulad-shim %d exit for execing timeout", pid);
--
2.25.1

View File

@ -1,60 +0,0 @@
From 069a36a0fbd5202ca6cf0d34550381b3bf1e3eb2 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Sat, 27 May 2023 17:10:55 +0800
Subject: [PATCH 12/15] fix hugetlbs malloc length
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/cmd/isulad-shim/common.c | 5 ++++-
src/daemon/modules/service/inspect_container.c | 2 +-
src/utils/cutils/utils.c | 5 ++++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/cmd/isulad-shim/common.c b/src/cmd/isulad-shim/common.c
index 3787cdfb..7fa3c836 100644
--- a/src/cmd/isulad-shim/common.c
+++ b/src/cmd/isulad-shim/common.c
@@ -381,7 +381,10 @@ void util_usleep_nointerupt(unsigned long usec)
void *util_smart_calloc_s(size_t unit_size, size_t count)
{
- if (unit_size == 0) {
+ // If count or size is 0,
+ // then calloc() returns either NULL,
+ // or a unique pointer value that can later be successfully passed to free()
+ if (unit_size == 0 || count == 0) {
return NULL;
}
diff --git a/src/daemon/modules/service/inspect_container.c b/src/daemon/modules/service/inspect_container.c
index b1050bc7..40cf7aa1 100644
--- a/src/daemon/modules/service/inspect_container.c
+++ b/src/daemon/modules/service/inspect_container.c
@@ -751,7 +751,7 @@ static int pack_inspect_resources(const container_t *cont, container_inspect *in
resources->memory = cont->hostconfig->memory;
resources->memory_swap = cont->hostconfig->memory_swap;
resources->hugetlbs = util_smart_calloc_s(sizeof(container_inspect_resources_hugetlbs_element *),
- resources->hugetlbs_len);
+ cont->hostconfig->hugetlbs_len);
if (resources->hugetlbs == NULL) {
ERROR("Out of memory");
ret = -1;
diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c
index 3500d8f8..103c7c5b 100644
--- a/src/utils/cutils/utils.c
+++ b/src/utils/cutils/utils.c
@@ -253,7 +253,10 @@ int util_sig_parse(const char *sig_name)
void *util_smart_calloc_s(size_t unit_size, size_t count)
{
- if (unit_size == 0) {
+ // If count or size is 0,
+ // then calloc() returns either NULL,
+ // or a unique pointer value that can later be successfully passed to free()
+ if (unit_size == 0 || count == 0) {
return NULL;
}
--
2.25.1

View File

@ -1,25 +0,0 @@
From 165912f5f5a8346613f75ec16c4c5b2aeb7e81e7 Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Sat, 27 May 2023 02:44:46 -0700
Subject: [PATCH 13/15] fix forget to set return value
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
.../image/oci/storage/remote_layer_support/ro_symlink_maintain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
index 2bcc43e6..4d234aab 100644
--- a/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
+++ b/src/daemon/modules/image/oci/storage/remote_layer_support/ro_symlink_maintain.c
@@ -135,6 +135,7 @@ static int do_build_ro_dir(const char *home, const char *id)
nret = asprintf(&ro_layer_dir, "%s/%s/%s", home, REMOTE_RO_LAYER_DIR, id);
if (nret < 0 || nret > PATH_MAX) {
+ ret = -1;
SYSERROR("Failed to create ro layer dir path");
goto out;
}
--
2.25.1

View File

@ -1,33 +0,0 @@
From 1f71bbfb6ac54d0e8c4c4a4b9cf669301939dc65 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Sat, 27 May 2023 10:18:40 +0800
Subject: [PATCH 14/15] ensure define in local and use correctly type
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
src/cmd/isula/volume/prune.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/isula/volume/prune.c b/src/cmd/isula/volume/prune.c
index 2a3bca3e..c8d632ed 100644
--- a/src/cmd/isula/volume/prune.c
+++ b/src/cmd/isula/volume/prune.c
@@ -85,7 +85,6 @@ int cmd_volume_prune_main(int argc, const char **argv)
command_t cmd;
char **volumes = NULL;
size_t volumes_len = 0;
- char ch = 'n';
struct command_option options[] = { LOG_OPTIONS(lconf) COMMON_OPTIONS(g_cmd_volume_prune_args)
PRUNE_OPTIONS(g_cmd_volume_prune_args)
};
@@ -113,6 +112,7 @@ int cmd_volume_prune_main(int argc, const char **argv)
}
if (!g_cmd_volume_prune_args.force) {
+ int ch;
printf("WARNING! This will remove all local volumes not used by at least one container.\n");
printf("Are you sure you want to continue? [y/N]");
ch = getchar();
--
2.25.1

View File

@ -1,72 +0,0 @@
From 57ed3f3f177f0ffad972edda4cfec049f87fb153 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Mon, 29 May 2023 16:19:38 +0800
Subject: [PATCH 15/15] Revert the changes in util_smart_calloc_s
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/cmd/isulad-shim/common.c | 11 +++++++----
src/utils/cutils/utils.c | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/cmd/isulad-shim/common.c b/src/cmd/isulad-shim/common.c
index 7fa3c836..fc4f6035 100644
--- a/src/cmd/isulad-shim/common.c
+++ b/src/cmd/isulad-shim/common.c
@@ -381,10 +381,7 @@ void util_usleep_nointerupt(unsigned long usec)
void *util_smart_calloc_s(size_t unit_size, size_t count)
{
- // If count or size is 0,
- // then calloc() returns either NULL,
- // or a unique pointer value that can later be successfully passed to free()
- if (unit_size == 0 || count == 0) {
+ if (unit_size == 0) {
return NULL;
}
@@ -392,6 +389,12 @@ void *util_smart_calloc_s(size_t unit_size, size_t count)
return NULL;
}
+ // If count or size is 0,
+ // then calloc() returns either NULL,
+ // or a unique pointer value that can later be successfully passed to free()
+ // In current linux implementation, if the size for memory allocation is 0,
+ // then a unique pointer value is returned. If the return value is Null pointer,
+ // it means out of memory.
return calloc(count, unit_size);
}
diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c
index 103c7c5b..1e17853a 100644
--- a/src/utils/cutils/utils.c
+++ b/src/utils/cutils/utils.c
@@ -253,10 +253,7 @@ int util_sig_parse(const char *sig_name)
void *util_smart_calloc_s(size_t unit_size, size_t count)
{
- // If count or size is 0,
- // then calloc() returns either NULL,
- // or a unique pointer value that can later be successfully passed to free()
- if (unit_size == 0 || count == 0) {
+ if (unit_size == 0 ) {
return NULL;
}
@@ -264,6 +261,12 @@ void *util_smart_calloc_s(size_t unit_size, size_t count)
return NULL;
}
+ // If count or size is 0,
+ // then calloc() returns either NULL,
+ // or a unique pointer value that can later be successfully passed to free()
+ // In current linux implementation, if the size for memory allocation is 0,
+ // then a unique pointer value is returned. If the return value is Null pointer,
+ // it means out of memory.
return calloc(count, unit_size);
}
--
2.25.1

View File

@ -1,6 +1,7 @@
%global _version 2.1.2
%global _release 8
%global _version 2.1.3
%global _release 1
%global is_systemd 1
%global enable_criv1 1
%global enable_shimv2 1
%global is_embedded 1
%global cpp_std 17
@ -14,22 +15,7 @@ URL: https://gitee.com/openeuler/iSulad
Source: https://gitee.com/openeuler/iSulad/repository/archive/v%{version}.tar.gz
BuildRoot: {_tmppath}/iSulad-%{version}
Patch0001: 0001-convert-files-from-CRLF-to-LF.patch
Patch0002: 0002-restore-ping-head.patch
Patch0003: 0003-fix-health_check.sh.patch
Patch0004: 0004-ensure-isulad_io-not-NULL-before-close-fd.patch
Patch0005: 0005-recheck-delete-command-exit-status.patch
Patch0006: 0006-restore-execSync-return-value.patch
Patch0007: 0007-reinforce-cri_stream.sh-and-health_check.sh.patch
Patch0008: 0008-reinforce-omit-health_check.sh.patch
Patch0009: 0009-fix-memory-leak-and-array-access-out-of-range.patch
Patch0010: 0010-fix-memory-leak-of-top_layer.patch
Patch0011: 0011-distinguishing-exit-codes-between-shim-and-container.patch
Patch0012: 0012-fix-hugetlbs-malloc-length.patch
Patch0013: 0013-fix-forget-to-set-return-value.patch
Patch0014: 0014-ensure-define-in-local-and-use-correctly-type.patch
Patch0015: 0015-Revert-the-changes-in-util_smart_calloc_s.patch
Patch0001: 0001-Use-reference-in-loop-in-listpodsandbox.patch
Patch6001: 6001-fix-execlp-not-enough-args.patch
Patch6002: 6002-modify-daemon-json-default-runtime-to-runc.patch
@ -60,8 +46,8 @@ Requires: sqlite
BuildRequires: gtest-devel gmock-devel
%endif
%define lcrver_lower 2.1.1-0
%define lcrver_upper 2.1.2-0
%define lcrver_lower 2.1.2-0
%define lcrver_upper 2.1.3-0
BuildRequires: libisula-devel > %{lcrver_lower} libisula-devel < %{lcrver_upper}
BuildRequires: cmake gcc-c++ yajl-devel lxc lxc-devel
@ -97,21 +83,30 @@ Runtime Daemon, written by C.
%build
mkdir -p build
cd build
%cmake \
-DDEBUG=ON \
-DCMAKE_SKIP_RPATH=TRUE \
-DLIB_INSTALL_DIR=%{_libdir} \
-DCMAKE_INSTALL_PREFIX=/usr \
%if 0%{?enable_criv1}
-DENABLE_CRI_API_V1=ON \
-DENABLE_SANDBOXER=ON \
%endif
%if 0%{?enable_shimv2}
-DENABLE_SHIM_V2=ON \
%endif
%if %{defined openeuler}
%cmake -DDEBUG=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_SHIM_V2=ON -DENABLE_UT=OFF -DENABLE_GRPC_REMOTE_CONNECT=OFF -DENABLE_GRPC=ON -DCMAKE_CXX_STANDARD=%{cpp_std} ../
%else
%cmake -DDEBUG=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_SHIM_V2=ON -DENABLE_GRPC_REMOTE_CONNECT=OFF -DENABLE_GRPC=ON -DCMAKE_CXX_STANDARD=%{cpp_std} ../
%endif
%else
%if %{defined openeuler}
%cmake -DDEBUG=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_UT=OFF -DENABLE_GRPC_REMOTE_CONNECT=OFF -DENABLE_GRPC=ON -DCMAKE_CXX_STANDARD=%{cpp_std} ../
%else
%cmake -DDEBUG=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_GRPC_REMOTE_CONNECT=OFF -DENABLE_GRPC=ON -DCMAKE_CXX_STANDARD=%{cpp_std} ../
%endif
-DENABLE_UT=OFF \
%endif
-DENABLE_GRPC_REMOTE_CONNECT=OFF \
-DENABLE_GRPC=ON \
-DCMAKE_CXX_STANDARD=%{cpp_std} \
../
sed -i "10 a\# undef linux" grpc/src/api/services/cri/api.pb.h
sed -i "10 a\# undef linux" grpc/src/api/services/cri/v1alpha/api.pb.h
%if 0%{?enable_criv1}
sed -i "10 a\# undef linux" grpc/src/api/services/cri/v1/api_v1.pb.h
%endif
%make_build
@ -277,6 +272,12 @@ fi
%endif
%changelog
* Tue Aug 29 2023 xuxuepeng <xuxuepeng1@huawei.com> - 2.1.3-1
- Type: update
- ID: NA
- SUG: NA
- DESC: update to v2.1.3
* Mon Aug 28 2023 zhangxiaoyu <zhangxiaoyu58@huawei.com> - 2.1.2-8
- Type: bugfix
- ID: NA

Binary file not shown.