mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
implement EnqueueExtensions interface in volumebinding
This commit is contained in:
parent
defcc916ed
commit
83ee392ed4
@ -362,6 +362,14 @@ func addAllEventHandlers(
|
|||||||
informerFactory.Storage().V1().CSINodes().Informer().AddEventHandler(
|
informerFactory.Storage().V1().CSINodes().Informer().AddEventHandler(
|
||||||
buildEvtResHandler(at, framework.CSINode, "CSINode"),
|
buildEvtResHandler(at, framework.CSINode, "CSINode"),
|
||||||
)
|
)
|
||||||
|
case framework.CSIDriver:
|
||||||
|
informerFactory.Storage().V1().CSIDrivers().Informer().AddEventHandler(
|
||||||
|
buildEvtResHandler(at, framework.CSIDriver, "CSIDriver"),
|
||||||
|
)
|
||||||
|
case framework.CSIStorageCapacity:
|
||||||
|
informerFactory.Storage().V1beta1().CSIStorageCapacities().Informer().AddEventHandler(
|
||||||
|
buildEvtResHandler(at, framework.CSIStorageCapacity, "CSIStorageCapacity"),
|
||||||
|
)
|
||||||
case framework.PersistentVolume:
|
case framework.PersistentVolume:
|
||||||
// MaxPDVolumeCountPredicate: since it relies on the counts of PV.
|
// MaxPDVolumeCountPredicate: since it relies on the counts of PV.
|
||||||
//
|
//
|
||||||
@ -392,6 +400,15 @@ func addAllEventHandlers(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if at&framework.Update != 0 {
|
||||||
|
informerFactory.Storage().V1().StorageClasses().Informer().AddEventHandler(
|
||||||
|
cache.ResourceEventHandlerFuncs{
|
||||||
|
UpdateFunc: func(_, _ interface{}) {
|
||||||
|
sched.SchedulingQueue.MoveAllToActiveOrBackoffQueue(queue.StorageClassUpdate, nil)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
case framework.Service:
|
case framework.Service:
|
||||||
// ServiceAffinity: affected by the selector of the service is updated.
|
// ServiceAffinity: affected by the selector of the service is updated.
|
||||||
// Also, if new service is added, equivalence cache will also become invalid since
|
// Also, if new service is added, equivalence cache will also become invalid since
|
||||||
|
@ -81,6 +81,7 @@ var _ framework.FilterPlugin = &VolumeBinding{}
|
|||||||
var _ framework.ReservePlugin = &VolumeBinding{}
|
var _ framework.ReservePlugin = &VolumeBinding{}
|
||||||
var _ framework.PreBindPlugin = &VolumeBinding{}
|
var _ framework.PreBindPlugin = &VolumeBinding{}
|
||||||
var _ framework.ScorePlugin = &VolumeBinding{}
|
var _ framework.ScorePlugin = &VolumeBinding{}
|
||||||
|
var _ framework.EnqueueExtensions = &VolumeBinding{}
|
||||||
|
|
||||||
// Name is the name of the plugin used in Registry and configurations.
|
// Name is the name of the plugin used in Registry and configurations.
|
||||||
const Name = names.VolumeBinding
|
const Name = names.VolumeBinding
|
||||||
@ -90,6 +91,35 @@ func (pl *VolumeBinding) Name() string {
|
|||||||
return Name
|
return Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventsToRegister returns the possible events that may make a Pod
|
||||||
|
// failed by this plugin schedulable.
|
||||||
|
func (pl *VolumeBinding) EventsToRegister() []framework.ClusterEvent {
|
||||||
|
events := []framework.ClusterEvent{
|
||||||
|
// Pods may fail because of missing or mis-configured storage class
|
||||||
|
// (e.g., allowedTopologies, volumeBindingMode), and hence may become
|
||||||
|
// schedulable upon StorageClass Add or Update events.
|
||||||
|
{Resource: framework.StorageClass, ActionType: framework.Add | framework.Update},
|
||||||
|
// We bind PVCs with PVs, so any changes may make the pods schedulable.
|
||||||
|
{Resource: framework.PersistentVolumeClaim, ActionType: framework.Add | framework.Update},
|
||||||
|
{Resource: framework.PersistentVolume, ActionType: framework.Add | framework.Update},
|
||||||
|
// Pods may fail to find available PVs because the node labels do not
|
||||||
|
// match the storage class's allowed topologies or PV's node affinity.
|
||||||
|
// A new or updated node may make pods schedulable.
|
||||||
|
{Resource: framework.Node, ActionType: framework.Add | framework.Update},
|
||||||
|
// We rely on CSI node to translate in-tree PV to CSI.
|
||||||
|
{Resource: framework.CSINode, ActionType: framework.Add | framework.Update},
|
||||||
|
}
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity) {
|
||||||
|
// When CSIStorageCapacity is enabled, pods may become schedulable
|
||||||
|
// on CSI driver & storage capacity changes.
|
||||||
|
events = append(events, []framework.ClusterEvent{
|
||||||
|
{Resource: framework.CSIDriver, ActionType: framework.Add | framework.Update},
|
||||||
|
{Resource: framework.CSIStorageCapacity, ActionType: framework.Add | framework.Update},
|
||||||
|
}...)
|
||||||
|
}
|
||||||
|
return events
|
||||||
|
}
|
||||||
|
|
||||||
// podHasPVCs returns 2 values:
|
// podHasPVCs returns 2 values:
|
||||||
// - the first one to denote if the given "pod" has any PVC defined.
|
// - 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.
|
// - the second one to return any error if the requested PVC is illegal.
|
||||||
|
@ -69,6 +69,8 @@ const (
|
|||||||
Service GVK = "Service"
|
Service GVK = "Service"
|
||||||
StorageClass GVK = "storage.k8s.io/StorageClass"
|
StorageClass GVK = "storage.k8s.io/StorageClass"
|
||||||
CSINode GVK = "storage.k8s.io/CSINode"
|
CSINode GVK = "storage.k8s.io/CSINode"
|
||||||
|
CSIDriver GVK = "storage.k8s.io/CSIDriver"
|
||||||
|
CSIStorageCapacity GVK = "storage.k8s.io/CSIStorageCapacity"
|
||||||
WildCard GVK = "*"
|
WildCard GVK = "*"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,10 +61,20 @@ var (
|
|||||||
PvcUpdate = framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Update, Label: "PvcUpdate"}
|
PvcUpdate = framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Update, Label: "PvcUpdate"}
|
||||||
// StorageClassAdd is the event when a StorageClass is added in the cluster.
|
// StorageClassAdd is the event when a StorageClass is added in the cluster.
|
||||||
StorageClassAdd = framework.ClusterEvent{Resource: framework.StorageClass, ActionType: framework.Add, Label: "StorageClassAdd"}
|
StorageClassAdd = framework.ClusterEvent{Resource: framework.StorageClass, ActionType: framework.Add, Label: "StorageClassAdd"}
|
||||||
|
// StorageClassUpdate is the event when a StorageClass is updated in the cluster.
|
||||||
|
StorageClassUpdate = framework.ClusterEvent{Resource: framework.StorageClass, ActionType: framework.Update, Label: "StorageClassUpdate"}
|
||||||
// CSINodeAdd is the event when a CSI node is added in the cluster.
|
// CSINodeAdd is the event when a CSI node is added in the cluster.
|
||||||
CSINodeAdd = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Add, Label: "CSINodeAdd"}
|
CSINodeAdd = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Add, Label: "CSINodeAdd"}
|
||||||
// CSINodeUpdate is the event when a CSI node is updated in the cluster.
|
// CSINodeUpdate is the event when a CSI node is updated in the cluster.
|
||||||
CSINodeUpdate = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Update, Label: "CSINodeUpdate"}
|
CSINodeUpdate = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Update, Label: "CSINodeUpdate"}
|
||||||
|
// CSIDriverAdd is the event when a CSI node is added in the cluster.
|
||||||
|
CSIDriverAdd = framework.ClusterEvent{Resource: framework.CSIDriver, ActionType: framework.Add, Label: "CSIDriverAdd"}
|
||||||
|
// CSIDriverUpdate is the event when a CSI node is updated in the cluster.
|
||||||
|
CSIDriverUpdate = framework.ClusterEvent{Resource: framework.CSIDriver, ActionType: framework.Update, Label: "CSIDriverUpdate"}
|
||||||
|
// CSIStorageCapacityAdd is the event when a CSI node is added in the cluster.
|
||||||
|
CSIStorageCapacityAdd = framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Add, Label: "CSIStorageCapacityAdd"}
|
||||||
|
// CSIStorageCapacityUpdate is the event when a CSI node is updated in the cluster.
|
||||||
|
CSIStorageCapacityUpdate = framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Update, Label: "CSIStorageCapacityUpdate"}
|
||||||
// ServiceAdd is the event when a service is added in the cluster.
|
// ServiceAdd is the event when a service is added in the cluster.
|
||||||
ServiceAdd = framework.ClusterEvent{Resource: framework.Service, ActionType: framework.Add, Label: "ServiceAdd"}
|
ServiceAdd = framework.ClusterEvent{Resource: framework.Service, ActionType: framework.Add, Label: "ServiceAdd"}
|
||||||
// ServiceUpdate is the event when a service is updated in the cluster.
|
// ServiceUpdate is the event when a service is updated in the cluster.
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
"github.com/google/go-cmp/cmp/cmpopts"
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/clock"
|
"k8s.io/apimachinery/pkg/util/clock"
|
||||||
@ -447,8 +447,13 @@ func BenchmarkMoveAllToActiveOrBackoffQueue(b *testing.B) {
|
|||||||
PvAdd,
|
PvAdd,
|
||||||
PvUpdate,
|
PvUpdate,
|
||||||
StorageClassAdd,
|
StorageClassAdd,
|
||||||
|
StorageClassUpdate,
|
||||||
CSINodeAdd,
|
CSINodeAdd,
|
||||||
CSINodeUpdate,
|
CSINodeUpdate,
|
||||||
|
CSIDriverAdd,
|
||||||
|
CSIDriverUpdate,
|
||||||
|
CSIStorageCapacityAdd,
|
||||||
|
CSIStorageCapacityUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginNum := 20
|
pluginNum := 20
|
||||||
|
Loading…
Reference in New Issue
Block a user