@@ -70,6 +70,7 @@ func podWithRequests(namespace, name, pgName, schedulerName, cpu, memory string)
7070 commonconstants .PodGroupAnnotationForPod : pgName ,
7171 },
7272 },
73+ Status : corev1.PodStatus {Phase : corev1 .PodRunning },
7374 Spec : corev1.PodSpec {
7475 SchedulerName : schedulerName ,
7576 Containers : []corev1.Container {
@@ -407,6 +408,7 @@ func TestPodResizeValidator_SidecarUpsize_DeniedWhenLimitExceeded(t *testing.T)
407408 commonconstants .PodGroupAnnotationForPod : "pg" ,
408409 },
409410 },
411+ Status : corev1.PodStatus {Phase : corev1 .PodRunning },
410412 Spec : corev1.PodSpec {
411413 SchedulerName : testSchedulerName ,
412414 InitContainers : []corev1.Container {
@@ -476,6 +478,7 @@ func TestPodResizeValidator_Redistribution_AllowedAtLimit(t *testing.T) {
476478 commonconstants .PodGroupAnnotationForPod : "pg" ,
477479 },
478480 },
481+ Status : corev1.PodStatus {Phase : corev1 .PodRunning },
479482 Spec : corev1.PodSpec {
480483 SchedulerName : testSchedulerName ,
481484 Containers : []corev1.Container {
@@ -529,3 +532,37 @@ func TestPodResizeValidator_InitPeakDominates_NoDelta(t *testing.T) {
529532 _ , err := v .ValidateUpdate (context .Background (), oldPod , newPod )
530533 assert .NoError (t , err , "queue charge is unchanged, so the resize must be admitted at the limit" )
531534}
535+
536+ func TestPodResizeValidator_PendingUnscheduled_NotValidated (t * testing.T ) {
537+ scheme := buildScheme ()
538+ // Queue already at its limit — a checked upsize would be denied.
539+ queue := newQueue ("q" , 2000 , - 1 , 0 , "2" , "0" )
540+ pg := newPodGroup ("pg" , "ns" , "q" )
541+ c := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (queue , pg ).Build ()
542+ v := NewPodResizeValidator (c , testSchedulerName , true , false )
543+
544+ oldPod := podWithRequests ("ns" , "p" , "pg" , testSchedulerName , "1" , "0" )
545+ oldPod .Status .Phase = corev1 .PodPending
546+ newPod := podWithRequests ("ns" , "p" , "pg" , testSchedulerName , "5" , "0" )
547+
548+ _ , err := v .ValidateUpdate (context .Background (), oldPod , newPod )
549+ assert .NoError (t , err , "unscheduled pending pod resize must not be quota-checked" )
550+ }
551+
552+ func TestPodResizeValidator_PendingScheduled_StillValidated (t * testing.T ) {
553+ scheme := buildScheme ()
554+ queue := newQueue ("q" , 2000 , - 1 , 0 , "2" , "0" )
555+ pg := newPodGroup ("pg" , "ns" , "q" )
556+ c := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (queue , pg ).Build ()
557+ v := NewPodResizeValidator (c , testSchedulerName , true , false )
558+
559+ oldPod := podWithRequests ("ns" , "p" , "pg" , testSchedulerName , "1" , "0" )
560+ oldPod .Status .Phase = corev1 .PodPending
561+ oldPod .Status .Conditions = []corev1.PodCondition {
562+ {Type : corev1 .PodScheduled , Status : corev1 .ConditionTrue },
563+ }
564+ newPod := podWithRequests ("ns" , "p" , "pg" , testSchedulerName , "5" , "0" )
565+
566+ _ , err := v .ValidateUpdate (context .Background (), oldPod , newPod )
567+ assert .Error (t , err , "scheduled pending pod holds capacity and must be checked" )
568+ }
0 commit comments