Skip to content

Commit b36d896

Browse files
committed
layer: remove OS from layerstore
This was added in commits fc21bf2 and 0380fbf in support of LCOW, but was now always set to runtime.GOOS. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent da277f8 commit b36d896

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

daemon/daemon.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
948948
IDMapping: idMapping,
949949
PluginGetter: d.PluginStore,
950950
ExperimentalEnabled: config.Experimental,
951-
OS: runtime.GOOS,
952951
})
953952
if err != nil {
954953
return nil, err

integration/image/remove_unix_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"io"
99
"os"
1010
"path/filepath"
11-
"runtime"
1211
"strconv"
1312
"strings"
1413
"syscall"
@@ -53,7 +52,6 @@ func TestRemoveImageGarbageCollector(t *testing.T) {
5352
IDMapping: &idtools.IdentityMapping{},
5453
PluginGetter: nil,
5554
ExperimentalEnabled: false,
56-
OS: runtime.GOOS,
5755
})
5856
i := images.NewImageService(images.ImageServiceConfig{
5957
LayerStore: layerStore,

layer/layer_store.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ type layerStore struct {
4141

4242
// protect *RWLayer() methods from operating on the same name/id
4343
locker *locker.Locker
44-
45-
os string
4644
}
4745

4846
// StoreOptions are the options used to create a new Store instance
@@ -54,7 +52,6 @@ type StoreOptions struct {
5452
IDMapping *idtools.IdentityMapping
5553
PluginGetter plugingetter.PluginGetter
5654
ExperimentalEnabled bool
57-
OS string
5855
}
5956

6057
// NewStoreFromOptions creates a new Store instance
@@ -73,16 +70,13 @@ func NewStoreFromOptions(options StoreOptions) (Store, error) {
7370

7471
root := fmt.Sprintf(options.MetadataStorePathTemplate, driver)
7572

76-
return newStoreFromGraphDriver(root, driver, options.OS)
73+
return newStoreFromGraphDriver(root, driver)
7774
}
7875

7976
// newStoreFromGraphDriver creates a new Store instance using the provided
8077
// metadata store and graph driver. The metadata store will be used to restore
8178
// the Store.
82-
func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string) (Store, error) {
83-
if !system.IsOSSupported(os) {
84-
return nil, fmt.Errorf("failed to initialize layer store as operating system '%s' is not supported", os)
85-
}
79+
func newStoreFromGraphDriver(root string, driver graphdriver.Driver) (Store, error) {
8680
caps := graphdriver.Capabilities{}
8781
if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok {
8882
caps = capDriver.Capabilities()
@@ -100,7 +94,6 @@ func newStoreFromGraphDriver(root string, driver graphdriver.Driver, os string)
10094
mounts: map[string]*mountedLayer{},
10195
locker: locker.New(),
10296
useTarSplit: !caps.ReproducesExactDiffs,
103-
os: os,
10497
}
10598

10699
ids, mounts, err := ms.List()
@@ -168,8 +161,8 @@ func (ls *layerStore) loadLayer(layer ChainID) (*roLayer, error) {
168161
return nil, fmt.Errorf("failed to get operating system for %s: %s", layer, err)
169162
}
170163

171-
if os != ls.os {
172-
return nil, fmt.Errorf("failed to load layer with os %s into layerstore for %s", os, ls.os)
164+
if !system.IsOSSupported(os) {
165+
return nil, fmt.Errorf("failed to load layer with os %s into layerstore: %w", os, system.ErrNotSupportedOperatingSystem)
173166
}
174167

175168
cl = &roLayer{

layer/layer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func newTestStore(t *testing.T) (Store, string, func()) {
6969

7070
graph, graphcleanup := newTestGraphDriver(t)
7171

72-
ls, err := newStoreFromGraphDriver(td, graph, runtime.GOOS)
72+
ls, err := newStoreFromGraphDriver(td, graph)
7373
if err != nil {
7474
t.Fatal(err)
7575
}
@@ -395,7 +395,7 @@ func TestStoreRestore(t *testing.T) {
395395
t.Fatal(err)
396396
}
397397

398-
ls2, err := newStoreFromGraphDriver(ls.(*layerStore).store.root, ls.(*layerStore).driver, runtime.GOOS)
398+
ls2, err := newStoreFromGraphDriver(ls.(*layerStore).store.root, ls.(*layerStore).driver)
399399
if err != nil {
400400
t.Fatal(err)
401401
}

layer/migration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestLayerMigration(t *testing.T) {
8888
}
8989

9090
root := filepath.Join(td, "layers")
91-
ls, err := newStoreFromGraphDriver(root, graph, runtime.GOOS)
91+
ls, err := newStoreFromGraphDriver(root, graph)
9292
if err != nil {
9393
t.Fatal(err)
9494
}
@@ -213,7 +213,7 @@ func TestLayerMigrationNoTarsplit(t *testing.T) {
213213
}
214214

215215
root := filepath.Join(td, "layers")
216-
ls, err := newStoreFromGraphDriver(root, graph, runtime.GOOS)
216+
ls, err := newStoreFromGraphDriver(root, graph)
217217
if err != nil {
218218
t.Fatal(err)
219219
}

layer/ro_layer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package layer // import "github.com/docker/docker/layer"
33
import (
44
"fmt"
55
"io"
6+
"runtime"
67

78
"github.com/docker/distribution"
89
digest "github.com/opencontainers/go-digest"
@@ -146,7 +147,7 @@ func storeLayer(tx *fileMetadataTransaction, layer *roLayer) error {
146147
return err
147148
}
148149
}
149-
return tx.setOS(layer.layerStore.os)
150+
return tx.setOS(runtime.GOOS)
150151
}
151152

152153
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {

0 commit comments

Comments
 (0)