Commit Graph

177 Commits

Author SHA1 Message Date
Maciej Skoczeń
5def93b10a Add a separate lock for pod nominator in scheduling queue 2024-07-17 07:58:59 +00:00
Maciej Skoczeń
31e89b1f4d Add activeQLock to scheduling queue to improve Pop() throughput 2024-07-09 11:37:19 +00:00
Kensei Nakada
e16aa35865 address review suggestions 2024-07-06 13:17:17 +00:00
Kensei Nakada
533140f065 take PodTopologySpread into consideration when requeueing Pods based on Pod related events 2024-07-06 13:17:14 +00:00
Maciej Skoczeń
c5d376dc20 Fix typos and error messages in scheduling queue tests 2024-07-01 11:37:53 +00:00
Kubernetes Prow Robot
59673f0f37
Merge pull request #125578 from nayihz/fix_sche_queue_update
skip update pod that exist in scheduling cycle
2024-06-25 14:18:19 -07:00
nayihz
26dcab1146 skip update pod that exist in scheduling cycle 2024-06-24 17:11:09 +08:00
Kensei Nakada
fa8da84835 remove fixme comment 2024-06-20 23:36:25 +00:00
Kensei Nakada
dd3af9a85b fix: skip isPodWorthRequeuing only when SchedulingGates gates the pod 2024-06-17 01:14:34 +00:00
AxeZhan
d66f8f9413 schedulingQueue update pod by queueHint 2024-06-12 21:26:09 +08:00
Kubernetes Prow Robot
db82fd1604
Merge pull request #124618 from gabesaba/gated_performance
Filter gated pods before calling isPodWorthRequeueing
2024-05-09 11:33:23 -07:00
Gabe
9a8197d0c3 Add unit test which checks Gated is set/unset properly 2024-05-02 10:41:19 +00:00
Gabe
6c6be931ee revert unit test 2024-05-02 10:29:15 +00:00
Gabe
9a8ec13505 make linter happy 2024-04-30 12:06:26 +00:00
Gabe
4e99ada05f Filter gated pods before calling isPodWorthRequeueing 2024-04-29 16:54:40 +00:00
Marek Siarkowicz
3ee8178768 Cleanup defer from SetFeatureGateDuringTest function call 2024-04-24 20:25:29 +02:00
Claudiu Belu
c2dfcf1e34 unittests: Fixes unit tests for Windows (part 9)
Currently, there are some unit tests that are failing on
Windows due to various reasons:

- time.Now() is not as precise on Windows, which means that
  2 consecutive calls may return the same timestamp.
- Different "File not found" error messages on Windows.
- The default Container Runtime URL scheme on Windows is npipe, not unix.
2024-03-26 13:42:50 +00:00
Kensei Nakada
18ba3b388e fix(scheduling queue): ignore events that interest no registered plugin 2024-02-24 06:42:19 +00:00
kerthcet
d81023db30 When matching clusterEvent, we should consider the "*" additionally
Signed-off-by: kerthcet <kerthcet@gmail.com>
2024-02-04 14:59:26 +08:00
amewayne
71c3593f85 support nodeAnnotationsChanged event to trigger rescheduling 2024-01-10 22:38:54 +08:00
AxeZhan
801afbf888 refactor TestPriorityQueue_Update 2024-01-06 16:53:05 +08:00
nayihz
16b6be1e50 add unit test for the scheduling queue for QueueingHint disabled 2023-12-15 10:55:52 +08:00
Kensei Nakada
3b8f25dfdd fix: disable SchedulerQueueingHints feature flag by default 2023-12-13 04:16:43 +00:00
Mengjiao Liu
b0a73213d6 kube-scheduler: convert the remaining part to use contextual logging 2023-10-24 17:56:48 +08:00
Kensei Nakada
cb5dc46edf feature(scheduler): simplify QueueingHint by introducing new statuses 2023-10-19 11:02:11 +00:00
carlory
0105a002bc when the hint fn returns error, the scheduling queue logs the error and treats it as QueueAfterBackoff.
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>

Co-authored-by: Kante Yin <kerthcet@gmail.com>

Co-authored-by: XsWack <xushiwei5@huawei.com>
2023-09-21 09:40:44 +08:00
Patrick Ohly
819eddaf9a scheduler: fix TestIncomingPodsMetrics unit test
addUnschedulablePodBackToBackoffQ happened to put the pod into the backoff
queue because
- the pod was not popped earlier and thus not in flight
- the PodInfo had UnschedulablePlugins set
- determineSchedulingHintForInFlightPod has code for "if UnschedulablePlugins
  is set and pod not in flight -> internal error, use backoff"

Relying on such special code is not good. A better way to force backoff is by
recording some concurrent event. isPodWorthRequeuing then calls the
queueHintReturnQueueAfterBackoff function and the pod goes to the backoff
queue.
2023-09-12 08:38:53 +02:00
Kensei Nakada
0d3eafdfa3
fix(scheduling_queue): always put Pods with no unschedulable plugins into activeQ/backoffQ (#119105)
* always put Pods with no unschedulable plugins into activeQ/backoffQ

* address review comments
2023-09-11 09:30:11 -07:00
Patrick Ohly
4e73634b53 scheduler: start scheduling attempt with clean UnschedulablePlugins
When some plugin was registered as "unschedulable" in some previous scheduling
attempt, it kept that attribute for a pod forever. When that plugin then later
failed with an error that requires backoff, the pod was incorrectly moved to the
"unschedulable" queue where it got stuck until the periodic flushing because
there was no event that the plugin was waiting for.

Here's an example where that happened:

     framework.go:1280: E0831 20:03:47.184243] Reserve/DynamicResources: Plugin failed err="Operation cannot be fulfilled on podschedulingcontexts.resource.k8s.io \"test-dragxd5c\": the object has been modified; please apply your changes to the latest version and try again" node="scheduler-perf-dra-7l2v2" plugin="DynamicResources" pod="test/test-dragxd5c"
    schedule_one.go:1001: E0831 20:03:47.184345] Error scheduling pod; retrying err="running Reserve plugin \"DynamicResources\": Operation cannot be fulfilled on podschedulingcontexts.resource.k8s.io \"test-dragxd5c\": the object has been modified; please apply your changes to the latest version and try again" pod="test/test-dragxd5c"
    ...
    scheduling_queue.go:745: I0831 20:03:47.198968] Pod moved to an internal scheduling queue pod="test/test-dragxd5c" event="ScheduleAttemptFailure" queue="Unschedulable" schedulingCycle=9576 hint="QueueSkip"

Pop still needs the information about unschedulable plugins to update the
UnschedulableReason metric. It can reset that information before returning the
PodInfo for the next scheduling attempt.
2023-09-08 16:52:36 +02:00
Patrick Ohly
c131c92b9f scheduler: unit test case for concurrent event with other pod
The problematic scenario was having one pod in flight, one event in the list,
and then detecting a concurrent event for a second pod after the first pod is
done. The new test case covers that.

To make it work without assumptions about the implementation, the QueuedPodInfo
returned by Pop must be the one passed to AddUnschedulableIfNotPresent
after (potentially) populating UnschedulablePlugins. This is done via callback
functions which bind to the same shared variable.
2023-09-05 21:01:13 +02:00
Patrick Ohly
cd943dd95e scheduler: fix tracking of concurrent events
The previous approach was based on the assumption that an in-flight pod can use
the head of the received event list as marker for identifying all events that
occur while the pod is in flight. That assumption is incorrect: when that
existing element gets removed from the list because all pods that were
in-flight when it was received are done, that marker's Next method returns nil
and the code which should have seen several concurrent events (if there were
any) missed all of those.

As a result, a pod with concurrent events could incorrectly get moved to the
unschedulable queue where it could got stuck until the next periodic purging
after 5 minutes if there was no other event for it.

The approach with maintaining a single list of concurrent events can be fixed
by inserting each in-flight pod into the list and using that element to
identify "more recent" events for the pod.
2023-09-05 19:58:38 +02:00
Kensei Nakada
c7e7eee554
feature(scheduling_queue): track events per Pods (#118438)
* feature(sscheduling_queue): track events per Pods

* fix typos

* record events in one slice and make each in-flight Pod to refer it

* fix: use Pop() in test before AddUnschedulableIfNotPresent to register in-flight Pods

* eliminate MakeNextPodFuncs

* call Done inside the scheduling queue

* fix comment

* implement done() not to require lock in it

* fix UTs

* improve the receivedEvents implementation based on suggestions

* call DonePod when we don't call AddUnschedulableIfNotPresent

* fix UT

* use queuehint to filter out events for in-flight Pods

* fix based on suggestion from aldo

* fix based on suggestion from Wei

* rename lastEventBefore → previousEvent

* fix based on suggestion

* address comments from aldo

* fix based on the suggestion from Abdullah

* gate in-flight Pods logic by the SchedulingQueueHints feature gate
2023-07-17 15:53:07 -07:00
carlory
0599b3caa0 change the QueueingHintFn to pass a logger 2023-07-13 00:56:41 +08:00
Kubernetes Prow Robot
0852a2759a
Merge pull request #118965 from mengjiao-liu/use-cmp.Diff-scheduler-queue
scheduler test: Use cmp.Diff instead of reflect.DeepEqual for pkg/scheduler/internal/queue/
2023-07-04 05:29:05 -07:00
Heba Elayoty
d548983dbb
Use table-driven table for TestPerPodSchedulingMetrics
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
2023-06-29 14:51:55 -07:00
Mengjiao Liu
72294e4eff scheduler test: Use cmp.Diff instead of reflect.DeepEqual for pkg/scheduler/internal/queue/ 2023-06-29 15:28:42 +08:00
Kubernetes Prow Robot
d9714078f8
Merge pull request #118551 from sanposhiho/event-to-register
feature(scheduler): implement ClusterEventWithHint to filter out useless events
2023-06-26 06:41:45 -07:00
Kensei Nakada
6f8d38406a feature(scheduler): implement ClusterEventWithHint to filter out useless events 2023-06-22 13:36:19 +00:00
Heba Elayoty
902c711fb4
Unset gated pod info timestamp in addToActiveQ
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
2023-06-21 14:16:08 -07:00
likakuli
5a14573258 clean: use info instead of error to log queue closed message when scheduler exit
Signed-off-by: likakuli <1154584512@qq.com>
2023-05-31 11:07:24 +08:00
Mengjiao Liu
074900e81b scheduler: update the scheduler interface and cache methods to use contextual logging 2023-05-29 13:26:32 +08:00
Kubernetes Prow Robot
29c8fb678c
Merge pull request #117194 from sanposhiho/revert-preenqueue
Revert "Optimization on running prePreEnqueuePlugins before adding pods into activeQ"
2023-04-13 16:00:50 -07:00
Kensei Nakada
2bed67d0f1 Revert "Optimization on running prePreEnqueuePlugins before adding pods into activeQ"
This reverts commit c01fa8279d.
2023-04-11 22:28:42 +00:00
sarab
8d18ae6fc2 Use the generic Set in scheduler 2023-04-09 11:34:17 +05:30
Kensei Nakada
6697467062 add(scheduler): implement "plugin_execution_duration_seconds" metric in PreEnqueue 2023-03-12 04:45:52 +00:00
Aldo Culquicondor
07a73bb2e1
One lock among PodNominator and SchedulingQueue
Change-Id: I17fe5da40250e42c04124c25b530ce6c8dea4154
2023-03-08 16:18:36 -05:00
lianghao208
c01fa8279d Optimization on running prePreEnqueuePlugins before adding pods into activeQ 2023-02-15 11:13:21 +08:00
Wei Huang
a731a44596
Fix an accuracy issue of scheduler_pending_pods metric 2022-11-21 21:33:16 -08:00
Wei Huang
0f66366aff
Fix an issue that pod may be added to backoffQ 2022-11-08 10:05:32 -08:00
Wei Huang
0b27f25252
PreEnqueue implementation
- Add PreEnqueuePlugin to Scheduler Framework
- Implement PreEnqueuePlugin in scheduler queue
- Implementation of SchedulingGates plugin
- Metrics
2022-11-07 14:02:58 -08:00