From 0e072f9a9785c67f38859ab989267397b57154c8 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Mon, 15 Apr 2019 18:45:52 +0000 Subject: Also download container images during restore If restoring a container from a checkpoint it was necessary that the image the container is based was already available (podman pull). This commit adds the image download to podman container restore if it does not exist. Signed-off-by: Adrian Reber --- pkg/adapter/checkpoint_restore.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/adapter') diff --git a/pkg/adapter/checkpoint_restore.go b/pkg/adapter/checkpoint_restore.go index 9df1704ea..4ca17dd93 100644 --- a/pkg/adapter/checkpoint_restore.go +++ b/pkg/adapter/checkpoint_restore.go @@ -5,10 +5,12 @@ package adapter import ( "context" "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/image" "github.com/containers/storage/pkg/archive" jsoniter "github.com/json-iterator/go" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" + "io" "io/ioutil" "os" "path/filepath" @@ -83,6 +85,20 @@ func crImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, input stri return nil, errors.Errorf("Cannot import checkpoints of containers with named volumes or dependencies") } + // The code to load the images is copied from create.go + var writer io.Writer + // In create.go this only set if '--quiet' does not exist. + writer = os.Stderr + rtc, err := runtime.GetConfig() + if err != nil { + return nil, err + } + + _, err = runtime.ImageRuntime().New(ctx, config.RootfsImageName, rtc.SignaturePolicyPath, "", writer, nil, image.SigningOptions{}, false, nil) + if err != nil { + return nil, err + } + // Now create a new container from the just loaded information container, err := runtime.RestoreContainer(ctx, spec, config) if err != nil { -- cgit v1.2.3-54-g00ecf