From 9f67d23b81babd5be844d1e5abad6fbbe74a3aca Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 19 Dec 2023 18:31:30 +0800
Subject: [PATCH 182/198] fix stopp removes cont error & remove inspect error
 log

Signed-off-by: jikai <jikai11@huawei.com>
---
 .../cri_pod_sandbox_manager_service_impl.cc   | 36 ++++++++-----------
 .../container_cb/execution_information.c      |  2 +-
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
index edf4dc81..da23cb21 100644
--- a/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
+++ b/src/daemon/entry/cri/cri_pod_sandbox_manager_service_impl.cc
@@ -663,30 +663,22 @@ auto PodSandboxManagerServiceImpl::GetRealSandboxIDToStop(const std::string &pod
                                                           std::map<std::string, std::string> &stdAnnos, Errors &error)
 -> int
 {
-    Errors statusErr;
+    auto status = PodSandboxStatus(podSandboxID, error);
+    if (error.NotEmpty()) {
+        return -1;
+    }
 
-    auto status = PodSandboxStatus(podSandboxID, statusErr);
-    if (statusErr.Empty()) {
-        if (status->linux().namespaces().has_options()) {
-            hostNetwork = (status->linux().namespaces().options().network() == runtime::v1alpha2::NamespaceMode::NODE);
-        }
-        // if metadata is invalid, don't return -1 and continue stopping pod
-        if (status->has_metadata()) {
-            name = status->metadata().name();
-            ns = status->metadata().namespace_();
-        }
-        realSandboxID = status->id();
-        CRIHelpers::ProtobufAnnoMapToStd(status->annotations(), stdAnnos);
-    } else {
-        if (CRIHelpers::IsContainerNotFoundError(statusErr.GetMessage())) {
-            WARN("Both sandbox container and checkpoint for id %s could not be found. "
-                 "Proceed without further sandbox information.",
-                 podSandboxID.c_str());
-        } else {
-            error.Errorf("failed to get sandbox status: %s", statusErr.GetCMessage());
-            return -1;
-        }
+    if (status->linux().namespaces().has_options()) {
+        hostNetwork = (status->linux().namespaces().options().network() == runtime::v1alpha2::NamespaceMode::NODE);
     }
+    // if metadata is invalid, don't return -1 and continue stopping pod
+    if (status->has_metadata()) {
+        name = status->metadata().name();
+        ns = status->metadata().namespace_();
+    }
+    realSandboxID = status->id();
+    CRIHelpers::ProtobufAnnoMapToStd(status->annotations(), stdAnnos);
+
     if (realSandboxID.empty()) {
         realSandboxID = podSandboxID;
     }
diff --git a/src/daemon/executor/container_cb/execution_information.c b/src/daemon/executor/container_cb/execution_information.c
index ba33bdfa..6489797d 100644
--- a/src/daemon/executor/container_cb/execution_information.c
+++ b/src/daemon/executor/container_cb/execution_information.c
@@ -909,7 +909,7 @@ static int inspect_container_helper(const char *id, int timeout, char **containe
 
     inspect = inspect_container(id, timeout, true);
     if (inspect == NULL) {
-        ERROR("Failed to inspect container:%s", id);
+        DEBUG("Failed to inspect container:%s", id);
         ret = -1;
         goto out;
     }
-- 
2.25.1

