mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add image metrics for push and pull
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
d47c45175b
commit
6910019bbe
2 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
dist "github.com/docker/distribution"
|
dist "github.com/docker/distribution"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
@ -20,6 +21,7 @@ import (
|
||||||
// PullImage initiates a pull operation. image is the repository name to pull, and
|
// 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.
|
// 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 {
|
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
|
// Special case: "pull -a" may send an image name with a
|
||||||
// trailing :. This is ugly, but let's not break API
|
// trailing :. This is ugly, but let's not break API
|
||||||
// compatibility.
|
// 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 {
|
func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference.Named, os string, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package images // import "github.com/docker/docker/daemon/images"
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/docker/distribution/manifest/schema2"
|
"github.com/docker/distribution/manifest/schema2"
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
@ -14,6 +15,7 @@ import (
|
||||||
|
|
||||||
// PushImage initiates a push operation on the repository named localName.
|
// 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 {
|
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)
|
ref, err := reference.ParseNormalizedNamed(image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -59,5 +61,6 @@ func (i *ImageService) PushImage(ctx context.Context, image, tag string, metaHea
|
||||||
err = distribution.Push(ctx, ref, imagePushConfig)
|
err = distribution.Push(ctx, ref, imagePushConfig)
|
||||||
close(progressChan)
|
close(progressChan)
|
||||||
<-writesDone
|
<-writesDone
|
||||||
|
imageActions.WithValues("push").UpdateSince(start)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue