diff options
author | John Howard <jhoward@microsoft.com> | 2017-08-24 11:48:16 -0700 |
---|---|---|
committer | John Howard <jhoward@microsoft.com> | 2018-01-18 08:29:19 -0800 |
commit | ce8e529e182bde057cdfafded62c210b7293b8ba (patch) | |
tree | 0d0ac1a44ad2ae13b763afbd42d1b066fd2781e1 /layer/migration.go | |
parent | 6feae060033544985e548dcf1b9127f8f634fe2b (diff) | |
download | docker-ce8e529e182bde057cdfafded62c210b7293b8ba.tar.gz |
LCOW: Re-coalesce stores
Signed-off-by: John Howard <jhoward@microsoft.com>
The re-coalesces the daemon stores which were split as part of the
original LCOW implementation.
This is part of the work discussed in https://github.com/moby/moby/issues/34617,
in particular see the document linked to in that issue.
Diffstat (limited to 'layer/migration.go')
-rw-r--r-- | layer/migration.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/layer/migration.go b/layer/migration.go index 9c0c2c94ed..f42cfa9af0 100644 --- a/layer/migration.go +++ b/layer/migration.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "runtime" "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" @@ -16,7 +17,7 @@ import ( // CreateRWLayerByGraphID creates a RWLayer in the layer store using // the provided name with the given graphID. To get the RWLayer // after migration the layer may be retrieved by the given name. -func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent ChainID) (err error) { +func (ls *layerStore) CreateRWLayerByGraphID(name, graphID, os string, parent ChainID) (err error) { ls.mountL.Lock() defer ls.mountL.Unlock() m, ok := ls.mounts[name] @@ -31,7 +32,11 @@ func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent return nil } - if !ls.driver.Exists(graphID) { + // Ensure the operating system is set to the host OS if not populated. + if os == "" { + os = runtime.GOOS + } + if !ls.drivers[os].Exists(graphID) { return fmt.Errorf("graph ID does not exist: %q", graphID) } @@ -60,11 +65,12 @@ func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent mountID: graphID, layerStore: ls, references: map[RWLayer]*referencedRWLayer{}, + os: os, } // Check for existing init layer initID := fmt.Sprintf("%s-init", graphID) - if ls.driver.Exists(initID) { + if ls.drivers[os].Exists(initID) { m.initID = initID } @@ -95,7 +101,10 @@ func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataP } dgst := digest.Canonical.Digester() - err = ls.assembleTarTo(id, uncompressed, &size, dgst.Hash()) + // Note - we use the host OS here. This is a safe assumption as its during migration, and + // no host OS which supports migration also supports multiple image OS's. In other words, + // it's only on Linux, not on Windows. + err = ls.assembleTarTo(id, runtime.GOOS, uncompressed, &size, dgst.Hash()) if err != nil { return } @@ -111,7 +120,10 @@ func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataP } func (ls *layerStore) checksumForGraphIDNoTarsplit(id, parent, newTarDataPath string) (diffID DiffID, size int64, err error) { - rawarchive, err := ls.driver.Diff(id, parent) + // Note - we use the host OS here. This is a safe assumption as its during migration, and + // no host OS which supports migration also supports multiple image OS's. In other words, + // it's only on Linux, not on Windows. + rawarchive, err := ls.drivers[runtime.GOOS].Diff(id, parent) if err != nil { return } |