cri: make swapping disabled with memory limit
OCI runtime spec defines memory.swap as 'limit of memory+Swap usage' so setting them to equal should disable the swap. Also, this change should make containerd behaviour same as other runtimes e.g 'cri-dockerd/dockershim' and won't be impacted when user turn on 'NodeSwap' (https://github.com/kubernetes/enhancements/issues/2400) feature. Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
This commit is contained in:
@@ -448,6 +448,10 @@ func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHu
|
||||
}
|
||||
if limit != 0 {
|
||||
s.Linux.Resources.Memory.Limit = &limit
|
||||
// swap/memory limit should be equal to prevent container from swapping by default
|
||||
if swapLimit == 0 {
|
||||
s.Linux.Resources.Memory.Swap = &limit
|
||||
}
|
||||
}
|
||||
if swapLimit != 0 {
|
||||
s.Linux.Resources.Memory.Swap = &swapLimit
|
||||
|
||||
Reference in New Issue
Block a user