]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: use std namespace
authorPatrick Donnelly <pdonnell@ibm.com>
Thu, 30 Jan 2025 22:05:25 +0000 (17:05 -0500)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 17 Mar 2025 19:43:21 +0000 (15:43 -0400)
This C++ code was relying on the Client.h header to bring in these names from
the std:: namespace. A subsequent commit plans to remove that header so add
namespace qualifier now.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
(cherry picked from commit 706b2be416246dd5923478d8a7ee015246f03e95)

Conflicts:
src/mgr/DaemonServer.h: no header cleanup

src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/DaemonServer.cc
src/mgr/DaemonServer.h
src/mgr/Mgr.cc
src/mgr/PyModuleRegistry.h

index 17bb3951142abe2dad0bf1547d1b2edda378af3e..c7a8e8054834b5f99482dc751febd95b76889b62 100644 (file)
@@ -245,7 +245,7 @@ PyObject *ActivePyModules::get_python(const std::string &what)
   } else if (what == "modified_config_options") {
     without_gil_t no_gil;
     auto all_daemons = daemon_state.get_all();
-    set<string> names;
+    std::set<string> names;
     for (auto& [key, daemon] : all_daemons) {
       std::lock_guard l(daemon->lock);
       for (auto& [name, valmap] : daemon->config) {
@@ -782,7 +782,7 @@ std::map<std::string, std::string> ActivePyModules::get_services() const
 void ActivePyModules::update_kv_data(
   const std::string prefix,
   bool incremental,
-  const map<std::string, std::optional<bufferlist>, std::less<>>& data)
+  const std::map<std::string, std::optional<bufferlist>, std::less<>>& data)
 {
   std::lock_guard l(lock);
   bool do_config = false;
@@ -1118,7 +1118,7 @@ PyObject *ActivePyModules::get_foreign_config(
 
   std::map<std::string,std::string,std::less<>> config;
   cluster_state.with_osdmap([&](const OSDMap &osdmap) {
-      map<string,string> crush_location;
+      std::map<string,string> crush_location;
       string device_class;
       if (entity.is_osd()) {
        osdmap.crush->get_full_location(who, &crush_location);
@@ -1277,7 +1277,7 @@ void ActivePyModules::set_device_wear_level(const std::string& devid,
                                            float wear_level)
 {
   // update mgr state
-  map<string,string> meta;
+  std::map<string,string> meta;
   daemon_state.with_device(
     devid,
     [wear_level, &meta] (DeviceState& dev) {
index d6ade4849f78a53b78dff4fc7f5a4dec1567e0e2..c48a06ce95e4d36067f84842810c743fc4b8fdcf 100644 (file)
 #include "ClusterState.h"
 #include "OSDPerfMetricTypes.h"
 
+#include <map>
+#include <set>
+#include <string>
+
 class health_check_map_t;
 class DaemonServer;
 class MgrSession;
@@ -179,7 +183,7 @@ public:
   void update_kv_data(
     const std::string prefix,
     bool incremental,
-    const map<std::string, std::optional<bufferlist>, std::less<>>& data);
+    const std::map<std::string, std::optional<bufferlist>, std::less<>>& data);
   void _refresh_config_map();
 
   // Public so that MonCommandCompletion can use it
index cb0a2e36deb376f338b3dea6ea3a2512472edc22..60c0637d551a051ea679b12e780b53a14eb7c72e 100644 (file)
 #include "common/errno.h"
 #include "common/pick_address.h"
 
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_mgr
 #undef dout_prefix
@@ -806,14 +811,14 @@ bool DaemonServer::handle_report(const ref_t<MMgrReport>& m)
 
 void DaemonServer::_generate_command_map(
   cmdmap_t& cmdmap,
-  map<string,string> &param_str_map)
+  std::map<string,string> &param_str_map)
 {
   for (auto p = cmdmap.begin();
        p != cmdmap.end(); ++p) {
     if (p->first == "prefix")
       continue;
     if (p->first == "caps") {
-      vector<string> cv;
+      std::vector<string> cv;
       if (cmd_getval(cmdmap, "caps", cv) &&
          cv.size() % 2 == 0) {
        for (unsigned i = 0; i < cv.size(); i += 2) {
@@ -847,7 +852,7 @@ bool DaemonServer::_allowed_command(
   const string &module,
   const string &prefix,
   const cmdmap_t& cmdmap,
-  const map<string,string>& param_str_map,
+  const std::map<string,string>& param_str_map,
   const MonCommand *this_cmd) {
 
   if (s->entity_name.is_mon()) {
@@ -994,7 +999,7 @@ void DaemonServer::log_access_denied(
 }
 
 void DaemonServer::_check_offlines_pgs(
-  const set<int>& osds,
+  const std::set<int>& osds,
   const OSDMap& osdmap,
   const PGMap& pgmap,
   offline_pg_report *report)
@@ -1004,7 +1009,7 @@ void DaemonServer::_check_offlines_pgs(
   report->osds = osds;
 
   for (const auto& q : pgmap.pg_stat) {
-    set<int32_t> pg_acting;  // net acting sets (with no missing if degraded)
+    std::set<int32_t> pg_acting;  // net acting sets (with no missing if degraded)
     bool found = false;
     if (q.second.state == 0) {
       report->unknown.insert(q.first);
@@ -1066,7 +1071,7 @@ void DaemonServer::_check_offlines_pgs(
 }
 
 void DaemonServer::_maximize_ok_to_stop_set(
-  const set<int>& orig_osds,
+  const std::set<int>& orig_osds,
   unsigned max,
   const OSDMap& osdmap,
   const PGMap& pgmap,
@@ -1084,9 +1089,9 @@ void DaemonServer::_maximize_ok_to_stop_set(
 
   // semi-arbitrarily start with the first osd in the set
   offline_pg_report report;
-  set<int> osds = orig_osds;
+  std::set<int> osds = orig_osds;
   int parent = *osds.begin();
-  set<int> children;
+  std::set<int> children;
 
   while (true) {
     // identify the next parent
@@ -1152,7 +1157,7 @@ bool DaemonServer::_handle_command(
     session->inst.name = m->get_source();
   }
 
-  map<string,string> param_str_map;
+  std::map<string,string> param_str_map;
   std::stringstream ss;
   int r = 0;
 
@@ -1367,7 +1372,7 @@ bool DaemonServer::_handle_command(
     }
     for (auto& con : p->second) {
       assert(HAVE_FEATURE(con->get_features(), SERVER_OCTOPUS));
-      vector<spg_t> pgs = { spgid };
+      std::vector<spg_t> pgs = { spgid };
       con->send_message(new MOSDScrub2(monc->get_fsid(),
                                       epoch,
                                       pgs,
@@ -1383,10 +1388,10 @@ bool DaemonServer::_handle_command(
              prefix == "osd repair") {
     string whostr;
     cmd_getval(cmdctx->cmdmap, "who", whostr);
-    vector<string> pvec;
+    std::vector<string> pvec;
     get_str_vec(prefix, pvec);
 
-    set<int> osds;
+    std::set<int> osds;
     if (whostr == "*" || whostr == "all" || whostr == "any") {
       cluster_state.with_osdmap([&](const OSDMap& osdmap) {
          for (int i = 0; i < osdmap.get_max_osd(); i++)
@@ -1412,9 +1417,9 @@ bool DaemonServer::_handle_command(
        return true;
       }
     }
-    set<int> sent_osds, failed_osds;
+    std::set<int> sent_osds, failed_osds;
     for (auto osd : osds) {
-      vector<spg_t> spgs;
+      std::vector<spg_t> spgs;
       epoch_t epoch;
       cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pgmap) {
          epoch = osdmap.get_epoch();
@@ -1460,7 +1465,7 @@ bool DaemonServer::_handle_command(
   } else if (prefix == "osd pool scrub" ||
              prefix == "osd pool deep-scrub" ||
              prefix == "osd pool repair") {
-    vector<string> pool_names;
+    std::vector<string> pool_names;
     cmd_getval(cmdctx->cmdmap, "who", pool_names);
     if (pool_names.empty()) {
       ss << "must specify one or more pool names";
@@ -1468,8 +1473,8 @@ bool DaemonServer::_handle_command(
       return true;
     }
     epoch_t epoch;
-    map<int32_t, vector<pg_t>> pgs_by_primary; // legacy
-    map<int32_t, vector<spg_t>> spgs_by_primary;
+    std::map<int32_t, std::vector<pg_t>> pgs_by_primary; // legacy
+    std::map<int32_t, std::vector<spg_t>> spgs_by_primary;
     cluster_state.with_osdmap([&](const OSDMap& osdmap) {
       epoch = osdmap.get_epoch();
       for (auto& pool_name : pool_names) {
@@ -1524,8 +1529,8 @@ bool DaemonServer::_handle_command(
       prefix == "osd test-reweight-by-pg" ||
       prefix == "osd test-reweight-by-utilization";
     int64_t oload = cmd_getval_or<int64_t>(cmdctx->cmdmap, "oload", 120);
-    set<int64_t> pools;
-    vector<string> poolnames;
+    std::set<int64_t> pools;
+    std::vector<string> poolnames;
     cmd_getval(cmdctx->cmdmap, "pools", poolnames);
     cluster_state.with_osdmap([&](const OSDMap& osdmap) {
        for (const auto& poolname : poolnames) {
@@ -1677,10 +1682,10 @@ bool DaemonServer::_handle_command(
   } else if (prefix == "osd safe-to-destroy" ||
             prefix == "osd destroy" ||
             prefix == "osd purge") {
-    set<int> osds;
+    std::set<int> osds;
     int r = 0;
     if (prefix == "osd safe-to-destroy") {
-      vector<string> ids;
+      std::vector<string> ids;
       cmd_getval(cmdctx->cmdmap, "ids", ids);
       cluster_state.with_osdmap([&](const OSDMap& osdmap) {
                                  r = osdmap.parse_osd_id_list(ids, &osds, &ss);
@@ -1702,7 +1707,7 @@ bool DaemonServer::_handle_command(
       cmdctx->reply(r, ss);
       return true;
     }
-    set<int> active_osds, missing_stats, stored_pgs, safe_to_destroy;
+    std::set<int> active_osds, missing_stats, stored_pgs, safe_to_destroy;
     int affected_pgs = 0;
     cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
        if (pg_map.num_pg_unknown > 0) {
@@ -1837,9 +1842,9 @@ bool DaemonServer::_handle_command(
     monc->start_mon_command({cmd}, {}, nullptr, &on_finish->outs, on_finish);
     return true;
   } else if (prefix == "osd ok-to-stop") {
-    vector<string> ids;
+    std::vector<string> ids;
     cmd_getval(cmdctx->cmdmap, "ids", ids);
-    set<int> osds;
+    std::set<int> osds;
     int64_t max = 1;
     cmd_getval(cmdctx->cmdmap, "max", max);
     int r;
@@ -1889,11 +1894,11 @@ bool DaemonServer::_handle_command(
              prefix == "osd pool force-backfill" ||
              prefix == "osd pool cancel-force-recovery" ||
              prefix == "osd pool cancel-force-backfill") {
-    vector<string> vs;
+    std::vector<string> vs;
     get_str_vec(prefix, vs);
     auto& granularity = vs.front();
     auto& forceop = vs.back();
-    vector<pg_t> pgs;
+    std::vector<pg_t> pgs;
 
     // figure out actual op just once
     int actual_op = 0;
@@ -1907,10 +1912,10 @@ bool DaemonServer::_handle_command(
       actual_op = OFR_RECOVERY | OFR_CANCEL;
     }
 
-    set<pg_t> candidates; // deduped
+    std::set<pg_t> candidates; // deduped
     if (granularity == "pg") {
       // covnert pg names to pgs, discard any invalid ones while at it
-      vector<string> pgids;
+      std::vector<string> pgids;
       cmd_getval(cmdctx->cmdmap, "pgid", pgids);
       for (auto& i : pgids) {
         pg_t pgid;
@@ -1923,7 +1928,7 @@ bool DaemonServer::_handle_command(
       }
     } else {
       // per pool
-      vector<string> pool_names;
+      std::vector<string> pool_names;
       cmd_getval(cmdctx->cmdmap, "who", pool_names);
       if (pool_names.empty()) {
         ss << "must specify one or more pool names";
@@ -2018,7 +2023,7 @@ bool DaemonServer::_handle_command(
     // message per distinct OSD
     cluster_state.with_osdmap([&](const OSDMap& osdmap) {
        // group pgs to process by osd
-       map<int, vector<spg_t>> osdpgs;
+       std::map<int, std::vector<spg_t>> osdpgs;
        for (auto& pgid : pgs) {
          int primary;
          spg_t spg;
@@ -2264,7 +2269,7 @@ bool DaemonServer::_handle_command(
     cmdctx->reply(r, ss);
     return true;
   } else if (prefix == "device ls") {
-    set<string> devids;
+    std::set<string> devids;
     TextTable tbl;
     if (f) {
       f->open_array_section("devices");
@@ -2363,7 +2368,7 @@ bool DaemonServer::_handle_command(
   } else if (prefix == "device ls-by-host") {
     string host;
     cmd_getval(cmdctx->cmdmap, "host", host);
-    set<string> devids;
+    std::set<string> devids;
     daemon_state.list_devids_by_server(host, &devids);
     if (f) {
       f->open_array_section("devices");
@@ -2452,7 +2457,7 @@ bool DaemonServer::_handle_command(
       r = -EINVAL;
       cmdctx->reply(r, ss);
     } else {
-      map<string,string> meta;
+      std::map<string,string> meta;
       daemon_state.with_device_create(
        devid,
        [from, to, &meta] (DeviceState& dev) {
@@ -2478,7 +2483,7 @@ bool DaemonServer::_handle_command(
   } else if (prefix == "device rm-life-expectancy") {
     string devid;
     cmd_getval(cmdctx->cmdmap, "devid", devid);
-    map<string,string> meta;
+    std::map<string,string> meta;
     if (daemon_state.with_device_write(devid, [&meta] (DeviceState& dev) {
          dev.rm_life_expectancy();
          meta = dev.metadata;
@@ -2733,7 +2738,7 @@ void DaemonServer::send_report()
        });
     });
 
-  map<daemon_metric, unique_ptr<DaemonHealthMetricCollector>> accumulated;
+  std::map<daemon_metric, unique_ptr<DaemonHealthMetricCollector>> accumulated;
   for (auto service : {"osd", "mon"} ) {
     auto daemons = daemon_state.get_by_service(service);
     for (const auto& [key,state] : daemons) {
@@ -2772,9 +2777,9 @@ void DaemonServer::adjust_pgs()
   double max_misplaced = g_conf().get_val<double>("target_max_misplaced_ratio");
   bool aggro = g_conf().get_val<bool>("mgr_debug_aggressive_pg_num_changes");
 
-  map<string,unsigned> pg_num_to_set;
-  map<string,unsigned> pgp_num_to_set;
-  set<pg_t> upmaps_to_clear;
+  std::map<string,unsigned> pg_num_to_set;
+  std::map<string,unsigned> pgp_num_to_set;
+  std::set<pg_t> upmaps_to_clear;
   cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
       unsigned creating_or_unknown = 0;
       for (auto& i : pg_map.num_pg_by_state) {
@@ -2844,7 +2849,7 @@ void DaemonServer::adjust_pgs()
                       << dendl;
              ok = false;
            }
-           vector<int32_t> source_acting;
+           std::vector<int32_t> source_acting;
             for (auto &merge_participant : {merge_source, merge_target}) {
               bool is_merge_source = merge_participant == merge_source;
               if (osdmap.have_pg_upmaps(merge_participant)) {
@@ -3136,7 +3141,7 @@ void DaemonServer::got_service_map()
 void DaemonServer::got_mgr_map()
 {
   std::lock_guard l(lock);
-  set<std::string> have;
+  std::set<std::string> have;
   cluster_state.with_mgrmap([&](const MgrMap& mgrmap) {
       auto md_update = [&] (DaemonKey key) {
         std::ostringstream oss;
@@ -3272,8 +3277,8 @@ bool DaemonServer::asok_command(
 even those get stuck. Please enable \"mgr_enable_op_tracker\", and the tracker \
 will start to track new ops received afterwards.";
 
-    set<string> filters;
-    vector<string> filter_str;
+    std::set<string> filters;
+    std::vector<string> filter_str;
     if (cmd_getval(cmdmap, "filterstr", filter_str)) {
         copy(filter_str.begin(), filter_str.end(),
            inserter(filters, filters.end()));
index 1193805def57277e52b73f0da5fe61c5cfc52de1..c1c92883f3d5bc6de878dec50e689d96e790f808 100644 (file)
@@ -19,6 +19,8 @@
 #include <set>
 #include <string>
 #include <boost/variant.hpp>
+#include <unordered_map>
+#include <vector>
 
 #include "common/ceph_mutex.h"
 #include "common/LogClient.h"
@@ -49,10 +51,10 @@ struct MDSPerfMetricQuery;
 
 
 struct offline_pg_report {
-  set<int> osds;
-  set<pg_t> ok, not_ok, unknown;
-  set<pg_t> ok_become_degraded, ok_become_more_degraded;             // ok
-  set<pg_t> bad_no_pool, bad_already_inactive, bad_become_inactive;  // not ok
+  std::set<int> osds;
+  std::set<pg_t> ok, not_ok, unknown;
+  std::set<pg_t> ok_become_degraded, ok_become_more_degraded;             // ok
+  std::set<pg_t> bad_no_pool, bad_already_inactive, bad_become_inactive;  // not ok
 
   bool ok_to_stop() const {
     return not_ok.empty() && unknown.empty();
@@ -180,7 +182,7 @@ private:
     const PGMap& pgmap,
     offline_pg_report *report);
   void _maximize_ok_to_stop_set(
-    const set<int>& orig_osds,
+    const std::set<int>& orig_osds,
     unsigned max,
     const OSDMap& osdmap,
     const PGMap& pgmap,
index b320ea484be673c01a2394003e055dd5b0bc4fb8..0154a04e0ef5d29f0e43456a2fea820818545631 100644 (file)
@@ -113,7 +113,7 @@ void MetadataUpdate::finish(int r)
 
       if (daemon_state.exists(key)) {
         DaemonStatePtr state = daemon_state.get(key);
-       map<string,string> m;
+       std::map<string,string> m;
        {
          std::lock_guard l(state->lock);
          state->hostname = daemon_meta.at("hostname").get_str();
@@ -141,7 +141,7 @@ void MetadataUpdate::finish(int r)
         }
         daemon_meta.erase("hostname");
 
-       map<string,string> m;
+       std::map<string,string> m;
         for (const auto &[key, val] : daemon_meta) {
           m.emplace(key, val.get_str());
         }
@@ -330,7 +330,7 @@ void Mgr::init()
        ++p) {
     string devid = p->first.substr(7);
     dout(10) << "  updating " << devid << dendl;
-    map<string,string> meta;
+    std::map<string,string> meta;
     ostringstream ss;
     int r = get_json_str_map(p->second, ss, &meta, false);
     if (r < 0) {
@@ -449,7 +449,7 @@ void Mgr::load_all_metadata()
     daemon_meta.erase("name");
     daemon_meta.erase("hostname");
 
-    map<string,string> m;
+    std::map<string,string> m;
     for (const auto &[key, val] : daemon_meta) {
       m.emplace(key, val.get_str());
     }
@@ -474,7 +474,7 @@ void Mgr::load_all_metadata()
     osd_metadata.erase("id");
     osd_metadata.erase("hostname");
 
-    map<string,string> m;
+    std::map<string,string> m;
     for (const auto &i : osd_metadata) {
       m[i.first] = i.second.get_str();
     }
@@ -733,7 +733,7 @@ bool Mgr::got_mgr_map(const MgrMap& m)
   std::lock_guard l(lock);
   dout(10) << m << dendl;
 
-  set<string> old_modules;
+  std::set<string> old_modules;
   cluster_state.with_mgrmap([&](const MgrMap& m) {
       old_modules = m.modules;
     });
index 9d6d9c2cdd0210b9b0077ffd4be3f996a7c65d29..294fc7a8277f03df02017ca4fa32f4311b098e04 100644 (file)
 // First because it includes Python.h
 #include "PyModule.h"
 
-#include <string>
-#include <map>
-#include <set>
-#include <memory>
-
 #include "common/LogClient.h"
 
 #include "ActivePyModules.h"
 #include "StandbyPyModules.h"
 
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
 class MgrSession;
 
 /**
@@ -69,7 +70,7 @@ public:
   void update_kv_data(
     const std::string prefix,
     bool incremental,
-    const map<std::string, std::optional<bufferlist>, std::less<>>& data) {
+    const std::map<std::string, std::optional<bufferlist>, std::less<>>& data) {
     ceph_assert(active_modules);
     active_modules->update_kv_data(prefix, incremental, data);
   }
@@ -164,7 +165,7 @@ public:
    */
   void get_health_checks(health_check_map_t *checks);
 
-  void get_progress_events(map<std::string,ProgressEvent> *events) {
+  void get_progress_events(std::map<std::string,ProgressEvent> *events) {
     if (active_modules) {
       active_modules->get_progress_events(events);
     }