diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index 84b73c44954f0..80caa04bda0e3 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -385,17 +385,45 @@ func buildQueueingHintMap(es []framework.EnqueueExtensions) internalqueue.Queuei // cannot be moved by any regular cluster event. // So, we can just ignore such EventsToRegister here. + registerNodeAdded := false + registerNodeUpdated := false for _, event := range events { fn := event.QueueingHintFn if fn == nil || !utilfeature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints) { fn = defaultQueueingHintFn } + if event.Event.Resource == framework.Node { + if event.Event.ActionType&framework.Add == 0 { + registerNodeAdded = true + } + if event.Event.ActionType&framework.Update == 0 { + registerNodeUpdated = true + } + } + queueingHintMap[event.Event] = append(queueingHintMap[event.Event], &internalqueue.QueueingHintFunction{ PluginName: e.Name(), QueueingHintFn: fn, }) } + if registerNodeAdded && !registerNodeUpdated { + // Temporally fix for the issue https://github.com/kubernetes/kubernetes/issues/109437 + // Currently, NodeAdded QueueingHint could not be called because of preCheck. + // It's definitely not something expected for plugin developers, + // and registering NodeUpdated event is the only mitigation for now. + // + // So, here, we'll register NodeUpdated event for plugins that has NodeAdded event, but doesn't have NodeUpdated event. + // It has a bad impact for the requeuing efficiency though, a lot better than some Pods being stuch in the + // unschedulable pod pool. + queueingHintMap[framework.ClusterEvent{Resource: framework.Node, ActionType: framework.Update}] = + append(queueingHintMap[framework.ClusterEvent{Resource: framework.Node, ActionType: framework.Update}], + &internalqueue.QueueingHintFunction{ + PluginName: e.Name(), + QueueingHintFn: defaultQueueingHintFn, + }, + ) + } } return queueingHintMap }