-
Notifications
You must be signed in to change notification settings - Fork 41.1k
scheduler cache: Fix memory leak in scheduler cache management #133411
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
base: master
Are you sure you want to change the base?
scheduler cache: Fix memory leak in scheduler cache management #133411
Conversation
Please note that we're already in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Thu Aug 7 03:00:08 UTC 2025. |
|
Welcome @ravisastryk! |
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Hi @ravisastryk. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ravisastryk The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @ravisastryk |
Aren't these two functions equivalent?
Seems |
Thank you for your quick review @AxeZhan. You are right sets.Set[T], is just map[T]Empty under the hood. Both are functionally identical and apparently both deletion methods are same and the potential problem is not in this path. I attempted couple of approaches in the cache management but does seem to be the root cause. However, I discovered now that memory leak is potentially happening in the Kubernetes framework, in particular pods removal code path. It was caused by improper slice element removal in the removeFromSlice()
|
b3d7bcf
to
73171fe
Compare
73171fe
to
542d54e
Compare
542d54e
to
e415eef
Compare
/ok-to-test |
/retest |
e415eef
to
f51c404
Compare
/retest-required |
…ete() instead code review comments changesscheduler cache snapshot management revert set deletion changes improper slice element removal skip if any pod info is nil nil pointer dereference fix
f51c404
to
58d6d89
Compare
@ravisastryk: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This fixes a memory leak in the Kubernetes framework, in particular pods removal code path. It was caused by improper slice element removal in the removeFromSlice()
When pods were removed from NodeInfo slices (Pods, PodsWithAffinity, PodsWithRequiredAntiAffinity), the function was:
This meant that even after pod gets deleted, the array still held references to
PodInfo
objects at positions beyond the slice length. This is preventing garbage collection(GC). WithStatefulSets
using PVCs and anti-affinity (which populate these slices), this creates a significant memory leak as pods are deleted but their PodInfo objects remain referenced in memory.Which issue(s) this PR is related to:
Fixes #133365
Special notes for your reviewer:
Does this PR introduce a user-facing change?
NONE
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
N/A