Implemented function EventsToRegister for NodePorts

Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>

Added pod deletion event

Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>

Deleted node condition update event & added service deletion

Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>

Implemented function EventsToRegister for NodePorts

Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>

Deleted service deletion

Signed-off-by: Zhang Zhanpeng <zhanpeng.zhang@daocloud.io>

Added a comment to explain why not registering pod update events
This commit is contained in:
Zhang Zhanpeng 2021-03-09 19:54:53 +08:00
parent 04e0e52271
commit 2678f26944

View File

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