Treat -1 as default value for memory swappiness.
In some older kernels setting swappiness fails. This happens even when nobody tries to configure swappiness from docker UI because we would still get some default value from host config. With this we treat -1 value as default value (set implicitly) and skip the enforcement of swappiness. However from the docker UI setting an invalid value anything other than 0-100 including -1 should fail. This patch enables that fix in docker UI. without this fix container creation with invalid value succeeds with a default value (60) which in incorrect. Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
This commit is contained in:
parent
00f6b56903
commit
88104a4444
|
@ -75,6 +75,10 @@ func (s *MemoryGroup) Set(path string, cgroup *configs.Cgroup) error {
|
|||
if err := writeFile(path, "memory.swappiness", strconv.FormatInt(cgroup.MemorySwappiness, 10)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if cgroup.MemorySwappiness == -1 {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("invalid value:%d. valid memory swappiness range is 0-100", cgroup.MemorySwappiness)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -511,6 +511,10 @@ func joinMemory(c *configs.Cgroup, pid int) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if c.MemorySwappiness == -1 {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("invalid value:%d. valid memory swappiness range is 0-100", c.MemorySwappiness)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue