Repository navigation
mgr/DaemonState: prune empty DeviceState in with_device_create - #72170
stzuraski898 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
@stzuraski898 , The fix is fine, but I don't see the bug happening today.
- with_device_create has only two callers:
-
device set-life-expectancy: set_life_expectancy() always adds 3 metadata keys, so the device is never empty after it.
-
Mgr startup, loading device/* keys: the device is empty only if the stored value is {}. Ceph never writes that, because rm-life-expectancy removes the key when the metadata becomes empty.
So in practice the new if (d->empty()) check never fires.
-
Please update the description. The claim that an empty DeviceState stays in the map "forever" doesn't match the current code. Can you share how to reproduce it? If this is only a consistency cleanup with with_device_write, please say that.
-
Please keep the code change and add a unit test. For example: call with_device_create with a callback that does nothing, then check that the device was removed from the map. The test fails without your fix and passes with it, and it keeps future callers of with_device_create covered.
with_device_create created a DeviceState and ran a callback but never checked whether the device was still empty() afterward, unlike its sibling with_device_write which erases the device in that case. In the current codebase the asymmetry is dormant: the only two callers (set-life-expectancy in DaemonServer.cc and the startup device/* key loader in Mgr.cc) always populate the device before returning, so the new check never fires in practice. The fix is a consistency cleanup: it makes with_device_create honour the same post-callback invariant as with_device_write, ensuring any future caller that passes a no-op or emptying callback does not leave a stale entry in the devices map. Fixes: https://tracker.ceph.com/issues/80655 Assisted-by: Claude Code (Opus) Signed-off-by: Steven Zuraski <[email protected]>
Add DaemonStateIndex.WithDeviceCreateNopPrunesDevice to test_daemonstate.cc. The test calls with_device_create with a no-op callback, then asserts that with_device returns false, confirming the empty DeviceState was removed from the map. The test fails without the if (d->empty()) _erase_device(d) block added to with_device_create in the preceding commit, and passes with it. Fixes: https://tracker.ceph.com/issues/80655 Signed-off-by: Steven Zuraski <[email protected]>
18d6b24 to
6f7650f
Compare
|
jenkins test make check arm64 |
1 similar comment
|
jenkins test make check arm64 |
|
This PR has been added to wip-bharath37-testing-20261124.044935-main. |
with_device_createcreated aDeviceStateand ran a callback but never checked whether the device was stillempty()afterward, unlike its siblingwith_device_write, which erases the device in that case.In the current codebase, this asymmetry is dormant: the only two callers—
set-life-expectancyinDaemonServer.ccand the startupdevice/*key loader inMgr.cc—always populate the device before returning, so the new check never fires in practice. The fix is therefore a consistency cleanup: it makeswith_device_createhonor the same post-callback invariant aswith_device_write, ensuring that any future caller that passes a no-op or emptying callback does not leave a stale entry in the devices map.Fixes: https://tracker.ceph.com/issues/80655
Assisted-by: Claude Code (Opus)
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.