Browse code

Vendor docker/distribution to 7dc8d4a26b689bd4892f2f2322dbce0b7119d686

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2015/07/31 10:14:39
Showing 6 changed files
... ...
@@ -36,7 +36,7 @@ clone git github.com/coreos/go-etcd v2.0.0
36 36
 clone git github.com/hashicorp/consul v0.5.2
37 37
 
38 38
 # get graph and distribution packages
39
-clone git github.com/docker/distribution e83345626608aa943d5c8a027fddcf54814d9545
39
+clone git github.com/docker/distribution 7dc8d4a26b689bd4892f2f2322dbce0b7119d686
40 40
 clone git github.com/vbatts/tar-split v0.9.4
41 41
 
42 42
 clone git github.com/docker/notary 77bced079e83d80f40c1f0a544b1a8a3b97fb052
... ...
@@ -10,6 +10,7 @@ ENV DOCKER_BUILDTAGS include_rados
10 10
 
11 11
 WORKDIR $DISTRIBUTION_DIR
12 12
 COPY . $DISTRIBUTION_DIR
13
+COPY cmd/registry/config-dev.yml $DISTRIBUTION_DIR/cmd/registry/config.yml
13 14
 RUN make PREFIX=/go clean binaries
14 15
 
15 16
 VOLUME ["/var/lib/registry"]
... ...
@@ -1,6 +1,8 @@
1 1
 package context
2 2
 
3 3
 import (
4
+	"sync"
5
+
4 6
 	"github.com/docker/distribution/uuid"
5 7
 	"golang.org/x/net/context"
6 8
 )
... ...
@@ -14,11 +16,19 @@ type Context interface {
14 14
 // provided as the main background context.
15 15
 type instanceContext struct {
16 16
 	Context
17
-	id string // id of context, logged as "instance.id"
17
+	id   string    // id of context, logged as "instance.id"
18
+	once sync.Once // once protect generation of the id
18 19
 }
19 20
 
20 21
 func (ic *instanceContext) Value(key interface{}) interface{} {
21 22
 	if key == "instance.id" {
23
+		ic.once.Do(func() {
24
+			// We want to lazy initialize the UUID such that we don't
25
+			// call a random generator from the package initialization
26
+			// code. For various reasons random could not be available
27
+			// https://github.com/docker/distribution/issues/782
28
+			ic.id = uuid.Generate().String()
29
+		})
22 30
 		return ic.id
23 31
 	}
24 32
 
... ...
@@ -27,7 +37,6 @@ func (ic *instanceContext) Value(key interface{}) interface{} {
27 27
 
28 28
 var background = &instanceContext{
29 29
 	Context: context.Background(),
30
-	id:      uuid.Generate().String(),
31 30
 }
32 31
 
33 32
 // Background returns a non-nil, empty Context. The background context
... ...
@@ -3,8 +3,6 @@ package context
3 3
 import (
4 4
 	"fmt"
5 5
 
6
-	"github.com/docker/distribution/uuid"
7
-
8 6
 	"github.com/Sirupsen/logrus"
9 7
 )
10 8
 
... ...
@@ -101,8 +99,3 @@ func getLogrusLogger(ctx Context, keys ...interface{}) *logrus.Entry {
101 101
 
102 102
 	return logger.WithFields(fields)
103 103
 }
104
-
105
-func init() {
106
-	// inject a logger into the uuid library.
107
-	uuid.Loggerf = GetLogger(Background()).Warnf
108
-}
... ...
@@ -607,7 +607,7 @@ var routeDescriptors = []RouteDescriptor{
607 607
 						Successes: []ResponseDescriptor{
608 608
 							{
609 609
 								Description: "The manifest has been accepted by the registry and is stored under the specified `name` and `tag`.",
610
-								StatusCode:  http.StatusAccepted,
610
+								StatusCode:  http.StatusCreated,
611 611
 								Headers: []ParameterDescriptor{
612 612
 									{
613 613
 										Name:        "Location",
... ...
@@ -8,7 +8,6 @@ import (
8 8
 	"crypto/rand"
9 9
 	"fmt"
10 10
 	"io"
11
-	"log"
12 11
 	"os"
13 12
 	"syscall"
14 13
 	"time"
... ...
@@ -30,7 +29,7 @@ var (
30 30
 
31 31
 	// Loggerf can be used to override the default logging destination. Such
32 32
 	// log messages in this library should be logged at warning or higher.
33
-	Loggerf = log.Printf
33
+	Loggerf = func(format string, args ...interface{}) {}
34 34
 )
35 35
 
36 36
 // UUID represents a UUID value. UUIDs can be compared and set to other values
... ...
@@ -49,6 +48,7 @@ func Generate() (u UUID) {
49 49
 
50 50
 	var (
51 51
 		totalBackoff time.Duration
52
+		count        int
52 53
 		retries      int
53 54
 	)
54 55
 
... ...
@@ -60,9 +60,10 @@ func Generate() (u UUID) {
60 60
 		time.Sleep(b)
61 61
 		totalBackoff += b
62 62
 
63
-		_, err := io.ReadFull(rand.Reader, u[:])
63
+		n, err := io.ReadFull(rand.Reader, u[count:])
64 64
 		if err != nil {
65 65
 			if retryOnError(err) && retries < maxretries {
66
+				count += n
66 67
 				retries++
67 68
 				Loggerf("error generating version 4 uuid, retrying: %v", err)
68 69
 				continue