diff --git a/control/control_containerd.go b/control/control_containerd.go index e53bebe7..74c97584 100644 --- a/control/control_containerd.go +++ b/control/control_containerd.go @@ -46,7 +46,7 @@ func NewContainerd(root, address string) (*Controller, error) { func newContainerdPullDeps(client *containerd.Client) *pullDeps { diff := client.DiffService() return &pullDeps{ - Snapshotter: client.SnapshotService(), + Snapshotter: client.SnapshotService(""), ContentStore: client.ContentStore(), Applier: diff, Differ: diff, diff --git a/exporter/containerimage/export.go b/exporter/containerimage/export.go index e8fd5d3a..79e0c913 100644 --- a/exporter/containerimage/export.go +++ b/exporter/containerimage/export.go @@ -9,6 +9,7 @@ import ( "github.com/Sirupsen/logrus" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/rootfs" @@ -214,14 +215,26 @@ func (e *imageExporterInstance) Export(ctx context.Context, ref cache.ImmutableR mfstDone(nil) if e.opt.Images != nil && e.targetName != "" { - tagDone := oneOffProgress(ctx, "tagging to "+e.targetName) - err := e.opt.Images.Update(ctx, e.targetName, ocispec.Descriptor{ - Digest: dgst, - Size: int64(len(dt)), - MediaType: ocispec.MediaTypeImageManifest, - }) + tagDone := oneOffProgress(ctx, "naming to "+e.targetName) + imgrec := images.Image{ + Name: e.targetName, + Target: ocispec.Descriptor{ + Digest: dgst, + Size: int64(len(dt)), + MediaType: ocispec.MediaTypeImageManifest, + }, + CreatedAt: time.Now(), + } + _, err := e.opt.Images.Update(ctx, imgrec) if err != nil { - return tagDone(err) + if !errdefs.IsNotFound(err) { + return tagDone(err) + } + + _, err := e.opt.Images.Create(ctx, imgrec) + if err != nil { + return tagDone(err) + } } tagDone(nil) } diff --git a/source/containerimage/pull.go b/source/containerimage/pull.go index adb374c2..cfc460de 100644 --- a/source/containerimage/pull.go +++ b/source/containerimage/pull.go @@ -241,7 +241,7 @@ func showProgress(ctx context.Context, ongoing *jobs, cs content.Store) { actives := make(map[string]statusInfo) if !done { - active, err := cs.Status(ctx, "") + active, err := cs.ListStatuses(ctx, "") if err != nil { // log.G(ctx).WithError(err).Error("active check failed") continue @@ -290,7 +290,7 @@ func showProgress(ctx context.Context, ongoing *jobs, cs content.Store) { Action: "done", Current: int(info.Size), Total: int(info.Size), - Completed: &info.CommittedAt, + Completed: &info.CreatedAt, Started: &j.started, }) }