mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
fix: handle Activate event properly
This commit is contained in:
parent
102d79ec93
commit
623b2a20d2
@ -413,6 +413,18 @@ func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework
|
|||||||
}
|
}
|
||||||
|
|
||||||
if event.IsWildCard() {
|
if event.IsWildCard() {
|
||||||
|
// If the wildcard event has a Pod in newObj,
|
||||||
|
// that indicates that the event wants to be effective for the Pod only.
|
||||||
|
// Specifically, EventForceActivate could have a target Pod in newObj.
|
||||||
|
if newObj != nil {
|
||||||
|
if pod, ok := newObj.(*v1.Pod); ok && pod.UID == pInfo.Pod.UID {
|
||||||
|
logger.V(6).Info("Worth requeuing because the event is wildcard", "pod", klog.KObj(pInfo.Pod))
|
||||||
|
return queueAfterBackoff
|
||||||
|
}
|
||||||
|
// This wildcard event is not for this Pod.
|
||||||
|
return queueSkip
|
||||||
|
}
|
||||||
|
|
||||||
// If the wildcard event is special one as someone wants to force all Pods to move to activeQ/backoffQ.
|
// If the wildcard event is special one as someone wants to force all Pods to move to activeQ/backoffQ.
|
||||||
// We return queueAfterBackoff in this case, while resetting all blocked plugins.
|
// We return queueAfterBackoff in this case, while resetting all blocked plugins.
|
||||||
logger.V(6).Info("Worth requeuing because the event is wildcard", "pod", klog.KObj(pInfo.Pod))
|
logger.V(6).Info("Worth requeuing because the event is wildcard", "pod", klog.KObj(pInfo.Pod))
|
||||||
@ -609,6 +621,8 @@ func (p *PriorityQueue) Activate(logger klog.Logger, pods map[string]*v1.Pod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If this pod is in-flight, register the activation event so that the pod will be requeued when it comes back.
|
// If this pod is in-flight, register the activation event so that the pod will be requeued when it comes back.
|
||||||
|
// Specifically in the in-tree plugins, this is for the scenario with the preemption plugin
|
||||||
|
// where the async preemption API calls are all done or fail at some point before the Pod comes back to the queue.
|
||||||
p.activeQ.addEventsIfPodInFlight(nil, pod, []framework.ClusterEvent{framework.EventForceActivate})
|
p.activeQ.addEventsIfPodInFlight(nil, pod, []framework.ClusterEvent{framework.EventForceActivate})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3838,6 +3838,7 @@ func mustNewPodInfo(pod *v1.Pod) *framework.PodInfo {
|
|||||||
|
|
||||||
// Test_isPodWorthRequeuing tests isPodWorthRequeuing function.
|
// Test_isPodWorthRequeuing tests isPodWorthRequeuing function.
|
||||||
func Test_isPodWorthRequeuing(t *testing.T) {
|
func Test_isPodWorthRequeuing(t *testing.T) {
|
||||||
|
metrics.Register()
|
||||||
count := 0
|
count := 0
|
||||||
queueHintReturnQueue := func(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) (framework.QueueingHint, error) {
|
queueHintReturnQueue := func(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) (framework.QueueingHint, error) {
|
||||||
count++
|
count++
|
||||||
@ -3916,11 +3917,37 @@ func Test_isPodWorthRequeuing(t *testing.T) {
|
|||||||
},
|
},
|
||||||
event: framework.EventUnschedulableTimeout,
|
event: framework.EventUnschedulableTimeout,
|
||||||
oldObj: nil,
|
oldObj: nil,
|
||||||
newObj: st.MakeNode().Obj(),
|
newObj: nil,
|
||||||
expected: queueAfterBackoff,
|
expected: queueAfterBackoff,
|
||||||
expectedExecutionCount: 0,
|
expectedExecutionCount: 0,
|
||||||
queueingHintMap: QueueingHintMapPerProfile{},
|
queueingHintMap: QueueingHintMapPerProfile{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "return Queue when the event is wildcard and the wildcard targets the pod to be requeued right now",
|
||||||
|
podInfo: &framework.QueuedPodInfo{
|
||||||
|
UnschedulablePlugins: sets.New("fooPlugin1"),
|
||||||
|
PodInfo: mustNewPodInfo(st.MakePod().Name("pod1").Namespace("ns1").UID("1").Obj()),
|
||||||
|
},
|
||||||
|
event: framework.EventForceActivate,
|
||||||
|
oldObj: nil,
|
||||||
|
newObj: st.MakePod().Name("pod1").Namespace("ns1").UID("1").Obj(),
|
||||||
|
expected: queueAfterBackoff,
|
||||||
|
expectedExecutionCount: 0,
|
||||||
|
queueingHintMap: QueueingHintMapPerProfile{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "return Skip when the event is wildcard, but the wildcard targets a different pod",
|
||||||
|
podInfo: &framework.QueuedPodInfo{
|
||||||
|
UnschedulablePlugins: sets.New("fooPlugin1"),
|
||||||
|
PodInfo: mustNewPodInfo(st.MakePod().Name("pod1").Namespace("ns1").UID("1").Obj()),
|
||||||
|
},
|
||||||
|
event: framework.EventForceActivate,
|
||||||
|
oldObj: nil,
|
||||||
|
newObj: st.MakePod().Name("pod-different").Namespace("ns2").UID("2").Obj(),
|
||||||
|
expected: queueSkip,
|
||||||
|
expectedExecutionCount: 0,
|
||||||
|
queueingHintMap: QueueingHintMapPerProfile{},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "interprets Queue from the Pending plugin as queueImmediately",
|
name: "interprets Queue from the Pending plugin as queueImmediately",
|
||||||
podInfo: &framework.QueuedPodInfo{
|
podInfo: &framework.QueuedPodInfo{
|
||||||
|
Loading…
Reference in New Issue
Block a user