Add IO Resource Controls for Windows

Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 8df2066341931d9b7ba552afa902e2ef12e5eed5
Component: engine
This commit is contained in:
Darren Stahl
2016-04-25 13:07:29 -07:00
parent bdb0102fb8
commit 87afb49f07
10 changed files with 112 additions and 9 deletions
+5
View File
@@ -62,6 +62,11 @@ func DecodeContainerConfig(src io.Reader) (*container.Config, *container.HostCon
if err := ValidateIsolation(hc); err != nil {
return nil, nil, nil, err
}
// Validate QoS
if err := ValidateQoS(hc); err != nil {
return nil, nil, nil, err
}
return w.Config, hc, w.NetworkingConfig, nil
}
@@ -87,3 +87,21 @@ func ValidateIsolation(hc *container.HostConfig) error {
}
return nil
}
// ValidateQoS performs platform specific validation of the QoS settings
// a disk can be limited by either Bps or IOps, but not both.
func ValidateQoS(hc *container.HostConfig) error {
// We may not be passed a host config, such as in the case of docker commit
if hc == nil {
return nil
}
if hc.IOMaximumBandwidth != 0 {
return fmt.Errorf("invalid QoS settings: %s does not support --maximum-bandwidth", runtime.GOOS)
}
if hc.IOMaximumIOps != 0 {
return fmt.Errorf("invalid QoS settings: %s does not support --maximum-iops", runtime.GOOS)
}
return nil
}
@@ -44,3 +44,17 @@ func ValidateIsolation(hc *container.HostConfig) error {
}
return nil
}
// ValidateQoS performs platform specific validation of the Qos settings
// a disk can be limited by either Bps or IOps, but not both.
func ValidateQoS(hc *container.HostConfig) error {
// We may not be passed a host config, such as in the case of docker commit
if hc == nil {
return nil
}
if hc.IOMaximumIOps != 0 && hc.IOMaximumBandwidth != 0 {
return fmt.Errorf("invalid QoS settings: maximum bandwidth and maximum iops cannot both be set")
}
return nil
}
+16
View File
@@ -84,6 +84,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
flCpusetCpus = cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
flCpusetMems = cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
flBlkioWeight = cmd.Uint16([]string{"-blkio-weight"}, 0, "Block IO (relative weight), between 10 and 1000")
flIOMaxBandwidth = cmd.String([]string{"-io-maxbandwidth"}, "", "Maximum IO bandwidth limit for the system drive (Windows only)")
flIOMaxIOps = cmd.Uint64([]string{"-io-maxiops"}, 0, "Maximum IOps limit for the system drive (Windows only)")
flSwappiness = cmd.Int64([]string{"-memory-swappiness"}, -1, "Tune container memory swappiness (0 to 100)")
flNetMode = cmd.String([]string{"-net"}, "default", "Connect a container to a network")
flMacAddress = cmd.String([]string{"-mac-address"}, "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)")
@@ -210,6 +212,18 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
}
}
// TODO FIXME units.RAMInBytes should have a uint64 version
var maxIOBandwidth int64
if *flIOMaxBandwidth != "" {
maxIOBandwidth, err = units.RAMInBytes(*flIOMaxBandwidth)
if err != nil {
return nil, nil, nil, cmd, err
}
if maxIOBandwidth < 0 {
return nil, nil, nil, cmd, fmt.Errorf("invalid value: %s. Maximum IO Bandwidth must be positive", *flIOMaxBandwidth)
}
}
var binds []string
// add any bind targets to the list of container volumes
for bind := range flVolumes.GetMap() {
@@ -368,6 +382,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
BlkioDeviceWriteBps: flDeviceWriteBps.GetList(),
BlkioDeviceReadIOps: flDeviceReadIOps.GetList(),
BlkioDeviceWriteIOps: flDeviceWriteIOps.GetList(),
IOMaximumIOps: *flIOMaxIOps,
IOMaximumBandwidth: uint64(maxIOBandwidth),
Ulimits: flUlimits.GetList(),
Devices: deviceMappings,
}