From e33b7915d9ef5092252bc3ce5d93fbde74d73990 Mon Sep 17 00:00:00 2001 From: jikai Date: Mon, 27 Nov 2023 15:09:39 +0800 Subject: [PATCH 38/64] save sandbox to disk after network ready Signed-off-by: jikai --- .../cri/v1/v1_cri_pod_sandbox_manager_service.cc | 13 ++++++++++--- src/daemon/sandbox/sandbox.cc | 6 ------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc index 0f6b8508..a0c45111 100644 --- a/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc +++ b/src/daemon/entry/cri/v1/v1_cri_pod_sandbox_manager_service.cc @@ -358,14 +358,21 @@ auto PodSandboxManagerService::RunPodSandbox(const runtime::v1::PodSandboxConfig goto cleanup_sandbox; } - // Step 8: Call sandbox create. + // Step 8: Save sandbox to disk + sandbox->Save(error); + if (error.NotEmpty()) { + ERROR("Failed to save sandbox, %s", sandboxName.c_str()); + goto cleanup_network; + } + + // Step 9: Call sandbox create. sandbox->Create(error); if (error.NotEmpty()) { ERROR("Failed to create sandbox: %s", sandboxName.c_str()); goto cleanup_network; } - // Step 9: Save network settings json to disk + // Step 10: Save network settings json to disk // Update network settings before start sandbox since sandbox container will use the sandbox key if (namespace_is_cni(networkMode.c_str())) { Errors tmpErr; @@ -376,7 +383,7 @@ auto PodSandboxManagerService::RunPodSandbox(const runtime::v1::PodSandboxConfig } } - // Step 10: Call sandbox start. + // Step 11: Call sandbox start. sandbox->Start(error); if (error.NotEmpty()) { ERROR("Failed to start sandbox: %s", sandboxName.c_str()); diff --git a/src/daemon/sandbox/sandbox.cc b/src/daemon/sandbox/sandbox.cc index b1832265..9fe9fa48 100644 --- a/src/daemon/sandbox/sandbox.cc +++ b/src/daemon/sandbox/sandbox.cc @@ -599,12 +599,6 @@ void Sandbox::PrepareSandboxDirs(Errors &error) goto out; } - if (!Save(error)) { - error.Errorf("Failed to save sandbox, %s", m_id.c_str()); - ERROR("Failed to save sandbox, %s", m_id.c_str()); - goto out; - } - umask(mask); return; -- 2.42.0