Sync patches from upstream
including: 3e0cafd6 supplementary registry design documentation a6b8a2c0 bugfix:do purge container when do_start_container failed 2a307813 image store: add UT 255fada4 image layer:fix code style 6766ace8 bugfix:fix exec --detach for shim v2 3c9d51bf bugfix for workdir len verify f55efffa bug fix: Isula ps not display N/A when ports empty 9006b290 bugfix:overwriting when i is len-1 Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com> (cherry picked from commit ca9c755d85eeece47f587426603a8f0d5c99eac9)
This commit is contained in:
parent
1dc43c9f12
commit
d2bf32cae3
31
0159-bugfix-overwriting-when-i-is-len-1.patch
Normal file
31
0159-bugfix-overwriting-when-i-is-len-1.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From 9006b2901cb17b5cf0fa3579334ddb765ac3fe11 Mon Sep 17 00:00:00 2001
|
||||
From: liuxu <liuxu156@huawei.com>
|
||||
Date: Mon, 25 Nov 2024 19:42:02 +0800
|
||||
Subject: [PATCH 01/19] bugfix:overwriting when i is len-1
|
||||
|
||||
Signed-off-by: liuxu <liuxu156@huawei.com>
|
||||
---
|
||||
src/daemon/modules/spec/specs.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/modules/spec/specs.c b/src/daemon/modules/spec/specs.c
|
||||
index 36e89343..67a47257 100644
|
||||
--- a/src/daemon/modules/spec/specs.c
|
||||
+++ b/src/daemon/modules/spec/specs.c
|
||||
@@ -2779,8 +2779,11 @@ void spec_remove_mount(oci_runtime_spec *oci_spec, const char *dest)
|
||||
for (i = 0; i < oci_spec->mounts_len; i++) {
|
||||
if (strcmp(oci_spec->mounts[i]->destination, dest) == 0) {
|
||||
free_defs_mount(oci_spec->mounts[i]);
|
||||
- (void)memcpy((void **)&oci_spec->mounts[i], (void **)&oci_spec->mounts[i + 1],
|
||||
- (oci_spec->mounts_len - i - 1) * sizeof(void *));
|
||||
+ oci_spec->mounts[i] = NULL;
|
||||
+ if (i != oci_spec->mounts_len - 1) {
|
||||
+ (void)memcpy((void **)&oci_spec->mounts[i], (void **)&oci_spec->mounts[i + 1],
|
||||
+ (oci_spec->mounts_len - i - 1) * sizeof(void *));
|
||||
+ }
|
||||
oci_spec->mounts_len--;
|
||||
return;
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
25
0160-bug-fix-Isula-ps-not-display-N-A-when-ports-empty.patch
Normal file
25
0160-bug-fix-Isula-ps-not-display-N-A-when-ports-empty.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From f55efffaeb1f28ac4e4e1b60b820b2b4694067b4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=E6=AD=A6=E7=A7=AF=E8=B6=85?= <wujichao1@huawei.com>
|
||||
Date: Tue, 26 Nov 2024 20:29:29 +0800
|
||||
Subject: [PATCH 02/19] bug fix: Isula ps not display N/A when ports empty
|
||||
|
||||
---
|
||||
src/cmd/isula/information/ps.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/cmd/isula/information/ps.c b/src/cmd/isula/information/ps.c
|
||||
index 6bdc157f..5f46ef22 100644
|
||||
--- a/src/cmd/isula/information/ps.c
|
||||
+++ b/src/cmd/isula/information/ps.c
|
||||
@@ -332,7 +332,7 @@ static void print_basic_container_info_item(const struct isula_container_summary
|
||||
} else if (strcmp(name, "Created") == 0) {
|
||||
print_created_field(in->created, length->created_length);
|
||||
} else if (strcmp(name, "Ports") == 0) {
|
||||
- const char *ports = (in->ports != NULL ? in->ports : "N/A");
|
||||
+ const char *ports = (in->ports != NULL ? in->ports : " ");
|
||||
printf("%-*s", (int)length->ports_length, ports);
|
||||
}
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
28
0161-bugfix-for-workdir-len-verify.patch
Normal file
28
0161-bugfix-for-workdir-len-verify.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 3c9d51bfdf0e71ac846946d746003139bf3a02c8 Mon Sep 17 00:00:00 2001
|
||||
From: zhongtao <zhongtao17@huawei.com>
|
||||
Date: Tue, 26 Nov 2024 23:46:52 +1400
|
||||
Subject: [PATCH 03/19] bugfix for workdir len verify
|
||||
|
||||
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
||||
---
|
||||
src/daemon/modules/runtime/isula/isula_rt_ops.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
index e628c3fe..22608e4c 100644
|
||||
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
@@ -786,8 +786,8 @@ static int shielded_output_check(const char *output, const char *workdir)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (sizeof(chdir_pattern) > PATH_MAX - strlen("chdir ") - strlen(" failed")) {
|
||||
- INFO("chdir_pattern is too long");
|
||||
+ if (strlen(workdir) > PATH_MAX - strlen("chdir ") - strlen(" failed")) {
|
||||
+ INFO("workdir is too long");
|
||||
return -1;
|
||||
}
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
115
0162-bugfix-fix-exec-detach-for-shim-v2.patch
Normal file
115
0162-bugfix-fix-exec-detach-for-shim-v2.patch
Normal file
@ -0,0 +1,115 @@
|
||||
From 6766ace88ac35f217b5e6b6ddab7c30e126a7956 Mon Sep 17 00:00:00 2001
|
||||
From: liuxu <liuxu156@huawei.com>
|
||||
Date: Tue, 26 Nov 2024 15:37:46 +0800
|
||||
Subject: [PATCH 04/19] bugfix:fix exec --detach for shim v2
|
||||
|
||||
Signed-off-by: liuxu <liuxu156@huawei.com>
|
||||
---
|
||||
.../modules/runtime/isula/isula_rt_ops.c | 11 ++----
|
||||
src/daemon/modules/runtime/runtime_common.h | 35 +++++++++++++++++++
|
||||
src/daemon/modules/runtime/shim/shim_rt_ops.c | 4 ++-
|
||||
3 files changed, 40 insertions(+), 10 deletions(-)
|
||||
create mode 100644 src/daemon/modules/runtime/runtime_common.h
|
||||
|
||||
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
index e628c3fe..11288310 100644
|
||||
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "utils_file.h"
|
||||
#include "console.h"
|
||||
#include "shim_constants.h"
|
||||
+#include "runtime_common.h"
|
||||
|
||||
#define SHIM_BINARY "isulad-shim"
|
||||
#define RESIZE_FIFO_NAME "resize_fifo"
|
||||
@@ -1393,14 +1394,6 @@ int rt_isula_rm(const char *id, const char *runtime, const rt_rm_params_t *param
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static bool fg_exec(const rt_exec_params_t *params)
|
||||
-{
|
||||
- if (params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || params->console_fifos[2] != NULL) {
|
||||
- return true;
|
||||
- }
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
static char *try_generate_random_id()
|
||||
{
|
||||
char *id = NULL;
|
||||
@@ -1536,7 +1529,7 @@ int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *p
|
||||
}
|
||||
}
|
||||
|
||||
- args.fg = fg_exec(params);
|
||||
+ args.fg = rt_fg_exec(params);
|
||||
args.id = id;
|
||||
args.workdir = workdir;
|
||||
args.bundle = bundle;
|
||||
diff --git a/src/daemon/modules/runtime/runtime_common.h b/src/daemon/modules/runtime/runtime_common.h
|
||||
new file mode 100644
|
||||
index 00000000..dde47110
|
||||
--- /dev/null
|
||||
+++ b/src/daemon/modules/runtime/runtime_common.h
|
||||
@@ -0,0 +1,35 @@
|
||||
+/******************************************************************************
|
||||
+ * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
|
||||
+ * iSulad licensed under the Mulan PSL v2.
|
||||
+ * You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
+ * You may obtain a copy of Mulan PSL v2 at:
|
||||
+ * http://license.coscl.org.cn/MulanPSL2
|
||||
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
+ * PURPOSE.
|
||||
+ * See the Mulan PSL v2 for more details.
|
||||
+ * Author: liuxu
|
||||
+ * Create: 2024-11-28
|
||||
+ * Description: runtime common definition
|
||||
+ ******************************************************************************/
|
||||
+
|
||||
+#ifndef DAEMON_MODULES_RUNTIME_COMMON_H
|
||||
+#define DAEMON_MODULES_RUNTIME_COMMON_H
|
||||
+
|
||||
+#include "runtime_api.h"
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+static inline bool rt_fg_exec(const rt_exec_params_t *params)
|
||||
+{
|
||||
+ return params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || params->console_fifos[2] != NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#endif // DAEMON_MODULES_RUNTIME_COMMON_H
|
||||
diff --git a/src/daemon/modules/runtime/shim/shim_rt_ops.c b/src/daemon/modules/runtime/shim/shim_rt_ops.c
|
||||
index fc4d8e3a..fce18ade 100644
|
||||
--- a/src/daemon/modules/runtime/shim/shim_rt_ops.c
|
||||
+++ b/src/daemon/modules/runtime/shim/shim_rt_ops.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "shim_rt_monitor.h"
|
||||
#include "supervisor.h"
|
||||
#include "isulad_config.h"
|
||||
+#include "runtime_common.h"
|
||||
|
||||
#define EXIT_SIGNAL_OFFSET_X 128
|
||||
|
||||
@@ -589,7 +590,8 @@ int rt_shim_exec(const char *id, const char *runtime, const rt_exec_params_t *pa
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (shim_v2_wait(id, params->suffix, exit_code) != 0) {
|
||||
+ if (rt_fg_exec(params) &&
|
||||
+ shim_v2_wait(id, params->suffix, exit_code) != 0) {
|
||||
ERROR("%s: failed to wait exec process", id);
|
||||
ret = -1;
|
||||
goto out;
|
||||
--
|
||||
2.23.0
|
||||
|
||||
114
0163-image-layer-fix-code-style.patch
Normal file
114
0163-image-layer-fix-code-style.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From 255fada49877e854690d628dc7832c3e459fd5aa Mon Sep 17 00:00:00 2001
|
||||
From: liuxu <liuxu156@huawei.com>
|
||||
Date: Thu, 5 Dec 2024 19:59:15 +0800
|
||||
Subject: [PATCH 05/19] image layer:fix code style
|
||||
|
||||
Signed-off-by: liuxu <liuxu156@huawei.com>
|
||||
---
|
||||
.../modules/image/oci/storage/layer_store/layer.c | 9 +++++----
|
||||
.../modules/image/oci/storage/layer_store/layer.h | 6 +++---
|
||||
.../image/oci/storage/layer_store/layer_store.c | 11 ++++++-----
|
||||
.../image/oci/storage/layer_store/layer_store.h | 5 +++--
|
||||
4 files changed, 17 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer.c b/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
||||
index 4beb3d10..8fd9aa5b 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer.c
|
||||
@@ -15,16 +15,17 @@
|
||||
|
||||
#include "layer.h"
|
||||
|
||||
-#include <isula_libutils/json_common.h>
|
||||
-#include <isula_libutils/storage_layer.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
+#include <isula_libutils/json_common.h>
|
||||
+#include <isula_libutils/storage_layer.h>
|
||||
+#include <isula_libutils/storage_mount_point.h>
|
||||
+#include <isula_libutils/log.h>
|
||||
+
|
||||
#include "constants.h"
|
||||
-#include "isula_libutils/storage_mount_point.h"
|
||||
#include "util_atomic.h"
|
||||
#include "utils.h"
|
||||
-#include "isula_libutils/log.h"
|
||||
#include "utils_file.h"
|
||||
|
||||
void free_layer_t(layer_t *ptr)
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer.h b/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
||||
index 9387efe0..94831ef4 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer.h
|
||||
@@ -20,9 +20,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
-#include "isula_libutils/storage_layer.h"
|
||||
-#include "isula_libutils/storage_mount_point.h"
|
||||
-#include "isula_libutils/log.h"
|
||||
+#include <isula_libutils/storage_layer.h>
|
||||
+#include <isula_libutils/storage_mount_point.h>
|
||||
+#include <isula_libutils/log.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
||||
index 3ffe0ca7..bb2e7edc 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.c
|
||||
@@ -19,6 +19,11 @@
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
+#include <stdint.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/stat.h>
|
||||
+
|
||||
#include <isula_libutils/container_inspect.h>
|
||||
#include <isula_libutils/storage_layer.h>
|
||||
#include <isula_libutils/storage_mount_point.h>
|
||||
@@ -26,10 +31,6 @@
|
||||
#include <isula_libutils/log.h>
|
||||
#include <isula_libutils/storage_entry.h>
|
||||
#include <isula_libutils/go_crc64.h>
|
||||
-#include <stdint.h>
|
||||
-#include <stdlib.h>
|
||||
-#include <string.h>
|
||||
-#include <sys/stat.h>
|
||||
|
||||
#include "util_archive.h"
|
||||
#include "storage.h"
|
||||
@@ -1709,7 +1710,7 @@ static int load_layers_from_json_files()
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
- goto unlock_out;
|
||||
+
|
||||
unlock_out:
|
||||
layer_store_unlock();
|
||||
return ret;
|
||||
diff --git a/src/daemon/modules/image/oci/storage/layer_store/layer_store.h b/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
||||
index eba406d4..a1b0857e 100644
|
||||
--- a/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
||||
+++ b/src/daemon/modules/image/oci/storage/layer_store/layer_store.h
|
||||
@@ -16,11 +16,12 @@
|
||||
#define DAEMON_MODULES_IMAGE_OCI_STORAGE_LAYER_STORE_LAYER_STORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
-#include <isula_libutils/imagetool_fs_info.h>
|
||||
-#include <isula_libutils/json_common.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
+#include <isula_libutils/imagetool_fs_info.h>
|
||||
+#include <isula_libutils/json_common.h>
|
||||
+
|
||||
#include "storage.h"
|
||||
#include "io_wrapper.h"
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
207
0164-image-store-add-UT.patch
Normal file
207
0164-image-store-add-UT.patch
Normal file
@ -0,0 +1,207 @@
|
||||
From 2a3078132c461c45cba2932a75517314db06dcbd Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=E6=AD=A6=E7=A7=AF=E8=B6=85?= <wujichao1@huawei.com>
|
||||
Date: Fri, 6 Dec 2024 16:32:03 +0800
|
||||
Subject: [PATCH 06/19] image store: add UT
|
||||
|
||||
---
|
||||
.../oci/storage/images/storage_images_ut.cc | 53 ++++++++++++++++++-
|
||||
1 file changed, 51 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/test/image/oci/storage/images/storage_images_ut.cc b/test/image/oci/storage/images/storage_images_ut.cc
|
||||
index 001090fe..ad0084d6 100644
|
||||
--- a/test/image/oci/storage/images/storage_images_ut.cc
|
||||
+++ b/test/image/oci/storage/images/storage_images_ut.cc
|
||||
@@ -269,12 +269,21 @@ TEST_F(StorageImagesCompatibilityUnitTest, test_load_v1_image)
|
||||
EXPECT_CALL(m_storage_mock, FreeLayerList(_)).WillRepeatedly(Invoke(invokeFreeLayerList));
|
||||
opts.storage_root = strdup(store_real_path);
|
||||
opts.driver_name = strdup("overlay");
|
||||
+
|
||||
+ std::string converted_image_id { "597fa49c3dbc5dd1e84120dd1906b65223afd479a7e094c085b580060c0fccec" };
|
||||
+ ASSERT_FALSE(image_store_exists(converted_image_id.c_str())); // before init must false
|
||||
+ ASSERT_EQ(image_store_delete(converted_image_id.c_str()), -1); // before init must false
|
||||
+
|
||||
ASSERT_EQ(image_store_init(&opts), 0);
|
||||
+ // init twice will go to errror branch "Image store has already been initialized"
|
||||
+ ASSERT_EQ(image_store_init(&opts), -1);
|
||||
free(opts.storage_root);
|
||||
free(opts.driver_name);
|
||||
- std::string converted_image_id { "597fa49c3dbc5dd1e84120dd1906b65223afd479a7e094c085b580060c0fccec" };
|
||||
ASSERT_TRUE(image_store_exists(converted_image_id.c_str()));
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_FALSE(image_store_exists(null_id));
|
||||
ASSERT_EQ(image_store_delete(converted_image_id.c_str()), 0);
|
||||
+ ASSERT_EQ(image_store_delete(null_id), -1);
|
||||
}
|
||||
|
||||
class StorageImagesUnitTest : public testing::Test {
|
||||
@@ -320,6 +329,8 @@ protected:
|
||||
|
||||
TEST_F(StorageImagesUnitTest, test_images_load)
|
||||
{
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_EQ(image_store_get_image(null_id), nullptr);
|
||||
auto image = image_store_get_image(ids.at(0).c_str());
|
||||
ASSERT_NE(image, nullptr);
|
||||
|
||||
@@ -345,11 +356,17 @@ TEST_F(StorageImagesUnitTest, test_images_load)
|
||||
|
||||
char **names { nullptr };
|
||||
size_t names_len { 0 };
|
||||
+
|
||||
+ ASSERT_EQ(image_store_big_data_names(null_id, &names, &names_len), -1);
|
||||
ASSERT_EQ(image_store_big_data_names(ids.at(0).c_str(), &names, &names_len), 0);
|
||||
ASSERT_EQ(names_len, 2);
|
||||
ASSERT_STREQ(names[0], "sha256:39891ff67da98ab8540d71320915f33d2eb80ab42908e398472cab3c1ce7ac10");
|
||||
ASSERT_STREQ(names[1], "manifest");
|
||||
|
||||
+ const char* null_name = NULL;
|
||||
+ ASSERT_EQ(image_store_big_data_size(null_id, names[0]), -1);
|
||||
+ ASSERT_EQ(image_store_big_data_size(ids.at(0).c_str(), null_name), -1);
|
||||
+
|
||||
ASSERT_EQ(image_store_big_data_size(ids.at(0).c_str(), names[0]), 2235);
|
||||
ASSERT_EQ(image_store_big_data_size(ids.at(0).c_str(), names[1]), 741);
|
||||
for (size_t i {}; i < names_len; ++i) {
|
||||
@@ -418,7 +435,11 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
std::cout << buffer << std::endl;
|
||||
|
||||
std::string key = "sha256:" + std::string(created_image);
|
||||
+ const char* null_key = NULL;
|
||||
ASSERT_EQ(image_store_set_big_data(created_image, key.c_str(), buffer.c_str()), 0);
|
||||
+ ASSERT_EQ(image_store_set_big_data(created_image, null_key, buffer.c_str()), -1);
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_EQ(image_store_set_big_data(null_id, key.c_str(), buffer.c_str()), -1);
|
||||
|
||||
std::string img_store_path = std::string(store_real_path) + "/overlay-images/";
|
||||
ASSERT_TRUE(dirExists((img_store_path + id).c_str()));
|
||||
@@ -440,10 +461,13 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
std::cout << "manifest :" << std::endl;
|
||||
std::cout << manifest_content << std::endl;
|
||||
|
||||
+ ASSERT_EQ(image_store_big_data(null_id, "manifest"), nullptr);
|
||||
+ ASSERT_EQ(image_store_big_data(id.c_str(), null_key), nullptr);
|
||||
char *data = image_store_big_data(id.c_str(), "manifest");
|
||||
ASSERT_STREQ(data, manifest_content.c_str());
|
||||
free(data);
|
||||
|
||||
+ ASSERT_EQ(image_store_get_image(null_id), nullptr);
|
||||
auto image = image_store_get_image(id.c_str());
|
||||
ASSERT_NE(image, nullptr);
|
||||
ASSERT_NE(image->created, nullptr);
|
||||
@@ -476,16 +500,19 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
free_imagetool_image(image);
|
||||
|
||||
char *toplayer = nullptr;
|
||||
+ ASSERT_EQ(image_store_top_layer(null_id), nullptr);
|
||||
ASSERT_STREQ((toplayer = image_store_top_layer(id.c_str())),
|
||||
"6194458b07fcf01f1483d96cd6c34302ffff7f382bb151a6d023c4e80ba3050a");
|
||||
free(toplayer);
|
||||
|
||||
+ ASSERT_EQ(image_store_set_image_size(null_id, 1000), -1);
|
||||
ASSERT_EQ(image_store_set_image_size(id.c_str(), 1000), 0);
|
||||
|
||||
image = image_store_get_image(id.c_str());
|
||||
ASSERT_EQ(image->size, 1000);
|
||||
free_imagetool_image(image);
|
||||
|
||||
+ ASSERT_EQ(image_store_add_name(null_id, "isula.org/library/test:latest"), -1);
|
||||
ASSERT_EQ(image_store_add_name(id.c_str(), "isula.org/library/test:latest"), 0);
|
||||
image = image_store_get_image(id.c_str());
|
||||
ASSERT_EQ(image->repo_tags_len, 2);
|
||||
@@ -497,6 +524,9 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
img_names = (char **)util_common_calloc_s(2 * sizeof(char *));
|
||||
img_names[0] = util_strdup_s("busybox:latest");
|
||||
img_names[1] = util_strdup_s("centos:3.0");
|
||||
+ size_t names_len = 0;
|
||||
+ ASSERT_EQ(image_store_set_names(null_id, (const char **)img_names, 2), -1);
|
||||
+ ASSERT_EQ(image_store_set_names(id.c_str(), (const char **)img_names, names_len), -1);
|
||||
ASSERT_EQ(image_store_set_names(id.c_str(), (const char **)img_names, 2), 0);
|
||||
image = image_store_get_image(id.c_str());
|
||||
ASSERT_EQ(image->repo_tags_len, 2);
|
||||
@@ -505,13 +535,17 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
util_free_array_by_len(img_names, 2);
|
||||
free_imagetool_image(image);
|
||||
|
||||
+ ASSERT_EQ(image_store_set_metadata(null_id, "{metadata}"), -1);
|
||||
ASSERT_EQ(image_store_set_metadata(id.c_str(), "{metadata}"), 0);
|
||||
char *manifest_val = nullptr;
|
||||
+
|
||||
+ ASSERT_EQ(image_store_metadata(null_id), nullptr);
|
||||
ASSERT_STREQ((manifest_val = image_store_metadata(id.c_str())), "{metadata}");
|
||||
free(manifest_val);
|
||||
|
||||
free(created_image);
|
||||
|
||||
+ ASSERT_EQ(image_store_delete(null_id), -1);
|
||||
ASSERT_EQ(image_store_delete(id.c_str()), 0);
|
||||
ASSERT_EQ(image_store_get_image(id.c_str()), nullptr);
|
||||
ASSERT_FALSE(dirExists((img_store_path + id).c_str()));
|
||||
@@ -530,6 +564,7 @@ TEST_F(StorageImagesUnitTest, test_image_store_create)
|
||||
std::cout << cp_command << std::endl;
|
||||
ASSERT_EQ(system(cp_command.c_str()), 0);
|
||||
|
||||
+ ASSERT_EQ(image_store_big_data_digest(random_id, null_key), nullptr);
|
||||
char *digest = image_store_big_data_digest(random_id, "manifest");
|
||||
ASSERT_STREQ(digest, "sha256:fdb7b1fccaaa535cb8211a194dd6314acc643f3a36d1a7d2b79c299a9173fa7e");
|
||||
free(digest);
|
||||
@@ -547,6 +582,8 @@ TEST_F(StorageImagesUnitTest, test_image_store_lookup)
|
||||
std::string truncatedId { "e4db68de4ff27" };
|
||||
std::string incorrectId { "4db68de4ff27" };
|
||||
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_EQ(image_store_lookup(null_id), nullptr);
|
||||
char *value = nullptr;
|
||||
ASSERT_STREQ((value = image_store_lookup(name.c_str())), id.c_str());
|
||||
free(value);
|
||||
@@ -563,6 +600,8 @@ TEST_F(StorageImagesUnitTest, test_image_store_exists)
|
||||
std::string truncatedId { "398" };
|
||||
std::string incorrectId { "ff67da98ab8540d713209" };
|
||||
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_FALSE(image_store_exists(null_id));
|
||||
ASSERT_TRUE(image_store_exists(name.c_str()));
|
||||
ASSERT_TRUE(image_store_exists(truncatedId.c_str()));
|
||||
ASSERT_FALSE(image_store_exists(incorrectId.c_str()));
|
||||
@@ -584,6 +623,7 @@ TEST_F(StorageImagesUnitTest, test_image_store_metadata)
|
||||
TEST_F(StorageImagesUnitTest, test_image_store_get_all_images)
|
||||
{
|
||||
imagetool_images_list *images_list = nullptr;
|
||||
+ ASSERT_EQ(image_store_get_all_images(images_list), -1);
|
||||
|
||||
images_list = (imagetool_images_list *)util_common_calloc_s(sizeof(imagetool_images_list));
|
||||
ASSERT_NE(images_list, nullptr);
|
||||
@@ -613,7 +653,12 @@ TEST_F(StorageImagesUnitTest, test_image_store_get_something)
|
||||
|
||||
ASSERT_EQ(image_store_get_images_number(), 2);
|
||||
ASSERT_EQ(image_store_get_fs_info(fs_info), 0);
|
||||
+ imagetool_fs_info *null_fs_info = nullptr;
|
||||
+ ASSERT_EQ(image_store_get_fs_info(null_fs_info), -1);
|
||||
+
|
||||
ASSERT_EQ(image_store_get_names(ids.at(0).c_str(), &names, &names_len), 0);
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_EQ(image_store_get_names(null_id, &names, &names_len), -1);
|
||||
ASSERT_EQ(names_len, 1);
|
||||
ASSERT_STREQ(names[0], "imagehub.isulad.com/official/centos:latest");
|
||||
|
||||
@@ -632,7 +677,9 @@ TEST_F(StorageImagesUnitTest, test_image_store_delete)
|
||||
ASSERT_FALSE(image_store_exists(elem.c_str()));
|
||||
ASSERT_FALSE(dirExists((std::string(store_real_path) + "/overlay-images/" + elem).c_str()));
|
||||
}
|
||||
-
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_FALSE(image_store_exists(null_id));
|
||||
+ ASSERT_EQ(image_store_delete(null_id), -1);
|
||||
Restore();
|
||||
}
|
||||
|
||||
@@ -646,6 +693,8 @@ TEST_F(StorageImagesUnitTest, test_image_store_remove_single_name)
|
||||
}
|
||||
|
||||
ASSERT_EQ(image_store_add_name(ids.at(0).c_str(), "imagehub.isulad.com/official/busybox:latest"), 0);
|
||||
+ const char* null_id = NULL;
|
||||
+ ASSERT_EQ(image_store_add_name(null_id, "imagehub.isulad.com/official/busybox:latest"), -1);
|
||||
|
||||
Restore();
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
|
||||
125
0165-bugfix-do-purge-container-when-do_start_container-fa.patch
Normal file
125
0165-bugfix-do-purge-container-when-do_start_container-fa.patch
Normal file
@ -0,0 +1,125 @@
|
||||
From a6b8a2c04df21d940ce0d22128b776c00d460bba Mon Sep 17 00:00:00 2001
|
||||
From: liuxu <liuxu156@huawei.com>
|
||||
Date: Fri, 6 Dec 2024 10:39:22 +0800
|
||||
Subject: [PATCH 07/19] bugfix:do purge container when do_start_container
|
||||
failed
|
||||
|
||||
Signed-off-by: liuxu <liuxu156@huawei.com>
|
||||
---
|
||||
.../modules/container/restore/restore.c | 1 +
|
||||
.../modules/container/supervisor/supervisor.c | 4 +--
|
||||
.../modules/service/service_container.c | 25 ++++++++++++++++---
|
||||
3 files changed, 23 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/modules/container/restore/restore.c b/src/daemon/modules/container/restore/restore.c
|
||||
index 52f68d21..44ed14df 100644
|
||||
--- a/src/daemon/modules/container/restore/restore.c
|
||||
+++ b/src/daemon/modules/container/restore/restore.c
|
||||
@@ -95,6 +95,7 @@ static int restore_supervisor(const container_t *cont)
|
||||
|
||||
if (container_supervisor_add_exit_monitor(exit_fifo_fd, exit_fifo, &pid_info, cont)) {
|
||||
ERROR("Failed to add exit monitor to supervisor");
|
||||
+ close(exit_fifo_fd);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
diff --git a/src/daemon/modules/container/supervisor/supervisor.c b/src/daemon/modules/container/supervisor/supervisor.c
|
||||
index 294783eb..f77f58d7 100644
|
||||
--- a/src/daemon/modules/container/supervisor/supervisor.c
|
||||
+++ b/src/daemon/modules/container/supervisor/supervisor.c
|
||||
@@ -328,7 +328,6 @@ int container_supervisor_add_exit_monitor(int fd, const char *exit_fifo, const p
|
||||
|
||||
if (pid_info == NULL || cont == NULL || cont->common_config == NULL) {
|
||||
ERROR("Invalid input arguments");
|
||||
- close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -336,7 +335,6 @@ int container_supervisor_add_exit_monitor(int fd, const char *exit_fifo, const p
|
||||
cgroup_path = merge_container_cgroups_path(cont->common_config->id, cont->hostconfig);
|
||||
if (cgroup_path == NULL) {
|
||||
ERROR("Failed to get cgroup path");
|
||||
- close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
@@ -344,7 +342,6 @@ int container_supervisor_add_exit_monitor(int fd, const char *exit_fifo, const p
|
||||
data = util_common_calloc_s(sizeof(struct supervisor_handler_data));
|
||||
if (data == NULL) {
|
||||
ERROR("Memory out");
|
||||
- close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -385,6 +382,7 @@ int container_supervisor_add_exit_monitor(int fd, const char *exit_fifo, const p
|
||||
goto out;
|
||||
|
||||
err:
|
||||
+ data->fd = -1;
|
||||
supervisor_handler_data_free(data);
|
||||
#ifdef ENABLE_OOM_MONITOR
|
||||
common_free_cgroup_oom_handler_info(oom_handler_info);
|
||||
diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c
|
||||
index 8e80e936..250e8299 100644
|
||||
--- a/src/daemon/modules/service/service_container.c
|
||||
+++ b/src/daemon/modules/service/service_container.c
|
||||
@@ -283,7 +283,6 @@ static int do_post_start_on_success(container_t *cont, int exit_fifo_fd,
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
- // exit_fifo_fd was closed in container_supervisor_add_exit_monitor
|
||||
if (container_supervisor_add_exit_monitor(exit_fifo_fd, exit_fifo, pid_info, cont)) {
|
||||
ERROR("Failed to add exit monitor to supervisor");
|
||||
ret = -1;
|
||||
@@ -936,7 +935,11 @@ static int do_start_container(container_t *cont, const char *console_fifos[], bo
|
||||
|
||||
if (runtime_create(id, runtime, &create_params) != 0) {
|
||||
ret = -1;
|
||||
+#ifdef ENABLE_CRI_API_V1
|
||||
+ goto clean_prepare_container;
|
||||
+#else
|
||||
goto close_exit_fd;
|
||||
+#endif
|
||||
}
|
||||
|
||||
start_params.rootpath = cont->root_path;
|
||||
@@ -959,19 +962,33 @@ static int do_start_container(container_t *cont, const char *console_fifos[], bo
|
||||
if (do_post_start_on_success(cont, exit_fifo_fd, exit_fifo, pid_info) != 0) {
|
||||
ERROR("Failed to do post start on runtime start success");
|
||||
ret = -1;
|
||||
- goto clean_resources;
|
||||
+#ifdef ENABLE_CRI_API_V1
|
||||
+ goto clean_prepare_container;
|
||||
+#else
|
||||
+ goto close_exit_fd;
|
||||
+#endif
|
||||
}
|
||||
} else {
|
||||
// wait monitor cleanup cgroup and processes finished
|
||||
wait_exit_fifo(id, exit_fifo_fd);
|
||||
+#ifdef ENABLE_CRI_API_V1
|
||||
+ goto clean_prepare_container;
|
||||
+#else
|
||||
goto close_exit_fd;
|
||||
+#endif
|
||||
}
|
||||
goto out;
|
||||
|
||||
+#ifdef ENABLE_CRI_API_V1
|
||||
+clean_prepare_container:
|
||||
+ if (cont->common_config->sandbox_info != NULL &&
|
||||
+ sandbox_purge_container(cont->common_config) != 0) {
|
||||
+ ERROR("Failed to remove container %s from sandbox", id);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
close_exit_fd:
|
||||
close(exit_fifo_fd);
|
||||
-
|
||||
-clean_resources:
|
||||
clean_resources_on_failure(cont, engine_log_path, loglevel);
|
||||
|
||||
out:
|
||||
--
|
||||
2.23.0
|
||||
|
||||
101
0166-supplementary-registry-design-documentation.patch
Normal file
101
0166-supplementary-registry-design-documentation.patch
Normal file
File diff suppressed because one or more lines are too long
17
iSulad.spec
17
iSulad.spec
@ -1,5 +1,5 @@
|
||||
%global _version 2.1.5
|
||||
%global _release 16
|
||||
%global _release 17
|
||||
%global is_systemd 1
|
||||
%global enable_criv1 1
|
||||
%global enable_cdi 1
|
||||
@ -179,6 +179,15 @@ Patch0155: 0155-sandbox-fix-unused-variables.patch
|
||||
Patch0156: 0156-sandbox-sandbox-api-adapt-rust-interface-UT.patch
|
||||
Patch0157: 0157-bugfix-for-nri-init.patch
|
||||
Patch0158: 0158-Revert-move-nri-call-in-stop-and-remove-con.patch
|
||||
Patch0159: 0159-bugfix-overwriting-when-i-is-len-1.patch
|
||||
Patch0160: 0160-bug-fix-Isula-ps-not-display-N-A-when-ports-empty.patch
|
||||
Patch0161: 0161-bugfix-for-workdir-len-verify.patch
|
||||
Patch0162: 0162-bugfix-fix-exec-detach-for-shim-v2.patch
|
||||
Patch0163: 0163-image-layer-fix-code-style.patch
|
||||
Patch0164: 0164-image-store-add-UT.patch
|
||||
Patch0165: 0165-bugfix-do-purge-container-when-do_start_container-fa.patch
|
||||
Patch0166: 0166-supplementary-registry-design-documentation.patch
|
||||
|
||||
|
||||
%ifarch x86_64 aarch64
|
||||
Provides: libhttpclient.so()(64bit)
|
||||
@ -446,6 +455,12 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Dec 30 2024 jingxiaolu<lujingxiao@huawei.com> - 2.1.5-17
|
||||
- Type: bugfix
|
||||
- ID: NA
|
||||
- SUG: NA
|
||||
- DESC: sync patches from upstream
|
||||
|
||||
* Wed Dec 18 2024 zhongtao <zhongtao17@huawei.com> - 2.1.5-16
|
||||
- Type: bugfix
|
||||
- ID: NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user