Browse Source

LCOW: Spot fix for multi-os image pulling

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 7 years ago
parent
commit
b291f5a317
2 changed files with 14 additions and 3 deletions
  1. 6 1
      distribution/pull_v2.go
  2. 8 2
      integration-cli/docker_cli_pull_test.go

+ 6 - 1
distribution/pull_v2.go

@@ -709,11 +709,16 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf
 
 
 	logrus.Debugf("%s resolved to a manifestList object with %d entries; looking for a os/arch match", ref, len(mfstList.Manifests))
 	logrus.Debugf("%s resolved to a manifestList object with %d entries; looking for a os/arch match", ref, len(mfstList.Manifests))
 	var manifestDigest digest.Digest
 	var manifestDigest digest.Digest
+	// TODO @jhowardmsft LCOW Support: Need to remove the hard coding in LCOW mode.
+	lookingForOS := runtime.GOOS
+	if system.LCOWSupported() {
+		lookingForOS = "linux"
+	}
 	for _, manifestDescriptor := range mfstList.Manifests {
 	for _, manifestDescriptor := range mfstList.Manifests {
 		// TODO(aaronl): The manifest list spec supports optional
 		// TODO(aaronl): The manifest list spec supports optional
 		// "features" and "variant" fields. These are not yet used.
 		// "features" and "variant" fields. These are not yet used.
 		// Once they are, their values should be interpreted here.
 		// Once they are, their values should be interpreted here.
-		if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == runtime.GOOS {
+		if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == lookingForOS {
 			manifestDigest = manifestDescriptor.Digest
 			manifestDigest = manifestDescriptor.Digest
 			logrus.Debugf("found match for %s/%s with media type %s, digest %s", runtime.GOOS, runtime.GOARCH, manifestDescriptor.MediaType, manifestDigest.String())
 			logrus.Debugf("found match for %s/%s with media type %s, digest %s", runtime.GOOS, runtime.GOARCH, manifestDescriptor.MediaType, manifestDigest.String())
 			break
 			break

+ 8 - 2
integration-cli/docker_cli_pull_test.go

@@ -3,6 +3,7 @@ package main
 import (
 import (
 	"fmt"
 	"fmt"
 	"regexp"
 	"regexp"
+	"runtime"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
 	"time"
 	"time"
@@ -211,7 +212,12 @@ func (s *DockerHubPullSuite) TestPullAllTagsFromCentralRegistry(c *check.C) {
 			break
 			break
 		}
 		}
 	}
 	}
-	c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags"))
+
+	if runtime.GOARCH == "amd64" {
+		c.Assert(latestLine, checker.Not(checker.Equals), "", check.Commentf("no entry for busybox:latest found after pulling all tags"))
+	} else {
+		c.Assert(latestLine, checker.Not(checker.Contains), "", check.Commentf("no matching manifest"))
+	}
 	splitLatest := strings.Fields(latestLine)
 	splitLatest := strings.Fields(latestLine)
 	splitCurrent := strings.Fields(splitOutImageCmd[1])
 	splitCurrent := strings.Fields(splitOutImageCmd[1])
 
 
@@ -273,7 +279,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullNoCredentialsNotFound(c *check
 func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
 func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
 	testRequires(c, DaemonIsWindows, Network)
 	testRequires(c, DaemonIsWindows, Network)
 	_, _, err := dockerCmdWithError("pull", "ubuntu")
 	_, _, err := dockerCmdWithError("pull", "ubuntu")
-	c.Assert(err.Error(), checker.Contains, "cannot be used on this platform")
+	c.Assert(err.Error(), checker.Contains, "no matching manifest")
 }
 }
 
 
 // Regression test for https://github.com/docker/docker/issues/28892
 // Regression test for https://github.com/docker/docker/issues/28892