Make v1 pull/push output consistent with v2

- Use layer DiffIDs for progress output in v1 push. This makes the
  output consistent with v2 pushes, which means that a fallback to v1
  won't start progress bars for a different set of IDs.

- Change wording used in v1 status updates to be consistent with v2.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
Aaron Lehmann 2015-12-07 11:05:48 -08:00
parent a57478d65f
commit 891bbc17ec
2 changed files with 9 additions and 10 deletions

View File

@ -175,7 +175,6 @@ func (p *v1Puller) downloadImage(ctx context.Context, repoData *registry.Reposit
progress.Update(p.config.ProgressOutput, stringid.TruncateID(img.ID), err.Error())
return err
}
progress.Update(p.config.ProgressOutput, stringid.TruncateID(img.ID), "Download complete")
return nil
}

View File

@ -297,11 +297,13 @@ func (p *v1Pusher) lookupImageOnEndpoint(wg *sync.WaitGroup, endpoint string, im
defer wg.Done()
for image := range images {
v1ID := image.V1ID()
truncID := stringid.TruncateID(image.Layer().DiffID().String())
if err := p.session.LookupRemoteImage(v1ID, endpoint); err != nil {
logrus.Errorf("Error in LookupRemoteImage: %s", err)
imagesToPush <- v1ID
progress.Update(p.config.ProgressOutput, truncID, "Waiting")
} else {
progress.Messagef(p.config.ProgressOutput, "", "Image %s already pushed, skipping", stringid.TruncateID(v1ID))
progress.Update(p.config.ProgressOutput, truncID, "Already exists")
}
}
}
@ -372,7 +374,6 @@ func (p *v1Pusher) pushRepository(ctx context.Context) error {
if err != nil {
return err
}
progress.Message(p.config.ProgressOutput, "", "Sending image list")
imageIndex := createImageIndex(imgList, tags)
for _, data := range imageIndex {
@ -385,7 +386,6 @@ func (p *v1Pusher) pushRepository(ctx context.Context) error {
if err != nil {
return err
}
progress.Message(p.config.ProgressOutput, "", "Pushing repository "+p.repoInfo.FullName())
// push the repository to each of the endpoints only if it does not exist.
for _, endpoint := range repoData.Endpoints {
if err := p.pushImageToEndpoint(ctx, endpoint, imgList, tags, repoData); err != nil {
@ -397,10 +397,12 @@ func (p *v1Pusher) pushRepository(ctx context.Context) error {
}
func (p *v1Pusher) pushImage(ctx context.Context, v1Image v1Image, ep string) (checksum string, err error) {
l := v1Image.Layer()
v1ID := v1Image.V1ID()
truncID := stringid.TruncateID(l.DiffID().String())
jsonRaw := v1Image.Config()
progress.Update(p.config.ProgressOutput, stringid.TruncateID(v1ID), "Pushing")
progress.Update(p.config.ProgressOutput, truncID, "Pushing")
// General rule is to use ID for graph accesses and compatibilityID for
// calls to session.registry()
@ -411,14 +413,12 @@ func (p *v1Pusher) pushImage(ctx context.Context, v1Image v1Image, ep string) (c
// Send the json
if err := p.session.PushImageJSONRegistry(imgData, jsonRaw, ep); err != nil {
if err == registry.ErrAlreadyExists {
progress.Update(p.config.ProgressOutput, stringid.TruncateID(v1ID), "Image already pushed, skipping")
progress.Update(p.config.ProgressOutput, truncID, "Image already pushed, skipping")
return "", nil
}
return "", err
}
l := v1Image.Layer()
arch, err := l.TarStream()
if err != nil {
return "", err
@ -431,7 +431,7 @@ func (p *v1Pusher) pushImage(ctx context.Context, v1Image v1Image, ep string) (c
// Send the layer
logrus.Debugf("rendered layer for %s of [%d] size", v1ID, size)
reader := progress.NewProgressReader(ioutils.NewCancelReadCloser(ctx, arch), p.config.ProgressOutput, size, stringid.TruncateID(v1ID), "Pushing")
reader := progress.NewProgressReader(ioutils.NewCancelReadCloser(ctx, arch), p.config.ProgressOutput, size, truncID, "Pushing")
defer reader.Close()
checksum, checksumPayload, err := p.session.PushImageLayerRegistry(v1ID, reader, ep, jsonRaw)
@ -449,6 +449,6 @@ func (p *v1Pusher) pushImage(ctx context.Context, v1Image v1Image, ep string) (c
logrus.Warnf("Could not set v1 ID mapping: %v", err)
}
progress.Update(p.config.ProgressOutput, stringid.TruncateID(v1ID), "Image successfully pushed")
progress.Update(p.config.ProgressOutput, truncID, "Image successfully pushed")
return imgData.Checksum, nil
}