aboutsummaryrefslogtreecommitdiff
path: root/distribution
diff options
context:
space:
mode:
authorAkihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>2022-01-26 14:08:44 +0900
committerGitHub <noreply@github.com>2022-01-26 14:08:44 +0900
commit65b8bcc3216ec64c8f761f35c6caba109b788254 (patch)
treedd65dede30e8143bdf240f3cfd04d5322c16c081 /distribution
parent559ff0ac661c1ca27bb17765629f6166d90ff499 (diff)
parentbb66ebd62120efea46a8f012db2320531852cb5d (diff)
Merge pull request #43174 from thaJeztah/move_platformcheck
distribution: remove RootFSDownloadManager interface, and remove "os" argument from Download()
Diffstat (limited to 'distribution')
-rw-r--r--distribution/config.go11
-rw-r--r--distribution/pull_v2.go10
-rw-r--r--distribution/xfer/download.go14
-rw-r--r--distribution/xfer/download_test.go6
4 files changed, 13 insertions, 28 deletions
diff --git a/distribution/config.go b/distribution/config.go
index 48b0b46e26..220697f060 100644
--- a/distribution/config.go
+++ b/distribution/config.go
@@ -56,7 +56,7 @@ type ImagePullConfig struct {
Config
// DownloadManager manages concurrent pulls.
- DownloadManager RootFSDownloadManager
+ DownloadManager *xfer.LayerDownloadManager
// Schema2Types is the valid schema2 configuration types allowed
// by the pull operation.
Schema2Types []string
@@ -107,15 +107,6 @@ type PushLayer interface {
Release()
}
-// RootFSDownloadManager handles downloading of the rootfs
-type RootFSDownloadManager interface {
- // Download downloads the layers into the given initial rootfs and
- // returns the final rootfs.
- // Given progress output to track download progress
- // Returns function to release download resources
- Download(ctx context.Context, initialRootFS image.RootFS, os string, layers []xfer.DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error)
-}
-
type imageConfigStore struct {
image.Store
}
diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go
index 296f47372b..07cc1e5b86 100644
--- a/distribution/pull_v2.go
+++ b/distribution/pull_v2.go
@@ -547,7 +547,7 @@ func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Reference, unv
descriptors = append(descriptors, layerDescriptor)
}
- resultRootFS, release, err := p.config.DownloadManager.Download(ctx, *rootFS, runtime.GOOS, descriptors, p.config.ProgressOutput)
+ resultRootFS, release, err := p.config.DownloadManager.Download(ctx, *rootFS, descriptors, p.config.ProgressOutput)
if err != nil {
return "", "", err
}
@@ -665,6 +665,12 @@ func (p *v2Puller) pullSchema2Layers(ctx context.Context, target distribution.De
}
}
+ // Assume that the operating system is the host OS if blank, and validate it
+ // to ensure we don't cause a panic by an invalid index into the layerstores.
+ if layerStoreOS != "" && !system.IsOSSupported(layerStoreOS) {
+ return "", system.ErrNotSupportedOperatingSystem
+ }
+
if p.config.DownloadManager != nil {
go func() {
var (
@@ -672,7 +678,7 @@ func (p *v2Puller) pullSchema2Layers(ctx context.Context, target distribution.De
rootFS image.RootFS
)
downloadRootFS := *image.NewRootFS()
- rootFS, release, err = p.config.DownloadManager.Download(ctx, downloadRootFS, layerStoreOS, descriptors, p.config.ProgressOutput)
+ rootFS, release, err = p.config.DownloadManager.Download(ctx, downloadRootFS, descriptors, p.config.ProgressOutput)
if err != nil {
// Intentionally do not cancel the config download here
// as the error from config download (if there is one)
diff --git a/distribution/xfer/download.go b/distribution/xfer/download.go
index 847152d081..6eddfac0dd 100644
--- a/distribution/xfer/download.go
+++ b/distribution/xfer/download.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
- "runtime"
"time"
"github.com/docker/distribution"
@@ -14,7 +13,6 @@ import (
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/progress"
- "github.com/docker/docker/pkg/system"
"github.com/sirupsen/logrus"
)
@@ -106,7 +104,7 @@ type DownloadDescriptorWithRegistered interface {
// Download method is called to get the layer tar data. Layers are then
// registered in the appropriate order. The caller must call the returned
// release function once it is done with the returned RootFS object.
-func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, os string, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error) {
+func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS image.RootFS, layers []DownloadDescriptor, progressOutput progress.Output) (image.RootFS, func(), error) {
var (
topLayer layer.Layer
topDownload *downloadTransfer
@@ -116,16 +114,6 @@ func (ldm *LayerDownloadManager) Download(ctx context.Context, initialRootFS ima
downloadsByKey = make(map[string]*downloadTransfer)
)
- // Assume that the operating system is the host OS if blank, and validate it
- // to ensure we don't cause a panic by an invalid index into the layerstores.
- // TODO remove now that LCOW is no longer a thing
- if os == "" {
- os = runtime.GOOS
- }
- if !system.IsOSSupported(os) {
- return image.RootFS{}, nil, system.ErrNotSupportedOperatingSystem
- }
-
rootFS := initialRootFS
for _, descriptor := range layers {
key := descriptor.Key()
diff --git a/distribution/xfer/download_test.go b/distribution/xfer/download_test.go
index 9e51c6306f..0913d49510 100644
--- a/distribution/xfer/download_test.go
+++ b/distribution/xfer/download_test.go
@@ -293,7 +293,7 @@ func TestSuccessfulDownload(t *testing.T) {
}
firstDescriptor.diffID = l.DiffID()
- rootFS, releaseFunc, err := ldm.Download(context.Background(), *image.NewRootFS(), runtime.GOOS, descriptors, progress.ChanOutput(progressChan))
+ rootFS, releaseFunc, err := ldm.Download(context.Background(), *image.NewRootFS(), descriptors, progress.ChanOutput(progressChan))
if err != nil {
t.Fatalf("download error: %v", err)
}
@@ -348,7 +348,7 @@ func TestCancelledDownload(t *testing.T) {
}()
descriptors := downloadDescriptors(nil)
- _, _, err := ldm.Download(ctx, *image.NewRootFS(), runtime.GOOS, descriptors, progress.ChanOutput(progressChan))
+ _, _, err := ldm.Download(ctx, *image.NewRootFS(), descriptors, progress.ChanOutput(progressChan))
if err != context.Canceled {
close(progressChan)
t.Fatal("expected download to be cancelled")
@@ -413,7 +413,7 @@ func TestMaxDownloadAttempts(t *testing.T) {
descriptors := downloadDescriptors(&currentDownloads)
descriptors[4].(*mockDownloadDescriptor).simulateRetries = tc.simulateRetries
- _, _, err := ldm.Download(context.Background(), *image.NewRootFS(), runtime.GOOS, descriptors, progress.ChanOutput(progressChan))
+ _, _, err := ldm.Download(context.Background(), *image.NewRootFS(), descriptors, progress.ChanOutput(progressChan))
if tc.expectedErr == "" {
assert.NilError(t, err)
} else {