Merge pull request #23391 from Microsoft/WindowsSandboxSize

Windows: Added support for storage-opt size
This commit is contained in:
Sebastiaan van Stijn 2016-08-09 15:34:39 +02:00 committed by GitHub
commit 04e021d751
5 changed files with 44 additions and 10 deletions

View File

@ -30,12 +30,19 @@ import (
"github.com/docker/docker/pkg/longpath"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/system"
"github.com/docker/go-units"
"github.com/vbatts/tar-split/tar/storage"
)
// filterDriver is an HCSShim driver type for the Windows Filter driver.
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.
func init() {
graphdriver.Register("windowsfilter", InitFilter)
@ -116,10 +123,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 {
if len(storageOpt) != 0 {
return fmt.Errorf("--storage-opt is not supported for windows")
}
rPId, err := d.resolveID(parent)
if err != nil {
return err
@ -182,6 +185,17 @@ func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt
if err := hcsshim.CreateSandboxLayer(d.info, id, parentPath, layerChain); err != nil {
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 {
@ -777,3 +791,27 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
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
}

View File

@ -180,7 +180,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
Storage: &windowsoci.Storage{
Bps: &c.HostConfig.IOMaximumBandwidth,
Iops: &c.HostConfig.IOMaximumIOps,
//TODO SandboxSize: ...,
},
}
return (*libcontainerd.Spec)(&s), nil

View File

@ -170,7 +170,7 @@ Set storage driver options per container.
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
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)

View File

@ -198,7 +198,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.
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)

View File

@ -76,9 +76,6 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio
if spec.Windows.Resources.Storage.Iops != nil {
configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
}
if spec.Windows.Resources.Storage.SandboxSize != nil {
configuration.StorageSandboxSize = *spec.Windows.Resources.Storage.SandboxSize
}
}
}