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 9c2ea42329179c589f5a8991ccf0253eb10fc897)
Conflicts:
vendor/src/github.com/docker/engine-api/types/container/host_config.go
| ... | ... |
@@ -90,7 +90,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 90 | 90 |
os.Exit(125) |
| 91 | 91 |
} |
| 92 | 92 |
|
| 93 |
- if hostConfig.OomKillDisable && hostConfig.Memory == 0 {
|
|
| 93 |
+ if hostConfig.OomKillDisable != nil && *hostConfig.OomKillDisable && hostConfig.Memory == 0 {
|
|
| 94 | 94 |
fmt.Fprintf(cli.err, "WARNING: Dangerous only disable the OOM Killer on containers but not set the '-m/--memory' option\n") |
| 95 | 95 |
} |
| 96 | 96 |
|
| ... | ... |
@@ -209,7 +209,7 @@ func (daemon *Daemon) populateCommand(c *container.Container, env []string) erro |
| 209 | 209 |
BlkioThrottleWriteBpsDevice: writeBpsDevice, |
| 210 | 210 |
BlkioThrottleReadIOpsDevice: readIOpsDevice, |
| 211 | 211 |
BlkioThrottleWriteIOpsDevice: writeIOpsDevice, |
| 212 |
- OomKillDisable: c.HostConfig.OomKillDisable, |
|
| 212 |
+ OomKillDisable: *c.HostConfig.OomKillDisable, |
|
| 213 | 213 |
MemorySwappiness: -1, |
| 214 | 214 |
} |
| 215 | 215 |
|
| ... | ... |
@@ -210,6 +210,10 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf |
| 210 | 210 |
defaultSwappiness := int64(-1) |
| 211 | 211 |
hostConfig.MemorySwappiness = &defaultSwappiness |
| 212 | 212 |
} |
| 213 |
+ if hostConfig.OomKillDisable == nil {
|
|
| 214 |
+ defaultOomKillDisable := false |
|
| 215 |
+ hostConfig.OomKillDisable = &defaultOomKillDisable |
|
| 216 |
+ } |
|
| 213 | 217 |
|
| 214 | 218 |
return nil |
| 215 | 219 |
} |
| ... | ... |
@@ -270,8 +274,8 @@ func verifyContainerResources(resources *containertypes.Resources) ([]string, er |
| 270 | 270 |
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.") |
| 271 | 271 |
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.")
|
| 272 | 272 |
} |
| 273 |
- if resources.OomKillDisable && !sysInfo.OomKillDisable {
|
|
| 274 |
- resources.OomKillDisable = false |
|
| 273 |
+ if resources.OomKillDisable != nil && !sysInfo.OomKillDisable {
|
|
| 274 |
+ resources.OomKillDisable = nil |
|
| 275 | 275 |
return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
|
| 276 | 276 |
} |
| 277 | 277 |
|
| ... | ... |
@@ -327,7 +327,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host |
| 327 | 327 |
MemorySwap: memorySwap, |
| 328 | 328 |
MemorySwappiness: flSwappiness, |
| 329 | 329 |
KernelMemory: KernelMemory, |
| 330 |
- OomKillDisable: *flOomKillDisable, |
|
| 330 |
+ OomKillDisable: flOomKillDisable, |
|
| 331 | 331 |
CPUShares: *flCPUShares, |
| 332 | 332 |
CPUPeriod: *flCPUPeriod, |
| 333 | 333 |
CpusetCpus: *flCpusetCpus, |