Reset Swap when memory is set to unlimited (-1)

Kernel validation fails if memory set to -1 which is unlimited but
swap is not set so.

Signed-off-by: Mohammad Arab <boynux@gmail.com>
This commit is contained in:
Mohammad Arab
2016-10-19 12:15:55 +02:00
committed by boynux
parent 1e4ca86a72
commit 18ebc51b3c
4 changed files with 60 additions and 59 deletions
+11 -5
View File
@@ -193,16 +193,22 @@ other options are ignored.
opt string
dest *uint64
}{
{"memory", r.Memory.Limit},
{"memory-swap", r.Memory.Swap},
{"kernel-memory", r.Memory.Kernel},
{"kernel-memory-tcp", r.Memory.KernelTCP},
{"memory", r.Memory.Limit},
{"memory-reservation", r.Memory.Reservation},
{"memory-swap", r.Memory.Swap},
} {
if val := context.String(pair.opt); val != "" {
v, err := units.RAMInBytes(val)
if err != nil {
return fmt.Errorf("invalid value for %s: %s", pair.opt, err)
var v int64
if val != "-1" {
v, err = units.RAMInBytes(val)
if err != nil {
return fmt.Errorf("invalid value for %s: %s", pair.opt, err)
}
} else {
v = -1
}
*pair.dest = uint64(v)
}