Commit Graph

37 Commits

Author SHA1 Message Date
Alejandro Ruiz b8f808a8bf
Fix typo in test files (#174) 2025-08-28 10:15:36 -04:00
Alejandro Ruiz d9be1e6a05
Add "ctx" label to lasso handler metrics (#156) 2025-07-04 15:57:56 -04:00
Chad Roberts 0e3b207abb
Fix potential panic in observeDeletedObjectAfterFinalize where recentDeletions could be nil (#165)
* Fix potential panic in observeDeletedObjectAfterFinalize where recentDeletions could be nil

* Update test to cover latest panic fix
2025-06-23 16:56:24 -04:00
Alejandro Ruiz 6f565c15d7
Fix panic when SharedHandler.Register is never called (#164)
* add failing test

* Fix panic when SharedHandler.Register is never called
2025-06-23 12:09:23 -04:00
Krunal Hingu 7a2694908a
[v1.33] Bump dependencies for 1.33 (#163)
* feat: update Go version and bump dependencies to support Kubernetes 1.33

* fix: regenerate SharedIndexInformer mock to include AddEventHandlerWithOptions
2025-06-09 21:07:25 -07:00
Alejandro Ruiz d35c3dff56
Avoid race-condition removing object with multiple finalizers (#160)
* Add (failing) unit tests

* Allow retryAfter via custom error type

* Skip OnChange for just-deleted resources

* Fast-track objects not marked for deletion
2025-06-03 06:58:58 -04:00
Alejandro Ruiz 6b2576c47b
Switch from github.com/golang/mock to go.uber.org/mock (#100)
* Add missing go:generate

* Run go generate with new mockgen

* Update imports

* go mod tidy
2024-09-11 12:33:54 -05:00
Silvio Moioli 89b352efa3
Update pkg/controller/controller.go
Co-authored-by: Tom Lebreux <me@tomlebreux.com>
2024-02-27 12:43:24 +01:00
Silvio Moioli 8b8bf070a8
Explain default rate limiting behavior
Signed-off-by: Silvio Moioli <silvio@moioli.net>
2023-08-04 16:47:14 +02:00
Ricardo Weir dfcaeab10d Add to README 2023-03-31 15:29:35 -07:00
Ricardo Weir b7ec3b315a Add tests 2022-12-21 15:29:19 -07:00
Ricardo Weir 9424bfce77 Add the ability to configure useragent
Added the ability to configure a client's user agent. Added wrappers
for controllers, and factories that provide the ability to configure
the user agent of the clients they use.
2022-12-21 15:29:14 -07:00
Ricardo Weir 5e907eb105 Add docs for controller package 2022-05-17 17:51:42 -07:00
Ricardo Weir 5492937d69 Add option to only enqueue if actually updated
This option causes the handle function to only proceed if the
object was actually updated. This is intended to be used by
applications with many objects and/or controllers types that
have alternative means of rerunning when necessary. When the
informer's resync their cache the update function is run.
This reducing the overhead but has the tradeoff of not
rerunning handlers that may rely on external objects or
services or experience a bug causing them to not retry even
if it was necessary. The result is that running the handler
func on resync will mostly only serve the purpose of catching
missed cache events.
2022-05-17 17:51:39 -07:00
Ricardo Weir 6bec1c42ea Add metrics 2022-02-15 16:07:42 -07:00
michelia 5eb28ac4f6 expose metrics for controller reconciliation and work queue 2022-02-14 17:07:12 -07:00
Jacie b241bd94ec fix gouroutine leak when sharedcontroller has been started 2022-01-10 08:46:51 +08:00
Darren Shepherd 3c6118a306 Don't hold controller lock during cache sync
While waiting for caches to sync it is possible that one of the resources
calls the sharedcontrollerfactory to acquire a controller. This will cause
a deadlock as the controller is waiting on the cache which is waiting on
a handler which is blocked on the controller.
2021-12-16 18:30:41 -07:00
Dan Ramich 290d1f010b Drop bucket rate limiter 2021-05-25 16:36:26 -06:00
Darren Shepherd 58c8a34182
Merge pull request #6 from dramich/queue
Add a max timeout bucket
2021-05-25 15:12:23 -07:00
Darren Shepherd a3ff816367 Don't hold lock while handlers are running 2021-05-25 09:43:41 -07:00
Dan Ramich b4294eb8b7 Add a max timeout bucket 2021-05-24 10:49:56 -06:00
Darren Shepherd f563295372 Use read lock to avoid concurrency issues 2021-05-20 12:12:30 -07:00
Darren Shepherd 202b992227 Reduce max backoff to 2 minutes 2021-05-12 14:00:11 -07:00
Kinara Shah 785b05b9a7 don't rate limit key when registering handlers
Problem:
EnqueueKey rate limits the key and is called by sharedcontroller's RegisterHandler.
This is an issue because on startup we start enqueuing each key for each handler, causing the rate limit duration spike to hours very quickly.

Solution:
Adding the key to workqueue directly in EnqueueKey. This is what 2.4.x did as well,
https://github.com/rancher/norman/blob/release/v2.4/controller/generic_controller.go#L187
2021-04-08 16:06:03 -07:00
Darren Shepherd 459cd42cfd Don't propagate zero value runtime.Object between handlers 2021-03-25 16:09:05 -07:00
Darren Shepherd 0a141fe42c Properly handle tombstones 2021-02-10 16:27:36 -07:00
Darren Shepherd 1ca69e6537 Add support for unstructured watches based on gvk 2021-02-10 16:27:36 -07:00
Darren Shepherd fb5e396643 Don't use goroutines as the ordering is non-deterministic 2020-09-04 15:49:12 -07:00
Darren Shepherd fff0364fb3 Don't nil the workqueue on shutdown
When shutdown is called the queue consumer could still be processing
items so don't set the workqueue to nil.  There is no reason to
nil the workqueue as there is no way to restart a controller.
It most be thrown away and a new one created.
2020-08-07 16:13:17 -07:00
Darren Shepherd 961184571d Ignore GVK lookup error
If while creating the controller the GVK lookup to determine worker size
failes ignore the issue.
2020-07-27 22:51:26 -07:00
Darren Shepherd 8079eb2290 Refactor to allow mode that does not require RESTMapper to be invoked 2020-05-15 08:52:39 -07:00
rmweir 0e42fdc3e0 return non ignore errs 2020-05-13 16:06:25 -07:00
Darren Shepherd e0509f89f3 Don't require type to exist in k8s until controllers are started 2020-04-27 10:17:00 -07:00
Darren Shepherd 37670edbf7 Fix bug where OnChange did not trigger controller start 2020-04-22 16:09:12 -07:00
Darren Shepherd 783ff11440 Add GVK() and ForObject() methods 2020-04-15 22:13:13 -07:00
Darren Shepherd 6cfd718cfe Initial Commit 2020-04-15 02:14:08 -07:00