Browse code

Revert #14884

This reverts commit 810d3b2642d4a82dc186d6eff8c2e487ee624bc5.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>

Arnaud Porterie authored on 2015/08/13 10:32:23
Showing 3 changed files
... ...
@@ -29,13 +29,12 @@ func (s *TagStore) NewPusher(endpoint registry.APIEndpoint, localRepo Repository
29 29
 	switch endpoint.Version {
30 30
 	case registry.APIVersion2:
31 31
 		return &v2Pusher{
32
-			TagStore:   s,
33
-			endpoint:   endpoint,
34
-			localRepo:  localRepo,
35
-			repoInfo:   repoInfo,
36
-			config:     imagePushConfig,
37
-			sf:         sf,
38
-			layersSeen: make(map[string]bool),
32
+			TagStore:  s,
33
+			endpoint:  endpoint,
34
+			localRepo: localRepo,
35
+			repoInfo:  repoInfo,
36
+			config:    imagePushConfig,
37
+			sf:        sf,
39 38
 		}, nil
40 39
 	case registry.APIVersion1:
41 40
 		return &v1Pusher{
... ...
@@ -27,11 +27,6 @@ type v2Pusher struct {
27 27
 	config    *ImagePushConfig
28 28
 	sf        *streamformatter.StreamFormatter
29 29
 	repo      distribution.Repository
30
-
31
-	// layersSeen is the set of layers known to exist on the remote side.
32
-	// This avoids redundant queries when pushing multiple tags that
33
-	// involve the same layers.
34
-	layersSeen map[string]bool
35 30
 }
36 31
 
37 32
 func (p *v2Pusher) Push() (fallback bool, err error) {
... ...
@@ -92,6 +87,8 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
92 92
 		return fmt.Errorf("tag does not exist: %s", tag)
93 93
 	}
94 94
 
95
+	layersSeen := make(map[string]bool)
96
+
95 97
 	layer, err := p.graph.Get(layerId)
96 98
 	if err != nil {
97 99
 		return err
... ...
@@ -120,7 +117,7 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
120 120
 			return err
121 121
 		}
122 122
 
123
-		if p.layersSeen[layer.ID] {
123
+		if layersSeen[layer.ID] {
124 124
 			break
125 125
 		}
126 126
 
... ...
@@ -175,7 +172,7 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
175 175
 		m.FSLayers = append(m.FSLayers, manifest.FSLayer{BlobSum: dgst})
176 176
 		m.History = append(m.History, manifest.History{V1Compatibility: string(jsonData)})
177 177
 
178
-		p.layersSeen[layer.ID] = true
178
+		layersSeen[layer.ID] = true
179 179
 	}
180 180
 
181 181
 	logrus.Infof("Signed manifest for %s:%s using daemon's key: %s", p.repo.Name(), tag, p.trustKey.KeyID())
... ...
@@ -60,32 +60,7 @@ func (s *DockerRegistrySuite) TestPushMultipleTags(c *check.C) {
60 60
 
61 61
 	dockerCmd(c, "tag", "busybox", repoTag2)
62 62
 
63
-	out, _ := dockerCmd(c, "push", repoName)
64
-
65
-	// There should be no duplicate hashes in the output
66
-	imageSuccessfullyPushed := ": Image successfully pushed"
67
-	imageAlreadyExists := ": Image already exists"
68
-	imagePushHashes := make(map[string]struct{})
69
-	outputLines := strings.Split(out, "\n")
70
-	for _, outputLine := range outputLines {
71
-		if strings.Contains(outputLine, imageSuccessfullyPushed) {
72
-			hash := strings.TrimSuffix(outputLine, imageSuccessfullyPushed)
73
-			if _, present := imagePushHashes[hash]; present {
74
-				c.Fatalf("Duplicate image push: %s", outputLine)
75
-			}
76
-			imagePushHashes[hash] = struct{}{}
77
-		} else if strings.Contains(outputLine, imageAlreadyExists) {
78
-			hash := strings.TrimSuffix(outputLine, imageAlreadyExists)
79
-			if _, present := imagePushHashes[hash]; present {
80
-				c.Fatalf("Duplicate image push: %s", outputLine)
81
-			}
82
-			imagePushHashes[hash] = struct{}{}
83
-		}
84
-	}
85
-
86
-	if len(imagePushHashes) == 0 {
87
-		c.Fatal(`Expected at least one line containing "Image successfully pushed"`)
88
-	}
63
+	dockerCmd(c, "push", repoName)
89 64
 }
90 65
 
91 66
 func (s *DockerRegistrySuite) TestPushInterrupt(c *check.C) {