1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

use new events implementation and take recorder out of EvictPod

This commit is contained in:
Lucas Severo Alves
2022-07-21 16:59:42 +02:00
committed by Lucas Severo Alves
parent 0d3ff8a84f
commit 0aa233415e
20 changed files with 139 additions and 15 deletions

View File

@@ -36,6 +36,7 @@ import (
"k8s.io/client-go/informers"
coreinformers "k8s.io/client-go/informers/core/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/events"
v1qos "k8s.io/kubectl/pkg/util/qos"
"k8s.io/utils/pointer"
@@ -107,7 +108,7 @@ func RcByNameContainer(name, namespace string, replicas int32, labels map[string
}
func initializeClient(t *testing.T) (clientset.Interface, coreinformers.NodeInformer, podutil.GetPodsAssignedToNodeFunc, chan struct{}) {
clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG"))
clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG"), "")
if err != nil {
t.Errorf("Error during client creation with %v", err)
}
@@ -193,6 +194,8 @@ func runPodLifetimeStrategy(
t.Fatalf("Failed to get threshold priority from strategy's params")
}
eventRecorder := &events.FakeRecorder{}
strategies.PodLifeTime(
ctx,
clientset,
@@ -206,6 +209,7 @@ func runPodLifetimeStrategy(
maxPodsToEvictPerNamespace,
nodes,
false,
eventRecorder,
),
evictions.NewEvictorFilter(
nodes,
@@ -1035,7 +1039,7 @@ func TestPodLifeTimeOldestEvicted(t *testing.T) {
func TestDeschedulingInterval(t *testing.T) {
ctx := context.Background()
clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG"))
clientSet, err := client.CreateClient(os.Getenv("KUBECONFIG"), "")
if err != nil {
t.Errorf("Error during client creation with %v", err)
}
@@ -1424,6 +1428,9 @@ func initPodEvictorOrFail(t *testing.T, clientSet clientset.Interface, getPodsAs
if err != nil || len(evictionPolicyGroupVersion) == 0 {
t.Fatalf("Error creating eviction policy group: %v", err)
}
eventRecorder := &events.FakeRecorder{}
return evictions.NewPodEvictor(
clientSet,
evictionPolicyGroupVersion,
@@ -1432,5 +1439,6 @@ func initPodEvictorOrFail(t *testing.T, clientSet clientset.Interface, getPodsAs
nil,
nodes,
false,
eventRecorder,
)
}