From 3cfbdd232e7c2fcf7fde33591dbe4a3d1207f807 Mon Sep 17 00:00:00 2001 From: zhangxiaoyu Date: Thu, 6 May 2021 16:14:23 +0800 Subject: [PATCH] network: fix residual network issue and make remove containers quickly Signed-off-by: zhangxiaoyu --- src/daemon/executor/container_cb/execution.c | 3 ++- src/daemon/modules/service/service_container.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c index 9d31aa851..8882212e7 100644 --- a/src/daemon/executor/container_cb/execution.c +++ b/src/daemon/executor/container_cb/execution.c @@ -481,6 +481,8 @@ static uint32_t stop_and_start(container_t *cont, int timeout) set_container_skip_remove_network(cont); ret = stop_container(cont, timeout, false, true); + reset_container_skip_remove_network(cont); + if (ret != 0) { cc = ISULAD_ERR_EXEC; container_state_set_error(cont->state, (const char *)g_isulad_errmsg); @@ -507,7 +509,6 @@ static uint32_t stop_and_start(container_t *cont, int timeout) } out: - reset_container_skip_remove_network(cont); container_state_reset_starting(cont->state); return cc; } diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c index a15296416..b761b95e0 100644 --- a/src/daemon/modules/service/service_container.c +++ b/src/daemon/modules/service/service_container.c @@ -1112,8 +1112,9 @@ static int do_delete_container(container_t *cont) } // try to clean up network resource - if (remove_network(cont) != 0) { - WARN("Failed to remove network when delete container %s, maybe it has been cleaned up", cont->common_config->id); + if (cont->network_settings != NULL && util_file_exists(cont->network_settings->sandbox_key) && + remove_network(cont) != 0) { + ERROR("Failed to remove network when delete container %s, maybe it has been cleaned up", cont->common_config->id); } ret = snprintf(container_state, sizeof(container_state), "%s/%s", statepath, id); -- Gitee