1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Windows: Fix regression pulling linux images

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-09-08 16:28:23 -07:00
parent 93e8aff1bc
commit 8437d0a329
2 changed files with 39 additions and 9 deletions

View file

@ -550,15 +550,36 @@ func (p *v2Puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *s
) )
// https://github.com/docker/docker/issues/24766 - Err on the side of caution, // https://github.com/docker/docker/issues/24766 - Err on the side of caution,
// explicitly blocking images intended for linux from the Windows daemon // explicitly blocking images intended for linux from the Windows daemon. On
if runtime.GOOS == "windows" && unmarshalledConfig.OS == "linux" { // Windows, we do this before the attempt to download, effectively serialising
// the download slightly slowing it down. We have to do it this way, as
// chances are the download of layers itself would fail due to file names
// which aren't suitable for NTFS. At some point in the future, if a similar
// check to block Windows images being pulled on Linux is implemented, it
// may be necessary to perform the same type of serialisation.
if runtime.GOOS == "windows" {
configJSON, unmarshalledConfig, err = receiveConfig(configChan, errChan)
if err != nil {
return "", "", err
}
if unmarshalledConfig.RootFS == nil {
return "", "", errRootFSInvalid
}
if unmarshalledConfig.OS == "linux" {
return "", "", fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS) return "", "", fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS)
} }
}
downloadRootFS = *image.NewRootFS() downloadRootFS = *image.NewRootFS()
rootFS, release, err := p.config.DownloadManager.Download(ctx, downloadRootFS, descriptors, p.config.ProgressOutput) rootFS, release, err := p.config.DownloadManager.Download(ctx, downloadRootFS, descriptors, p.config.ProgressOutput)
if err != nil { if err != nil {
if configJSON != nil {
// Already received the config
return "", "", err
}
select { select {
case err = <-errChan: case err = <-errChan:
return "", "", err return "", "", err
@ -573,6 +594,7 @@ func (p *v2Puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *s
} }
defer release() defer release()
if configJSON == nil {
configJSON, unmarshalledConfig, err = receiveConfig(configChan, errChan) configJSON, unmarshalledConfig, err = receiveConfig(configChan, errChan)
if err != nil { if err != nil {
return "", "", err return "", "", err
@ -581,6 +603,7 @@ func (p *v2Puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *s
if unmarshalledConfig.RootFS == nil { if unmarshalledConfig.RootFS == nil {
return "", "", errRootFSInvalid return "", "", errRootFSInvalid
} }
}
// The DiffIDs returned in rootFS MUST match those in the config. // The DiffIDs returned in rootFS MUST match those in the config.
// Otherwise the image config could be referencing layers that aren't // Otherwise the image config could be referencing layers that aren't

View file

@ -272,3 +272,10 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullNoCredentialsNotFound(c *check
c.Assert(err, check.NotNil, check.Commentf(out)) c.Assert(err, check.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "Error: image busybox:latest not found") c.Assert(out, checker.Contains, "Error: image busybox:latest not found")
} }
// Regression test for https://github.com/docker/docker/issues/26429
func (s *DockerSuite) TestPullLinuxImageFailsOnWindows(c *check.C) {
testRequires(c, DaemonIsWindows, Network)
_, _, err := dockerCmdWithError("pull", "ubuntu")
c.Assert(err.Error(), checker.Contains, "cannot be used on this platform")
}