@@ -46,27 +46,6 @@ import (
46
46
"k8s.io/kubernetes/pkg/scheduler/util/assumecache"
47
47
)
48
48
49
- func (sched * Scheduler ) onStorageClassAdd (obj interface {}) {
50
- start := time .Now ()
51
- defer metrics .EventHandlingLatency .WithLabelValues (framework .StorageClassAdd .Label ).Observe (metrics .SinceInSeconds (start ))
52
- logger := sched .logger
53
- sc , ok := obj .(* storagev1.StorageClass )
54
- if ! ok {
55
- logger .Error (nil , "Cannot convert to *storagev1.StorageClass" , "obj" , obj )
56
- return
57
- }
58
-
59
- // CheckVolumeBindingPred fails if pod has unbound immediate PVCs. If these
60
- // PVCs have specified StorageClass name, creating StorageClass objects
61
- // with late binding will cause predicates to pass, so we need to move pods
62
- // to active queue.
63
- // We don't need to invalidate cached results because results will not be
64
- // cached for pod that has unbound immediate PVCs.
65
- if sc .VolumeBindingMode != nil && * sc .VolumeBindingMode == storagev1 .VolumeBindingWaitForFirstConsumer {
66
- sched .SchedulingQueue .MoveAllToActiveOrBackoffQueue (logger , framework .StorageClassAdd , nil , sc , nil )
67
- }
68
- }
69
-
70
49
func (sched * Scheduler ) addNodeToCache (obj interface {}) {
71
50
start := time .Now ()
72
51
defer metrics .EventHandlingLatency .WithLabelValues (framework .NodeAdd .Label ).Observe (metrics .SinceInSeconds (start ))
@@ -437,8 +416,25 @@ func addAllEventHandlers(
437
416
evt := framework.ClusterEvent {Resource : gvk , ActionType : framework .Add , Label : label }
438
417
funcs .AddFunc = func (obj interface {}) {
439
418
start := time .Now ()
419
+ defer metrics .EventHandlingLatency .WithLabelValues (label ).Observe (metrics .SinceInSeconds (start ))
420
+ if gvk == framework .StorageClass && ! utilfeature .DefaultFeatureGate .Enabled (features .SchedulerQueueingHints ) {
421
+ sc , ok := obj .(* storagev1.StorageClass )
422
+ if ! ok {
423
+ logger .Error (nil , "Cannot convert to *storagev1.StorageClass" , "obj" , obj )
424
+ return
425
+ }
426
+
427
+ // CheckVolumeBindingPred fails if pod has unbound immediate PVCs. If these
428
+ // PVCs have specified StorageClass name, creating StorageClass objects
429
+ // with late binding will cause predicates to pass, so we need to move pods
430
+ // to active queue.
431
+ // We don't need to invalidate cached results because results will not be
432
+ // cached for pod that has unbound immediate PVCs.
433
+ if sc .VolumeBindingMode == nil || * sc .VolumeBindingMode != storagev1 .VolumeBindingWaitForFirstConsumer {
434
+ return
435
+ }
436
+ }
440
437
sched .SchedulingQueue .MoveAllToActiveOrBackoffQueue (logger , evt , nil , obj , nil )
441
- metrics .EventHandlingLatency .WithLabelValues (label ).Observe (metrics .SinceInSeconds (start ))
442
438
}
443
439
}
444
440
if at & framework .Update != 0 {
@@ -550,30 +546,12 @@ func addAllEventHandlers(
550
546
handlers = append (handlers , handlerRegistration )
551
547
}
552
548
case framework .StorageClass :
553
- if at & framework .Add != 0 {
554
- if handlerRegistration , err = informerFactory .Storage ().V1 ().StorageClasses ().Informer ().AddEventHandler (
555
- cache.ResourceEventHandlerFuncs {
556
- AddFunc : sched .onStorageClassAdd ,
557
- },
558
- ); err != nil {
559
- return err
560
- }
561
- handlers = append (handlers , handlerRegistration )
562
- }
563
- if at & framework .Update != 0 {
564
- if handlerRegistration , err = informerFactory .Storage ().V1 ().StorageClasses ().Informer ().AddEventHandler (
565
- cache.ResourceEventHandlerFuncs {
566
- UpdateFunc : func (old , obj interface {}) {
567
- start := time .Now ()
568
- defer metrics .EventHandlingLatency .WithLabelValues (framework .StorageClassUpdate .Label ).Observe (metrics .SinceInSeconds (start ))
569
- sched .SchedulingQueue .MoveAllToActiveOrBackoffQueue (logger , framework .StorageClassUpdate , old , obj , nil )
570
- },
571
- },
572
- ); err != nil {
573
- return err
574
- }
575
- handlers = append (handlers , handlerRegistration )
549
+ if handlerRegistration , err = informerFactory .Storage ().V1 ().StorageClasses ().Informer ().AddEventHandler (
550
+ buildEvtResHandler (at , framework .StorageClass , "StorageClass" ),
551
+ ); err != nil {
552
+ return err
576
553
}
554
+ handlers = append (handlers , handlerRegistration )
577
555
default :
578
556
// Tests may not instantiate dynInformerFactory.
579
557
if dynInformerFactory == nil {
0 commit comments