571 Commits
Author SHA1 Message Date
Michael Aspinwall 2b96ebcfe0 Move consistency store to client-go utils 2026-09-30 20:22:05 +00:00
Davanum Srinivas 0dbaa388df Dereference pointer args passed to %d in Errorf/Fatalf calls
Go 1.27 vet rejects %d with a pointer argument (golang/go#62595).
k/k's go.mod declares go 1.27.0, so seven call sites that pass a
*int32, *uint64 or *int to %d now fail. update.go uses ptr.Deref
because CollisionCount can be nil; the other six sites check nil first.
2026-09-13 14:16:52 -04: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
Ryan Brewster 435ee330eb daemonset: add benchmark for the controller's per-node evaluation loop 2026-07-01 19:53:46 +00:00
Joe Betz e89ecc6af0 generate 2026-06-30 18:02:28 -04:00
Joe Betz 119a1460c1 Generate deepcopy 2026-05-11 12:27:56 -04: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
PatrickLaabs 8abcdf0885 chore: depr. pointer pkg replacement for pkg/controller 2025-07-07 13:13:39 +02: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
Patrick Ohly 8a908e0c0b remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
2024-12-02 16:59:34 +01:00
Maciej Szulik 174288d751 Add unit tests verifying the update touches old, unhealthy pods first, and only after new pods.
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2024-10-31 11:13:01 +01:00
Kubernetes Prow Robot ea379082fb Merge pull request #126322 from lance5890/ds_update_typo
typo: update the daemon update typo
2024-10-23 01:18:06 +01:00
Joe Betz 2595aa1309 generate 2024-09-03 14:26:26 -04:00
lan.tian 5fec38dc9b typo: update the daemon update typo
Signed-off-by: lan.tian <lance5890@163.com>
2024-07-24 15:00:52 +08:00
Kubernetes Prow Robot 5cd78a1e9d Merge pull request #123233 from marshallbrekka/bugfix/daemonset-update-old-ready
Fix daemonset to ensure old unhealthy pods are counted towards max unavailable budget.
2024-05-13 09:53:53 -07:00
Kubernetes Prow Robot de7d9a9897 Merge pull request #108349 from LastNight1997/optimize-dedup
optimize dedupCurHistories func in DaemonSetsController
2024-05-08 15:13:17 -07: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
Marek Siarkowicz 3ee8178768 Cleanup defer from SetFeatureGateDuringTest function call 2024-04-24 20:25:29 +02: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
Marshall Brekka 9b300c978b Fix daemonset to ensure old unhealthy pods are counted towards max unavailable budget. 2024-02-10 13:10:35 -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
LastNight1997 153dca4832 optimize dedupCurHistories func in DaemonSetsController
Signed-off-by: LastNight1997 <934104625@qq.com>
2023-10-12 12:29:59 +08:00
mochizuki875 2a82776745 change rolling update logic to exclude sunsetting nodes 2023-09-19 11:39:32 +00:00
git-jxj a5b3a4b738 cleanup: Update deprecated FromInt to FromInt32 (#119858)
* redo commit

* apply suggestions from liggitt

* update Parse function based on suggestions
2023-08-16 09:33:01 -07: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
Kante Yin a7035f5459 Pass Context to StartTestServer
Signed-off-by: Kante Yin <kerthcet@gmail.com>
2023-05-04 10:25:09 +08:00
Stephen Kitt 5bfe738af2 apps: replace intstr.FromInt with intstr.FromInt32
This touches cases where FromInt() is used on numeric constants, or
values which are already int32s, or int variables which are defined
close by and can be changed to int32s with little impact.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2023-05-01 09:17:05 +02: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 da3d98277b Merge pull request #111839 from ialidzhikov/cleanup/pkg-controller
pkg/controller: Replace deprecated func usage from the `k8s.io/utils/pointer` pkg
2022-12-09 15:42:37 -08: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