Commit Graph

160 Commits

Author SHA1 Message Date
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
Claudiu Belu
9f95b7b18c unittests: Fixes unit tests for Windows (part 3)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- paths not properly joined (filepath.Join should be used).
- Proxy Mode IPVS not supported on Windows.
- DeadlineExceeded can occur when trying to read data from an UDP
  socket. This can be used to detect whether the port was closed or not.
- In Windows, with long file name support enabled, file names can have
  up to 32,767 characters. In this case, the error
  windows.ERROR_FILENAME_EXCED_RANGE will be encountered instead.
- files not closed, which means that they cannot be removed / renamed.
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- path.Base() will return the same path. filepath.Base() should be used
  instead.
- path.Join() will always join the paths with a / instead of the OS
  specific separator. filepath.Join() should be used instead.
2022-10-21 19:25:48 +03:00
kidddddddddddddddddddddd
b901ef0f68 changes in test files 2022-10-12 22:11:04 +08:00
Wei Huang
7df9bfcfef
Expose a pending pods summary in scheudler's dummper output 2022-08-05 22:02:38 -07:00
akankshakumari393
5d53407cc2 [Minor] Fix typos in the variable name in scheduling_queue_test.go 2022-07-23 19:27:15 +05:30
Yibo Zhuang
fd08d47d8b cleanup: move scheduler tests to use PodWrapper
Move to use testing PodWrapper where applicable to
reduce duplicating pod creation code and shorten
number of lines.

Adding additional wrapper functions in PodWrapper
to ensure it covers all pod spec under tests.

Signed-off-by: Yibo Zhuang <yibzhuang@gmail.com>
2022-05-05 10:48:26 -07:00
Yuan Chen
d1a2f699a7 Add PodWrapper functions for scheduler testing
Fix a typo in comment
2022-04-19 20:30:04 -07:00
Aldo Culquicondor
429457e184 Fix: abort nominating a pod that was already scheduled to a node
Change-Id: Iacb8530769e7a93e3bc8384cf51d7a8fd9a192e1
2022-04-04 10:52:59 -04:00
Kubernetes Prow Robot
317f8afe92
Merge pull request #108976 from ArangoGutierrez/devel/typos/scheduler
Fix typos under pkg/scheduler
2022-03-25 15:35:09 -07:00
Carlos Eduardo Arango Gutierrez
d2f67b42b7
Fix typos under pkg/scheduler
./scheduler/framework/plugins/noderesources/most_allocated_test.go:227: negtive ==> negative
./scheduler/framework/plugins/noderesources/most_allocated_test.go:228: negtive ==> negative
./scheduler/framework/plugins/volumebinding/binder.go:402: everytime ==> every time
./scheduler/framework/preemption/preemption_test.go:67: staus ==> status
./scheduler/framework/runtime/framework_test.go:1252: followings ==> following
./scheduler/internal/cache/cache_test.go:932: datas ==> data
./scheduler/internal/cache/node_tree_test.go:471: unknow ==> unknown
./scheduler/internal/queue/scheduling_queue_test.go:442: actived ==> activated
./scheduler/internal/queue/scheduling_queue_test.go:2209: covert ==> convert

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
2022-03-24 08:01:25 -04:00
Alex Wang
8a5df1302a rename unschedulableQ to unschedulablePods
Signed-off-by: Alex Wang <wangqingcan1990@gmail.com>
2022-03-24 17:38:49 +08:00
Daniel Smith
2831f9a343 remove unneeded references 2022-03-23 15:26:38 +00:00
Alex Wang
87549203e9 add deprecated flag for flush pods to activeq interval 2022-02-16 11:05:52 +08:00
Alex Wang
ca50e459b0 check activeQ len before pop 2022-02-08 18:05:05 +08:00
Wei Huang
939e98135c
sched: fix goroutine leak in unit tests 2022-01-22 22:53:11 -08:00
Kubernetes Prow Robot
b960f7a0e0
Merge pull request #106203 from 2014BDuck/test-priority-queue-activate
add test cases for scheduler/PriorityQueue.Activate
2022-01-05 02:22:32 -08:00
Jiekun
30e06ecf1e #106203 Added test cases for PriorityQueue Activate 2021-12-18 22:12:46 +08:00
Wei Huang
2433b083a9
clear pod's .status.nominatedNodeName when necessary 2021-12-16 10:55:13 -08:00