!90 ignore list containers errors
From: @lifeng2221dd1 Reviewed-by: @duguhaotian Signed-off-by: @duguhaotian
This commit is contained in:
commit
a1fce1239d
136
0018-clean-code-ignore-list-containers-error.patch
Normal file
136
0018-clean-code-ignore-list-containers-error.patch
Normal file
@ -0,0 +1,136 @@
|
||||
From 051be757db25c8ac7e6c4beb1ec219b4fde3641c Mon Sep 17 00:00:00 2001
|
||||
From: lifeng68 <lifeng68@huawei.com>
|
||||
Date: Sat, 5 Dec 2020 10:24:58 +0800
|
||||
Subject: [PATCH 18/18] clean code: ignore list containers error
|
||||
|
||||
Signed-off-by: lifeng68 <lifeng68@huawei.com>
|
||||
---
|
||||
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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
%global _version 2.0.7
|
||||
%global _release 20201203.190902.git48f598fd
|
||||
%global _release 20201205.145752.gita461cc51
|
||||
%global is_systemd 1
|
||||
|
||||
Name: iSulad
|
||||
@ -29,6 +29,7 @@ Patch0014: 0014-error-out-if-unpack-layer-failed.patch
|
||||
Patch0015: 0015-ignore-get-ip-error-for-mutlnetwork.patch
|
||||
Patch0016: 0016-support-default-container-log-options.patch
|
||||
Patch0017: 0017-add-testcase-for-default-container-log-configs.patch
|
||||
Patch0018: 0018-clean-code-ignore-list-containers-error.patch
|
||||
|
||||
%ifarch x86_64 aarch64
|
||||
Provides: libhttpclient.so()(64bit)
|
||||
@ -231,6 +232,12 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Sat Dec 5 2020 lifeng <lifeng68@huawei.com> - 2.0.7-20201205.145752.gita461cc51
|
||||
- Type: bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: ignore list containers errors
|
||||
|
||||
* Thu Dec 3 2020 haozi007 <liuhao27@huawei.com> - 2.0.7-20201203.190902.git48f598fd
|
||||
- Type:update from master
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user