]> 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>
Fri, 28 Feb 2025 00:55:45 +0000 (19:55 -0500)
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>
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 0d10a275a1066e95768b55df462ea039bb52b369..c7b4db2d29469d2b75f3054f9cbecbb31a7e048f 100644 (file)
@@ -246,7 +246,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) {
@@ -783,7 +783,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;
@@ -1119,7 +1119,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);
@@ -1278,7 +1278,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 5cd4dd00a38557709c24866acef591710b64492f..5820b3f1abd55044a0ecb46c6be492369d570fda 100644 (file)
 
 #include <iomanip>
 
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_mgr
 #undef dout_prefix
@@ -815,14 +820,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) {
@@ -856,7 +861,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()) {
@@ -1003,7 +1008,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)
@@ -1013,7 +1018,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);
@@ -1075,7 +1080,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,
@@ -1093,9 +1098,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
@@ -1161,7 +1166,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;
 
@@ -1376,7 +1381,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,
@@ -1392,10 +1397,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++)
@@ -1421,9 +1426,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();
@@ -1469,7 +1474,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";
@@ -1477,8 +1482,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) {
@@ -1533,8 +1538,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) {
@@ -1686,10 +1691,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);
@@ -1711,7 +1716,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) {
@@ -1846,9 +1851,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;
@@ -1898,11 +1903,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;
@@ -1916,10 +1921,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;
@@ -1932,7 +1937,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";
@@ -2027,7 +2032,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;
@@ -2273,7 +2278,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");
@@ -2372,7 +2377,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");
@@ -2461,7 +2466,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) {
@@ -2487,7 +2492,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;
@@ -2742,7 +2747,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) {
@@ -2783,9 +2788,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) {
@@ -2855,7 +2860,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)) {
@@ -3147,7 +3152,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;
@@ -3283,8 +3288,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 1da225ffb7e9f8a1c9684c8de9e81a6ea5daddaa..ee0c26f94dea2cbe1422be843b0e52899a829334 100644 (file)
@@ -20,6 +20,7 @@
 #include <set>
 #include <string>
 #include <unordered_map>
+#include <vector>
 
 #include "common/ceph_mutex.h"
 #include "common/LogClient.h"
@@ -52,10 +53,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();
@@ -183,7 +184,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 26f93563517a92e3872ae397f4d42d41a2753680..9acd58248fbfe01ec4b693f6a270daa4ec329899 100644 (file)
@@ -115,7 +115,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();
@@ -143,7 +143,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());
         }
@@ -332,7 +332,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) {
@@ -451,7 +451,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());
     }
@@ -476,7 +476,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();
     }
@@ -742,7 +742,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 da5bb596c938dfdee176d4ce1e3eaa4dc40e7594..5224ab2040059f78ec36747a0f64821038746788 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;
 
 /**
@@ -70,7 +71,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);
   }
@@ -165,7 +166,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);
     }