upgrade from upstream

Signed-off-by: zhongtao <zhongtao17@huawei.com>
This commit is contained in:
zhongtao 2023-05-24 16:52:28 +08:00
parent cf02fcda43
commit e8650fd6c2
10 changed files with 2567 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
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

@ -0,0 +1,42 @@
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

@ -0,0 +1,62 @@
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

@ -0,0 +1,75 @@
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

@ -0,0 +1,31 @@
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

@ -0,0 +1,131 @@
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

@ -0,0 +1,166 @@
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

@ -0,0 +1,75 @@
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,5 +1,5 @@
%global _version 2.1.2
%global _release 2
%global _release 3
%global is_systemd 1
%global enable_shimv2 1
%global is_embedded 1
@ -13,6 +13,16 @@ 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
%ifarch x86_64 aarch64
Provides: libhttpclient.so()(64bit)
Provides: libisula_client.so()(64bit)
@ -254,6 +264,12 @@ fi
%endif
%changelog
* Thu May 25 2023 zhongtao <zhongtao17@huawei.com> - 2.1.2-3
- Type: bugfix
- ID: NA
- SUG: NA
- DESC: upgrade from upstream
* Fri May 12 2023 zhangxiaoyu <zhangxiaoyu58@huawei.com> - 2.1.2-2
- Type: bugfix
- ID: NA