mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
use PodUpdateOther internally
This commit is contained in:
@@ -48,10 +48,11 @@ type ActionType int64
|
||||
const (
|
||||
Add ActionType = 1 << iota
|
||||
Delete
|
||||
|
||||
// UpdateNodeXYZ is only applicable for Node events.
|
||||
// If you use UpdateNodeXYZ,
|
||||
// your plugin's QueueingHint is only executed for the specific sub-Update event.
|
||||
// It's better to narrow down the scope of the event by specifying them
|
||||
// It's better to narrow down the scope of the event by using them instead of just using Update event
|
||||
// for better performance in requeueing.
|
||||
UpdateNodeAllocatable
|
||||
UpdateNodeLabel
|
||||
@@ -60,9 +61,19 @@ const (
|
||||
UpdateNodeAnnotation
|
||||
|
||||
// UpdatePodXYZ is only applicable for Pod events.
|
||||
// If you use UpdatePodXYZ,
|
||||
// your plugin's QueueingHint is only executed for the specific sub-Update event.
|
||||
// It's better to narrow down the scope of the event by using them instead of Update event
|
||||
// for better performance in requeueing.
|
||||
UpdatePodLabel
|
||||
// UpdatePodRequest is a update for pod's resource request calculated by resource.PodRequests() function.
|
||||
UpdatePodRequest
|
||||
// UpdatePodOther is a update for pod's other fields.
|
||||
// NOT RECOMMENDED using it in your plugin's EventsToRegister,
|
||||
// use Pod/Update instead when you have to subscribe Pod updates which are not covered by other UpdatePodXYZ events.
|
||||
// Otherwise, your plugin would be broken when the upstream supports a new Pod specific Update event.
|
||||
// It's used only for the internal event handling.
|
||||
UpdatePodOther
|
||||
|
||||
All ActionType = 1<<iota - 1
|
||||
|
||||
@@ -190,25 +201,14 @@ func (ce ClusterEvent) IsWildCard() bool {
|
||||
}
|
||||
|
||||
// Match returns true if ClusterEvent is matched with the coming event.
|
||||
// "match" means the coming event is the same or more specific than the ce.
|
||||
// i.e., when ce.ActionType is Update, it return true if a coming event is UpdateNodeLabel
|
||||
// because UpdateNodeLabel is more specific than Update.
|
||||
// On the other hand, when ce.ActionType is UpdateNodeLabel, it doesn't return true if a coming event is Update.
|
||||
// This is based on the fact that the scheduler interprets the coming cluster event as specific event if possible;
|
||||
// meaning, if a coming event is Node/Update,
|
||||
// it means that Node's update is not something that can be interpreted as any of Node's specific Update events.
|
||||
//
|
||||
// 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 "*".
|
||||
// (which should never happen in the current implementation of the scheduling queue.)
|
||||
//
|
||||
// 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(comingEvent ClusterEvent) bool {
|
||||
return ce.IsWildCard() ||
|
||||
(ce.Resource == WildCard || ce.Resource == comingEvent.Resource) &&
|
||||
(ce.ActionType&comingEvent.ActionType != 0 && comingEvent.ActionType <= ce.ActionType)
|
||||
func (ce ClusterEvent) Match(event ClusterEvent) bool {
|
||||
return ce.IsWildCard() || (ce.Resource == WildCard || ce.Resource == event.Resource) && ce.ActionType&event.ActionType != 0
|
||||
}
|
||||
|
||||
func UnrollWildCardResource() []ClusterEventWithHint {
|
||||
|
@@ -1626,16 +1626,9 @@ func TestCloudEvent_Match(t *testing.T) {
|
||||
wantResult: true,
|
||||
},
|
||||
{
|
||||
name: "no match if a coming event is less specific",
|
||||
event: ClusterEvent{Resource: Node, ActionType: UpdateNodeLabel},
|
||||
comingEvent: ClusterEvent{Resource: Node, ActionType: Update},
|
||||
wantResult: false,
|
||||
},
|
||||
{
|
||||
name: "match if a coming event is more specific",
|
||||
event: ClusterEvent{Resource: Node, ActionType: Update},
|
||||
comingEvent: ClusterEvent{Resource: Node, ActionType: UpdateNodeLabel},
|
||||
wantResult: true,
|
||||
name: "event with resource = 'Pod' matching with coming events carries same actionType",
|
||||
event: ClusterEvent{Resource: Pod, ActionType: UpdateNodeLabel | UpdateNodeTaint},
|
||||
comingEvent: ClusterEvent{Resource: Pod, ActionType: UpdateNodeLabel},
|
||||
},
|
||||
{
|
||||
name: "event with resource = '*' matching with coming events carries same actionType",
|
||||
|
@@ -50,6 +50,8 @@ var (
|
||||
AssignedPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "AssignedPodUpdate"}
|
||||
// UnscheduledPodAdd is the event when an unscheduled pod is added.
|
||||
UnscheduledPodAdd = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "UnschedulablePodAdd"}
|
||||
// AssignedPodOtherUpdate is the event when an assigned pod got updated in fields that are not covered by framework.UpdatePodXXX.
|
||||
AssignedPodOtherUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.UpdatePodOther, Label: "AssignedPodUpdate"}
|
||||
// UnscheduledPodUpdate is the event when an unscheduled pod is updated.
|
||||
UnscheduledPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "UnschedulablePodUpdate"}
|
||||
// UnscheduledPodDelete is the event when an unscheduled pod is deleted.
|
||||
@@ -117,7 +119,9 @@ func PodSchedulingPropertiesChange(newPod *v1.Pod, oldPod *v1.Pod) (events []fra
|
||||
}
|
||||
|
||||
if len(events) == 0 {
|
||||
events = append(events, AssignedPodUpdate)
|
||||
// When no specific event is found, we use AssignedPodOtherUpdate,
|
||||
// which should only trigger plugins registering a general Pod/Update event.
|
||||
events = append(events, AssignedPodOtherUpdate)
|
||||
}
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user