1 Star 0 Fork 43

zhongtao/src-iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0090-modify-the-user-error-log-to-be-the-same-as-before.patch 4.43 KB
一键复制 编辑 原始数据 按行查看 历史
zhongtao 提交于 2024-06-11 19:55 . code improve and bugfix
From 3b0f34c7cd55686cf18f65efbdc0be8a84f13e3e Mon Sep 17 00:00:00 2001
From: zhongtao <[email protected]>
Date: Mon, 20 May 2024 17:54:04 +1400
Subject: [PATCH 090/108] modify the user error log to be the same as before
Signed-off-by: zhongtao <[email protected]>
---
src/daemon/common/id_name_manager.c | 4 +--
.../executor/container_cb/execution_create.c | 26 +++++++++++--------
.../container_cb/execution_information.c | 4 ++-
3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/daemon/common/id_name_manager.c b/src/daemon/common/id_name_manager.c
index 263a584d..f64094b9 100644
--- a/src/daemon/common/id_name_manager.c
+++ b/src/daemon/common/id_name_manager.c
@@ -242,7 +242,7 @@ static bool try_add_name(const char *name)
}
if (!util_valid_container_name(name)) {
- ERROR("Failed to add invalid name: %s", name);
+ ERROR("Invalid container name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", name);
return false;
}
@@ -262,7 +262,7 @@ static bool try_remove_name(const char *name)
}
if (!util_valid_container_name(name)) {
- ERROR("Failed to remove invalid name: %s", name);
+ ERROR("Invalid container name (%s), only [a-zA-Z0-9][a-zA-Z0-9_.-]+$ are allowed.", name);
return false;
}
diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c
index 785b4e27..041089dd 100644
--- a/src/daemon/executor/container_cb/execution_create.c
+++ b/src/daemon/executor/container_cb/execution_create.c
@@ -761,8 +761,17 @@ static int maintain_container_id(const container_create_request *request, char *
#endif
if (!nret) {
- ERROR("Failed to add entry to id name manager with new id and name");
- isulad_set_error_message("Failed to add entry to id name manager with new id and name");
+ __isula_auto_free char *used_id = NULL;
+ used_id = container_name_index_get(name);
+ if(used_id != NULL) {
+ ERROR("Name %s is in use by container %s", name, used_id);
+ isulad_set_error_message("Conflict. The name \"%s\" is already in use by container %s. "
+ "You have to remove (or rename) that container to be able to reuse that name.",
+ name, used_id);
+ } else {
+ ERROR("Failed to add entry to id name manager with new id and name");
+ isulad_set_error_message("Failed to add entry to id name manager with new id and name");
+ }
ret = -1;
goto out;
}
@@ -775,19 +784,14 @@ static int maintain_container_id(const container_create_request *request, char *
goto out;
}
- char *used_id = NULL;
- used_id = container_name_index_get(name);
- ERROR("Name %s is in use by container %s", name, used_id);
- isulad_set_error_message("Conflict. The name \"%s\" is already in use by container %s. "
- "You have to remove (or rename) that container to be able to reuse that name.",
- name, used_id);
- free(used_id);
- used_id = NULL;
- ret = -1;
if (!skip_id_name_manage && !id_name_manager_remove_entry(id, name)) {
WARN("Failed to remove %s and %s from id name manager", id, name);
}
+ ERROR("Failed to add %s to container name index", name);
+ isulad_set_error_message("Failed to add %s to container name index", name);
+ ret = -1;
+
out:
*out_id = id;
*out_name = name;
diff --git a/src/daemon/executor/container_cb/execution_information.c b/src/daemon/executor/container_cb/execution_information.c
index c02cc830..58924257 100644
--- a/src/daemon/executor/container_cb/execution_information.c
+++ b/src/daemon/executor/container_cb/execution_information.c
@@ -1149,7 +1149,9 @@ static int container_rename(container_t *cont, const char *new_name)
if (!id_name_manager_rename(new_name, old_name)) {
ERROR("Failed to rename %s to %s in id-name manager", old_name, new_name);
- isulad_set_error_message("Failed to rename %s to %s in id-name manager", old_name, new_name);
+ isulad_set_error_message("Conflict. The name \"%s\" is already in use by container %s. "
+ "You have to remove (or rename) that container to be able to reuse that name.",
+ new_name, new_name);
ret = -1;
goto out;
}
--
2.25.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/taotao-sauce/src-iSulad.git
[email protected]:taotao-sauce/src-iSulad.git
taotao-sauce
src-iSulad
src-iSulad
master

搜索帮助