mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
Critical pod annotation scheduler.alpha.kubernetes.io/critical-pod has been drop, no need to set it anymore in the tests
This commit is contained in:
@@ -17,11 +17,11 @@ limitations under the License.
|
|||||||
package pod
|
package pod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sigs.k8s.io/descheduler/pkg/utils"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
|
"sigs.k8s.io/descheduler/pkg/utils"
|
||||||
"sigs.k8s.io/descheduler/test"
|
"sigs.k8s.io/descheduler/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -150,15 +150,19 @@ func TestIsEvictable(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
pod: test.BuildTestPod("p12", 400, 0, n1.Name),
|
pod: test.BuildTestPod("p12", 400, 0, n1.Name),
|
||||||
runBefore: func(pod *v1.Pod) {
|
runBefore: func(pod *v1.Pod) {
|
||||||
pod.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
pod.Spec.Priority = &priority
|
||||||
},
|
},
|
||||||
evictLocalStoragePods: false,
|
evictLocalStoragePods: false,
|
||||||
result: false,
|
result: false,
|
||||||
}, {
|
}, {
|
||||||
pod: test.BuildTestPod("p13", 400, 0, n1.Name),
|
pod: test.BuildTestPod("p13", 400, 0, n1.Name),
|
||||||
runBefore: func(pod *v1.Pod) {
|
runBefore: func(pod *v1.Pod) {
|
||||||
pod.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
pod.Annotations["descheduler.alpha.kubernetes.io/evict"] = "true"
|
pod.Spec.Priority = &priority
|
||||||
|
pod.Annotations = map[string]string{
|
||||||
|
"descheduler.alpha.kubernetes.io/evict": "true",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
evictLocalStoragePods: false,
|
evictLocalStoragePods: false,
|
||||||
result: true,
|
result: true,
|
||||||
@@ -208,7 +212,8 @@ func TestPodTypes(t *testing.T) {
|
|||||||
p4.Annotations = test.GetMirrorPodAnnotation()
|
p4.Annotations = test.GetMirrorPodAnnotation()
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
p5.Namespace = "kube-system"
|
p5.Namespace = "kube-system"
|
||||||
p5.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
p5.Spec.Priority = &priority
|
||||||
systemCriticalPriority := utils.SystemCriticalPriority
|
systemCriticalPriority := utils.SystemCriticalPriority
|
||||||
p5.Spec.Priority = &systemCriticalPriority
|
p5.Spec.Priority = &systemCriticalPriority
|
||||||
if !IsMirrorPod(p4) {
|
if !IsMirrorPod(p4) {
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ func TestFindDuplicatePods(t *testing.T) {
|
|||||||
p6.Annotations = test.GetMirrorPodAnnotation()
|
p6.Annotations = test.GetMirrorPodAnnotation()
|
||||||
|
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
p7.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
p7.Spec.Priority = &priority
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
description string
|
description string
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
"reflect"
|
|
||||||
"sigs.k8s.io/descheduler/pkg/api"
|
"sigs.k8s.io/descheduler/pkg/api"
|
||||||
"sigs.k8s.io/descheduler/pkg/utils"
|
"sigs.k8s.io/descheduler/pkg/utils"
|
||||||
"sigs.k8s.io/descheduler/test"
|
"sigs.k8s.io/descheduler/test"
|
||||||
@@ -81,7 +82,8 @@ func TestLowNodeUtilizationWithoutPriority(t *testing.T) {
|
|||||||
p7.Annotations = test.GetMirrorPodAnnotation()
|
p7.Annotations = test.GetMirrorPodAnnotation()
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
p8.Namespace = "kube-system"
|
p8.Namespace = "kube-system"
|
||||||
p8.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
p8.Spec.Priority = &priority
|
||||||
p9 := test.BuildTestPod("p9", 400, 0, n1.Name)
|
p9 := test.BuildTestPod("p9", 400, 0, n1.Name)
|
||||||
p9.ObjectMeta.OwnerReferences = test.GetReplicaSetOwnerRefList()
|
p9.ObjectMeta.OwnerReferences = test.GetReplicaSetOwnerRefList()
|
||||||
fakeClient := &fake.Clientset{}
|
fakeClient := &fake.Clientset{}
|
||||||
@@ -186,7 +188,8 @@ func TestLowNodeUtilizationWithPriorities(t *testing.T) {
|
|||||||
p7.Annotations = test.GetMirrorPodAnnotation()
|
p7.Annotations = test.GetMirrorPodAnnotation()
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
p8.Namespace = "kube-system"
|
p8.Namespace = "kube-system"
|
||||||
p8.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
p8.Spec.Priority = &priority
|
||||||
p9 := test.BuildTestPod("p9", 400, 0, n1.Name)
|
p9 := test.BuildTestPod("p9", 400, 0, n1.Name)
|
||||||
p9.ObjectMeta.OwnerReferences = test.GetReplicaSetOwnerRefList()
|
p9.ObjectMeta.OwnerReferences = test.GetReplicaSetOwnerRefList()
|
||||||
fakeClient := &fake.Clientset{}
|
fakeClient := &fake.Clientset{}
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
|
|||||||
// The following 4 pods won't get evicted.
|
// The following 4 pods won't get evicted.
|
||||||
// A Critical Pod.
|
// A Critical Pod.
|
||||||
p7.Namespace = "kube-system"
|
p7.Namespace = "kube-system"
|
||||||
p7.Annotations = test.GetCriticalPodAnnotation()
|
priority := utils.SystemCriticalPriority
|
||||||
|
p7.Spec.Priority = &priority
|
||||||
|
|
||||||
// A daemonset.
|
// A daemonset.
|
||||||
p8.ObjectMeta.OwnerReferences = test.GetDaemonSetOwnerRefList()
|
p8.ObjectMeta.OwnerReferences = test.GetDaemonSetOwnerRefList()
|
||||||
|
|||||||
@@ -84,14 +84,6 @@ func GetDaemonSetOwnerRefList() []metav1.OwnerReference {
|
|||||||
return ownerRefList
|
return ownerRefList
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCriticalPodAnnotation returns the annotation needed for critical pod.
|
|
||||||
func GetCriticalPodAnnotation() map[string]string {
|
|
||||||
return map[string]string{
|
|
||||||
"kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Pod\"}}",
|
|
||||||
"scheduler.alpha.kubernetes.io/critical-pod": "",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildTestNode creates a node with specified capacity.
|
// BuildTestNode creates a node with specified capacity.
|
||||||
func BuildTestNode(name string, millicpu int64, mem int64, pods int64) *v1.Node {
|
func BuildTestNode(name string, millicpu int64, mem int64, pods int64) *v1.Node {
|
||||||
node := &v1.Node{
|
node := &v1.Node{
|
||||||
|
|||||||
Reference in New Issue
Block a user