layer: remove OS from layerstore

This was added in commits fc21bf280b and
0380fbff37 in support of LCOW, but was
now always set to runtime.GOOS.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-01-25 14:16:43 +01:00
parent da277f891a
commit b36d896fce
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
6 changed files with 10 additions and 19 deletions

View file

@ -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

View file

@ -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,

View file

@ -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{

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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) {