-
Notifications
You must be signed in to change notification settings - Fork 61
Avoid race-condition removing object with multiple finalizers #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
| defer cancel() | ||
|
|
||
| queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- The new typed interface allows using
stringinstead ofany, getting stricter type-checking and avoiding checks like this.- (The deprecated
RateLimitingQueueis just an "alias" ofTypedRateLimitingQueue[any]
- (The deprecated
- This leads to a breaking change, since
RateLimiterfromOptionsshould also need to changed toTypedRateLimiter[string]. - Sadly, only the
workqueuewas adapted to support generics. It would be much more interesting if theSharedIndexInformerand itsStorewere also parameterized, so we don't need to cast objects toruntime.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.
There was a problem hiding this comment.
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
ericpromislow
left a comment
There was a problem hiding this 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
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:
processSingleItem(instead ofAddRateLimited, which may retry immediately).deletionTimestampnot nil and and empty finalizers).retryAftermechanism to delay its execution (waiting for theDELETEevent, which will prune the object from the informer store and also enqueue this key immediately).