@@ -807,100 +807,148 @@ var _ = ginkgo.Describe("Scheduler", ginkgo.Ordered, ginkgo.ContinueOnFailure, f
807807 util .ExpectClusterQueueWeightedShareMetric (cqp1 , 445 )
808808 util .ExpectClusterQueueWeightedShareMetric (cqp2 , 556 )
809809 })
810+ })
810811
811- // kueue#6929
812- ginkgo .When ("ClusterQueue head has inadmissible workload" , func () {
813- var (
814- cq1 * kueue.ClusterQueue
815- cq2 * kueue.ClusterQueue
816- )
817- ginkgo .BeforeEach (func () {
818- fungibility := kueue.FlavorFungibility {
819- WhenCanBorrow : kueue .TryNextFlavor ,
820- WhenCanPreempt : kueue .TryNextFlavor ,
821- }
822- preemption := kueue.ClusterQueuePreemption {
823- ReclaimWithinCohort : kueue .PreemptionPolicyAny ,
824- WithinClusterQueue : kueue .PreemptionPolicyLowerPriority ,
812+ // kueue#6929
813+ ginkgo .When ("ClusterQueue head has inadmissible workload" , func () {
814+ var (
815+ cq1 * kueue.ClusterQueue
816+ cq2 * kueue.ClusterQueue
817+ cohortA * kueue.Cohort
818+ )
819+ ginkgo .BeforeEach (func () {
820+ fungibility := kueue.FlavorFungibility {
821+ WhenCanBorrow : kueue .TryNextFlavor ,
822+ WhenCanPreempt : kueue .TryNextFlavor ,
823+ }
824+ preemption := kueue.ClusterQueuePreemption {
825+ ReclaimWithinCohort : kueue .PreemptionPolicyAny ,
826+ WithinClusterQueue : kueue .PreemptionPolicyLowerPriority ,
827+ }
828+
829+ cohortA = createCohort (testing .MakeCohort ("cohort-a" ).
830+ Parent ("root" ).
831+ FairWeight (resource .MustParse ("1" )).
832+ ResourceGroup (
833+ * testing .MakeFlavorQuotas ("flavor1" ).Resource (corev1 .ResourceCPU , "3" ).Obj (),
834+ ).Obj ())
835+
836+ cq1 = createQueue (testing .MakeClusterQueue ("cq1" ).
837+ Cohort ("cohort-a" ).
838+ FairWeight (resource .MustParse ("1" )).
839+ ResourceGroup (
840+ * testing .MakeFlavorQuotas ("flavor1" ).Resource (corev1 .ResourceCPU , "0" ).Obj (),
841+ ).
842+ FlavorFungibility (fungibility ).
843+ Preemption (preemption ).
844+ Obj ())
845+
846+ cq2 = createQueue (testing .MakeClusterQueue ("cq2" ).
847+ Cohort ("root" ).
848+ FairWeight (resource .MustParse ("1" )).
849+ ResourceGroup (
850+ * testing .MakeFlavorQuotas ("flavor1" ).Resource (corev1 .ResourceCPU , "0" ).Obj (),
851+ ).
852+ FlavorFungibility (fungibility ).
853+ Preemption (preemption ).
854+ Obj ())
855+ })
856+
857+ ginkgo .It ("workload which fits behind ClusterQueue head is able to admit" , func () {
858+ ginkgo .By ("Creating borrowing workloads in queue2" )
859+ createWorkload ("cq2" , "1" )
860+ createWorkload ("cq2" , "1" )
861+ util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
862+
863+ ginkgo .By ("Create inadmissible workload in queue2" )
864+ createWorkloadWithPriority ("cq1" , "4" , 999 )
865+
866+ ginkgo .By ("Verify doesn't admit" )
867+ util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 0 )
868+
869+ ginkgo .By ("Create admissible workload in queue2" )
870+ createWorkloadWithPriority ("cq1" , "3" , 0 )
871+
872+ ginkgo .By ("Complete preemption" )
873+ util .FinishEvictionOfWorkloadsInCQ (ctx , k8sClient , cq2 , 2 )
874+
875+ ginkgo .By ("Expected Total Admitted Workloads and Weighted Share" )
876+ util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 1 )
877+ util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
878+ util .ExpectClusterQueueWeightedShareMetric (cq1 , 0 )
879+ util .ExpectClusterQueueWeightedShareMetric (cq2 , 0 )
880+ })
881+
882+ ginkgo .It ("sticky workload becomes inadmissible. next workload admits" , func () {
883+ ginkgo .By ("Creating borrowing workloads in queue2" )
884+ createWorkload ("cq2" , "1" )
885+ createWorkload ("cq2" , "1" )
886+ util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
887+
888+ ginkgo .By ("Create admissible workload in queue1" )
889+ createWorkloadWithPriority ("cq1" , "3" , 99 )
890+
891+ ginkgo .By ("Create another admissible workload in queue1" )
892+ createWorkloadWithPriority ("cq1" , "2" , 9 )
893+
894+ ginkgo .By ("Validate pending workloads" )
895+ util .ExpectPendingWorkloadsMetric (cq1 , 2 , 0 )
896+
897+ ginkgo .By ("Decreasing cluster capacity, making 99 priority workload inadmissible" )
898+ updatedCohort := & kueue.Cohort {}
899+ gomega .Eventually (func (g gomega.Gomega ) {
900+ g .Expect (k8sClient .Get (ctx , client .ObjectKeyFromObject (cohortA ), updatedCohort )).Should (gomega .Succeed ())
901+ updatedCohort .Spec .ResourceGroups [0 ].Flavors [0 ].Resources [0 ] = kueue.ResourceQuota {
902+ Name : corev1 .ResourceCPU ,
903+ NominalQuota : resource .MustParse ("2" ),
825904 }
905+ g .Expect (k8sClient .Update (ctx , updatedCohort )).Should (gomega .Succeed ())
906+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
826907
827- cq1 = createQueue (testing .MakeClusterQueue ("cq1" ).
828- Cohort ("root" ).
829- FairWeight (resource .MustParse ("1" )).
830- ResourceGroup (
831- * testing .MakeFlavorQuotas ("flavor1" ).Resource (corev1 .ResourceCPU , "3" ).Obj (),
832- ).
833- FlavorFungibility (fungibility ).
834- Preemption (preemption ).
835- Obj ())
836-
837- cq2 = createQueue (testing .MakeClusterQueue ("cq2" ).
838- Cohort ("root" ).
839- FairWeight (resource .MustParse ("1" )).
840- ResourceGroup (
841- * testing .MakeFlavorQuotas ("flavor1" ).Resource (corev1 .ResourceCPU , "0" ).Obj (),
842- ).
843- FlavorFungibility (fungibility ).
844- Preemption (preemption ).
845- Obj ())
846- })
847-
848- ginkgo .It ("workload which fits behind ClusterQueue head is able to admit" , func () {
849- ginkgo .By ("Creating borrowing workloads in queue2" )
850- createWorkload ("cq2" , "1" )
851- createWorkload ("cq2" , "1" )
852- util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
853-
854- ginkgo .By ("Create inadmissible workload in queue2" )
855- createWorkloadWithPriority ("cq1" , "4" , 999 )
856-
857- ginkgo .By ("Verify doesn't admit" )
858- util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 0 )
859-
860- ginkgo .By ("Create admissible workload in queue2" )
861- createWorkloadWithPriority ("cq1" , "3" , 0 )
862-
863- ginkgo .By ("Complete preemption" )
864- util .FinishEvictionOfWorkloadsInCQ (ctx , k8sClient , cq2 , 2 )
865-
866- ginkgo .By ("Expected Total Admitted Workloads and Weighted Share" )
908+ ginkgo .By ("Validate pending workloads" )
909+ util .ExpectPendingWorkloadsMetric (cq1 , 1 , 1 )
910+
911+ gomega .Eventually (func (g gomega.Gomega ) {
912+ util .FinishEvictionsOfAnyWorkloadsInCq (ctx , k8sClient , cq2 )
867913 util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 1 )
868- util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
869914 util .ExpectClusterQueueWeightedShareMetric (cq1 , 0 )
870915 util .ExpectClusterQueueWeightedShareMetric (cq2 , 0 )
871- })
916+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
917+ })
872918
873- ginkgo .It ("sticky workload deleted, next workload can admit" , func () {
874- ginkgo .By ("Creating borrowing workloads in queue2" )
875- createWorkload ("cq2" , "1" )
876- createWorkload ("cq2" , "1" )
877- util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
919+ ginkgo .It ("sticky workload deleted, next workload can admit" , func () {
920+ ginkgo .By ("Creating borrowing workloads in queue2" )
921+ createWorkload ("cq2" , "1" )
922+ createWorkload ("cq2" , "1" )
923+ util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
878924
879- ginkgo .By ("Create inadmissible workload in queue2 " )
880- createWorkloadWithPriority ("cq1" , "4" , 999 )
925+ ginkgo .By ("Create inadmissible workload in queue1 " )
926+ createWorkloadWithPriority ("cq1" , "4" , 999 )
881927
882- ginkgo .By ("Verify doesn't admit" )
883- util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 0 )
928+ ginkgo .By ("Verify doesn't admit" )
929+ util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 0 )
884930
885- ginkgo .By ("Create admissible workloads in queue2 " )
886- stickyWorkload := createWorkloadWithPriority ("cq1" , "3" , 99 )
931+ ginkgo .By ("Create admissible workloads in queue1 " )
932+ stickyWorkload := createWorkloadWithPriority ("cq1" , "3" , 99 )
887933
888- ginkgo .By ("Another admissible workload in queue2 " )
889- createWorkloadWithPriority ("cq1" , "3" , 0 )
934+ ginkgo .By ("Another admissible workload in queue1 " )
935+ createWorkloadWithPriority ("cq1" , "3" , 0 )
890936
891- ginkgo .By ("Delete sticky workload" )
892- util .ExpectObjectToBeDeleted (ctx , k8sClient , stickyWorkload , true )
937+ ginkgo .By ("Delete sticky workload" )
938+ util .ExpectObjectToBeDeleted (ctx , k8sClient , stickyWorkload , true )
893939
894- ginkgo .By ("Complete preemption " )
895- util .FinishEvictionOfWorkloadsInCQ ( ctx , k8sClient , cq2 , 2 )
940+ ginkgo .By ("Validate pending workloads " )
941+ util .ExpectPendingWorkloadsMetric ( cq1 , 1 , 1 )
896942
897- ginkgo .By ("Expected Total Admitted Workloads and Weighted Share" )
943+ ginkgo .By ("Expected Total Admitted Workloads and Weighted Share" )
944+ gomega .Eventually (func (g gomega.Gomega ) {
945+ util .FinishEvictionsOfAnyWorkloadsInCq (ctx , k8sClient , cq2 )
898946 util .ExpectAdmittedWorkloadsTotalMetric (cq1 , "" , 1 )
899- util .ExpectAdmittedWorkloadsTotalMetric (cq2 , "" , 2 )
900947 util .ExpectClusterQueueWeightedShareMetric (cq1 , 0 )
901948 util .ExpectClusterQueueWeightedShareMetric (cq2 , 0 )
902- })
949+ }, util . Timeout , util . Interval ). Should ( gomega . Succeed () )
903950 })
951+
904952 })
905953
906954 ginkgo .When ("Using AdmissionFairSharing at ClusterQueue level" , func () {
0 commit comments