From 36d21e417b428d7a5f7a39e2e48787104fc7be54 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Thu, 30 Jul 2015 21:14:39 -0400 Subject: [PATCH] Vendor docker/distribution to 7dc8d4a26b689bd4892f2f2322dbce0b7119d686 Signed-off-by: Tibor Vass Upstream-commit: 0cce1fb37ffbcb209826fdc98c3148fc5b1e2abd Component: engine --- components/engine/hack/vendor.sh | 2 +- .../src/github.com/docker/distribution/Dockerfile | 1 + .../docker/distribution/context/context.go | 13 +++++++++++-- .../docker/distribution/context/logger.go | 7 ------- .../distribution/registry/api/v2/descriptors.go | 2 +- .../src/github.com/docker/distribution/uuid/uuid.go | 7 ++++--- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/components/engine/hack/vendor.sh b/components/engine/hack/vendor.sh index 08ae3267c9..e79c8fb9be 100755 --- a/components/engine/hack/vendor.sh +++ b/components/engine/hack/vendor.sh @@ -36,7 +36,7 @@ clone git github.com/coreos/go-etcd v2.0.0 clone git github.com/hashicorp/consul v0.5.2 # get graph and distribution packages -clone git github.com/docker/distribution e83345626608aa943d5c8a027fddcf54814d9545 +clone git github.com/docker/distribution 7dc8d4a26b689bd4892f2f2322dbce0b7119d686 clone git github.com/vbatts/tar-split v0.9.4 clone git github.com/docker/notary 77bced079e83d80f40c1f0a544b1a8a3b97fb052 diff --git a/components/engine/vendor/src/github.com/docker/distribution/Dockerfile b/components/engine/vendor/src/github.com/docker/distribution/Dockerfile index 66e568e423..5555606faa 100644 --- a/components/engine/vendor/src/github.com/docker/distribution/Dockerfile +++ b/components/engine/vendor/src/github.com/docker/distribution/Dockerfile @@ -10,6 +10,7 @@ ENV DOCKER_BUILDTAGS include_rados WORKDIR $DISTRIBUTION_DIR COPY . $DISTRIBUTION_DIR +COPY cmd/registry/config-dev.yml $DISTRIBUTION_DIR/cmd/registry/config.yml RUN make PREFIX=/go clean binaries VOLUME ["/var/lib/registry"] diff --git a/components/engine/vendor/src/github.com/docker/distribution/context/context.go b/components/engine/vendor/src/github.com/docker/distribution/context/context.go index 7a3a70e00d..23cbf5b545 100644 --- a/components/engine/vendor/src/github.com/docker/distribution/context/context.go +++ b/components/engine/vendor/src/github.com/docker/distribution/context/context.go @@ -1,6 +1,8 @@ package context import ( + "sync" + "github.com/docker/distribution/uuid" "golang.org/x/net/context" ) @@ -14,11 +16,19 @@ type Context interface { // provided as the main background context. type instanceContext struct { Context - id string // id of context, logged as "instance.id" + id string // id of context, logged as "instance.id" + once sync.Once // once protect generation of the id } func (ic *instanceContext) Value(key interface{}) interface{} { if key == "instance.id" { + ic.once.Do(func() { + // We want to lazy initialize the UUID such that we don't + // call a random generator from the package initialization + // code. For various reasons random could not be available + // https://github.com/docker/distribution/issues/782 + ic.id = uuid.Generate().String() + }) return ic.id } @@ -27,7 +37,6 @@ func (ic *instanceContext) Value(key interface{}) interface{} { var background = &instanceContext{ Context: context.Background(), - id: uuid.Generate().String(), } // Background returns a non-nil, empty Context. The background context diff --git a/components/engine/vendor/src/github.com/docker/distribution/context/logger.go b/components/engine/vendor/src/github.com/docker/distribution/context/logger.go index b0f0c50845..78e4212a0b 100644 --- a/components/engine/vendor/src/github.com/docker/distribution/context/logger.go +++ b/components/engine/vendor/src/github.com/docker/distribution/context/logger.go @@ -3,8 +3,6 @@ package context import ( "fmt" - "github.com/docker/distribution/uuid" - "github.com/Sirupsen/logrus" ) @@ -101,8 +99,3 @@ func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry { return logger.WithFields(fields) } - -func init() { - // inject a logger into the uuid library. - uuid.Loggerf = GetLogger(Background()).Warnf -} diff --git a/components/engine/vendor/src/github.com/docker/distribution/registry/api/v2/descriptors.go b/components/engine/vendor/src/github.com/docker/distribution/registry/api/v2/descriptors.go index 635cb7f901..74bdb9f2e2 100644 --- a/components/engine/vendor/src/github.com/docker/distribution/registry/api/v2/descriptors.go +++ b/components/engine/vendor/src/github.com/docker/distribution/registry/api/v2/descriptors.go @@ -607,7 +607,7 @@ var routeDescriptors = []RouteDescriptor{ Successes: []ResponseDescriptor{ { Description: "The manifest has been accepted by the registry and is stored under the specified `name` and `tag`.", - StatusCode: http.StatusAccepted, + StatusCode: http.StatusCreated, Headers: []ParameterDescriptor{ { Name: "Location", diff --git a/components/engine/vendor/src/github.com/docker/distribution/uuid/uuid.go b/components/engine/vendor/src/github.com/docker/distribution/uuid/uuid.go index 4bdd9700aa..d433ccaf51 100644 --- a/components/engine/vendor/src/github.com/docker/distribution/uuid/uuid.go +++ b/components/engine/vendor/src/github.com/docker/distribution/uuid/uuid.go @@ -8,7 +8,6 @@ import ( "crypto/rand" "fmt" "io" - "log" "os" "syscall" "time" @@ -30,7 +29,7 @@ var ( // Loggerf can be used to override the default logging destination. Such // log messages in this library should be logged at warning or higher. - Loggerf = log.Printf + Loggerf = func(format string, args ...interface{}) {} ) // UUID represents a UUID value. UUIDs can be compared and set to other values @@ -49,6 +48,7 @@ func Generate() (u UUID) { var ( totalBackoff time.Duration + count int retries int ) @@ -60,9 +60,10 @@ func Generate() (u UUID) { time.Sleep(b) totalBackoff += b - _, err := io.ReadFull(rand.Reader, u[:]) + n, err := io.ReadFull(rand.Reader, u[count:]) if err != nil { if retryOnError(err) && retries < maxretries { + count += n retries++ Loggerf("error generating version 4 uuid, retrying: %v", err) continue