mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 18:11:22 +00:00
Revert "Revert "[kubelet] Fix oom-score-adj policy in kubelet""
This commit is contained in:
@@ -21,8 +21,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PodInfraOOMAdj int = -999
|
||||
PodInfraOOMAdj int = -998
|
||||
KubeletOOMScoreAdj int = -999
|
||||
DockerOOMScoreAdj int = -999
|
||||
KubeProxyOOMScoreAdj int = -999
|
||||
guaranteedOOMScoreAdj int = -998
|
||||
besteffortOOMScoreAdj int = 1000
|
||||
@@ -53,10 +54,10 @@ func GetContainerOOMScoreAdjust(pod *api.Pod, container *api.Container, memoryCa
|
||||
// Note that this is a heuristic, it won't work if a container has many small processes.
|
||||
memoryRequest := container.Resources.Requests.Memory().Value()
|
||||
oomScoreAdjust := 1000 - (1000*memoryRequest)/memoryCapacity
|
||||
// A guaranteed pod using 100% of memory can have an OOM score of 1. Ensure
|
||||
// A guaranteed pod using 100% of memory can have an OOM score of 10. Ensure
|
||||
// that burstable pods have a higher OOM score adjustment.
|
||||
if oomScoreAdjust < 2 {
|
||||
return 2
|
||||
if int(oomScoreAdjust) < (1000 + guaranteedOOMScoreAdj) {
|
||||
return (1000 + guaranteedOOMScoreAdj)
|
||||
}
|
||||
// Give burstable pods a higher chance of survival over besteffort pods.
|
||||
if int(oomScoreAdjust) == besteffortOOMScoreAdj {
|
||||
|
Reference in New Issue
Block a user