From 9ea6aa536e56abebd25fb8336766c91cfaf316a0 Mon Sep 17 00:00:00 2001 From: Mike Dame Date: Fri, 11 Oct 2019 16:54:45 -0400 Subject: [PATCH] Update CriticalPod unit test The kubelet used to only determine critical pods by the namespace and an annotation (see [1], where our code switched from only checking the annotation to using the kubelet package helper, which at that revision also only checked for an annotation and namespace). However, now the kubelet uses Pod Priority to check for critical pods[3], which is controlled by an admission plugin[4]. Given that testing the functioning of the admission plugin is out of the scope of this repository, it is probably sufficient to manually set the pod priority to critical, to ensure that our Descheduler code behaves properly in response. [1] https://github.com/kubernetes-sigs/descheduler/commit/062b8698c73120d4469c74b9894c962d9a5ea552#diff-094ac8507e224603239ce19592b518f5 [2] https://github.com/kubernetes/kubernetes/blob/release-1.9/pkg/kubelet/types/pod_update.go#L151 [3] https://github.com/kubernetes/kubernetes/blob/a847874655/pkg/kubelet/types/pod_update.go#L153 [4] https://github.com/kubernetes/kubernetes/blob/a847874655/plugin/pkg/admission/priority/admission.go --- pkg/descheduler/pod/pods_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/descheduler/pod/pods_test.go b/pkg/descheduler/pod/pods_test.go index c35046286..1cd00c48e 100644 --- a/pkg/descheduler/pod/pods_test.go +++ b/pkg/descheduler/pod/pods_test.go @@ -21,6 +21,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + "k8s.io/kubernetes/pkg/apis/scheduling" "sigs.k8s.io/descheduler/test" ) @@ -208,6 +209,8 @@ func TestPodTypes(t *testing.T) { // A Critical Pod. p5.Namespace = "kube-system" p5.Annotations = test.GetCriticalPodAnnotation() + systemCriticalPriority := scheduling.SystemCriticalPriority + p5.Spec.Priority = &systemCriticalPriority if !IsMirrorPod(p4) { t.Errorf("Expected p4 to be a mirror pod.") }