Skip to content

Commit

Permalink
!2528 move nri call in stop and remove con
Browse files Browse the repository at this point in the history
From: @taotao-sauce 
Reviewed-by: @xuxuepeng 
Signed-off-by: @xuxuepeng
  • Loading branch information
openeuler-ci-bot authored and gitee-org committed Nov 19, 2024
2 parents 68afc3f + db60c64 commit 9d5401b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
18 changes: 18 additions & 0 deletions src/daemon/common/cri/cri_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
14 changes: 0 additions & 14 deletions src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -618,25 +618,11 @@ void ContainerManagerService::StartContainer(const std::string &containerID, Err

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());
Expand Down

0 comments on commit 9d5401b

Please sign in to comment.