diff --git a/daemon/daemon.go b/daemon/daemon.go index fce36eef82..7c47d9059c 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -948,7 +948,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S IDMapping: idMapping, PluginGetter: d.PluginStore, ExperimentalEnabled: config.Experimental, - OS: runtime.GOOS, }) if err != nil { return nil, err diff --git a/integration/image/remove_unix_test.go b/integration/image/remove_unix_test.go index 65fffe2c29..ed24e276ff 100644 --- a/integration/image/remove_unix_test.go +++ b/integration/image/remove_unix_test.go @@ -8,7 +8,6 @@ import ( "io" "os" "path/filepath" - "runtime" "strconv" "strings" "syscall" @@ -53,7 +52,6 @@ func TestRemoveImageGarbageCollector(t *testing.T) { IDMapping: &idtools.IdentityMapping{}, PluginGetter: nil, ExperimentalEnabled: false, - OS: runtime.GOOS, }) i := images.NewImageService(images.ImageServiceConfig{ LayerStore: layerStore, diff --git a/layer/layer_store.go b/layer/layer_store.go index 5520899b8d..6f9e0c2fa1 100644 --- a/layer/layer_store.go +++ b/layer/layer_store.go @@ -41,8 +41,6 @@ type layerStore struct { // protect *RWLayer() methods from operating on the same name/id locker *locker.Locker - - os string } // StoreOptions are the options used to create a new Store instance @@ -54,7 +52,6 @@ type StoreOptions struct { IDMapping *idtools.IdentityMapping PluginGetter plugingetter.PluginGetter ExperimentalEnabled bool - OS string } // NewStoreFromOptions creates a new Store instance @@ -73,16 +70,13 @@ func NewStoreFromOptions(options StoreOptions) (Store, error) { root := fmt.Sprintf(options.MetadataStorePathTemplate, driver) - return newStoreFromGraphDriver(root, driver, options.OS) + return newStoreFromGraphDriver(root, driver) } // newStoreFromGraphDriver creates a new Store instance using the provided // metadata store and graph driver. The metadata store will be used to restore // the Store. -func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string) (Store, error) { - if !system.IsOSSupported(os) { - return nil, fmt.Errorf("failed to initialize layer store as operating system '%s' is not supported", os) - } +func newStoreFromGraphDriver(root string, driver graphdriver.Driver) (Store, error) { caps := graphdriver.Capabilities{} if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok { caps = capDriver.Capabilities() @@ -100,7 +94,6 @@ func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string) mounts: map[string]*mountedLayer{}, locker: locker.New(), useTarSplit: !caps.ReproducesExactDiffs, - os: os, } ids, mounts, err := ms.List() @@ -168,8 +161,8 @@ func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) { return nil, fmt.Errorf("failed to get operating system for %s: %s", layer, err) } - if os != ls.os { - return nil, fmt.Errorf("failed to load layer with os %s into layerstore for %s", os, ls.os) + if !system.IsOSSupported(os) { + return nil, fmt.Errorf("failed to load layer with os %s into layerstore: %w", os, system.ErrNotSupportedOperatingSystem) } cl = &roLayer{ diff --git a/layer/layer_test.go b/layer/layer_test.go index 4a4bcfb90e..6f1b626b12 100644 --- a/layer/layer_test.go +++ b/layer/layer_test.go @@ -69,7 +69,7 @@ func newTestStore(t *testing.T) (Store, string, func()) { graph, graphcleanup := newTestGraphDriver(t) - ls, err := newStoreFromGraphDriver(td, graph, runtime.GOOS) + ls, err := newStoreFromGraphDriver(td, graph) if err != nil { t.Fatal(err) } @@ -395,7 +395,7 @@ func TestStoreRestore(t *testing.T) { t.Fatal(err) } - ls2, err := newStoreFromGraphDriver(ls.(*layerStore).store.root, ls.(*layerStore).driver, runtime.GOOS) + ls2, err := newStoreFromGraphDriver(ls.(*layerStore).store.root, ls.(*layerStore).driver) if err != nil { t.Fatal(err) } diff --git a/layer/migration_test.go b/layer/migration_test.go index 374d8cdcdc..de3e15f517 100644 --- a/layer/migration_test.go +++ b/layer/migration_test.go @@ -88,7 +88,7 @@ func TestLayerMigration(t *testing.T) { } root := filepath.Join(td, "layers") - ls, err := newStoreFromGraphDriver(root, graph, runtime.GOOS) + ls, err := newStoreFromGraphDriver(root, graph) if err != nil { t.Fatal(err) } @@ -213,7 +213,7 @@ func TestLayerMigrationNoTarsplit(t *testing.T) { } root := filepath.Join(td, "layers") - ls, err := newStoreFromGraphDriver(root, graph, runtime.GOOS) + ls, err := newStoreFromGraphDriver(root, graph) if err != nil { t.Fatal(err) } diff --git a/layer/ro_layer.go b/layer/ro_layer.go index 15841d5bd2..47e3505d34 100644 --- a/layer/ro_layer.go +++ b/layer/ro_layer.go @@ -3,6 +3,7 @@ package layer // import "github.com/docker/docker/layer" import ( "fmt" "io" + "runtime" "github.com/docker/distribution" digest "github.com/opencontainers/go-digest" @@ -146,7 +147,7 @@ func storeLayer(tx *fileMetadataTransaction, layer *roLayer) error { return err } } - return tx.setOS(layer.layerStore.os) + return tx.setOS(runtime.GOOS) } func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {