Merge pull request #100090 from whypro/enqueue-extension

Implement EnqueueExtensions interface in volumerestrictions and volumezone.
This commit is contained in:
Kubernetes Prow Robot 2021-04-14 11:57:09 -07:00 committed by GitHub
commit e42f44588a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -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()