-
Notifications
You must be signed in to change notification settings - Fork 39k
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
[client-go] Resource leak in kubernetes/client-go/tools/leaderelection #109554
Comments
|
/sig api-machinery |
I can understand why leaderelection doesn't delete lock resource when Leaderelection can rely on others to manage the lifecycle of lock resource, it just need to update it. If no lock resource available when |
are you proposing that the leaderElection logic doesn't create the resource and just depend on an external to create the resource used to determine the leader? |
Yes. |
/cc @roycaihw |
@aojea @silenceshell what about adding a |
I think an optional flag makes sense. Users still need to decide how to manage the lifecycle of lock resources. One option is we have a garbage collector that deletes expired Lease objects (the idea was using Lease as heartbeat, but could be extended to clean up unused leaderelection locks) |
Your proposal name |
The optional flag will help me much. In my user case, helm chart is designed to manage the lifecycle of the lock resource. The issue I met before is that a lock resource was left after So if we can have a choice not to create lock resource in leaderelection, my issue can be solved. |
SGTM. Would you like to send a PR? cc @mikedanese for visibility. |
@roycaihw i was hoping to send a PR for this (and explore the gc option for expired leases), if that's okay? 😅 |
yes, please! |
/assign |
@aryan Thanks for your PR! It works for those |
@silenceshell I don't see how that's a problem. Even if a |
@silenceshell Could you point out where the |
@roycaihw @aryan9600 There is still a chance that lock still exists when getting lock, but it is deleted somehow after getting lock and before updating lock. For those |
@silenceshell I understand your point, but I don't think it falls within the scope of this. |
@aryan9600 OK, I got your point. Then here |
Any update for this issue? #109875 seems stop updating for a long time... Looking forwards to merge it. |
I got the same issue that the lease lock would not be released sometimes, and I found that was caused by the Get method Incorrectly overriding the lock. Can you see if #112022 fixes your lock release issue? @silenceshell |
I'm sorry. I've looked carefully again, and I think what we said may not be the same thing. I will open another issue to record my problem. @silenceshell |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/triage accepted |
What happened?
Opinion 1
Lock resource is created in tryAcquireOrRenew(), but not deleted when release().
If resource cannot be deleted in pkg, it shall not be created. Or, at lease a choice to
ForbiddenCreation
.Opinion 2
Different lock resources react differently with
update
method.Some resources can be created via
update
method, but some cannot. Shall we changeupdate
method topatch
?What did you expect to happen?
Add a new
bool
parameterForbiddenCreation
inLeaderElectionConfig
struct.By default,
ForbiddenCreation
isfalse
, which doesn't impact current users. It's a compatible change.How can we reproduce it (as minimally and precisely as possible)?
Write a
main()
to takeleaderelection
into use.Anything else we need to know?
Code: https://github.com/kubernetes/client-go/tree/master/tools/leaderelection
Kubernetes version
Cloud provider
N/A
OS version
N/A
Install tools
N/A
Container runtime (CRI) and version (if applicable)
N/A
Related plugins (CNI, CSI, ...) and versions (if applicable)
N/A
The text was updated successfully, but these errors were encountered: