mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
use PodUpdateOther internally
This commit is contained in:
@@ -48,10 +48,11 @@ type ActionType int64
|
|||||||
const (
|
const (
|
||||||
Add ActionType = 1 << iota
|
Add ActionType = 1 << iota
|
||||||
Delete
|
Delete
|
||||||
|
|
||||||
// UpdateNodeXYZ is only applicable for Node events.
|
// UpdateNodeXYZ is only applicable for Node events.
|
||||||
// If you use UpdateNodeXYZ,
|
// If you use UpdateNodeXYZ,
|
||||||
// your plugin's QueueingHint is only executed for the specific sub-Update event.
|
// 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.
|
// for better performance in requeueing.
|
||||||
UpdateNodeAllocatable
|
UpdateNodeAllocatable
|
||||||
UpdateNodeLabel
|
UpdateNodeLabel
|
||||||
@@ -60,9 +61,19 @@ const (
|
|||||||
UpdateNodeAnnotation
|
UpdateNodeAnnotation
|
||||||
|
|
||||||
// UpdatePodXYZ is only applicable for Pod events.
|
// 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
|
UpdatePodLabel
|
||||||
// UpdatePodRequest is a update for pod's resource request calculated by resource.PodRequests() function.
|
// UpdatePodRequest is a update for pod's resource request calculated by resource.PodRequests() function.
|
||||||
UpdatePodRequest
|
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
|
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 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.
|
// 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 "*".
|
// 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,
|
// 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,
|
// 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.
|
// but we take it as an unmatched event unless the ce is also a wildcard one.
|
||||||
func (ce ClusterEvent) Match(comingEvent ClusterEvent) bool {
|
func (ce ClusterEvent) Match(event ClusterEvent) bool {
|
||||||
return ce.IsWildCard() ||
|
return ce.IsWildCard() || (ce.Resource == WildCard || ce.Resource == event.Resource) && ce.ActionType&event.ActionType != 0
|
||||||
(ce.Resource == WildCard || ce.Resource == comingEvent.Resource) &&
|
|
||||||
(ce.ActionType&comingEvent.ActionType != 0 && comingEvent.ActionType <= ce.ActionType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnrollWildCardResource() []ClusterEventWithHint {
|
func UnrollWildCardResource() []ClusterEventWithHint {
|
||||||
|
@@ -1626,16 +1626,9 @@ func TestCloudEvent_Match(t *testing.T) {
|
|||||||
wantResult: true,
|
wantResult: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "no match if a coming event is less specific",
|
name: "event with resource = 'Pod' matching with coming events carries same actionType",
|
||||||
event: ClusterEvent{Resource: Node, ActionType: UpdateNodeLabel},
|
event: ClusterEvent{Resource: Pod, ActionType: UpdateNodeLabel | UpdateNodeTaint},
|
||||||
comingEvent: ClusterEvent{Resource: Node, ActionType: Update},
|
comingEvent: ClusterEvent{Resource: Pod, ActionType: UpdateNodeLabel},
|
||||||
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 = '*' matching with coming events carries same actionType",
|
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"}
|
AssignedPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "AssignedPodUpdate"}
|
||||||
// UnscheduledPodAdd is the event when an unscheduled pod is added.
|
// UnscheduledPodAdd is the event when an unscheduled pod is added.
|
||||||
UnscheduledPodAdd = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "UnschedulablePodAdd"}
|
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 is the event when an unscheduled pod is updated.
|
||||||
UnscheduledPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "UnschedulablePodUpdate"}
|
UnscheduledPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "UnschedulablePodUpdate"}
|
||||||
// UnscheduledPodDelete is the event when an unscheduled pod is deleted.
|
// 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 {
|
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
|
return
|
||||||
|
Reference in New Issue
Block a user