From f97dec28407b12bf071aacfa52f8fa351f24c080 Mon Sep 17 00:00:00 2001 From: kerthcet Date: Mon, 5 Feb 2024 11:46:59 +0800 Subject: [PATCH] Add comments about wildcard clusterEvent Signed-off-by: kerthcet --- pkg/scheduler/framework/types.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/framework/types.go b/pkg/scheduler/framework/types.go index 72c35eef8b6..fc79e4afe13 100644 --- a/pkg/scheduler/framework/types.go +++ b/pkg/scheduler/framework/types.go @@ -83,7 +83,15 @@ const ( CSINode GVK = "storage.k8s.io/CSINode" CSIDriver GVK = "storage.k8s.io/CSIDriver" CSIStorageCapacity GVK = "storage.k8s.io/CSIStorageCapacity" - WildCard GVK = "*" + + // WildCard is a special GVK to match all resources. + // e.g., If you register `{Resource: "*", ActionType: All}` in EventsToRegister, + // all coming clusterEvents will be admitted. Be careful to register it, it will + // increase the computing pressure in requeueing unless you really need it. + // + // Meanwhile, if the coming clusterEvent is a wildcard one, all pods + // will be moved from unschedulablePod pool to activeQ/backoffQ forcibly. + WildCard GVK = "*" ) type ClusterEventWithHint struct { @@ -147,6 +155,10 @@ func (ce ClusterEvent) IsWildCard() bool { // Match returns true if ClusterEvent is matched with the coming event. // If the ce.Resource is "*", there's no requirement for the coming event' Resource. // Contrarily, if the coming event's Resource is "*", the ce.Resource should only be "*". +// +// Note: we have a special case here when the coming event is a wildcard event, +// it will force all Pods to move to activeQ/backoffQ, +// but we take it as an unmatched event unless the ce is also a wildcard one. func (ce ClusterEvent) Match(event ClusterEvent) bool { return ce.IsWildCard() || (ce.Resource == WildCard || ce.Resource == event.Resource) && ce.ActionType&event.ActionType != 0 }