diff --git a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go index c1cdafe6194..faf8d02175a 100644 --- a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go +++ b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go @@ -29,6 +29,7 @@ import ( type VolumeRestrictions struct{} var _ framework.FilterPlugin = &VolumeRestrictions{} +var _ framework.EnqueueExtensions = &VolumeRestrictions{} // Name is the name of the plugin used in the plugin registry and configurations. const Name = "VolumeRestrictions" @@ -130,6 +131,19 @@ func (pl *VolumeRestrictions) Filter(ctx context.Context, _ *framework.CycleStat return nil } +// EventsToRegister returns the possible events that may make a Pod +// failed by this plugin schedulable. +func (pl *VolumeRestrictions) EventsToRegister() []framework.ClusterEvent { + return []framework.ClusterEvent{ + // Pods may fail to schedule because of volumes conflicting with other pods on same node. + // Once running pods are deleted and volumes have been released, the unschedulable pod will be schedulable. + // Due to immutable fields `spec.volumes`, pod update events are ignored. + {Resource: framework.Pod, ActionType: framework.Delete}, + // A new Node may make a pod schedulable. + {Resource: framework.Node, ActionType: framework.Add}, + } +} + // New initializes a new plugin and returns it. func New(_ runtime.Object, _ framework.Handle) (framework.Plugin, error) { return &VolumeRestrictions{}, nil diff --git a/pkg/scheduler/framework/plugins/volumezone/volume_zone.go b/pkg/scheduler/framework/plugins/volumezone/volume_zone.go index b50baf6e811..05fa89d7b82 100644 --- a/pkg/scheduler/framework/plugins/volumezone/volume_zone.go +++ b/pkg/scheduler/framework/plugins/volumezone/volume_zone.go @@ -40,6 +40,7 @@ type VolumeZone struct { } var _ framework.FilterPlugin = &VolumeZone{} +var _ framework.EnqueueExtensions = &VolumeZone{} const ( // Name is the name of the plugin used in the plugin registry and configurations. @@ -171,6 +172,23 @@ func (pl *VolumeZone) Filter(ctx context.Context, _ *framework.CycleState, pod * return nil } +// EventsToRegister returns the possible events that may make a Pod +// failed by this plugin schedulable. +func (pl *VolumeZone) EventsToRegister() []framework.ClusterEvent { + return []framework.ClusterEvent{ + // New storageClass with bind mode `VolumeBindingWaitForFirstConsumer` will make a pod schedulable. + // Due to immutable field `storageClass.volumeBindingMode`, storageClass update events are ignored. + {Resource: framework.StorageClass, ActionType: framework.Add}, + // A new node or updating a node's volume zone labels may make a pod schedulable. + {Resource: framework.Node, ActionType: framework.Add | framework.UpdateNodeLabel}, + // A new pvc may make a pod schedulable. + // Due to fields are immutable except `spec.resources`, pvc update events are ignored. + {Resource: framework.PersistentVolumeClaim, ActionType: framework.Add}, + // A new pv or updating a pv's volume zone labels may make a pod shedulable. + {Resource: framework.PersistentVolume, ActionType: framework.Add | framework.Update}, + } +} + // New initializes a new plugin and returns it. func New(_ runtime.Object, handle framework.Handle) (framework.Plugin, error) { informerFactory := handle.SharedInformerFactory()