mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Added support for storage-opt size
Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
parent
7b2b4eb40c
commit
7e5ee6d176
5 changed files with 44 additions and 10 deletions
|
@ -32,12 +32,19 @@ import (
|
||||||
"github.com/docker/docker/pkg/longpath"
|
"github.com/docker/docker/pkg/longpath"
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
|
"github.com/docker/go-units"
|
||||||
"github.com/vbatts/tar-split/tar/storage"
|
"github.com/vbatts/tar-split/tar/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// filterDriver is an HCSShim driver type for the Windows Filter driver.
|
// filterDriver is an HCSShim driver type for the Windows Filter driver.
|
||||||
const filterDriver = 1
|
const filterDriver = 1
|
||||||
|
|
||||||
|
var (
|
||||||
|
vmcomputedll = syscall.NewLazyDLL("vmcompute.dll")
|
||||||
|
hcsExpandSandboxSize = vmcomputedll.NewProc("ExpandSandboxSize")
|
||||||
|
hcsSandboxSizeSupported = hcsExpandSandboxSize.Find() == nil
|
||||||
|
)
|
||||||
|
|
||||||
// init registers the windows graph drivers to the register.
|
// init registers the windows graph drivers to the register.
|
||||||
func init() {
|
func init() {
|
||||||
graphdriver.Register("windowsfilter", InitFilter)
|
graphdriver.Register("windowsfilter", InitFilter)
|
||||||
|
@ -118,10 +125,6 @@ func (d *Driver) Create(id, parent, mountLabel string, storageOpt map[string]str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt map[string]string) error {
|
func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt map[string]string) error {
|
||||||
if len(storageOpt) != 0 {
|
|
||||||
return fmt.Errorf("--storage-opt is not supported for windows")
|
|
||||||
}
|
|
||||||
|
|
||||||
rPId, err := d.resolveID(parent)
|
rPId, err := d.resolveID(parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -184,6 +187,17 @@ func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt
|
||||||
if err := hcsshim.CreateSandboxLayer(d.info, id, parentPath, layerChain); err != nil {
|
if err := hcsshim.CreateSandboxLayer(d.info, id, parentPath, layerChain); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storageOptions, err := parseStorageOpt(storageOpt)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to parse storage options - %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if hcsSandboxSizeSupported {
|
||||||
|
if err := hcsshim.ExpandSandboxSize(d.info, id, storageOptions.size); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Lstat(d.dir(parent)); err != nil {
|
if _, err := os.Lstat(d.dir(parent)); err != nil {
|
||||||
|
@ -851,3 +865,27 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
|
||||||
|
|
||||||
return &fileGetCloserWithBackupPrivileges{d.dir(id)}, nil
|
return &fileGetCloserWithBackupPrivileges{d.dir(id)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type storageOptions struct {
|
||||||
|
size uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
|
||||||
|
options := storageOptions{}
|
||||||
|
|
||||||
|
// Read size to change the block device size per container.
|
||||||
|
for key, val := range storageOpt {
|
||||||
|
key := strings.ToLower(key)
|
||||||
|
switch key {
|
||||||
|
case "size":
|
||||||
|
size, err := units.RAMInBytes(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
options.size = uint64(size)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("Unknown storage option: %s", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &options, nil
|
||||||
|
}
|
||||||
|
|
|
@ -185,7 +185,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
|
||||||
Storage: &windowsoci.Storage{
|
Storage: &windowsoci.Storage{
|
||||||
Bps: &c.HostConfig.IOMaximumBandwidth,
|
Bps: &c.HostConfig.IOMaximumBandwidth,
|
||||||
Iops: &c.HostConfig.IOMaximumIOps,
|
Iops: &c.HostConfig.IOMaximumIOps,
|
||||||
//TODO SandboxSize: ...,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return (*libcontainerd.Spec)(&s), nil
|
return (*libcontainerd.Spec)(&s), nil
|
||||||
|
|
|
@ -155,7 +155,7 @@ Set storage driver options per container.
|
||||||
|
|
||||||
This (size) will allow to set the container rootfs size to 120G at creation time.
|
This (size) will allow to set the container rootfs size to 120G at creation time.
|
||||||
User cannot pass a size less than the Default BaseFS Size. This option is only
|
User cannot pass a size less than the Default BaseFS Size. This option is only
|
||||||
available for the `devicemapper`, `btrfs`, and `zfs` graph drivers.
|
available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers.
|
||||||
|
|
||||||
### Specify isolation technology for container (--isolation)
|
### Specify isolation technology for container (--isolation)
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ The `-w` lets the command being executed inside directory given, here
|
||||||
|
|
||||||
This (size) will allow to set the container rootfs size to 120G at creation time.
|
This (size) will allow to set the container rootfs size to 120G at creation time.
|
||||||
User cannot pass a size less than the Default BaseFS Size. This option is only
|
User cannot pass a size less than the Default BaseFS Size. This option is only
|
||||||
available for the `devicemapper`, `btrfs`, and `zfs` graph drivers.
|
available for the `devicemapper`, `btrfs`, `windowsfilter`, and `zfs` graph drivers.
|
||||||
|
|
||||||
### Mount tmpfs (--tmpfs)
|
### Mount tmpfs (--tmpfs)
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,6 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio
|
||||||
if spec.Windows.Resources.Storage.Iops != nil {
|
if spec.Windows.Resources.Storage.Iops != nil {
|
||||||
configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
|
configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
|
||||||
}
|
}
|
||||||
if spec.Windows.Resources.Storage.SandboxSize != nil {
|
|
||||||
configuration.StorageSandboxSize = *spec.Windows.Resources.Storage.SandboxSize
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue