代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/iSulad 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 934d289aa535bbb87bfe484c4de34275b968fb87 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 8 May 2024 11:40:40 +0800
Subject: [PATCH 81/85] set the sandbox status to not ready under abnormal
circumstances
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/daemon/sandbox/sandbox.cc | 34 +++++++++++++++++++++++++---------
src/daemon/sandbox/sandbox.h | 1 +
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/src/daemon/sandbox/sandbox.cc b/src/daemon/sandbox/sandbox.cc
index bae5b8db..279bf628 100644
--- a/src/daemon/sandbox/sandbox.cc
+++ b/src/daemon/sandbox/sandbox.cc
@@ -371,6 +371,8 @@ void Sandbox::DoUpdateStatus(std::unique_ptr<ControllerSandboxStatus> status, Er
m_state.exitedAt = status->exitedAt;
if (status->state == std::string(SANDBOX_READY_STATE_STR)) {
m_state.status = SANDBOX_STATUS_RUNNING;
+ } else {
+ m_state.status = SANDBOX_STATUS_STOPPED;
}
}
@@ -459,6 +461,24 @@ auto Sandbox::Save(Errors &error) -> bool
return true;
}
+bool Sandbox::DoStatusUpdateAndWaitInLoad(const std::string &sandboxID, Errors &error)
+{
+ if (!UpdateStatus(error)) {
+ ERROR("Failed to update status of Sandbox, id='%s'", sandboxID.c_str());
+ return false;
+ }
+
+ // Regardless of whether the sandbox is ready,
+ // Wait() is required to call to monitor whether the kuasar sandbox is ready or exits.
+ // TODO: distinguish the meaning of Wait() return value in different states of sandbox
+ if (!m_controller->Wait(shared_from_this(), sandboxID, error)) {
+ ERROR("Failed to restore wait callback");
+ return false;
+ }
+
+ return true;
+}
+
auto Sandbox::Load(Errors &error) -> bool
{
if (!LoadState(error)) {
@@ -478,15 +498,11 @@ auto Sandbox::Load(Errors &error) -> bool
LoadNetworkSetting();
- if (!UpdateStatus(error)) {
- ERROR("Failed to update status of Sandbox, id='%s'", m_id.c_str());
- return false;
- }
-
- // TODO: distinguish the meaning of Wait() return value in different states of sandbox
- if (!m_controller->Wait(shared_from_this(), m_id, error)) {
- ERROR("Failed to restore wait callback");
- return false;
+ // When the sandbox status acquisition fails or wait fails, the sandbox status is set to not ready,
+ // and the user decides whether to delete the sandbox.
+ if (!DoStatusUpdateAndWaitInLoad(m_id, error)) {
+ WriteGuard<RWMutex> lock(m_stateMutex);
+ m_state.status = SANDBOX_STATUS_STOPPED;
}
return true;
diff --git a/src/daemon/sandbox/sandbox.h b/src/daemon/sandbox/sandbox.h
index 20a8e338..42fbee2a 100644
--- a/src/daemon/sandbox/sandbox.h
+++ b/src/daemon/sandbox/sandbox.h
@@ -156,6 +156,7 @@ private:
auto SetupSandboxFiles(Errors &error) -> bool;
void DoUpdateStatus(std::unique_ptr<ControllerSandboxStatus> status, Errors &error);
void DoUpdateExitedStatus(const ControllerExitInfo &exitInfo);
+ bool DoStatusUpdateAndWaitInLoad(const std::string &sandboxID, Errors &error);
auto GetMetadataJsonPath() -> std::string;
auto GetStatePath() -> std::string;
--
2.34.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。