@@ -24,6 +24,7 @@ import (
24
24
common "github.com/kubeflow/common/pkg/apis/common/v1"
25
25
batchv1 "k8s.io/api/batch/v1"
26
26
corev1 "k8s.io/api/core/v1"
27
+ schedulingv1 "k8s.io/api/scheduling/v1"
27
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
29
"k8s.io/apimachinery/pkg/labels"
29
30
"k8s.io/apimachinery/pkg/util/runtime"
@@ -490,6 +491,7 @@ func TestMPIJobWithSchedulerPlugins(t *testing.T) {
490
491
kubeflow .MPIReplicaTypeLauncher : {
491
492
Template : corev1.PodTemplateSpec {
492
493
Spec : corev1.PodSpec {
494
+ PriorityClassName : "test-pc" ,
493
495
Containers : []corev1.Container {
494
496
{
495
497
Name : "main" ,
@@ -515,8 +517,24 @@ func TestMPIJobWithSchedulerPlugins(t *testing.T) {
515
517
},
516
518
},
517
519
}
518
- // 1. Create MPIJob
520
+ priorityClass := & schedulingv1.PriorityClass {
521
+ TypeMeta : metav1.TypeMeta {
522
+ APIVersion : schedulingv1 .SchemeGroupVersion .String (),
523
+ Kind : "PriorityClass" ,
524
+ },
525
+ ObjectMeta : metav1.ObjectMeta {
526
+ Name : "test-pc" ,
527
+ },
528
+ Value : 100_000 ,
529
+ }
530
+ // 1. Create PriorityClass
519
531
var err error
532
+ _ , err = s .kClient .SchedulingV1 ().PriorityClasses ().Create (ctx , priorityClass , metav1.CreateOptions {})
533
+ if err != nil {
534
+ t .Fatalf ("Failed sending priorityClass to apiserver: %v" , err )
535
+ }
536
+
537
+ // 2. Create MPIJob
520
538
mpiJob , err = s .mpiClient .KubeflowV2beta1 ().MPIJobs (s .namespace ).Create (ctx , mpiJob , metav1.CreateOptions {})
521
539
if err != nil {
522
540
t .Fatalf ("Failed sending job to apiserver: %v" , err )
@@ -537,7 +555,7 @@ func TestMPIJobWithSchedulerPlugins(t *testing.T) {
537
555
}
538
556
s .events .verify (t )
539
557
540
- // 2 . Update SchedulingPolicy of MPIJob
558
+ // 3 . Update SchedulingPolicy of MPIJob
541
559
updatedScheduleTimeSeconds := int32 (10 )
542
560
mpiJob .Spec .RunPolicy .SchedulingPolicy .ScheduleTimeoutSeconds = & updatedScheduleTimeSeconds
543
561
mpiJob , err = s .mpiClient .KubeflowV2beta1 ().MPIJobs (s .namespace ).Update (ctx , mpiJob , metav1.UpdateOptions {})
@@ -567,11 +585,12 @@ func startController(
567
585
var podGroupCtrl controller.PodGroupControl
568
586
var priorityClassInformer schedulinginformers.PriorityClassInformer
569
587
if gangSchedulerCfg != nil {
570
- priorityClassInformer = kubeInformerFactory .Scheduling ().V1 ().PriorityClasses ()
571
588
if gangSchedulerCfg .schedulerName == "volcano" {
572
589
podGroupCtrl = controller .NewVolcanoCtrl (gangSchedulerCfg .volcanoClient , metav1 .NamespaceAll )
573
590
} else if len (gangSchedulerCfg .schedulerName ) != 0 {
574
- podGroupCtrl = controller .NewSchedulerPluginsCtrl (gangSchedulerCfg .schedClient , metav1 .NamespaceAll , gangSchedulerCfg .schedulerName )
591
+ priorityClassInformer = kubeInformerFactory .Scheduling ().V1 ().PriorityClasses ()
592
+ podGroupCtrl = controller .NewSchedulerPluginsCtrl (
593
+ gangSchedulerCfg .schedClient , metav1 .NamespaceAll , gangSchedulerCfg .schedulerName , priorityClassInformer .Lister ())
575
594
}
576
595
}
577
596
0 commit comments