158 Commits
Author SHA1 Message Date
Michael Aspinwall 2b96ebcfe0 Move consistency store to client-go utils 2026-09-30 20:22:05 +00:00
Patrick Ohly 2579861734 kube-controller-manager: use context-aware client-go
Kubernetes 1.37 finished the introduction of context-aware client-go APIs.
Components like kube-controller-manager which are meant to support contextual
logging should use those new APIs.

This is not enforced yet because existing code must be updated first. Once
that is done, enforcement of everything touched here can be enabled tree-wide.
2026-09-07 16:49:09 +02:00
Ryan Brewster 3a319040cb daemonset: hoist per-node pod construction and affinity parsing out of sync loops
NodeShouldRunDaemonPod built a pod from the DaemonSet template and parsed
its required node affinity on every call, and the controller's sync paths
call it once per node in the cluster. Both inputs depend only on the
DaemonSet: the checks consume the daemon pod's tolerations and the parsed
required node affinity, so compute exactly those, once per sync, in
manage, updateDaemonSetStatus, rollingUpdate and updatedDesiredNodeCounts
- no pod object is constructed at all. The affinity is parsed straight
from the pod template via nodeaffinity.NewRequiredNodeAffinity; the
tolerations are the template's plus the daemon-pod defaults
(daemonPodTolerations).

predicates' fitsNodeName check is dropped: it was vacuously true (NewPod
pinned Spec.NodeName to the examined node, so the comparison always
passed); the template NodeName precondition is still checked directly in
nodeShouldRunDaemonPod. NodeShouldRunDaemonPod keeps its signature and
behavior.

benchstat vs the benchmark commit (BenchmarkUpdateDaemonSetStatus,
-benchtime 1s -count 10): geomean sec/op -97.5%, B/op -99.6%,
allocs/op -99.6%.
2026-07-01 19:53:46 +00:00
Michael Aspinwall 1d78c7f2b1 Update comments to explain why we delete on all errors in DaemonSet 2026-04-07 16:56:58 +00:00
Jordan Liggitt 45900a1deb Fix vet error 2026-03-05 18:11:02 -05:00
Michael Aspinwall 61d0dd30fb Add the ability for the job controller to read its own writes 2026-02-25 01:19:48 +00:00
Michael Aspinwall 65eb0e94c2 Daemonset Consistency
Add the ability for the daemonset controller to figure out whether it has read its own writes for pods and daemonset objects.
2026-02-19 16:53:19 +00:00
Heba aceb89debc KEP-5471: Extend tolerations operators (#134665)
* Add numeric operations to tolerations

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* add default feature gate

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add integration tests

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add toleration value validation

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Add validate options for new operators

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove log

Signed-off-by: helayoty <heelayot@microsoft.com>

* Update feature gate check

Signed-off-by: helayoty <heelayot@microsoft.com>

* emove IsValidNumericString func

Signed-off-by: helayoty <heelayot@microsoft.com>

* Implement IsDecimalInteger

Signed-off-by: helayoty <heelayot@microsoft.com>

* code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add logs to v1/toleration

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>

* Update integration tests and address code review feedback

Signed-off-by: helayoty <heelayot@microsoft.com>

* Add feature gate to the scheduler framework

Signed-off-by: helayoty <heelayot@microsoft.com>

* Remove extra test

Signed-off-by: helayoty <heelayot@microsoft.com>

* Fix integration test

Signed-off-by: helayoty <heelayot@microsoft.com>

* pass feature gate via TolerationsTolerateTaint

Signed-off-by: helayoty <heelayot@microsoft.com>

---------

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Signed-off-by: helayoty <heelayot@microsoft.com>
2025-11-10 12:42:54 -08:00
Ondra Kupka e8b0f27456 controller/daemon: Improve goroutine mgmt
Make sure all threads are terminated when Run returns.
2025-10-29 19:00:30 +01:00
Jordan Liggitt 91d135f344 Include relevant dimensions in pod controller indexing 2025-10-16 13:27:50 -04:00
Aditi Gupta 7d14367f57 Change WaitForNamedCacheSync to WaitForNamedCacheSyncWithContext.
This is part of the ongoing effort to adopt contextual logging
and utilities throughout the codebase.

Contributes to  #126379

Signed-off-by: Aditi Gupta <aditigpta@google.com>
2025-09-05 18:49:31 +00:00
xigang 3eb69eb852 Fix DaemonSet misscheduled status not updating on node taint changes
Signed-off-by: xigang <wangxigang2014@gmail.com>
2025-08-12 07:52:40 +08:00
Michal Wozniak ac86e67b7d Commonize filtering of Pods by Owner with all orphans in namespace 2025-06-30 08:07:21 +02:00
xigang 66c611125c Add namespace-aware orphan pod indexing
Signed-off-by: xigang <wangxigang2014@gmail.com>
2025-06-19 16:32:20 +08:00
Harish Kuna a67cc3aac1 Reduce locking duration on cache to fetch data in DaemonSet Controller 2025-03-20 16:00:27 +00:00
xigang aa32537e9a Add workqueue for node updates in DaemonSetController
Signed-off-by: xigang <wangxigang2014@gmail.com>
2025-03-19 01:09:44 +08:00
Alvaro Aleman 6d0ac8c561 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
2024-05-04 14:33:12 -04:00
Mengjiao Liu b584b87a94 kube-controller-manager: readjust log verbosity
- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise.
- Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value.
- test: use cancellation from ktesting
- golangci-hints: checked error return value
2024-02-26 14:51:56 +08:00
weilaaa eb8f3f194f use build-in max and min func to instead of k8s.io/utils/integer funcs 2023-12-15 15:09:11 +08:00
xigang 6b3476b79f node labels and taints do not change, node events are ignored in daemonset controller
Signed-off-by: xigang <wangxigang2014@gmail.com>
2023-11-02 17:53:44 +08:00
Patrick Ohly 7d064812bb kube-controller-manager: finish conversion to contextual logging
This removes all exceptions and fixes the remaining unconverted log calls.
2023-07-12 14:57:29 +02:00
Kubernetes Prow Robot 74bd77a9df Merge pull request #118917 from kmala/daemonsetfix
increase the log level for the GetTargetNodeName error message
2023-06-28 00:08:32 -07:00
Aldo Culquicondor a4519665fe Skip terminal Pods with a deletion timestamp from the Daemonset sync (#118716)
* Skip terminal Pods with a deletion timestamp from the Daemonset sync

Change-Id: I64a347a87c02ee2bd48be10e6fff380c8c81f742

* Review comments and fix integration test

Change-Id: I3eb5ec62bce8b4b150726a1e9b2b517c4e993713

* Include deleted terminal pods in history

Change-Id: I8b921157e6be1c809dd59f8035ec259ea4d96301
2023-06-27 08:56:33 -07:00
Keerthan Reddy Mala 0033f65808 increase the log level for the GetTargetNodeName error message 2023-06-26 17:31:50 -07:00
Michal Wozniak b5dd5f1f3a Investigate and fix the handling of Succeeded pods in DaemonSet 2023-04-04 19:21:15 +02:00
mantuliu 0567c93b2a Improve the performance of map usage
Signed-off-by: mantuliu <240951888@qq.com>
2023-03-21 20:37:53 +08:00
Patrick Ohly 99151c39b7 kube-controller-manager: convert to structured logging
Most of the individual controllers were already converted earlier. Some log
calls were missed or added and then not updated during a rebase. Some of those
get updated here to fill those gaps.

Adding of the name to the logger used by each controller gets
consolidated in this commit. By using the name under which the
controller is registered we ensure that the names in the log
are consistent.
2023-03-14 19:16:32 +01:00
ZhangKe10140699 7198bcffcd daemonset: use contextual logging 2023-03-14 08:50:27 +08:00
Gunju Kim 69fcde750a Update daemonSet status even if syncDaemonSet fails
This ensures that the daemonset controller updates daemonset statuses in
a best-effort manner even if syncDaemonSet fails.

In order to add an integration test, this also replaces
`cmd/kube-apiserver/app/testing.StartTestServer` with
`test/integration/framework.StartTestServer` and adds
`setupWithServerSetup` to configure the admission control of the
apiserver.
2022-12-10 11:45:56 +09:00
Kubernetes Prow Robot 5fe12aae11 Merge pull request #111207 from lucming/code-cleanup2
Reduce indentation in daemonset controller code
2022-12-09 15:41:41 -08:00
Maciej Szulik 3c93d540c6 Revert "Update daemonSet status even if syncDaemonSet fails"
This reverts commit 2ee024a4df.
2022-11-08 15:01:09 +01:00
Kubernetes Prow Robot b4f42864f5 Merge pull request #112127 from gjkim42/update-status-despite-error
Update daemonSet status even if syncDaemonSet fails
2022-11-07 16:00:28 -08:00
Kubernetes Prow Robot 20ffe3bbf9 Merge pull request #111607 from tnqn/reduce-redundant-index
Remove duplicate and unused index from PodIndexer
2022-11-04 09:36:16 -07:00
Han Kang 2bbd445f50 remove rate limiter metric as it is not in use
Change-Id: I91157653e3860eeecc3f572aee88da6ffc65faed
2022-10-13 13:07:11 -07:00
Gunju Kim 2ee024a4df Update daemonSet status even if syncDaemonSet fails 2022-10-11 22:55:50 +09:00
Quan Tian f40067a8cc Remove duplicate and unused index from PodIndexer
DaemonSetsController adds a "nodeName" index to PodIndexer, which is
redundant with the "spec.nodeName" index of NodeLifecycleController.
However, DaemonSetsController hasn't been using this index since #86730.
This patch removes the redundant and unused index to reduce memory and
CPU spent on it.

Signed-off-by: Quan Tian <qtian@vmware.com>
2022-08-02 10:53:54 +08:00
Davanum Srinivas a9593d634c Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
lucming fba637c33d code clean up 2022-07-18 16:06:20 +08:00
Wojciech Tyczyński 11b679c66a Fix event broadcaster shutdown in multiple controllers 2022-05-17 22:14:19 +02:00
Bartłomiej Wróblewski b2e2fb8d89 Make daemon.NodeShouldRunDaemonPod function public 2022-03-08 11:32:17 +00:00
Mike Dame 80c01707e0 Wire contexts to Batch controllers (#105491)
* Wire contexts to Batch controllers

* (hold) feedback + updates that overlap with Apps controllers

* fixup errors
2021-11-10 14:56:46 -08:00
Mike Dame 41fcb95f2f Wire contexts to Apps controllers 2021-10-13 16:32:13 -04:00
Aldo Culquicondor d8aad7944c Remove unused util CreatePods
And rename CreatePodsWithControllerRef to simply CreatePods
2021-05-20 20:27:21 +00:00
Kubernetes Prow Robot 89e0b2d185 Merge pull request #99398 from tnqn/ds-update-retry
Fix DaemonSet status update retry
2021-05-18 22:32:50 -07:00
Kubernetes Prow Robot 5779fec3c4 Merge pull request #99959 from AliceZhang2016/nodeaffinity-cleanup
Move nodeaffinity helpers to component-helpers package
2021-04-21 17:03:53 -07:00
Kubernetes Prow Robot e7dc0df323 Merge pull request #97650 from ialidzhikov/cleanup/redundant-imports
Clean up some redundant imports
2021-04-08 14:27:22 -07:00
Mengxue Zhang bdda9728e7 move nodeaffinity helpers to component-helpers package 2021-03-10 20:19:25 +00:00
Quan Tian 60bb2a3a6f Fix DaemonSet status update retry
It's easy to get update conflict when processing a DaemonSet
continuously. storeDaemonSetStatus had a retry logic that it gets the
resource from apiserver to update the DaemonSet with the latest resource
version. However, it never really retried because of a wrong check and
always made an useless get call. This patch fixes the logic to allow
the function retry once on update error.
2021-03-09 00:39:25 +08:00
Clayton Coleman 8d8884a907 daemonset: Remove unnecessary error returns in strategy code
The nodeShouldRunDaemonPod method does not need to return an error
because there are no scenarios under which it fails. Remove the
error return path for its direct calls as well.
2021-03-01 13:23:18 -05:00
Clayton Coleman 18f43e4120 daemonset: Implement MaxSurge on daemonset update
If MaxSurge is set, the controller will attempt to double up nodes
up to the allowed limit with a new pod, and then when the most recent
(by hash) pod is ready, trigger deletion on the old pod. If the old
pod goes unready before the new pod is ready, the old pod is immediately
deleted. If an old pod goes unready before a new pod is placed on that
node, a new pod is immediately added for that node even past the MaxSurge
limit.

The backoff clock is used consistently throughout the daemonset controller
as an injectable clock for the purposes of testing.
2021-03-01 13:21:12 -05:00