diff --git a/pkg/apis/scheduling/v1alpha1/types.go b/pkg/apis/scheduling/v1alpha1/types.go index 728e126ae..98391942b 100644 --- a/pkg/apis/scheduling/v1alpha1/types.go +++ b/pkg/apis/scheduling/v1alpha1/types.go @@ -19,6 +19,7 @@ package v1alpha1 import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling" ) // +genclient @@ -107,6 +108,9 @@ const ( // PodGroupFailed means at least one of `spec.minMember` pods is failed. PodGroupFailed PodGroupPhase = "Failed" + + // PodGroupLabel is the default label of coscheduling + PodGroupLabel = "pod-group." + scheduling.GroupName ) // +genclient diff --git a/pkg/controller/podgroup.go b/pkg/controller/podgroup.go index 20cf4ad08..0f7ae3613 100644 --- a/pkg/controller/podgroup.go +++ b/pkg/controller/podgroup.go @@ -206,7 +206,7 @@ func (ctrl *PodGroupController) syncHandler(key string) error { } pgCopy := pg.DeepCopy() - selector := labels.Set(map[string]string{util.PodGroupLabel: pgCopy.Name}).AsSelector() + selector := labels.Set(map[string]string{schedv1alpha1.PodGroupLabel: pgCopy.Name}).AsSelector() pods, err := ctrl.podLister.List(selector) if err != nil { klog.ErrorS(err, "List pods for group failed", "podGroup", klog.KObj(pgCopy)) diff --git a/pkg/controller/podgroup_test.go b/pkg/controller/podgroup_test.go index 036638e57..8ef838bc8 100644 --- a/pkg/controller/podgroup_test.go +++ b/pkg/controller/podgroup_test.go @@ -17,7 +17,6 @@ import ( "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" pgfake "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/fake" schedinformer "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" - "sigs.k8s.io/scheduler-plugins/pkg/util" ) func Test_Run(t *testing.T) { @@ -188,7 +187,7 @@ func makePods(podNames []string, pgName string, phase v1.PodPhase) []*v1.Pod { pds := make([]*v1.Pod, 0) for _, name := range podNames { pod := st.MakePod().Namespace("default").Name(name).Obj() - pod.Labels = map[string]string{util.PodGroupLabel: pgName} + pod.Labels = map[string]string{v1alpha1.PodGroupLabel: pgName} pod.Status.Phase = phase pds = append(pds, pod) } diff --git a/pkg/coscheduling/core/core.go b/pkg/coscheduling/core/core.go index b5091a6b4..3396395d3 100644 --- a/pkg/coscheduling/core/core.go +++ b/pkg/coscheduling/core/core.go @@ -115,7 +115,7 @@ func (pgMgr *PodGroupManager) ActivateSiblings(pod *corev1.Pod, state *framework } pods, err := pgMgr.podLister.Pods(pod.Namespace).List( - labels.SelectorFromSet(labels.Set{util.PodGroupLabel: pgName}), + labels.SelectorFromSet(labels.Set{v1alpha1.PodGroupLabel: pgName}), ) if err != nil { klog.ErrorS(err, "Failed to obtain pods belong to a PodGroup", "podGroup", pgName) @@ -156,7 +156,7 @@ func (pgMgr *PodGroupManager) PreFilter(ctx context.Context, pod *corev1.Pod) er return fmt.Errorf("pod with pgName: %v last failed in 3s, deny", pgFullName) } pods, err := pgMgr.podLister.Pods(pod.Namespace).List( - labels.SelectorFromSet(labels.Set{util.PodGroupLabel: util.GetPodGroupLabel(pod)}), + labels.SelectorFromSet(labels.Set{v1alpha1.PodGroupLabel: util.GetPodGroupLabel(pod)}), ) if err != nil { return fmt.Errorf("podLister list pods failed: %v", err) @@ -312,7 +312,7 @@ func (pgMgr *PodGroupManager) CalculateAssignedPods(podGroupName, namespace stri for _, nodeInfo := range nodeInfos { for _, podInfo := range nodeInfo.Pods { pod := podInfo.Pod - if pod.Labels[util.PodGroupLabel] == podGroupName && pod.Namespace == namespace && pod.Spec.NodeName != "" { + if pod.Labels[v1alpha1.PodGroupLabel] == podGroupName && pod.Namespace == namespace && pod.Spec.NodeName != "" { count++ } } diff --git a/pkg/coscheduling/core/core_test.go b/pkg/coscheduling/core/core_test.go index f1253480f..4557e635a 100644 --- a/pkg/coscheduling/core/core_test.go +++ b/pkg/coscheduling/core/core_test.go @@ -70,82 +70,82 @@ func TestPreFilter(t *testing.T) { name: "pod does not belong to any pg", pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg2").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: true, }, { name: "pg was previously denied", - pod: st.MakePod().Name("p1").UID("p1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p1").UID("p1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), lastDeniedPG: denyCache, expectedSuccess: false, }, { name: "pod belongs to a non-existing pg", - pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(util.PodGroupLabel, "pg-notexisting").Obj(), + pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg-notexisting").Obj(), lastDeniedPG: newCache(), expectedSuccess: true, }, { name: "pod count less than minMember", - pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg2").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: false, }, { name: "pod count equal minMember", - pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: true, }, { name: "pod count more minMember", - pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p2").UID("p2").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), - st.MakePod().Name("pg3-1").UID("pg3-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg3-1").UID("pg3-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: true, }, { name: "cluster resource enough, min Resource", - pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg2"). + pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2"). Req(map[corev1.ResourceName]string{corev1.ResourceCPU: "1"}).Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg2").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg2").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: true, }, { name: "cluster resource not enough, min Resource", - pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg3"). + pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg3"). Req(map[corev1.ResourceName]string{corev1.ResourceCPU: "20"}).Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg3").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg3").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg3").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg3").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: false, }, { name: "cluster resource enough not required", - pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p2-1").UID("p2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), pods: []*corev1.Pod{ - st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), - st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg1-1").UID("pg1-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), + st.MakePod().Name("pg2-1").UID("pg2-1").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), }, lastDeniedPG: newCache(), expectedSuccess: true, @@ -189,7 +189,7 @@ func TestPermit(t *testing.T) { pgInformer.Informer().GetStore().Add(pg1) pgLister := pgInformer.Lister() - existingPods, allNodes := testutil.MakeNodesAndPods(map[string]string{util.PodGroupLabel: "pg1"}, 1, 1) + existingPods, allNodes := testutil.MakeNodesAndPods(map[string]string{v1alpha1.PodGroupLabel: "pg1"}, 1, 1) existingPods[0].Spec.NodeName = allNodes[0].Name existingPods[0].Namespace = "ns1" snapshot := testutil.NewFakeSharedLister(existingPods, allNodes) @@ -207,18 +207,18 @@ func TestPermit(t *testing.T) { }, { name: "pod belongs to a non-existing pg", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg-noexist").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg-noexist").Obj(), want: PodGroupNotFound, }, { name: "pod belongs to a pg that doesn't have enough pods", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), snapshot: testutil.NewFakeSharedLister([]*corev1.Pod{}, []*corev1.Node{}), want: Wait, }, { name: "pod belongs to a pg that has enough pods", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), snapshot: snapshot, want: Success, }, @@ -259,19 +259,19 @@ func TestPostBind(t *testing.T) { }{ { name: "pg status convert to scheduled", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg").Obj(), desiredGroupPhase: v1alpha1.PodGroupScheduled, desiredScheduled: 1, }, { name: "pg status convert to scheduling", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), desiredGroupPhase: v1alpha1.PodGroupScheduling, desiredScheduled: 1, }, { name: "pg status does not convert, although scheduled pods change", - pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(util.PodGroupLabel, "pg2").Obj(), + pod: st.MakePod().Name("p").UID("p").Namespace("ns1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), desiredGroupPhase: v1alpha1.PodGroupScheduling, desiredScheduled: 1, }, @@ -306,7 +306,7 @@ func TestCheckClusterResource(t *testing.T) { snapshot := testutil.NewFakeSharedLister(nil, []*corev1.Node{node}) nodeInfo, _ := snapshot.NodeInfos().List() - pod := st.MakePod().Name("t1-p1-3").Req(map[corev1.ResourceName]string{corev1.ResourceMemory: "100"}).Label(util.PodGroupLabel, + pod := st.MakePod().Name("t1-p1-3").Req(map[corev1.ResourceName]string{corev1.ResourceMemory: "100"}).Label(v1alpha1.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj() snapshotWithAssumedPod := testutil.NewFakeSharedLister([]*corev1.Pod{pod}, []*corev1.Node{node}) scheduledNodeInfo, _ := snapshotWithAssumedPod.NodeInfos().List() diff --git a/pkg/coscheduling/coscheduling.go b/pkg/coscheduling/coscheduling.go index e94cd432e..5ce30dab4 100644 --- a/pkg/coscheduling/coscheduling.go +++ b/pkg/coscheduling/coscheduling.go @@ -30,6 +30,7 @@ import ( "k8s.io/kubernetes/pkg/scheduler/framework" "sigs.k8s.io/scheduler-plugins/pkg/apis/config" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" "sigs.k8s.io/scheduler-plugins/pkg/coscheduling/core" pgclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" pgformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" @@ -159,7 +160,7 @@ func (cs *Coscheduling) PostFilter(ctx context.Context, state *framework.CycleSt // It's based on an implicit assumption: if the nth Pod failed, // it's inferrable other Pods belonging to the same PodGroup would be very likely to fail. cs.frameworkHandler.IterateOverWaitingPods(func(waitingPod framework.WaitingPod) { - if waitingPod.GetPod().Namespace == pod.Namespace && waitingPod.GetPod().Labels[util.PodGroupLabel] == pg.Name { + if waitingPod.GetPod().Namespace == pod.Namespace && waitingPod.GetPod().Labels[v1alpha1.PodGroupLabel] == pg.Name { klog.V(3).InfoS("PostFilter rejects the pod", "podGroup", klog.KObj(pg), "pod", klog.KObj(waitingPod.GetPod())) waitingPod.Reject(cs.Name(), "optimistic rejection in PostFilter") } @@ -222,7 +223,7 @@ func (cs *Coscheduling) Unreserve(ctx context.Context, state *framework.CycleSta return } cs.frameworkHandler.IterateOverWaitingPods(func(waitingPod framework.WaitingPod) { - if waitingPod.GetPod().Namespace == pod.Namespace && waitingPod.GetPod().Labels[util.PodGroupLabel] == pg.Name { + if waitingPod.GetPod().Namespace == pod.Namespace && waitingPod.GetPod().Labels[v1alpha1.PodGroupLabel] == pg.Name { klog.V(3).InfoS("Unreserve rejects", "pod", klog.KObj(waitingPod.GetPod()), "podGroup", klog.KObj(pg)) waitingPod.Reject(cs.Name(), "rejection in Unreserve") } diff --git a/pkg/coscheduling/coscheduling_test.go b/pkg/coscheduling/coscheduling_test.go index 00a1b09b0..db1c0598d 100644 --- a/pkg/coscheduling/coscheduling_test.go +++ b/pkg/coscheduling/coscheduling_test.go @@ -32,10 +32,10 @@ import ( st "k8s.io/kubernetes/pkg/scheduler/testing" _ "sigs.k8s.io/scheduler-plugins/pkg/apis/config/scheme" + "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" "sigs.k8s.io/scheduler-plugins/pkg/coscheduling/core" fakepgclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned/fake" pgformers "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions" - pgutil "sigs.k8s.io/scheduler-plugins/pkg/util" testutil "sigs.k8s.io/scheduler-plugins/test/util" ) @@ -145,7 +145,7 @@ func TestLess(t *testing.T) { { name: "p1.priority less than p2.priority, p1 belongs to podGroup1", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(lowPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(lowPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), }, p2: &framework.QueuedPodInfo{ PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Obj()), @@ -155,7 +155,7 @@ func TestLess(t *testing.T) { { name: "p1.priority greater than p2.priority, p1 belongs to podGroup1", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), }, p2: &framework.QueuedPodInfo{ PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(lowPriority).Obj()), @@ -165,7 +165,7 @@ func TestLess(t *testing.T) { { name: "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup3", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg3").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()), InitialAttemptTimestamp: times[0], }, p2: &framework.QueuedPodInfo{ @@ -177,7 +177,7 @@ func TestLess(t *testing.T) { { name: "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup3", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg3").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()), InitialAttemptTimestamp: times[1], }, p2: &framework.QueuedPodInfo{ @@ -190,31 +190,31 @@ func TestLess(t *testing.T) { { name: "p1.priority less than p2.priority, p1 belongs to podGroup1 and p2 belongs to podGroup2", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(lowPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(lowPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg2").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()), }, expected: false, // p2 should be ahead of p1 in the queue }, { name: "p1.priority greater than p2.priority, p1 belongs to podGroup1 and p2 belongs to podGroup2", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(lowPriority).Label(pgutil.PodGroupLabel, "pg2").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(lowPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()), }, expected: true, // p1 should be ahead of p2 in the queue }, { name: "equal priority. p1 is added to schedulingQ earlier than p2, p1 belongs to podGroup1 and p2 belongs to podGroup2", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), InitialAttemptTimestamp: times[0], }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg2").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()), InitialAttemptTimestamp: times[1], }, expected: true, // p1 should be ahead of p2 in the queue @@ -222,11 +222,11 @@ func TestLess(t *testing.T) { { name: "equal priority. p2 is added to schedulingQ earlier than p1, p1 belongs to podGroup4 and p2 belongs to podGroup3", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg4").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg4").Obj()), InitialAttemptTimestamp: times[1], }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg3").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg3").Obj()), InitialAttemptTimestamp: times[0], }, expected: false, // p2 should be ahead of p1 in the queue @@ -234,11 +234,11 @@ func TestLess(t *testing.T) { { name: "equal priority and creation time, p1 belongs to podGroup1 and p2 belongs to podGroup2", p1: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg1").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns1).Name("pod1").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg1").Obj()), InitialAttemptTimestamp: times[0], }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg2").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()), InitialAttemptTimestamp: times[0], }, expected: true, // p1 should be ahead of p2 in the queue @@ -250,7 +250,7 @@ func TestLess(t *testing.T) { InitialAttemptTimestamp: times[0], }, p2: &framework.QueuedPodInfo{ - PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(pgutil.PodGroupLabel, "pg2").Obj()), + PodInfo: framework.NewPodInfo(st.MakePod().Namespace(ns2).Name("pod2").Priority(highPriority).Label(v1alpha1.PodGroupLabel, "pg2").Obj()), InitialAttemptTimestamp: times[0], }, expected: true, // p1 should be ahead of p2 in the queue @@ -279,12 +279,12 @@ func TestPermit(t *testing.T) { }, { name: "pods belong to a podGroup, Wait", - pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(pgutil.PodGroupLabel, "pg1").Obj(), + pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(v1alpha1.PodGroupLabel, "pg1").Obj(), expected: framework.Wait, }, { name: "pods belong to a podGroup, Allow", - pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(pgutil.PodGroupLabel, "pg2").Obj(), + pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(v1alpha1.PodGroupLabel, "pg2").Obj(), expected: framework.Success, }, } @@ -363,7 +363,7 @@ func TestPostFilter(t *testing.T) { t.Fatal(err) } - existingPods, allNodes = testutil.MakeNodesAndPods(map[string]string{pgutil.PodGroupLabel: "pg"}, 10, 30) + existingPods, allNodes = testutil.MakeNodesAndPods(map[string]string{v1alpha1.PodGroupLabel: "pg"}, 10, 30) for _, pod := range existingPods { pod.Namespace = "ns1" } @@ -383,13 +383,13 @@ func TestPostFilter(t *testing.T) { }, { name: "enough pods assigned, do not reject all", - pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(pgutil.PodGroupLabel, "pg").Obj(), + pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(v1alpha1.PodGroupLabel, "pg").Obj(), expectedEmptyMsg: true, snapshotSharedLister: groupPodSnapshot, }, { name: "pod failed at filter phase, reject all pods", - pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(pgutil.PodGroupLabel, "pg").Obj(), + pod: st.MakePod().Name("pod1").Namespace("ns1").UID("pod1").Label(v1alpha1.PodGroupLabel, "pg").Obj(), expectedEmptyMsg: false, }, } diff --git a/pkg/util/constants.go b/pkg/util/constants.go deleted file mode 100644 index f03eb106b..000000000 --- a/pkg/util/constants.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package util - -const ( - // PodGroupLabel is the default label of coscheduling - PodGroupLabel = "pod-group.scheduling.sigs.k8s.io" -) diff --git a/pkg/util/podgroup.go b/pkg/util/podgroup.go index c9154a7c6..2fb22c560 100644 --- a/pkg/util/podgroup.go +++ b/pkg/util/podgroup.go @@ -49,7 +49,7 @@ func CreateMergePatch(original, new interface{}) ([]byte, error) { // GetPodGroupLabel get pod group from pod annotations func GetPodGroupLabel(pod *v1.Pod) string { - return pod.Labels[PodGroupLabel] + return pod.Labels[v1alpha1.PodGroupLabel] } // GetPodGroupFullName get namespaced group name from pod annotations diff --git a/test/integration/coscheduling_test.go b/test/integration/coscheduling_test.go index 7f1e9ecb1..7e5ed29ec 100644 --- a/test/integration/coscheduling_test.go +++ b/test/integration/coscheduling_test.go @@ -46,7 +46,6 @@ import ( "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" "sigs.k8s.io/scheduler-plugins/pkg/coscheduling" "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned" - coschedulingutil "sigs.k8s.io/scheduler-plugins/pkg/util" "sigs.k8s.io/scheduler-plugins/test/util" ) @@ -152,19 +151,19 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, sequentially pg1 meet min and pg2 not meet min", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t1-p2-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg1-2").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg1-1", ns.Name, 3, nil, nil), @@ -176,19 +175,19 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, not sequentially pg1 meet min and pg2 not meet min", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t2-p2-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg2-2").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg2-1", ns.Name, 3, nil, nil), @@ -200,15 +199,15 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, not sequentially pg1 not meet min and 3 regular pods", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t3-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t3-p2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( midPriority).ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t3-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t3-p3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( midPriority).ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t3-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg3-1").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg3-1", ns.Name, 4, nil, nil), @@ -219,17 +218,17 @@ func TestCoschedulingPlugin(t *testing.T) { name: "different priority, sequentially pg1 meet min and pg2 meet min", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg4-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t4-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg4-2").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg4-1", ns.Name, 3, nil, nil), @@ -241,17 +240,17 @@ func TestCoschedulingPlugin(t *testing.T) { name: "different priority, not sequentially pg1 meet min and pg2 meet min", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg5-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t5-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - highPriority).Label(coschedulingutil.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), + highPriority).Label(v1alpha1.PodGroupLabel, "pg5-2").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg5-1", ns.Name, 3, nil, nil), @@ -263,15 +262,15 @@ func TestCoschedulingPlugin(t *testing.T) { name: "different priority, not sequentially pg1 meet min and 3 regular pods", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( highPriority).ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( highPriority).ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg6-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t6-p4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( highPriority).ZeroTerminationGracePeriod().Obj(), pause), }, @@ -284,27 +283,27 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, not sequentially pg1 meet min and p2 p3 not meet min", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p3-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p3-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p3-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p2-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t7-p3-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg7-3").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg7-1", ns.Name, 3, nil, nil), @@ -317,27 +316,27 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, not sequentially pg1 meet min and p2 p3 not meet min, pgs have min resources", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p3-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p3-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p3-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p2-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t8-p3-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg8-3").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg8-1", ns.Name, 3, nil, &v1.ResourceList{v1.ResourceMemory: resource.MustParse("150")}), @@ -350,19 +349,19 @@ func TestCoschedulingPlugin(t *testing.T) { name: "equal priority, not sequentially pg1 meet min and pg2 not meet min, pgs have min resources", pods: []*v1.Pod{ WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p1-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p2-1").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p1-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p2-2").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p1-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "50"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-1").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p2-3").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), WithContainer(st.MakePod().Namespace(ns.Name).Name("t9-p2-4").Req(map[v1.ResourceName]string{v1.ResourceMemory: "100"}).Priority( - midPriority).Label(coschedulingutil.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), + midPriority).Label(v1alpha1.PodGroupLabel, "pg9-2").ZeroTerminationGracePeriod().Obj(), pause), }, podGroups: []*v1alpha1.PodGroup{ util.MakePG("pg9-1", ns.Name, 3, nil, &v1.ResourceList{v1.ResourceMemory: resource.MustParse("150")}),