代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/iSulad 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 051be757db25c8ac7e6c4beb1ec219b4fde3641c Mon Sep 17 00:00:00 2001
From: lifeng68 <[email protected]>
Date: Sat, 5 Dec 2020 10:24:58 +0800
Subject: [PATCH 18/18] clean code: ignore list containers error
Signed-off-by: lifeng68 <[email protected]>
---
src/daemon/executor/container_cb/list.c | 82 +++++++++++++++----------
1 file changed, 51 insertions(+), 31 deletions(-)
diff --git a/src/daemon/executor/container_cb/list.c b/src/daemon/executor/container_cb/list.c
index 4c9c9ed..3dea940 100644
--- a/src/daemon/executor/container_cb/list.c
+++ b/src/daemon/executor/container_cb/list.c
@@ -311,44 +311,73 @@ static void dup_id_name(const container_config_v2_common_config *common_config,
}
}
-static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config,
- container_container *isuladinfo)
+static void dup_container_labels(const map_t *map_labels, const container_config_v2_common_config *common_config,
+ container_container *isuladinfo)
{
int ret = 0;
- bool args_err = false;
-
- if (map_labels == NULL || common_config == NULL || isuladinfo == NULL) {
- return -1;
- }
if (common_config->config == NULL) {
- return 0;
+ return;
}
- args_err = (common_config->config->labels != NULL && common_config->config->labels->len != 0);
- if (args_err) {
+
+ if (common_config->config->labels != NULL && common_config->config->labels->len != 0) {
json_map_string_string *labels = common_config->config->labels;
ret = replace_labels(isuladinfo, labels, map_labels);
- if (ret == -1) {
- goto out;
+ if (ret != 0) {
+ ERROR("Failed to dup container %s labels", common_config->id);
}
}
+ return;
+}
+
+static void dup_container_annotations(const container_config_v2_common_config *common_config,
+ container_container *isuladinfo)
+{
+ int ret = 0;
+
+ if (common_config->config == NULL) {
+ return;
+ }
+
ret = replace_annotations(common_config, isuladinfo);
- if (ret == -1) {
- goto out;
+ if (ret != 0) {
+ ERROR("Failed to dup container %s annotations", common_config->id);
}
- dup_id_name(common_config, isuladinfo);
- args_err = (common_config->created != NULL &&
- util_to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0);
- if (args_err) {
- ret = -1;
- goto out;
+ return;
+}
+
+static void dup_container_created_time(const container_config_v2_common_config *common_config,
+ container_container *isuladinfo)
+{
+ if (common_config->created != NULL &&
+ util_to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0) {
+ ERROR("Failed to dup container %s created time", common_config->id);
+ }
+
+ return;
+}
+
+static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config,
+ container_container *isuladinfo)
+{
+ if (map_labels == NULL || common_config == NULL || isuladinfo == NULL) {
+ return -1;
}
+
+ dup_id_name(common_config, isuladinfo);
+
isuladinfo->restartcount = (uint64_t)common_config->restart_count;
-out:
- return ret;
+
+ dup_container_labels(map_labels, common_config, isuladinfo);
+
+ dup_container_annotations(common_config, isuladinfo);
+
+ dup_container_created_time(common_config, isuladinfo);
+
+ return 0;
}
static int container_info_match(const struct list_context *ctx, const map_t *map_labels,
@@ -413,7 +442,6 @@ static int fill_isuladinfo(container_container *isuladinfo, const container_conf
char *image = NULL;
char *timestr = NULL;
char *defvalue = "-";
- int64_t created_nanos = 0;
ret = convert_common_config_info(map_labels, cont->common_config, isuladinfo);
if (ret != 0) {
@@ -438,14 +466,6 @@ static int fill_isuladinfo(container_container *isuladinfo, const container_conf
isuladinfo->runtime = cont->runtime ? util_strdup_s(cont->runtime) : util_strdup_s("none");
isuladinfo->health_state = container_get_health_state(cont_state);
- if (cont->common_config->created != NULL) {
- ret = util_to_unix_nanos_from_str(cont->common_config->created, &created_nanos);
- if (ret != 0) {
- goto out;
- }
- }
-
- isuladinfo->created = created_nanos;
out:
return ret;
--
2.25.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。