Repository navigation
mgr/rook: don't leak a watcher thread per orchestrator call - #70071
Conversation
e62df13 to
b346eef
Compare
|
jenkins test rook e2e |
1 similar comment
|
jenkins test rook e2e |
|
jenkins test windows |
|
@phlogistonjohn hi John, do you mind helping review this change? |
|
@travisn hi Travis, do you mind taking a look? |
travisn
left a comment
There was a problem hiding this comment.
LGTM, but I am not very familiar with the rook module internals. The key will be the testing. Can we get a ceph image with the change to test it out?
There was a problem hiding this comment.
Pull request overview
This PR addresses a resource leak in the mgr/rook orchestrator integration where short-lived KubernetesResource/KubernetesCustomResource instances can spawn watcher threads that outlive the caller, accumulating threads/connections and eventually causing OOM in long-running mgr daemons.
Changes:
- Introduce
fetch_k8s_items()as a one-shot “list” helper that does not start watcher threads. - Convert per-call fetch sites (device fetchers and
get_resource()) to usefetch_k8s_items(), and updateget_osds()to filter the long-livedrook_podswatch instead of creating new watchers. - Add a unit test covering
fetch_k8s_items()return handling (object response vs dict response).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/pybind/mgr/rook/rook_cluster.py | Adds fetch_k8s_items() and replaces per-call watcher usage to prevent thread/connection leaks; updates get_osds() to reuse the long-lived pod cache. |
| src/pybind/mgr/rook/tests/test_rook.py | Adds a unit test for fetch_k8s_items() and its “no watcher thread” contract. |
b346eef to
4740720
Compare
KubernetesResource spawns a watch thread on the first access to .items, and the thread runs until the watch stream ends. get_osds(), get_resource() and the device fetchers create a KubernetesResource per call, so one describe_service() leaks up to five threads, their HTTPS connections to the apiserver, and the item dicts the threads keep updating. Poll the orchestrator every few seconds and the active mgr accumulates threads until it is OOM-killed. Filter the long-lived rook_pods watch in get_osds() the way describe_pods() does. Convert the other per-call sites to fetch_k8s_items(), a one-shot list call that spawns no watcher. KubernetesResource stays watch-only, for the three long-lived caches in RookCluster. Fixes: https://tracker.ceph.com/issues/78589 Signed-off-by: Kefu Chai <[email protected]>
4740720 to
0c468fe
Compare
|
@tchaikov do you know if we have any test coverage for that issue? Should we add something to cover it? i also not sure who is calling the test_rook.py tests in that change. |
|
@tchaikov how can we proceed with that pr ? |
@NitzanMordhai sorry that i missed your ping.
i think we just need to run this change with a teuthology-basd test. something like |
|
@tchaikov thank you for the explanation on that! |
|
@NitzanMordhai thank you actually. |
|
jenkins test rook e2e |
|
How is the testing looking? Rook users would really appreciate having this fix in the next patch releases. |
|
This PR has been added to wip-bharath1-testing-20260810.014116-main. |
|
@tchaikov To be clear, this PR is not a blocker, right? IIUC according to this comment that the memory leak would not be observed anymore since #70146 was merged and backported? |
@travisn hi Travis, probably. as i cannot prove that #70146 address all leaks we observed. but yes, there are good chances that this change is not a blocker. but i'd prefer having all leak fixes merged in main, and backported. |
|
@ceph/rook hello root maintainers, could you help review this change? |
Sounds good, thanks for the confirmation that it is expected to largely be fixed already.
Rook maintainers honestly are likely not help in reviews of the rook mgr module. Better if someone from @ceph/dashboard can take a look. |
|
@nizamial09 can you also take a look? |
nizamial09
left a comment
There was a problem hiding this comment.
overall lgtm on the code, thanks.
KubernetesResource spawns a watch thread on the first access to .items, and the thread runs until the watch stream ends.
get_osds(),get_resource()and the device fetchers create aKubernetesResourceper call, so onedescribe_service()leaks up to five threads, their HTTPS connections to the apiserver, and the item dicts the threads keep updating. Poll the orchestrator every few seconds and the active mgr accumulates threads until it is OOM-killed.Filter the long-lived rook_pods watch in
get_osds()the waydescribe_pods()does. Convert the other per-call sites tofetch_k8s_items(), a one-shot list call that spawns no watcher.KubernetesResourcestays watch-only, for the three long-lived caches inRookCluster.Fixes: https://tracker.ceph.com/issues/78589
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.