Parse storage-opt in GraphDriver init on Windows
This ensures the storage-opts applies to all operations by the graph drivers, replacing the merging of storage-opts into container storage config at container-creation time, and hence applying storage-opts to non-container operations like `COPY` and `ADD` in the builder. Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
parent
56d378a88f
commit
db7b7f6df9
|
@ -187,23 +187,6 @@ func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr
|
||||||
|
|
||||||
ctr.HostConfig.StorageOpt = opts.params.HostConfig.StorageOpt
|
ctr.HostConfig.StorageOpt = opts.params.HostConfig.StorageOpt
|
||||||
|
|
||||||
// Fixes: https://github.com/moby/moby/issues/34074 and
|
|
||||||
// https://github.com/docker/for-win/issues/999.
|
|
||||||
// Merge the daemon's storage options if they aren't already present. We only
|
|
||||||
// do this on Windows as there's no effective sandbox size limit other than
|
|
||||||
// physical on Linux.
|
|
||||||
if isWindows {
|
|
||||||
if ctr.HostConfig.StorageOpt == nil {
|
|
||||||
ctr.HostConfig.StorageOpt = make(map[string]string)
|
|
||||||
}
|
|
||||||
for _, v := range daemon.configStore.GraphOptions {
|
|
||||||
opt := strings.SplitN(v, "=", 2)
|
|
||||||
if _, ok := ctr.HostConfig.StorageOpt[opt[0]]; !ok {
|
|
||||||
ctr.HostConfig.StorageOpt[opt[0]] = opt[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set RWLayer for container after mount labels have been set
|
// Set RWLayer for container after mount labels have been set
|
||||||
rwLayer, err := daemon.imageService.CreateLayer(ctr, setupInitLayer(daemon.idMapping))
|
rwLayer, err := daemon.imageService.CreateLayer(ctr, setupInitLayer(daemon.idMapping))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -124,6 +124,7 @@ type Driver struct {
|
||||||
cachedScratchMutex sync.Mutex // Protects race conditions from multiple threads creating the cached scratch.
|
cachedScratchMutex sync.Mutex // Protects race conditions from multiple threads creating the cached scratch.
|
||||||
options []string // Graphdriver options we are initialised with.
|
options []string // Graphdriver options we are initialised with.
|
||||||
globalMode bool // Indicates if running in an unsafe/global service VM mode.
|
globalMode bool // Indicates if running in an unsafe/global service VM mode.
|
||||||
|
defaultSandboxSize uint64 // The default sandbox size to use if one is not specified
|
||||||
|
|
||||||
// NOTE: It is OK to use a cache here because Windows does not support
|
// NOTE: It is OK to use a cache here because Windows does not support
|
||||||
// restoring containers when the daemon dies.
|
// restoring containers when the daemon dies.
|
||||||
|
@ -163,7 +164,8 @@ func InitDriver(dataRoot string, options []string, _, _ []idtools.IDMap) (graphd
|
||||||
serviceVms: &serviceVMMap{
|
serviceVms: &serviceVMMap{
|
||||||
svms: make(map[string]*serviceVMMapItem),
|
svms: make(map[string]*serviceVMMapItem),
|
||||||
},
|
},
|
||||||
globalMode: false,
|
globalMode: false,
|
||||||
|
defaultSandboxSize: client.DefaultVhdxSizeGB,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looks for relevant options
|
// Looks for relevant options
|
||||||
|
@ -178,6 +180,16 @@ func InitDriver(dataRoot string, options []string, _, _ []idtools.IDMap) (graphd
|
||||||
return nil, fmt.Errorf("%s failed to parse value for 'lcow.globalmode' - must be 'true' or 'false'", title)
|
return nil, fmt.Errorf("%s failed to parse value for 'lcow.globalmode' - must be 'true' or 'false'", title)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case "lcow.sandboxsize":
|
||||||
|
var err error
|
||||||
|
d.defaultSandboxSize, err = strconv.ParseUint(opt[1], 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s failed to parse value '%s' for 'lcow.sandboxsize'", title, v)
|
||||||
|
}
|
||||||
|
if d.defaultSandboxSize < client.DefaultVhdxSizeGB {
|
||||||
|
return nil, fmt.Errorf("%s 'lcow.sandboxsize' option cannot be less than %d", title, client.DefaultVhdxSizeGB)
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,7 +529,7 @@ func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for an explicit sandbox size option.
|
// Look for an explicit sandbox size option.
|
||||||
sandboxSize := uint64(client.DefaultVhdxSizeGB)
|
sandboxSize := d.defaultSandboxSize
|
||||||
for k, v := range opts.StorageOpt {
|
for k, v := range opts.StorageOpt {
|
||||||
switch strings.ToLower(k) {
|
switch strings.ToLower(k) {
|
||||||
case "lcow.sandboxsize":
|
case "lcow.sandboxsize":
|
||||||
|
|
|
@ -112,9 +112,17 @@ func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap)
|
||||||
return nil, fmt.Errorf("windowsfilter failed to create '%s': %v", home, err)
|
return nil, fmt.Errorf("windowsfilter failed to create '%s': %v", home, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
size, err := units.RAMInBytes(defaultSandboxSize)
|
storageOpt := make(map[string]string)
|
||||||
|
storageOpt["size"] = defaultSandboxSize
|
||||||
|
|
||||||
|
for _, v := range options {
|
||||||
|
opt := strings.SplitN(v, "=", 2)
|
||||||
|
storageOpt[strings.ToLower(opt[0])] = opt[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
storageOptions, err := parseStorageOpt(storageOpt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("windowsfilter failed to parse default size '%s': %v", defaultSandboxSize, err)
|
return nil, fmt.Errorf("windowsfilter failed to parse default storage options - %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d := &Driver{
|
d := &Driver{
|
||||||
|
@ -122,11 +130,9 @@ func InitFilter(home string, options []string, uidMaps, gidMaps []idtools.IDMap)
|
||||||
HomeDir: home,
|
HomeDir: home,
|
||||||
Flavour: filterDriver,
|
Flavour: filterDriver,
|
||||||
},
|
},
|
||||||
cache: make(map[string]string),
|
cache: make(map[string]string),
|
||||||
ctr: graphdriver.NewRefCounter(&checker{}),
|
ctr: graphdriver.NewRefCounter(&checker{}),
|
||||||
defaultStorageOpts: &storageOptions{
|
defaultStorageOpts: storageOptions,
|
||||||
size: uint64(size),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return d, nil
|
return d, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue