diff --git a/internal/lib/container_server.go b/internal/lib/container_server.go index e91c17c5931..2dac6900715 100644 --- a/internal/lib/container_server.go +++ b/internal/lib/container_server.go @@ -283,6 +283,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 2134bbc5887..695178a6066 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()