@@ -25,6 +25,7 @@ import (
25
25
26
26
v1 "k8s.io/api/core/v1"
27
27
storagev1 "k8s.io/api/storage/v1"
28
+ apiequality "k8s.io/apimachinery/pkg/api/equality"
28
29
apierrors "k8s.io/apimachinery/pkg/api/errors"
29
30
"k8s.io/apimachinery/pkg/runtime"
30
31
corelisters "k8s.io/client-go/listers/core/v1"
@@ -98,7 +99,7 @@ func (pl *VolumeBinding) EventsToRegister() []framework.ClusterEventWithHint {
98
99
// Pods may fail because of missing or mis-configured storage class
99
100
// (e.g., allowedTopologies, volumeBindingMode), and hence may become
100
101
// schedulable upon StorageClass Add or Update events.
101
- {Event : framework.ClusterEvent {Resource : framework .StorageClass , ActionType : framework .Add | framework .Update }},
102
+ {Event : framework.ClusterEvent {Resource : framework .StorageClass , ActionType : framework .Add | framework .Update }, QueueingHintFn : pl . isSchedulableAfterStorageClassChange },
102
103
103
104
// We bind PVCs with PVs, so any changes may make the pods schedulable.
104
105
{Event : framework.ClusterEvent {Resource : framework .PersistentVolumeClaim , ActionType : framework .Add | framework .Update }, QueueingHintFn : pl .isSchedulableAfterPersistentVolumeClaimChange },
@@ -195,6 +196,38 @@ func (pl *VolumeBinding) isSchedulableAfterPersistentVolumeClaimChange(logger kl
195
196
return framework .QueueSkip , nil
196
197
}
197
198
199
+ // isSchedulableAfterStorageClassChange checks whether an StorageClass event might make a Pod schedulable or not.
200
+ // Any StorageClass addition and a StorageClass update to allowedTopologies
201
+ // might make a Pod schedulable.
202
+ // Note that an update to volume binding mode is not allowed and we don't have to consider while examining the update event.
203
+ func (pl * VolumeBinding ) isSchedulableAfterStorageClassChange (logger klog.Logger , pod * v1.Pod , oldObj , newObj interface {}) (framework.QueueingHint , error ) {
204
+ oldSC , newSC , err := util .As [* storagev1.StorageClass ](oldObj , newObj )
205
+ if err != nil {
206
+ return framework .Queue , err
207
+ }
208
+
209
+ logger = klog .LoggerWithValues (
210
+ logger ,
211
+ "Pod" , klog .KObj (pod ),
212
+ "StorageClass" , klog .KObj (newSC ),
213
+ )
214
+
215
+ if oldSC == nil {
216
+ // No further filtering can be made for a creation event,
217
+ // and we just always return Queue.
218
+ logger .V (5 ).Info ("A new StorageClass was created, which could make a Pod schedulable" )
219
+ return framework .Queue , nil
220
+ }
221
+
222
+ if ! apiequality .Semantic .DeepEqual (newSC .AllowedTopologies , oldSC .AllowedTopologies ) {
223
+ logger .V (5 ).Info ("StorageClass got an update in AllowedTopologies" , "AllowedTopologies" , newSC .AllowedTopologies )
224
+ return framework .Queue , nil
225
+ }
226
+
227
+ logger .V (5 ).Info ("StorageClass was updated, but it doesn't make this pod schedulable" )
228
+ return framework .QueueSkip , nil
229
+ }
230
+
198
231
// podHasPVCs returns 2 values:
199
232
// - the first one to denote if the given "pod" has any PVC defined.
200
233
// - the second one to return any error if the requested PVC is illegal.
0 commit comments