diff --git a/0001-isulad-shim-fix-probabilistic-bad-fd.patch b/0001-isulad-shim-fix-probabilistic-bad-fd.patch new file mode 100644 index 0000000..4ffbdd2 --- /dev/null +++ b/0001-isulad-shim-fix-probabilistic-bad-fd.patch @@ -0,0 +1,157 @@ +From 2c990693f8f78a202e2f7cc1115e133ad6950f34 Mon Sep 17 00:00:00 2001 +From: leizhongkai +Date: Thu, 18 Jun 2020 12:06:12 +0800 +Subject: [PATCH 1/6] isulad-shim: fix probabilistic bad fd + +1. fix `epoll_ctl()` probabilistic returns bad fd when the epfd not read +2. fix typos + +Signed-off-by: leizhongkai +--- + src/cmd/isulad-shim/process.c | 36 +++++++++++++++++++++++------------ + src/cmd/isulad-shim/process.h | 1 + + 2 files changed, 25 insertions(+), 12 deletions(-) + +diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c +index cf315359..da9bdb64 100644 +--- a/src/cmd/isulad-shim/process.c ++++ b/src/cmd/isulad-shim/process.c +@@ -242,7 +242,7 @@ static void* task_io_copy(void *data) + + for (;;) { + memset(buf, 0, DEFAULT_IO_COPY_BUF); +- sem_wait(&(io_thd->sem_thd)); ++ (void)sem_wait(&(io_thd->sem_thd)); + if (io_thd->is_stdin && io_thd->shutdown) { + break; + } +@@ -295,10 +295,10 @@ static void do_io_copy(int fd, uint32_t event, void *data) + } + + if (event & EPOLLIN) { +- sem_post(&thd->sem_thd); ++ (void)sem_post(&thd->sem_thd); + } else if (event & EPOLLHUP) { + thd->shutdown = true; +- sem_post(&thd->sem_thd); ++ (void)sem_post(&thd->sem_thd); + } + + return; +@@ -325,7 +325,7 @@ static int process_io_start(process_t *p, int std_id) + if (io_thd == NULL) { + goto failure; + } +- if (sem_init(&io_thd->sem_thd, 0, 0) == -1) { ++ if (sem_init(&io_thd->sem_thd, 0, 0) != 0) { + write_message(g_log_fd, ERR_MSG, "sem init failed:%d", SHIM_SYS_ERR(errno)); + goto failure; + } +@@ -373,7 +373,7 @@ static int start_io_copy_threads(process_t *p) + return SHIM_OK; + } + +-static void destory_io_thread(process_t *p, int std_id) ++static void destroy_io_thread(process_t *p, int std_id) + { + io_thread_t *io_thd = p->io_threads[std_id]; + if (io_thd == NULL) { +@@ -381,7 +381,7 @@ static void destory_io_thread(process_t *p, int std_id) + } + + io_thd->shutdown = true; +- sem_post(&io_thd->sem_thd); ++ (void)sem_post(&io_thd->sem_thd); + pthread_join(io_thd->tid, NULL); + if (io_thd->ioc != NULL) { + free(io_thd->ioc); +@@ -422,7 +422,7 @@ static int connect_to_isulad(process_t *p, int std_id, const char *isulad_stdio, + } + + // if no I/O source is available, the I/O thread nead to be destroyed +- destory_io_thread(p, std_id); ++ destroy_io_thread(p, std_id); + + return SHIM_OK; + } +@@ -461,7 +461,7 @@ static void* task_console_accept(void *data) + } + + // if the terminal is used, we do not need to active the io copy of stderr pipe +- destory_io_thread(ac->p, stdid_err); ++ destroy_io_thread(ac->p, stdid_err); + + out: + // release listen socket +@@ -491,6 +491,7 @@ static void* task_io_loop(void *data) + write_message(g_log_fd, ERR_MSG, "epoll create failed:%d", SHIM_SYS_ERR(errno)); + exit(EXIT_FAILURE); + } ++ (void)sem_post(&p->sem_mainloop); + + // begin wait + while (1) { +@@ -762,11 +763,15 @@ process_t* new_process(char *id, char *bundle, char *runtime) + if (p == NULL) { + return NULL; + } ++ ++ ret = sem_init(&p->sem_mainloop, 0, 0); ++ if (ret != 0) { ++ goto failure; ++ } ++ + ret = terminal_init(&(p->terminal), p_state); + if (ret != SHIM_OK) { +- free(p); +- p = NULL; +- return p; ++ goto failure; + } + + p->id = id; +@@ -786,6 +791,11 @@ process_t* new_process(char *id, char *bundle, char *runtime) + } + + return p; ++ ++failure: ++ free(p); ++ p = NULL; ++ return NULL; + } + + int open_io(process_t *p) +@@ -813,6 +823,8 @@ int process_io_init(process_t *p) + if (ret != SHIM_OK) { + return SHIM_SYS_ERR(errno); + } ++ (void)sem_wait(&p->sem_mainloop); ++ (void)sem_destroy(&p->sem_mainloop); + + return SHIM_OK; + } +@@ -1087,7 +1099,7 @@ int process_signal_handle_routine(process_t *p) + (void)write_nointr(p->exit_fd, &status, sizeof(int)); + } + for (i = 0; i < 3; i ++) { +- destory_io_thread(p, i); ++ destroy_io_thread(p, i); + } + return status; + } +diff --git a/src/cmd/isulad-shim/process.h b/src/cmd/isulad-shim/process.h +index 6d0fb195..71bc20cc 100644 +--- a/src/cmd/isulad-shim/process.h ++++ b/src/cmd/isulad-shim/process.h +@@ -75,6 +75,7 @@ typedef struct process { + stdio_t *shim_io; + io_thread_t *io_threads[3];// stdin,stdout,stderr + shim_client_process_state *state; ++ sem_t sem_mainloop; + } process_t; + + typedef struct { +-- +2.25.1 + diff --git a/0002-iSulad-resolve-coredump-of-isula-inspect.patch b/0002-iSulad-resolve-coredump-of-isula-inspect.patch new file mode 100644 index 0000000..c88e7c2 --- /dev/null +++ b/0002-iSulad-resolve-coredump-of-isula-inspect.patch @@ -0,0 +1,37 @@ +From 9e2556703a44d96feb66972541ce200cd018801a Mon Sep 17 00:00:00 2001 +From: jikui +Date: Tue, 23 Jun 2020 20:59:09 +0800 +Subject: [PATCH 2/6] iSulad: resolve coredump of isula inspect "" + +Signed-off-by: jikui +--- + src/cmd/isula/information/inspect.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/cmd/isula/information/inspect.c b/src/cmd/isula/information/inspect.c +index e9b6ff6d..fe011ad9 100644 +--- a/src/cmd/isula/information/inspect.c ++++ b/src/cmd/isula/information/inspect.c +@@ -199,8 +199,9 @@ static int client_inspect_container(const struct isula_inspect_request *request, + + ret = ops->container.inspect(request, response, config); + if (ret != 0) { +- if ((strstr(response->errmsg, "Inspect invalid name") != NULL) || +- (strstr(response->errmsg, "No such image or container or accelerator") != NULL)) { ++ if ((response->errmsg != NULL) && ++ (strstr(response->errmsg, "Inspect invalid name") != NULL || ++ strstr(response->errmsg, "No such image or container or accelerator") != NULL)) { + return CONTAINER_NOT_FOUND; + } + +@@ -814,6 +815,7 @@ int cmd_inspect_main(int argc, const char **argv) + free(filter_string); + + if (status) { ++ COMMAND_ERROR("Inspec error: No such object:%s", g_cmd_inspect_args.name); + exit(ECOMMON); + } + exit(EXIT_SUCCESS); +-- +2.25.1 + diff --git a/0003-Add-Pull-Request-Template-And-Issue-Template.patch b/0003-Add-Pull-Request-Template-And-Issue-Template.patch new file mode 100644 index 0000000..b36c485 --- /dev/null +++ b/0003-Add-Pull-Request-Template-And-Issue-Template.patch @@ -0,0 +1,120 @@ +From 74229fbdc66ba00b8bb3febbd4cdfa3358375a9a Mon Sep 17 00:00:00 2001 +From: wujing +Date: Wed, 24 Jun 2020 11:11:45 +0800 +Subject: [PATCH 3/6] Add Pull Request Template And Issue Template + +Signed-off-by: wujing +--- + .gitee/ISSUE_TEMPLATE.en.md | 13 +++++++++++++ + .gitee/ISSUE_TEMPLATE.zh-CN.md | 16 ++++++++++++++++ + .gitee/PULL_REQUEST_TEMPLATE.en.md | 16 ++++++++++++++++ + .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 15 +++++++++++++++ + .gitignore | 3 +++ + 5 files changed, 63 insertions(+) + create mode 100644 .gitee/ISSUE_TEMPLATE.en.md + create mode 100644 .gitee/ISSUE_TEMPLATE.zh-CN.md + create mode 100644 .gitee/PULL_REQUEST_TEMPLATE.en.md + create mode 100644 .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md + +diff --git a/.gitee/ISSUE_TEMPLATE.en.md b/.gitee/ISSUE_TEMPLATE.en.md +new file mode 100644 +index 00000000..a00edf17 +--- /dev/null ++++ b/.gitee/ISSUE_TEMPLATE.en.md +@@ -0,0 +1,13 @@ ++## [DT/Function Test/Code Review] ++ ++### What version of iSulad and which branch are you using? ++ ++ ++### What operating system (Linux, Windows,...) and version? What compiler are you using? ++ ++ ++### What did you do and what did you see? ++ ++ ++### What did you expect to see? ++ +diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md +new file mode 100644 +index 00000000..aac2216e +--- /dev/null ++++ b/.gitee/ISSUE_TEMPLATE.zh-CN.md +@@ -0,0 +1,16 @@ ++## 【开发者测试/功能测试/代码检视】 ++ ++### iSula版本信息及项目分支 ++ ++ ++ ++### 操作系统版本及编译器版本 ++ ++ ++ ++### 问题描述及重现步骤 ++ ++ ++ ++### 预期结果 ++ +diff --git a/.gitee/PULL_REQUEST_TEMPLATE.en.md b/.gitee/PULL_REQUEST_TEMPLATE.en.md +new file mode 100644 +index 00000000..911ad96d +--- /dev/null ++++ b/.gitee/PULL_REQUEST_TEMPLATE.en.md +@@ -0,0 +1,16 @@ ++### Description ++ ++### Related Issue ++ ++### Type of change ++ ++- Bug Fix ++- New Feature ++- Breaking Change ++- Code Refactoring ++- Interface Change ++- Documentation Update ++ ++### Test Case ++ ++### Validation Report +diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +new file mode 100644 +index 00000000..a842cab7 +--- /dev/null ++++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +@@ -0,0 +1,15 @@ ++### 描述 ++ ++### 关联issue ++ ++### 修改类型 ++ ++- 问题修复 ++- 新特性开发 ++- 代码重构 ++- 接口变更 ++- 文档更新 ++ ++### 测试用例 ++ ++### 验证报告 +diff --git a/.gitignore b/.gitignore +index 11cbe8e8..7e1bcf63 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -2,7 +2,10 @@ build + *.pyc + .deps + .dirstamp ++.clangd + GPATH + GRTAGS + GTAGS + iSula-libutils ++compile_commands.json ++tags +-- +2.25.1 + diff --git a/0004-fix-bug-of-creating-symlink-for-etc-mtab-when-etc-sy.patch b/0004-fix-bug-of-creating-symlink-for-etc-mtab-when-etc-sy.patch new file mode 100644 index 0000000..50c24f4 --- /dev/null +++ b/0004-fix-bug-of-creating-symlink-for-etc-mtab-when-etc-sy.patch @@ -0,0 +1,59 @@ +From 274e8a2964d5d2ab566f92bd0930c08a346cb158 Mon Sep 17 00:00:00 2001 +From: gaohuatao +Date: Tue, 23 Jun 2020 06:40:17 -0400 +Subject: [PATCH 4/6] fix bug of creating symlink for /etc/mtab when /etc + symlink exists + +Signed-off-by: gaohuatao +--- + src/services/execution/execute/execution.c | 23 ++++++++++------------ + 1 file changed, 10 insertions(+), 13 deletions(-) + +diff --git a/src/services/execution/execute/execution.c b/src/services/execution/execute/execution.c +index 19b6a751..4ffcde7a 100644 +--- a/src/services/execution/execute/execution.c ++++ b/src/services/execution/execute/execution.c +@@ -818,30 +818,27 @@ static int create_mtab_link(const oci_runtime_spec *oci_spec) + goto out; + } + +- if (!util_dir_exists(dir)) { +- ret = util_mkdir_p(dir, ETC_FILE_MODE); +- if (ret != 0) { +- ERROR("Unable to create mtab directory %s.", dir); +- goto out; +- } ++ if (unlink(dir) != 0) { ++ WARN("Failed to delete \"%s\": %s", dir, strerror(errno)); + } + + if (util_file_exists(slink)) { + goto out; + } + +- ret = symlink(pathname, slink); +- if (ret < 0 && errno != EEXIST) { +- if (errno == EROFS) { +- WARN("Failed to create link %s for target %s. Read-only filesystem", slink, pathname); +- } else { +- SYSERROR("Failed to create \"%s\"", slink); ++ if (!util_dir_exists(dir)) { ++ if (util_mkdir_p(dir, ETC_FILE_MODE) != 0) { + ret = -1; ++ ERROR("Unable to create mtab directory %s.", dir); + goto out; + } + } + +- ret = 0; ++ if (symlink(pathname, slink) != 0) { ++ ret = -1; ++ SYSERROR("Failed to create \"%s\"", slink); ++ goto out; ++ } + + out: + free(slink); +-- +2.25.1 + diff --git a/0005-fix-label-file-reading-bug.patch b/0005-fix-label-file-reading-bug.patch new file mode 100644 index 0000000..9b71313 --- /dev/null +++ b/0005-fix-label-file-reading-bug.patch @@ -0,0 +1,89 @@ +From d5698095b50813afa2a0c0063c8a7c3df142bac9 Mon Sep 17 00:00:00 2001 +From: wujing +Date: Wed, 24 Jun 2020 12:07:39 +0800 +Subject: [PATCH 5/6] fix label-file reading bug + +Signed-off-by: wujing +--- + src/cmd/isula/base/create.c | 11 +++-------- + src/services/execution/spec/selinux_label.c | 6 +----- + 2 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/src/cmd/isula/base/create.c b/src/cmd/isula/base/create.c +index 6fbc294e..148eea16 100644 +--- a/src/cmd/isula/base/create.c ++++ b/src/cmd/isula/base/create.c +@@ -26,6 +26,7 @@ + #include "arguments.h" + #include "isula_libutils/log.h" + #include "utils.h" ++#include "utils_string.h" + #include "console.h" + #include "create.h" + #include "commands.h" +@@ -433,7 +434,6 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai + FILE *fp = NULL; + char *buf = NULL; + size_t len; +- ssize_t num; + + if (file_size == 0) { + return 0; +@@ -444,14 +444,10 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai + return -1; + } + __fsetlocking(fp, FSETLOCKING_BYCALLER); +- num = getline(&buf, &len, fp); +- while (num != -1) { +- size_t len = strlen(buf); +- if (len == 1) { +- num = getline(&buf, &len, fp); ++ while (getline(&buf, &len, fp) != -1) { ++ if (strlen(util_trim_space(buf)) == 0) { + continue; + } +- buf[len - 1] = '\0'; + if (!validate_label(buf)) { + COMMAND_ERROR("Invalid label '%s': empty name", buf); + ret = -1; +@@ -462,7 +458,6 @@ static int read_label_from_file(const char *path, size_t file_size, isula_contai + ret = -1; + goto out; + } +- num = getline(&buf, &len, fp); + } + + out: +diff --git a/src/services/execution/spec/selinux_label.c b/src/services/execution/spec/selinux_label.c +index 203ee29c..5732880f 100644 +--- a/src/services/execution/spec/selinux_label.c ++++ b/src/services/execution/spec/selinux_label.c +@@ -125,7 +125,6 @@ static void find_selinux_fs_among_mounts(char **fs) + char *buf = NULL; + char **fields = NULL; + size_t len; +- ssize_t num; + + fp = fopen("/proc/self/mountinfo", "re"); + if (fp == NULL) { +@@ -134,16 +133,13 @@ static void find_selinux_fs_among_mounts(char **fs) + } + __fsetlocking(fp, FSETLOCKING_BYCALLER); + +- num = getline(&buf, &len, fp); +- while (num != -1) { ++ while (getline(&buf, &len, fp) != -1) { + if (!strstr(buf, " - selinuxfs ")) { +- num = getline(&buf, &len, fp); + continue; + } + fields = util_string_split((const char *)buf, ' '); + if (fields == NULL || util_array_len((const char **)fields) < MOUNT_POOINT_FIFTH_FIELD + 1) { + util_free_array(fields); +- num = getline(&buf, &len, fp); + continue; + } + if (verify_selinuxfs_mount(fields[MOUNT_POOINT_FIFTH_FIELD - 1])) { +-- +2.25.1 + diff --git a/0006-CI-add-testcases-use-host-rootfs.patch b/0006-CI-add-testcases-use-host-rootfs.patch new file mode 100644 index 0000000..91a444c --- /dev/null +++ b/0006-CI-add-testcases-use-host-rootfs.patch @@ -0,0 +1,44 @@ +From bb9fd6c70af00857af1e7cbfa14ccf31e2cbc1e5 Mon Sep 17 00:00:00 2001 +From: lifeng68 +Date: Wed, 24 Jun 2020 17:25:50 +0800 +Subject: [PATCH 6/6] CI: add testcases use host rootfs / + +Signed-off-by: lifeng68 +--- + CI/test_cases/basic_cases/run.bash | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/CI/test_cases/basic_cases/run.bash b/CI/test_cases/basic_cases/run.bash +index 9b57c2e6..8db3f1ee 100755 +--- a/CI/test_cases/basic_cases/run.bash ++++ b/CI/test_cases/basic_cases/run.bash +@@ -50,7 +50,7 @@ function do_test_t() + + echo AA > /tmp/test_run_env + +- isula run --name $containername -itd -e AA=BB -e AA --env-file /tmp/test_run_env busybox ++ isula run --name $containername -itd -e AAA=BB -e BAA --env-file /tmp/test_run_env busybox + fn_check_eq "$?" "0" "run failed" + testcontainer $containername running + +@@ -61,6 +61,17 @@ function do_test_t() + isula rm $containername + fn_check_eq "$?" "0" "rm failed" + ++ isula run --name $containername -itd --external-rootfs / --read-only none sh ++ fn_check_eq "$?" "0" "run container with host rootfs failed" ++ testcontainer $containername running ++ ++ isula stop -t 0 $containername ++ fn_check_eq "$?" "0" "stop failed" ++ testcontainer $containername exited ++ ++ isula rm $containername ++ fn_check_eq "$?" "0" "rm failed" ++ + return $TC_RET_T + } + +-- +2.25.1 + diff --git a/iSulad.spec b/iSulad.spec index 16f243d..9297840 100644 --- a/iSulad.spec +++ b/iSulad.spec @@ -1,5 +1,5 @@ %global _version 2.0.3 -%global _release 20200616.162831.gitf2fda744 +%global _release 20200628.170704.git76a33943 %global is_systemd 1 %global debug_package %{nil} @@ -13,6 +13,13 @@ Source: iSulad-2.0.3.tar.gz BuildRoot: {_tmppath}/iSulad-%{version} ExclusiveArch: x86_64 aarch64 +Patch9000: 0001-isulad-shim-fix-probabilistic-bad-fd.patch +Patch9001: 0002-iSulad-resolve-coredump-of-isula-inspect.patch +Patch9002: 0003-Add-Pull-Request-Template-And-Issue-Template.patch +Patch9003: 0004-fix-bug-of-creating-symlink-for-etc-mtab-when-etc-sy.patch +Patch9004: 0005-fix-label-file-reading-bug.patch +Patch9005: 0006-CI-add-testcases-use-host-rootfs.patch + %ifarch x86_64 aarch64 Provides: libhttpclient.so()(64bit) Provides: libisula.so()(64bit)