Skip to content

Conversation

@aruiz14
Copy link
Contributor

@aruiz14 aruiz14 commented May 7, 2025

Refers to rancher/rancher#49328

This PR adds a (failing) unit test for the issue described in the parent PR. Then, it also introduces a fix based on:

  • Added support for retrying with a specific period to processSingleItem (instead of AddRateLimited, which may retry immediately).
  • Temporarily keep the UIDs of those resources that were just finalized after all handlers were executed (deletionTimestamp not nil and and empty finalizers).
  • Check if an object was just deleted before executing handlers, then use the retryAfter mechanism to delay its execution (waiting for the DELETE event, which will prune the object from the informer store and also enqueue this key immediately).

@aruiz14 aruiz14 force-pushed the finalizers-race branch from fa19327 to 0be5161 Compare May 7, 2025 11:07
@aruiz14 aruiz14 marked this pull request as ready for review May 7, 2025 11:16
@aruiz14 aruiz14 requested a review from a team as a code owner May 7, 2025 11:16
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These calls are now deprecated in k8s/client-go v0.32 but dang if I can figure out how to use the generic equivalents.

Copy link
Contributor Author

@aruiz14 aruiz14 May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it's actually lasso's controller which has some field with a deprecated type. Happy to help refactoring that to adopt new types based on generics in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking a quick look, and have some comments about this:

  1. The new typed interface allows using string instead of any, getting stricter type-checking and avoiding checks like this.
    • (The deprecated RateLimitingQueue is just an "alias" of TypedRateLimitingQueue[any]
  2. This leads to a breaking change, since RateLimiter from Options should also need to changed to TypedRateLimiter[string].
  3. Sadly, only the workqueue was adapted to support generics. It would be much more interesting if the SharedIndexInformer and its Store were also parameterized, so we don't need to cast objects to runtime.Object.

Taking that into account, I believe there is not much motivation to move this forward at the moment. We could still migrate to use TypedRateLimitingQueue[any], which will keep the compatibility with existing code but also completely miss the benefit of using generics. Also, that could also even reduce our chances of ever migrating to use the correct type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a draft PR with the changes, for completeness:
#162
please feel free to do whatever you think appropriate with it

Copy link
Contributor

@ericpromislow ericpromislow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine. Not worth dealing with the deprecated functions for now

@crobby crobby requested a review from a team May 9, 2025 18:09
@crobby crobby merged commit d35c3df into rancher:main Jun 3, 2025
1 check passed
@aruiz14 aruiz14 deleted the finalizers-race branch June 3, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants