From 1d51e3e9f14199854cc2d586651c5809345aee18 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 8 May 2024 14:48:47 +0800
Subject: [PATCH 82/85] fix shim controller set incorrect sandbox status state

Signed-off-by: jikai <jikai11@huawei.com>
---
 src/daemon/sandbox/controller/controller.h            | 3 +++
 src/daemon/sandbox/controller/shim/shim_controller.cc | 6 ++++--
 src/daemon/sandbox/sandbox.cc                         | 3 ---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/daemon/sandbox/controller/controller.h b/src/daemon/sandbox/controller/controller.h
index f479a0ac..9ad45855 100644
--- a/src/daemon/sandbox/controller/controller.h
+++ b/src/daemon/sandbox/controller/controller.h
@@ -27,6 +27,9 @@
 
 namespace sandbox {
 
+#define SANDBOX_READY_STATE_STR "SANDBOX_READY"
+#define SANDBOX_NOTREADY_STATE_STR "SANDBOX_NOTREADY"
+
 struct ControllerMountInfo {
     std::string source;
     std::string destination;
diff --git a/src/daemon/sandbox/controller/shim/shim_controller.cc b/src/daemon/sandbox/controller/shim/shim_controller.cc
index 4da637c7..ce09c076 100644
--- a/src/daemon/sandbox/controller/shim/shim_controller.cc
+++ b/src/daemon/sandbox/controller/shim/shim_controller.cc
@@ -446,8 +446,10 @@ void ShimController::InspectResponseToSandboxStatus(container_inspect *inspect,
     sandboxStatus.id = inspect->id;
     if (inspect->state != nullptr) {
         sandboxStatus.pid = inspect->state->pid;
-        if (inspect->state->status != nullptr) {
-            sandboxStatus.state = std::string(inspect->state->status);
+        if (inspect->state->running) {
+            sandboxStatus.state = std::string(SANDBOX_READY_STATE_STR);
+        } else {
+            sandboxStatus.state = std::string(SANDBOX_NOTREADY_STATE_STR);
         }
     }
 
diff --git a/src/daemon/sandbox/sandbox.cc b/src/daemon/sandbox/sandbox.cc
index 279bf628..d44abb99 100644
--- a/src/daemon/sandbox/sandbox.cc
+++ b/src/daemon/sandbox/sandbox.cc
@@ -39,9 +39,6 @@
 #include "utils_timestamp.h"
 #include "mailbox.h"
 
-#define SANDBOX_READY_STATE_STR "SANDBOX_READY"
-#define SANDBOX_NOTREADY_STATE_STR "SANDBOX_NOTREADY"
-
 namespace sandbox {
 
 const std::string SHM_MOUNT_POINT = "/dev/shm";
-- 
2.34.1

