From 2678f269447c3e84448f3225f7b9584e68f5186d Mon Sep 17 00:00:00 2001 From: Zhang Zhanpeng Date: Tue, 9 Mar 2021 19:54:53 +0800 Subject: [PATCH] Implemented function EventsToRegister for NodePorts Signed-off-by: Zhang Zhanpeng Added pod deletion event Signed-off-by: Zhang Zhanpeng Deleted node condition update event & added service deletion Signed-off-by: Zhang Zhanpeng Implemented function EventsToRegister for NodePorts Signed-off-by: Zhang Zhanpeng Deleted service deletion Signed-off-by: Zhang Zhanpeng Added a comment to explain why not registering pod update events --- .../framework/plugins/nodeports/node_ports.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/scheduler/framework/plugins/nodeports/node_ports.go b/pkg/scheduler/framework/plugins/nodeports/node_ports.go index 1006655b5eb..9b665599e75 100644 --- a/pkg/scheduler/framework/plugins/nodeports/node_ports.go +++ b/pkg/scheduler/framework/plugins/nodeports/node_ports.go @@ -30,6 +30,7 @@ type NodePorts struct{} var _ framework.PreFilterPlugin = &NodePorts{} var _ framework.FilterPlugin = &NodePorts{} +var _ framework.EnqueueExtensions = &NodePorts{} const ( // Name is the name of the plugin used in the plugin registry and configurations. @@ -97,6 +98,16 @@ func getPreFilterState(cycleState *framework.CycleState) (preFilterState, error) return s, nil } +// EventsToRegister returns the possible events that may make a Pod +// failed by this plugin schedulable. +func (pl *NodePorts) EventsToRegister() []framework.ClusterEvent { + return []framework.ClusterEvent{ + // Due to immutable fields `spec.containers[*].ports`, pod update events are ignored. + {Resource: framework.Pod, ActionType: framework.Delete}, + {Resource: framework.Node, ActionType: framework.Add}, + } +} + // Filter invoked at the filter extension point. func (pl *NodePorts) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { wantPorts, err := getPreFilterState(cycleState)