From 207d1886cf381148fdefd0686ca11d089a4781c8 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 30 May 2025 14:47:07 -0400 Subject: [PATCH] mon: cleanup for loop Signed-off-by: Patrick Donnelly (cherry picked from commit 8c73055cb43aadebe1e69ff1e02d72306315eedb) --- src/auth/cephx/CephxKeyServer.h | 1 + src/mon/AuthMonitor.cc | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/auth/cephx/CephxKeyServer.h b/src/auth/cephx/CephxKeyServer.h index a041f4bd8e3..ce0836bc682 100644 --- a/src/auth/cephx/CephxKeyServer.h +++ b/src/auth/cephx/CephxKeyServer.h @@ -129,6 +129,7 @@ struct KeyServerData { bool get_caps(CephContext *cct, const EntityName& name, const std::string& type, AuthCapsInfo& caps) const; + auto const& get_secrets() const { return secrets; } std::map::iterator secrets_begin() { return secrets.begin(); } std::map::const_iterator secrets_begin() const diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 8b98de684ed..f6c1d076782 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -469,15 +469,13 @@ void AuthMonitor::encode_pending(MonitorDBStore::TransactionRef t) // health auto& next = get_health_checks_pending_writeable(); map> bad_detail; // entity -> details - for (auto i = mon.key_server.secrets_begin(); - i != mon.key_server.secrets_end(); - ++i) { - for (auto& p : i->second.caps) { + for (auto const& [entity, auth] : mon.key_server.get_secrets()) { + for (auto& p : auth.caps) { ostringstream ss; if (!valid_caps(p.first, p.second, &ss)) { ostringstream ss2; - ss2 << i->first << " " << ss.str(); - bad_detail[i->first.to_str()].push_back(ss2.str()); + ss2 << entity << " " << ss.str(); + bad_detail[entity.to_str()].push_back(ss2.str()); } } } -- 2.39.5