Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -72,8 +72,10 @@ func populateCommand(c *Container, env []string) error {
|
| 72 | 72 |
// TODO Windows. This can probably be factored out. |
| 73 | 73 |
pid.HostPid = c.hostConfig.PidMode.IsHost() |
| 74 | 74 |
|
| 75 |
- // TODO Windows. Resource controls to be implemented later. |
|
| 76 |
- resources := &execdriver.Resources{}
|
|
| 75 |
+ // TODO Windows. More resource controls to be implemented later. |
|
| 76 |
+ resources := &execdriver.Resources{
|
|
| 77 |
+ CPUShares: c.hostConfig.CPUShares, |
|
| 78 |
+ } |
|
| 77 | 79 |
|
| 78 | 80 |
// TODO Windows. Further refactoring required (privileged/user) |
| 79 | 81 |
processConfig := execdriver.ProcessConfig{
|
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"os" |
| 6 | 6 |
"syscall" |
| 7 | 7 |
|
| 8 |
+ "github.com/Sirupsen/logrus" |
|
| 8 | 9 |
"github.com/docker/docker/daemon/graphdriver" |
| 9 | 10 |
// register the windows graph driver |
| 10 | 11 |
_ "github.com/docker/docker/daemon/graphdriver/windows" |
| ... | ... |
@@ -16,6 +17,8 @@ import ( |
| 16 | 16 |
const ( |
| 17 | 17 |
defaultVirtualSwitch = "Virtual Switch" |
| 18 | 18 |
platformSupported = true |
| 19 |
+ windowsMinCPUShares = 1 |
|
| 20 |
+ windowsMaxCPUShares = 9 |
|
| 19 | 21 |
) |
| 20 | 22 |
|
| 21 | 23 |
func parseSecurityOpt(container *Container, config *runconfig.HostConfig) error {
|
| ... | ... |
@@ -33,6 +36,13 @@ func checkKernel() error {
|
| 33 | 33 |
// adaptContainerSettings is called during container creation to modify any |
| 34 | 34 |
// settings necessary in the HostConfig structure. |
| 35 | 35 |
func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, adjustCPUShares bool) {
|
| 36 |
+ if hostConfig.CPUShares < 0 {
|
|
| 37 |
+ logrus.Warnf("Changing requested CPUShares of %d to minimum allowed of %d", hostConfig.CPUShares, windowsMinCPUShares)
|
|
| 38 |
+ hostConfig.CPUShares = windowsMinCPUShares |
|
| 39 |
+ } else if hostConfig.CPUShares > windowsMaxCPUShares {
|
|
| 40 |
+ logrus.Warnf("Changing requested CPUShares of %d to maximum allowed of %d", hostConfig.CPUShares, windowsMaxCPUShares)
|
|
| 41 |
+ hostConfig.CPUShares = windowsMaxCPUShares |
|
| 42 |
+ } |
|
| 36 | 43 |
} |
| 37 | 44 |
|
| 38 | 45 |
// verifyPlatformContainerSettings performs platform-specific validation of the |
| ... | ... |
@@ -186,7 +186,7 @@ type ProcessConfig struct {
|
| 186 | 186 |
ConsoleSize [2]int `json:"-"` // h,w of initial console size |
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 |
-// Command wrapps an os/exec.Cmd to add more metadata |
|
| 189 |
+// Command wraps an os/exec.Cmd to add more metadata |
|
| 190 | 190 |
// |
| 191 | 191 |
// TODO Windows: Factor out unused fields such as LxcConfig, AppArmorProfile, |
| 192 | 192 |
// and CgroupParent. |
| ... | ... |
@@ -69,6 +69,7 @@ type containerInit struct {
|
| 69 | 69 |
IgnoreFlushesDuringBoot bool // Optimisation hint for container startup in Windows |
| 70 | 70 |
LayerFolderPath string // Where the layer folders are located |
| 71 | 71 |
Layers []layer // List of storage layers |
| 72 |
+ ProcessorWeight int64 // CPU Shares 1..9 on Windows; or 0 is platform default. |
|
| 72 | 73 |
} |
| 73 | 74 |
|
| 74 | 75 |
// defaultOwner is a tag passed to HCS to allow it to differentiate between |
| ... | ... |
@@ -98,6 +99,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd |
| 98 | 98 |
VolumePath: c.Rootfs, |
| 99 | 99 |
IgnoreFlushesDuringBoot: c.FirstStart, |
| 100 | 100 |
LayerFolderPath: c.LayerFolder, |
| 101 |
+ ProcessorWeight: c.Resources.CPUShares, |
|
| 101 | 102 |
} |
| 102 | 103 |
|
| 103 | 104 |
for i := 0; i < len(c.LayerPaths); i++ {
|