Skip to content

Commit

Permalink
Merge pull request moby#46589 from vvoland/c8d-push-mounted-exists
Browse files Browse the repository at this point in the history
c8d/push: Show Mounted/Already exists status
  • Loading branch information
vvoland authored Oct 12, 2023
2 parents c538935 + 44dbbeb commit 3205ace
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
3 changes: 0 additions & 3 deletions daemon/containerd/image_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ func (i *ImageService) pushRef(ctx context.Context, targetRef reference.Named, m
if err != nil {
return err
}
for dgst := range mountableBlobs {
pp.addMountable(dgst)
}

// Create a store which fakes the local existence of possibly mountable blobs.
// Otherwise they can't be pushed at all.
Expand Down
41 changes: 15 additions & 26 deletions daemon/containerd/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (

"github.com/containerd/containerd/content"
cerrdefs "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/log"
"github.com/distribution/reference"
"github.com/docker/docker/internal/compatcontext"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/stringid"
Expand Down Expand Up @@ -169,30 +171,7 @@ func (p pullProgress) UpdateProgress(ctx context.Context, ongoing *jobs, out pro
}

type pushProgress struct {
Tracker docker.StatusTracker
mountable map[digest.Digest]struct{}
mutex sync.Mutex
}

func (p *pushProgress) addMountable(dgst digest.Digest) {
p.mutex.Lock()
defer p.mutex.Unlock()

if p.mountable == nil {
p.mountable = map[digest.Digest]struct{}{}
}
p.mountable[dgst] = struct{}{}
}

func (p *pushProgress) isMountable(dgst digest.Digest) bool {
p.mutex.Lock()
defer p.mutex.Unlock()

if p.mountable == nil {
return false
}
_, has := p.mountable[dgst]
return has
Tracker docker.StatusTracker
}

func (p *pushProgress) UpdateProgress(ctx context.Context, ongoing *jobs, out progress.Output, start time.Time) error {
Expand All @@ -209,8 +188,18 @@ func (p *pushProgress) UpdateProgress(ctx context.Context, ongoing *jobs, out pr
}

if status.Committed && status.Offset >= status.Total {
if p.isMountable(j.Digest) {
progress.Update(out, id, "Mounted")
if status.MountedFrom != "" {
from := status.MountedFrom
if ref, err := reference.ParseNormalizedNamed(from); err == nil {
from = reference.Path(ref)
}
progress.Update(out, id, "Mounted from "+from)
} else if status.Exists {
if images.IsLayerType(j.MediaType) {
progress.Update(out, id, "Layer already exists")
} else {
progress.Update(out, id, "Already exists")
}
} else {
progress.Update(out, id, "Pushed")
}
Expand Down

0 comments on commit 3205ace

Please sign in to comment.