加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0149-move-nri-call-in-stop-and-remove-con.patch 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
liuxu 提交于 2024-11-25 16:34 . upgrade from upstream
From db60c64138b45539fe70282c853ac2dae5954924 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Thu, 14 Nov 2024 17:34:49 +0800
Subject: [PATCH 149/156] move nri call in stop and remove con
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/daemon/common/cri/cri_helpers.cc | 18 ++++++++++++++++++
.../cri/v1/v1_cri_container_manager_service.cc | 14 --------------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/src/daemon/common/cri/cri_helpers.cc b/src/daemon/common/cri/cri_helpers.cc
index a8cbd996..aa8e3c19 100644
--- a/src/daemon/common/cri/cri_helpers.cc
+++ b/src/daemon/common/cri/cri_helpers.cc
@@ -32,6 +32,10 @@
#include "isulad_config.h"
#include "sha256.h"
+#ifdef ENABLE_NRI
+#include "nri_adaption.h"
+#endif
+
namespace CRIHelpers {
const std::string Constants::POD_NETWORK_ANNOTATION_KEY { "network.alpha.kubernetes.io/network" };
const std::string Constants::CONTAINER_TYPE_LABEL_KEY { "cri.isulad.type" };
@@ -660,6 +664,13 @@ void RemoveContainerHelper(service_executor_t *cb, const std::string &containerI
goto cleanup;
}
+#ifdef ENABLE_NRI
+ if (!NRIAdaptation::GetInstance()->RemoveContainer(containerID, error)) {
+ ERROR("NRI RemoveContainer notification failed: %s", error.GetCMessage());
+ }
+ error.Clear();
+#endif
+
if (cb->container.remove(request, &response) != 0) {
if (response != nullptr && response->errmsg != nullptr) {
error.SetError(response->errmsg);
@@ -719,6 +730,13 @@ void StopContainerHelper(service_executor_t *cb, const std::string &containerID,
error.SetError(msg);
}
+#ifdef ENABLE_NRI
+ if (!NRIAdaptation::GetInstance()->StopContainer(containerID, error)) {
+ ERROR("NRI StopContainer notification failed: %s", error.GetCMessage());
+ }
+ error.Clear();
+#endif
+
free_container_stop_request(request);
free_container_stop_response(response);
}
diff --git a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
index 1e84d14c..b585b49c 100644
--- a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
@@ -618,25 +618,11 @@ cleanup:
void ContainerManagerService::StopContainer(const std::string &containerID, int64_t timeout, Errors &error)
{
-#ifdef ENABLE_NRI
- Errors nriErr;
-#endif
CRIHelpers::StopContainer(m_cb, containerID, timeout, error);
-#ifdef ENABLE_NRI
- if (!NRIAdaptation::GetInstance()->StopContainer(containerID, nriErr)) {
- ERROR("NRI StopContainer notification failed: %s", nriErr.GetCMessage());
- }
-#endif
}
void ContainerManagerService::RemoveContainer(const std::string &containerID, Errors &error)
{
-#ifdef ENABLE_NRI
- Errors nriErr;
- if (!NRIAdaptation::GetInstance()->RemoveContainer(containerID, nriErr)) {
- ERROR("NRI RemoveContainer notification failed: %s", nriErr.GetCMessage());
- }
-#endif
CRIHelpers::RemoveContainer(m_cb, containerID, error);
if (error.NotEmpty()) {
WARN("Failed to remove container %s", containerID.c_str());
--
2.34.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化