From c45261e6d4e382c168d6d641f503d0ba6395f3b5 Mon Sep 17 00:00:00 2001 From: dsxing Date: Fri, 2 Feb 2024 10:11:07 +0800 Subject: [PATCH] When crio restarts, restore the infraContainer Signed-off-by: dsxing --- internal/lib/container_server.go | 3 +++ internal/lib/container_server_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/internal/lib/container_server.go b/internal/lib/container_server.go index 9e2fff54b8e..4b0e13d5603 100644 --- a/internal/lib/container_server.go +++ b/internal/lib/container_server.go @@ -319,6 +319,9 @@ func (c *ContainerServer) LoadSandbox(ctx context.Context, id string) (sb *sandb return sb, err } + // We should restore the infraContainer to the container state store + c.AddInfraContainer(ctx, scontainer) + sb.RestoreStopped() // We add an NS only if we can load a permanent one. // Otherwise, the sandbox will live in the host namespace. diff --git a/internal/lib/container_server_test.go b/internal/lib/container_server_test.go index 5f059eee170..63b219a847b 100644 --- a/internal/lib/container_server_test.go +++ b/internal/lib/container_server_test.go @@ -157,6 +157,19 @@ var _ = t.Describe("ContainerServer", func() { Expect(err).To(BeNil()) }) + It("should succeed load infraContainer", func() { + // Given + createDummyState() + mockDirs(testManifest) + + // When + _, err := sut.LoadSandbox(context.Background(), "id") + + // Then + Expect(err).To(BeNil()) + Expect(sut.GetInfraContainer(context.Background(), sandboxID)).NotTo(BeNil()) + }) + It("should succeed with invalid network namespace", func() { // Given createDummyState()