volumebinding: scheduler queueing hints - CSIStorageCapacity (#124961)
* volumebinding: scheduler queueing hints - CSIStorageCapacity * Fixed points mentioned in the review * Fixed points mentioned in the review * Update pkg/scheduler/framework/plugins/volumebinding/volume_binding.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Update pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go Co-authored-by: Kensei Nakada <handbomusic@gmail.com> * Fixed points mentioned in the review * volume_binding.go を更新 Co-authored-by: Kensei Nakada <handbomusic@gmail.com> --------- Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
This commit is contained in:
@@ -126,7 +126,7 @@ func (pl *VolumeBinding) EventsToRegister(_ context.Context) ([]framework.Cluste
|
||||
// When CSIStorageCapacity is enabled, pods may become schedulable
|
||||
// on CSI driver & storage capacity changes.
|
||||
{Event: framework.ClusterEvent{Resource: framework.CSIDriver, ActionType: framework.Add | framework.Update}},
|
||||
{Event: framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Add | framework.Update}},
|
||||
{Event: framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Add | framework.Update}, QueueingHintFn: pl.isSchedulableAfterCSIStorageCapacityChange},
|
||||
}
|
||||
return events, nil
|
||||
}
|
||||
@@ -228,6 +228,47 @@ func (pl *VolumeBinding) isSchedulableAfterStorageClassChange(logger klog.Logger
|
||||
return framework.QueueSkip, nil
|
||||
}
|
||||
|
||||
// isSchedulableAfterCSIStorageCapacityChange checks whether a CSIStorageCapacity event
|
||||
// might make a Pod schedulable or not.
|
||||
// Any CSIStorageCapacity addition and a CSIStorageCapacity update to volume limit
|
||||
// (calculated based on capacity and maximumVolumeSize) might make a Pod schedulable.
|
||||
// Note that an update to nodeTopology and storageClassName is not allowed and
|
||||
// we don't have to consider while examining the update event.
|
||||
func (pl *VolumeBinding) isSchedulableAfterCSIStorageCapacityChange(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) (framework.QueueingHint, error) {
|
||||
oldCap, newCap, err := util.As[*storagev1.CSIStorageCapacity](oldObj, newObj)
|
||||
if err != nil {
|
||||
return framework.Queue, err
|
||||
}
|
||||
|
||||
if oldCap == nil {
|
||||
logger.V(5).Info(
|
||||
"A new CSIStorageCapacity was created, which could make a Pod schedulable",
|
||||
"Pod", klog.KObj(pod),
|
||||
"CSIStorageCapacity", klog.KObj(newCap),
|
||||
)
|
||||
return framework.Queue, nil
|
||||
}
|
||||
|
||||
oldLimit := volumeLimit(oldCap)
|
||||
newLimit := volumeLimit(newCap)
|
||||
|
||||
logger = klog.LoggerWithValues(
|
||||
logger,
|
||||
"Pod", klog.KObj(pod),
|
||||
"CSIStorageCapacity", klog.KObj(newCap),
|
||||
"volumeLimit(new)", newLimit,
|
||||
"volumeLimit(old)", oldLimit,
|
||||
)
|
||||
|
||||
if newLimit != nil && (oldLimit == nil || newLimit.Value() > oldLimit.Value()) {
|
||||
logger.V(5).Info("VolumeLimit was increased, which could make a Pod schedulable")
|
||||
return framework.Queue, nil
|
||||
}
|
||||
|
||||
logger.V(5).Info("CSIStorageCapacity was updated, but it doesn't make this pod schedulable")
|
||||
return framework.QueueSkip, nil
|
||||
}
|
||||
|
||||
// podHasPVCs returns 2 values:
|
||||
// - the first one to denote if the given "pod" has any PVC defined.
|
||||
// - the second one to return any error if the requested PVC is illegal.
|
||||
|
||||
Reference in New Issue
Block a user