diff --git a/internal/lib/container_server.go b/internal/lib/container_server.go index 2b826cdff1f..ff39b6fcf5a 100644 --- a/internal/lib/container_server.go +++ b/internal/lib/container_server.go @@ -281,6 +281,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 3b526e29e7a..2e4826012e4 100644 --- a/internal/lib/container_server_test.go +++ b/internal/lib/container_server_test.go @@ -156,6 +156,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()