Repository navigation
mgr: override OSD hostname with CRUSH physical host in all metadata paths - #66757
Conversation
|
Can one of the admins verify this patch? |
14 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
When running in Rook on Tentacle v20.2.0, I don't see any OSDs under Is something else needed to enable the If the devices aren't even listed, not sure this change will help. But if you have a test ceph image with the changes, I could try it out. |
|
Thanks for checking @travisn . The purpose of this patch is not to enable device tracking, in our clusters it’s already enabled. The issue is the hostname source. We run Rook on Gardener. Worker nodes get ephemeral hostnames on every redeploy. CRUSH
This breaks our automation (wipeout / redeploy) because device mapping by host becomes inconsistent after a redeploy. The patch makes To give you an idea.
After Gardener redeploy (same disks, new hostname): Result: |
|
@senolcolak Thanks, the change makes sense from your description. To clarify my previous question, I was just trying to see the results of |
I assume you are using the minikube deployment on your own laptop(test vm) so there is no real OSD devices attached. Since the OSDs are backed by virtual devices/files(HostPath) instead of physical disks, they don't expose the hardware metrics (like SMART data) that |
|
Ok makes sense that it requires the SMART devices, not just virtual devices. The changes LGTM then. |
644dd80 to
0d96230
Compare
|
jenkins test make check arm64 |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
@senolcolak -If this PR requires re-testing, please add the needs-qa label accordingly. |
|
Hi @rzarzynski |
…aths In containerized deployments (e.g. Rook), OSD daemons report the pod/container hostname. The CRUSH map records the physical host. This mismatch causes 'ceph device ls' to show pod names instead of physical hosts, breaking host-based device correlation. Fix by deriving the CRUSH host bucket name for each OSD and substituting it as the canonical hostname in all three metadata paths: - MetadataUpdate::finish (async mon metadata fetch, primary path) - Mgr::load_all_metadata OSD bulk-load (startup/failover) - DaemonServer::fetch_missing_metadata (via MetadataUpdate) The override is a no-op when the OSD is absent from CRUSH or when the OSD map is not yet available. Fixes: https://tracker.ceph.com/issues/73080 Signed-off-by: senol.colak <[email protected]>
0d96230 to
dcd9c5b
Compare
|
this patch needs to run tests against gardener shoots. |
zoorpha
left a comment
There was a problem hiding this comment.
Overall: LGTM — the v2 rework is a significant improvement over v1. The dead-code issue is fixed, lock ordering is preserved, and the by_server index consistency concern from the previous iteration is properly addressed. The approach is sound and the comments explaining the locking rationale are excellent.
I have a few minor suggestions below. Nothing blocking, but worth addressing before merge.
1. Redundant state->hostname assignment in the new-daemon path
In MetadataUpdate::finish(), the !daemon_state.exists(key) branch sets state->hostname three times:
state->hostname = daemon_meta.at("hostname").get_str(); // reported hostname
// ...
state->hostname = crush_host; // CRUSH override
// ...
state->set_metadata(m); // sets it again from mBecause DaemonState::set_metadata() updates hostname from the map when "hostname" is present, the middle assignment is redundant in the OSD-with-CRUSH-host case. Consider simplifying to:
// For non-OSDs or OSDs without a CRUSH host, preserve the reported hostname
if (key.type != "osd" || crush_host.empty()) {
m["hostname"] = daemon_meta.at("hostname").get_str();
} else {
m["hostname"] = crush_host;
}
state->set_metadata(m);This removes the direct state->hostname assignments entirely and lets set_metadata own the field.
2. Add automated test coverage
The PR description lists manual Rook verification steps, which is great for the final check, but core mgr metadata indexing changes should have some automated coverage. Two suggestions:
A. Unit test for crush_hostname_for_osd and by_server consistency
The crush_hostname_for_osd helper is currently static in Mgr.cc, so it's invisible to src/test/mgr/. Could you either:
- Move it to
ClusterStateas a public method (e.g.,ClusterState::get_crush_hostname_for_osd(int)), or - Declare it in
Mgr.hand make it non-static?
Then we can add a unittest_mgr_clusterstate test that builds a CrushWrapper, injects it into an OSDMap, and asserts the helper returns the correct "host" bucket. We should also test that DaemonStateIndex::update_metadata correctly migrates the by_server index when the hostname changes.
B. Integration test without containers
You don't need a real Rook cluster to verify this. A simple vstart or teuthology test can manufacture the mismatch by moving an OSD to a synthetic CRUSH host:
ceph osd crush move osd.0 host=fake-container-name
# ... verify ceph osd metadata 0 shows hostname=fake-container-nameThis exercises the exact code path (CRUSH host ≠ reported hostname) without any container infrastructure. I'd suggest adding either:
- A shell workunit under
qa/workunits/mgr/, or - A Python teuthology task under
qa/tasks/mgr/that performs the CRUSH move, fails the mgr, and assertsceph osd metadata 0 | jq -r '.hostname'.
3. Nit: load_all_metadata dout(4) behavior change
Not a bug, just an FYI: in load_all_metadata, the log line now prints the post-override hostname rather than the raw reported hostname. This is the correct behavior, but if anyone is debugging metadata issues they may notice the difference after this patch.
Thanks for the careful rework — the locking comments in MetadataUpdate::finish are particularly good and will save future maintainers a lot of head-scratching.
The previous patch only injected hostname into the metadata map for OSDs that were placed under a CRUSH host bucket. For mds/mgr/mon daemons and for OSDs absent from CRUSH, the original 'state->hostname = ...' line was removed without a replacement, so update_metadata received a map with no 'hostname' key. DaemonState::set_metadata only updates state->hostname when the map carries it, so a daemon restarting on a different host would be re-inserted in by_server under its stale hostname. Always seed m["hostname"] from the metadata-reported hostname, then prefer the CRUSH host when available. Apply the same shape to the new-daemon branch so set_metadata uniformly drives state->hostname, removing the redundant direct assignment. Reported-by: code review on PR ceph#66757 Signed-off-by: senol.colak <[email protected]>
|
Hi @rzarzynski, @adk3798, @SrinivasaBharath — small follow-up commit on top of the previously approved
It closes a Since QA last ran against Thanks for the patience on this one. |
|
Let's retest it! |
|
jenkins test make check arm64 |
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
The previous patch only injected hostname into the metadata map for OSDs that were placed under a CRUSH host bucket. For mds/mgr/mon daemons and for OSDs absent from CRUSH, the original 'state->hostname = ...' line was removed without a replacement, so update_metadata received a map with no 'hostname' key. DaemonState::set_metadata only updates state->hostname when the map carries it, so a daemon restarting on a different host would be re-inserted in by_server under its stale hostname. Always seed m["hostname"] from the metadata-reported hostname, then prefer the CRUSH host when available. Apply the same shape to the new-daemon branch so set_metadata uniformly drives state->hostname, removing the redundant direct assignment. Reported-by: code review on PR ceph#66757 Signed-off-by: senol.colak <[email protected]>
The previous patch only injected hostname into the metadata map for OSDs that were placed under a CRUSH host bucket. For mds/mgr/mon daemons and for OSDs absent from CRUSH, the original 'state->hostname = ...' line was removed without a replacement, so update_metadata received a map with no 'hostname' key. DaemonState::set_metadata only updates state->hostname when the map carries it, so a daemon restarting on a different host would be re-inserted in by_server under its stale hostname. Always seed m["hostname"] from the metadata-reported hostname, then prefer the CRUSH host when available. Apply the same shape to the new-daemon branch so set_metadata uniformly drives state->hostname, removing the redundant direct assignment. Reported-by: code review on PR ceph#66757 Signed-off-by: senol.colak <[email protected]>
Problem
In containerized Ceph deployments (e.g. Rook/OCS), OSD daemons report the
pod or container hostname. The CRUSH map records the physical host. This
mismatch causes
ceph device lsto show pod names instead of physicalhosts, breaking host-based device correlation.
Fixes: https://tracker.ceph.com/issues/73080
What was wrong with the previous version
The original patch inserted
_override_osd_crush_hostname()insideif (m->service_daemon)inhandle_open. OSDs connect withservice_daemon = false, so that branch is never reached for OSD daemons —the override was dead code.
In addition, the
handle_updateinsertion calledwith_osdmap(whichacquires
Objecter::rwlock) while holdingstate->lock, introducing anew lock ordering
state->lock → Objecter::rwlocknot present elsewhere.And setting
state->hostnamedirectly beforeupdate_metadatawouldcorrupt the
by_serverindex, because_erasereadsdm->hostnameatcall time to locate the entry to remove.
Solution
Move the override to the three paths where OSD metadata actually flows:
MetadataUpdate::finish— async mon metadata fetch (primary path,runs in Ceph finisher thread). CRUSH resolution happens before taking
state->lockto preserve lock ordering. The CRUSH hostname is injectedvia
m["hostname"]soDaemonStateIndex::update_metadata/set_metadatapicks it up correctly, keeping the
by_serverindex consistent.Mgr::load_all_metadata— OSD bulk-load at startup/failover.All five
MetadataUpdateconstruction sites are updated to passcluster_stateto the new 3-argument constructor.A static free function
crush_hostname_for_osd(ClusterState&, int)inMgr.cccallscluster_state.with_osdmapand returns the CRUSH"host"bucket name for the OSD, or an empty string when absent. The override is a
no-op when the OSD is absent from CRUSH or the OSD map is not yet loaded.
Testing
Verify in a Rook/containerized environment:
ceph device lsshows physical hostnames, not pod namesceph osd metadata <id>shows correcthostnamefieldload_all_metadata