Commit Graph

335 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
aa5abdd371 Merge pull request #136817 from kairosci/fix-gc-notfound-136525
Handle NotFound errors in garbage collector
2026-03-11 03:53:09 +05:30
Alessio Attilio
8ed40e7ae7 test: add unit tests for deleteObject NotFound handling in garbage collector
When deleteObject returns a NotFound error (the object was externally deleted
between the GET and the DELETE), attemptToDeleteItem should enqueue a virtual
delete event and return enqueuedVirtualDeleteEventErr.

Cover both code paths:
- default (background propagation): item with dangling owner
- waitingForDependentsDeletion: item whose owner is foreground-deleting
2026-03-10 20:43:30 +01:00
Kubernetes Prow Robot
9d7dda7186 Merge pull request #137245 from atombrella/feature/slices_contains_pkg_controller
Update `pkg/controller` to use slices.Contains
2026-03-04 18:04:20 +05:30
Mads Jensen
d11d54dc50 Update pkg/controller to use slices.Contains 2026-02-26 10:17:13 +01:00
Karthik Bhat
43bfd8615d Refactor NewTestContext to return Context instead of TContext 2026-02-26 11:27:26 +05:30
Alessio Attilio
ae3163eeca Fix issue 136525: Handle NotFound errors in garbage collector
When objects are deleted externally (e.g., pods deleted directly after
job deletion), the garbage collector should not log errors. This change
adds explicit NotFound error handling in attemptToDeleteItem to enqueue
virtual delete events when deleteObject returns NotFound, treating
external deletion as a successful outcome.

This follows the same pattern already used when getObject returns
NotFound, ensuring consistency across the function.
2026-02-13 00:01:22 +01:00
Davanum Srinivas
550cc8645b Move dump package from apimachinery to k8s.io/utils
Replace all imports of k8s.io/apimachinery/pkg/util/dump with
k8s.io/utils/dump across the repo. The apimachinery dump package
now contains deprecated wrapper functions that delegate to
k8s.io/utils/dump for backwards compatibility.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2026-02-12 07:34:19 -05:00
Kubernetes Prow Robot
8ccb55ffef Merge pull request #136040 from petern48/error-level-logs
fix(controller/resourcequota, controller/garbagecollector): Change V().Error() to V().Info()
2026-01-28 03:27:48 +05:30
Kubernetes Prow Robot
5fbb132d69 Merge pull request #135625 from atiratree/quotamonitor-race
mark QuotaMonitor as not running and invalidate monitors list
2026-01-08 17:19:38 +05:30
Peter Nguyen
384e516093 Change error log to info log in pkg/controller/garbagecollector/ 2026-01-05 13:13:16 -08:00
Manuel Grandeit
b18339638a Fix data race in garbage collector on node.owners field
Add ownersLock to protect concurrent access to node.owners between
GraphBuilder.processGraphChanges() (writer) and GC worker goroutines
reading in blockingDependents() and unblockOwnerReferences() methods.

Also fix concurrent reads in the HTTP debug handler (/graph endpoint)
for owners, dependents, beingDeleted, deletingDependents, and virtual
fields by using their respective thread-safe accessor methods.
2025-12-16 22:38:59 +01:00
Filip Křepinský
feffdbbcf2 mark QuotaMonitor as not running and invalidate monitors list
to prevent close of closed channel panic
2025-12-05 15:50:32 +01:00
Kubernetes Prow Robot
59d65dad34 Merge pull request #134945 from tchap/kcm-controllers-check-threads
pkg/controller: Improve goroutine management (part 2)
2025-11-06 00:43:01 -08:00
Ondra Kupka
d908a470a5 controller/garbagecollector: Improve goroutine mgmt
Make sure all threads are terminated when Run returns.
2025-11-04 23:58:15 +01:00
Lukasz Szaszkiewicz
c832203707 pkg/controller/garbagecollector/garbagecollector_test: wrap kubeClient with a client that doesn't support WatchList semantics. 2025-11-03 10:41:49 +01:00
Kubernetes Prow Robot
3ec2d82da5 Merge pull request #134784 from michaelasp/svm_beta2
SVM: bump the API to beta, remove unused fields
2025-10-29 13:56:02 -07:00
Michael Aspinwall
3b72759d1b Update SVM to Beta
Co-authored-by: Stanislav Láznička <stlaz.devel@proton.me>
2025-10-29 19:36:11 +00:00
Joe Betz
0e7d42dd45 Clean up OWNERS for all api machinery owned controllers 2025-10-24 13:38:10 -04:00
Jordan Liggitt
6d3d7553fb Lock all mutable fields when printing gc node 2025-10-02 08:50:17 -04:00
Kubernetes Prow Robot
d03d25f47c Merge pull request #133985 from aditigupta96/api-waitfornamedcachesync-with-context
Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/
2025-09-16 17:18:09 -07:00
Aditi Gupta
af231d2153 Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/ 2025-09-16 14:51:34 -07:00
Aditi Gupta
dfcadb4f89 Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/garbagecollector 2025-09-10 13:08:27 -07:00
Kubernetes Prow Robot
a5d8ab60ef Merge pull request #132632 from sdowell/gc-rv-race
fix: add RV check on GC delete calls
2025-07-24 17:58:47 -07:00
PatrickLaabs
8abcdf0885 chore: depr. pointer pkg replacement for pkg/controller 2025-07-07 13:13:39 +02:00
Sam Dowell
1c1f00a5f4 fix: add RV check on GC delete calls
It was possible that the object was changed between the live Get and
Delete calls while processing an attempt to delete, causing incorrect
deletion of objects by the garbage collector. A defensive
resourceVersion precondition is added to the delete call to ensure that
the object was properly classified for deletion.
2025-07-02 11:01:56 -07: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
Davanum Srinivas
2b0592ee77 Use k8s.io/utils/lru instead of github.com/golang/groupcache/lru
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-11-04 10:51:13 -05:00
Kubernetes Prow Robot
6edbee19b9 Merge pull request #123152 from tnqn/fix-error-log
Fix internal error when serializing groupLookupFailures in log
2024-10-23 01:17:29 +01:00
haorenfsa
da5f6cf053 garbagecollector: fix logs & comments in gc sync
Signed-off-by: haorenfsa <haorenfsa@gmail.com>
2024-09-14 00:01:38 +08:00
haorenfsa
87ca404634 garbagecollector: add initialSyncTimeout for Run
Signed-off-by: haorenfsa <haorenfsa@gmail.com>
2024-09-14 00:01:37 +08:00
haorenfsa
d4fdfaf17d test/integration/garbagecollector: add test TestCascadingDeleteOnCRDConversionFailure which tests that GC controller cannot be blocked by a bad conversion webhook
Signed-off-by: haorenfsa <haorenfsa@gmail.com>
Co-authored-by: Andrew Sy Kim <andrewsy@google.com>
2024-09-13 23:14:41 +08:00
Andrew Sy Kim
e8b1d7dc24 garbagecollector: controller loop should not be blocking on failed cache sync
Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
Co-authored-by: He Xiaoxi <xxhe@alauda.io>
2024-09-13 23:14:23 +08:00
Joe Betz
2595aa1309 generate 2024-09-03 14:26:26 -04:00
Dr. Stefan Schimanski
c7a1fa432a Call non-blocking informerFactory.Start synchronously to avoid races
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
2024-07-27 18:13:09 +02:00
Matthieu MOREL
f014b754fb fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-07-06 23:15:43 +00:00
Kubernetes Prow Robot
0d17892740 Merge pull request #123184 from googs1025/delete_repeat_comments
typo: delete useless comments
2024-06-24 16:48:32 -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
googs1025
a29dc0bc90 typo: delete useless comments 2024-03-30 17:14:39 +08:00
Nilekh Chaudhari
9161302e7f feat: implements svm controller
Signed-off-by: Nilekh Chaudhari <1626598+nilekhc@users.noreply.github.com>
2024-03-08 19:25:10 +00: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
Quan Tian
3160386f29 Fix internal error when serializing groupLookupFailures in log
When garbagecollector failed to look up ServerPreferredResources, it
logged the failed groups as "<internal error: json: unsupported type:
map[schema.GroupVersion]error>", making the failure more obscure.

It's because the logger tried to serialize the value using json encoder
but the type map[schema.GroupVersion]error is not supported. Either
schema.GroupVersion needs to implement TextMarshaler interface, or we
can serialize the type before passing it to the logger.

Signed-off-by: Quan Tian <qtian@vmware.com>
2024-02-06 18:55:05 +08:00
Jordan Liggitt
c9a084d59c Fix duplicate GC event handlers getting added if discovery flutters 2023-07-12 12:29:31 -04:00
Ziqi Zhao
dfc1838379 Migrated pkg/controller/volume|util|replicaset|nodeipam to contextual logging
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
2023-07-06 07:39:52 +08:00
xin.li
3cf2822bc5 Migrated pkg/controller/garbagecollector to contextual logging
Signed-off-by: xin.li <xin.li@daocloud.io>
2023-07-06 07:36:51 +08:00
Joe Betz
f0f92853ad Add api-machinery TL owners permissions for jpbetz 2023-05-15 11:09:54 -04:00
Daniel Smith
1ffe3f467e lavalamp is taking a long break 2023-05-11 16:43:38 +00:00
Hao Ruan
c4e1b01416 replace spew methods with dump methods 2023-04-14 08:05: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
Patrick Ohly
cbf7d96a85 garbagecollector: structured logging of objectReference
When using JSON as output format, we want objectReference values to be
represented as a struct. For example, "item" is such a value:

{"ts":1678135015708.349,"caller":"garbagecollector/garbagecollector.go:595","msg":"classify object references","v":5,"item":{"name":"dra-test-driver-g4tkd","namespace":"dra-1830","apiVersion":"v1","uid":"c3f88616-7282-488c-887c-3f04291e6f4f"},"solid":null,"dangling":[{"apiVersion":"apps/v1","kind":"ReplicaSet","name":"dra-test-driver","uid":"dbe9a90c-9dfd-4ad0-8395-e5fa228f9851","controller":true,"blockOwnerDeletion":true}],"waitingForDependentsDeletion":null}
2023-03-08 08:37:56 -05:00
Andy Goldstein
26e3dab78b garbagecollector: use contextual logging
Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
2023-03-08 08:37:56 -05:00