Actions
Bug #80661
closed
SZ
SZ
mgr: Empty Hostname Bucket Contamination in DaemonStateIndex
Bug #80661:
mgr: Empty Hostname Bucket Contamination in DaemonStateIndex
Due date:
% Done:
0%
Source:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Merge Commit:
Fixed In:
v22.0.0-1183-g82c09f6ce5
Released In:
Upkeep Timestamp:
2026-11-20T23:03:06+00:00
Description
When daemons are registered or inserted without an initialized hostname (or with an empty string hostname ""), DaemonStateIndex::_insert blindly inserts them into the by_server mapping under by_server[""]. This creates an invalid empty-key bucket in the index, which is directly exposed to mgr modules (e.g., Dashboard, Cephadm, Orchestrator) via with_daemons_by_server() and get_by_server().
DaemonStateIndex maintains two core lookup maps for daemons in the cluster:- all: Maps DaemonKey → DaemonStatePtr
- by_server: Maps hostname (string) → map<DaemonKey, DaemonStatePtr>
void DaemonStateIndex::_insert(DaemonStatePtr dm)
{
if (all.count(dm->key)) {
_erase(dm->key);
}
by_server[dm->hostname][dm->key] = dm;
all[dm->key] = dm;
...
}
If dm->hostname is empty (""):
- by_server[""][dm->key] is created.
- Python plugins and mgr modules calling with_daemons_by_server() observe a host named "" containing daemons.
- In service daemon registration paths (DaemonServer::handle_open()), a DaemonState is initially created and inserted before its metadata or hostname is populated, guaranteeing temporary or permanent pollution of by_server[""].
Proposed Fix:
Validate non-empty inside DaemonStateIndex so that daemons without a hostname do not create an empty string bucket in by_server:
--- a/src/mgr/DaemonState.cc
+++ b/src/mgr/DaemonState.cc
@@ -235,7 +235,9 @@ void DaemonStateIndex::_insert(DaemonStatePtr dm)
_erase(dm->key);
}
- by_server[dm->hostname][dm->key] = dm;
+ if (!dm->hostname.empty()) {
+ by_server[dm->hostname][dm->key] = dm;
+ }
all[dm->key] = dm;
for (auto& i : dm->devices) {
@@ -274,10 +276,12 @@ void DaemonStateIndex::_erase(const DaemonKey& dmk)
}
}
- auto &server_collection = by_server[dm->hostname];
- server_collection.erase(dm->key);
- if (server_collection.empty()) {
- by_server.erase(dm->hostname);
+ if (!dm->hostname.empty()) {
+ auto &server_collection = by_server[dm->hostname];
+ server_collection.erase(dm->key);
+ if (server_collection.empty()) {
+ by_server.erase(dm->hostname);
+ }
}
all.erase(to_erase);
SZ Updated by Steven Zuraski 2 months ago
- Pull request ID set to 72173
SZ Updated by Steven Zuraski 13 days ago
- Status changed from New to Fix Under Review
SZ Updated by Steven Zuraski 13 days ago
- Status changed from Fix Under Review to Resolved
UB Updated by Upkeep Bot 13 days ago
- Merge Commit set to 82c09f6ce5ddc4d3f6d764298bf346d11f7f5e78
- Fixed In set to v22.0.0-1183-g82c09f6ce5
- Upkeep Timestamp set to 2026-11-20T23:03:06+00:00
Actions