mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #99729 from ravisantoshgudimetla/low-oom-score
Only system-node-critical pods should be OOM Killed last
This commit is contained in:
commit
0691157ec4
@ -38,8 +38,8 @@ const (
|
||||
// and 1000. Containers with higher OOM scores are killed if the system runs out of memory.
|
||||
// See https://lwn.net/Articles/391222/ for more information.
|
||||
func GetContainerOOMScoreAdjust(pod *v1.Pod, container *v1.Container, memoryCapacity int64) int {
|
||||
if types.IsCriticalPod(pod) {
|
||||
// Critical pods should be the last to get killed.
|
||||
if types.IsNodeCriticalPod(pod) {
|
||||
// Only node critical pod should be the last to get killed.
|
||||
return guaranteedOOMScoreAdj
|
||||
}
|
||||
|
||||
|
@ -139,9 +139,24 @@ var (
|
||||
|
||||
systemCritical = scheduling.SystemCriticalPriority
|
||||
|
||||
critical = v1.Pod{
|
||||
clusterCritical = v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
Priority: &systemCritical,
|
||||
PriorityClassName: scheduling.SystemClusterCritical,
|
||||
Priority: &systemCritical,
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Resources: v1.ResourceRequirements{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
systemNodeCritical = scheduling.SystemCriticalPriority + 1000
|
||||
|
||||
nodeCritical = v1.Pod{
|
||||
Spec: v1.PodSpec{
|
||||
PriorityClassName: scheduling.SystemNodeCritical,
|
||||
Priority: &systemNodeCritical,
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Resources: v1.ResourceRequirements{},
|
||||
@ -203,7 +218,13 @@ func TestGetContainerOOMScoreAdjust(t *testing.T) {
|
||||
highOOMScoreAdj: 3,
|
||||
},
|
||||
{
|
||||
pod: &critical,
|
||||
pod: &clusterCritical,
|
||||
memoryCapacity: 4000000000,
|
||||
lowOOMScoreAdj: 1000,
|
||||
highOOMScoreAdj: 1000,
|
||||
},
|
||||
{
|
||||
pod: &nodeCritical,
|
||||
memoryCapacity: 4000000000,
|
||||
lowOOMScoreAdj: -997,
|
||||
highOOMScoreAdj: -997,
|
||||
|
@ -184,3 +184,8 @@ func Preemptable(preemptor, preemptee *v1.Pod) bool {
|
||||
func IsCriticalPodBasedOnPriority(priority int32) bool {
|
||||
return priority >= scheduling.SystemCriticalPriority
|
||||
}
|
||||
|
||||
// IsNodeCriticalPod checks if the given pod is a system-node-critical
|
||||
func IsNodeCriticalPod(pod *v1.Pod) bool {
|
||||
return IsCriticalPod(pod) && (pod.Spec.PriorityClassName == scheduling.SystemNodeCritical)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user