Browse code

LCOW: Spot fix for multi-os image pulling

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2017/09/13 11:28:21
Showing 2 changed files
... ...
@@ -709,11 +709,16 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf
709 709
 
710 710
 	logrus.Debugf("%s resolved to a manifestList object with %d entries; looking for a os/arch match", ref, len(mfstList.Manifests))
711 711
 	var manifestDigest digest.Digest
712
+	// TODO @jhowardmsft LCOW Support: Need to remove the hard coding in LCOW mode.
713
+	lookingForOS := runtime.GOOS
714
+	if system.LCOWSupported() {
715
+		lookingForOS = "linux"
716
+	}
712 717
 	for _, manifestDescriptor := range mfstList.Manifests {
713 718
 		// TODO(aaronl): The manifest list spec supports optional
714 719
 		// "features" and "variant" fields. These are not yet used.
715 720
 		// Once they are, their values should be interpreted here.
716
-		if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == runtime.GOOS {
721
+		if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == lookingForOS {
717 722
 			manifestDigest = manifestDescriptor.Digest
718 723
 			logrus.Debugf("found match for %s/%s with media type %s, digest %s", runtime.GOOS, runtime.GOARCH, manifestDescriptor.MediaType, manifestDigest.String())
719 724
 			break
... ...
@@ -3,6 +3,7 @@ package main
3 3
 import (
4 4
 	"fmt"
5 5
 	"regexp"
6
+	"runtime"
6 7
 	"strings"
7 8
 	"sync"
8 9
 	"time"
... ...
@@ -211,7 +212,12 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
211 211
 			break
212 212
 		}
213 213
 	}
214
-	c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags"))
214
+
215
+	if runtime.GOARCH == "amd64" {
216
+		c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags"))
217
+	} else {
218
+		c.Assert(latestLine, checker.Not(checker.Contains), "", check.Commentf("no matching manifest"))
219
+	}
215 220
 	splitLatest := strings.Fields(latestLine)
216 221
 	splitCurrent := strings.Fields(splitOutImageCmd[1])
217 222
 
... ...
@@ -273,7 +279,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullNoCredentialsNotFound(c *check
273 273
 func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
274 274
 	testRequires(c, DaemonIsWindows, Network)
275 275
 	_, _, err := dockerCmdWithError("pull", "ubuntu")
276
-	c.Assert(err.Error(), checker.Contains, "cannot be used on this platform")
276
+	c.Assert(err.Error(), checker.Contains, "no matching manifest")
277 277
 }
278 278
 
279 279
 // Regression test for https://github.com/docker/docker/issues/28892