mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Refactor resources structure
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
e252fe288c
commit
b1220a763c
7 changed files with 56 additions and 40 deletions
|
@ -279,19 +279,21 @@ func populateCommand(c *Container, env []string) error {
|
|||
}
|
||||
|
||||
resources := &execdriver.Resources{
|
||||
Memory: c.hostConfig.Memory,
|
||||
MemorySwap: c.hostConfig.MemorySwap,
|
||||
MemoryReservation: c.hostConfig.MemoryReservation,
|
||||
KernelMemory: c.hostConfig.KernelMemory,
|
||||
CPUShares: c.hostConfig.CPUShares,
|
||||
CpusetCpus: c.hostConfig.CpusetCpus,
|
||||
CpusetMems: c.hostConfig.CpusetMems,
|
||||
CPUPeriod: c.hostConfig.CPUPeriod,
|
||||
CPUQuota: c.hostConfig.CPUQuota,
|
||||
BlkioWeight: c.hostConfig.BlkioWeight,
|
||||
Rlimits: rlimits,
|
||||
OomKillDisable: c.hostConfig.OomKillDisable,
|
||||
MemorySwappiness: -1,
|
||||
CommonResources: execdriver.CommonResources{
|
||||
Memory: c.hostConfig.Memory,
|
||||
MemoryReservation: c.hostConfig.MemoryReservation,
|
||||
CPUShares: c.hostConfig.CPUShares,
|
||||
BlkioWeight: c.hostConfig.BlkioWeight,
|
||||
},
|
||||
MemorySwap: c.hostConfig.MemorySwap,
|
||||
KernelMemory: c.hostConfig.KernelMemory,
|
||||
CpusetCpus: c.hostConfig.CpusetCpus,
|
||||
CpusetMems: c.hostConfig.CpusetMems,
|
||||
CPUPeriod: c.hostConfig.CPUPeriod,
|
||||
CPUQuota: c.hostConfig.CPUQuota,
|
||||
Rlimits: rlimits,
|
||||
OomKillDisable: c.hostConfig.OomKillDisable,
|
||||
MemorySwappiness: -1,
|
||||
}
|
||||
|
||||
if c.hostConfig.MemorySwappiness != nil {
|
||||
|
|
|
@ -86,7 +86,9 @@ func populateCommand(c *Container, env []string) error {
|
|||
|
||||
// TODO Windows. More resource controls to be implemented later.
|
||||
resources := &execdriver.Resources{
|
||||
CPUShares: c.hostConfig.CPUShares,
|
||||
CommonResources: execdriver.CommonResources{
|
||||
CPUShares: c.hostConfig.CPUShares,
|
||||
},
|
||||
}
|
||||
|
||||
// TODO Windows. Further refactoring required (privileged/user)
|
||||
|
|
|
@ -7,8 +7,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
// TODO Windows: Factor out ulimit
|
||||
"github.com/docker/docker/pkg/ulimit"
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
)
|
||||
|
@ -138,23 +136,13 @@ type UTS struct {
|
|||
HostUTS bool `json:"host_uts"`
|
||||
}
|
||||
|
||||
// Resources contains all resource configs for a driver.
|
||||
// Currently these are all for cgroup configs.
|
||||
// TODO Windows: Factor out ulimit.Rlimit
|
||||
type Resources struct {
|
||||
Memory int64 `json:"memory"`
|
||||
MemorySwap int64 `json:"memory_swap"`
|
||||
MemoryReservation int64 `json:"memory_reservation"`
|
||||
KernelMemory int64 `json:"kernel_memory"`
|
||||
CPUShares int64 `json:"cpu_shares"`
|
||||
CpusetCpus string `json:"cpuset_cpus"`
|
||||
CpusetMems string `json:"cpuset_mems"`
|
||||
CPUPeriod int64 `json:"cpu_period"`
|
||||
CPUQuota int64 `json:"cpu_quota"`
|
||||
BlkioWeight uint16 `json:"blkio_weight"`
|
||||
Rlimits []*ulimit.Rlimit `json:"rlimits"`
|
||||
OomKillDisable bool `json:"oom_kill_disable"`
|
||||
MemorySwappiness int64 `json:"memory_swappiness"`
|
||||
// CommonResources contains the resource configs for a driver that are
|
||||
// common across platforms.
|
||||
type CommonResources struct {
|
||||
Memory int64 `json:"memory"`
|
||||
MemoryReservation int64 `json:"memory_reservation"`
|
||||
CPUShares int64 `json:"cpu_shares"`
|
||||
BlkioWeight uint16 `json:"blkio_weight"`
|
||||
}
|
||||
|
||||
// ResourceStats contains information about resource usage by a container.
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
|
||||
"github.com/docker/docker/daemon/execdriver/native/template"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/docker/docker/pkg/ulimit"
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
|
@ -27,6 +28,24 @@ type Mount struct {
|
|||
Slave bool `json:"slave"`
|
||||
}
|
||||
|
||||
// Resources contains all resource configs for a driver.
|
||||
// Currently these are all for cgroup configs.
|
||||
type Resources struct {
|
||||
CommonResources
|
||||
|
||||
// Fields below here are platform specific
|
||||
|
||||
MemorySwap int64 `json:"memory_swap"`
|
||||
KernelMemory int64 `json:"kernel_memory"`
|
||||
CPUQuota int64 `json:"cpu_quota"`
|
||||
CpusetCpus string `json:"cpuset_cpus"`
|
||||
CpusetMems string `json:"cpuset_mems"`
|
||||
CPUPeriod int64 `json:"cpu_period"`
|
||||
Rlimits []*ulimit.Rlimit `json:"rlimits"`
|
||||
OomKillDisable bool `json:"oom_kill_disable"`
|
||||
MemorySwappiness int64 `json:"memory_swappiness"`
|
||||
}
|
||||
|
||||
// Network settings of the container
|
||||
type Network struct {
|
||||
Mtu int `json:"mtu"`
|
||||
|
|
|
@ -9,6 +9,14 @@ type Mount struct {
|
|||
Writable bool `json:"writable"`
|
||||
}
|
||||
|
||||
// Resources contains all resource configs for a driver.
|
||||
// Currently these are all for cgroup configs.
|
||||
type Resources struct {
|
||||
CommonResources
|
||||
|
||||
// Fields below here are platform specific
|
||||
}
|
||||
|
||||
// Network settings of the container
|
||||
type Network struct {
|
||||
Interface *NetworkInterface `json:"interface"`
|
||||
|
|
|
@ -47,9 +47,11 @@ func TestLXCConfig(t *testing.T) {
|
|||
command := &execdriver.Command{
|
||||
ID: "1",
|
||||
Resources: &execdriver.Resources{
|
||||
Memory: int64(mem),
|
||||
MemorySwap: int64(swap),
|
||||
CPUShares: int64(cpu),
|
||||
CommonResources: execdriver.CommonResources{
|
||||
Memory: int64(mem),
|
||||
CPUShares: int64(cpu),
|
||||
},
|
||||
},
|
||||
Network: &execdriver.Network{
|
||||
Mtu: 1500,
|
||||
|
|
|
@ -24,11 +24,6 @@ func checkSupportedOptions(c *execdriver.Command) error {
|
|||
return errors.New("Windows does not support lxc options")
|
||||
}
|
||||
|
||||
// Windows doesn't support ulimit
|
||||
if c.Resources.Rlimits != nil {
|
||||
return errors.New("Windows does not support ulimit options")
|
||||
}
|
||||
|
||||
// TODO Windows: Validate other fields which Windows doesn't support, factor
|
||||
// out where applicable per platform.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue