diff --git a/daemon/images/image_pull.go b/daemon/images/image_pull.go index e25e1d0631..238c38b6b3 100644 --- a/daemon/images/image_pull.go +++ b/daemon/images/image_pull.go @@ -5,6 +5,7 @@ import ( "io" "runtime" "strings" + "time" dist "github.com/docker/distribution" "github.com/docker/distribution/reference" @@ -20,6 +21,7 @@ import ( // PullImage initiates a pull operation. image is the repository name to pull, and // tag may be either empty, or indicate a specific tag to pull. func (i *ImageService) PullImage(ctx context.Context, image, tag, os string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { + start := time.Now() // Special case: "pull -a" may send an image name with a // trailing :. This is ugly, but let's not break API // compatibility. @@ -44,7 +46,9 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag, os string, met } } - return i.pullImageWithReference(ctx, ref, os, metaHeaders, authConfig, outStream) + err = i.pullImageWithReference(ctx, ref, os, metaHeaders, authConfig, outStream) + imageActions.WithValues("pull").UpdateSince(start) + return err } func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, os string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { diff --git a/daemon/images/image_push.go b/daemon/images/image_push.go index a1a6d7f6d1..4c7be8d2e9 100644 --- a/daemon/images/image_push.go +++ b/daemon/images/image_push.go @@ -3,6 +3,7 @@ package images // import "github.com/docker/docker/daemon/images" import ( "context" "io" + "time" "github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/reference" @@ -14,6 +15,7 @@ import ( // PushImage initiates a push operation on the repository named localName. func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error { + start := time.Now() ref, err := reference.ParseNormalizedNamed(image) if err != nil { return err @@ -59,5 +61,6 @@ func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHea err = distribution.Push(ctx, ref, imagePushConfig) close(progressChan) <-writesDone + imageActions.WithValues("push").UpdateSince(start) return err }