diff options
author | CoprDistGit <infra@openeuler.org> | 2024-09-03 03:24:28 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2024-09-03 03:24:28 +0000 |
commit | e45819fcb4a96649a4030db7684f140d5ca46735 (patch) | |
tree | 544dac3e30a0448eabdc50add41aa3a18982d9f1 /0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch | |
parent | 1a71e3afebb4b43be63949dcc8e882fe7643f13b (diff) |
automatic import of iSuladopeneuler24.03_LTS
Diffstat (limited to '0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch')
-rw-r--r-- | 0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch b/0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch new file mode 100644 index 0000000..91a57f2 --- /dev/null +++ b/0081-set-the-sandbox-status-to-not-ready-under-abnormal-c.patch @@ -0,0 +1,86 @@ +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 + |