mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Change OomKillDisable to be pointer
It's like `MemorySwappiness`, the default value has specific
meaning (default false means enable oom kill).
We need to change it to pointer so we can update it after
container is created.
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
(cherry picked from commit 9c2ea42329
)
Conflicts:
vendor/src/github.com/docker/engine-api/types/container/host_config.go
This commit is contained in:
parent
0627bf1a83
commit
f4a687334b
4 changed files with 9 additions and 5 deletions
|
@ -90,7 +90,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
|||
os.Exit(125)
|
||||
}
|
||||
|
||||
if hostConfig.OomKillDisable && hostConfig.Memory == 0 {
|
||||
if hostConfig.OomKillDisable != nil && *hostConfig.OomKillDisable && hostConfig.Memory == 0 {
|
||||
fmt.Fprintf(cli.err, "WARNING: Dangerous only disable the OOM Killer on containers but not set the '-m/--memory' option\n")
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro
|
|||
BlkioThrottleWriteBpsDevice: writeBpsDevice,
|
||||
BlkioThrottleReadIOpsDevice: readIOpsDevice,
|
||||
BlkioThrottleWriteIOpsDevice: writeIOpsDevice,
|
||||
OomKillDisable: c.HostConfig.OomKillDisable,
|
||||
OomKillDisable: *c.HostConfig.OomKillDisable,
|
||||
MemorySwappiness: -1,
|
||||
}
|
||||
|
||||
|
|
|
@ -210,6 +210,10 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf
|
|||
defaultSwappiness := int64(-1)
|
||||
hostConfig.MemorySwappiness = &defaultSwappiness
|
||||
}
|
||||
if hostConfig.OomKillDisable == nil {
|
||||
defaultOomKillDisable := false
|
||||
hostConfig.OomKillDisable = &defaultOomKillDisable
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -270,8 +274,8 @@ func verifyContainerResources(resources *containertypes.Resources) ([]string, er
|
|||
warnings = append(warnings, "You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
|
||||
logrus.Warnf("You specified a kernel memory limit on a kernel older than 4.0. Kernel memory limits are experimental on older kernels, it won't work as expected and can cause your system to be unstable.")
|
||||
}
|
||||
if resources.OomKillDisable && !sysInfo.OomKillDisable {
|
||||
resources.OomKillDisable = false
|
||||
if resources.OomKillDisable != nil && !sysInfo.OomKillDisable {
|
||||
resources.OomKillDisable = nil
|
||||
return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
|
|||
MemorySwap: memorySwap,
|
||||
MemorySwappiness: flSwappiness,
|
||||
KernelMemory: KernelMemory,
|
||||
OomKillDisable: *flOomKillDisable,
|
||||
OomKillDisable: flOomKillDisable,
|
||||
CPUShares: *flCPUShares,
|
||||
CPUPeriod: *flCPUPeriod,
|
||||
CpusetCpus: *flCpusetCpus,
|
||||
|
|
Loading…
Add table
Reference in a new issue