Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1945856: 99729:Only system-node-critical pods should be OOM Killed last #642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/kubelet/qos/policy.go
Expand Up @@ -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
}

Expand Down
27 changes: 24 additions & 3 deletions pkg/kubelet/qos/policy_test.go
Expand Up @@ -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{},
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions pkg/kubelet/types/pod_update.go
Expand Up @@ -179,3 +179,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)
}