]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: cleanup command descriptions
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 10 Oct 2018 16:11:46 +0000 (09:11 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 10 Oct 2018 18:32:35 +0000 (11:32 -0700)
In particular, the cap on the command had no effect. (We require "*"
unconditionally when processing commands.)

Fixes: http://tracker.ceph.com/issues/36380
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSDaemon.h

index 99f12fc7eda2a0ba6aad30511562c2e7b2fdec3d..a27de15c9a40fee8fba9b0541ae4e79f1c0e740d 100644 (file)
@@ -643,70 +643,31 @@ void MDSDaemon::handle_command(const MCommand::const_ref &m)
   }
 }
 
-
-struct MDSCommand {
-  string cmdstring;
-  string helpstring;
-  string module;
-  string perm;
-  string availability;
-} mds_commands[] = {
-
-#define COMMAND(parsesig, helptext, module, perm, availability) \
-  {parsesig, helptext, module, perm, availability},
-
-COMMAND("injectargs " \
-       "name=injected_args,type=CephString,n=N",
-       "inject configuration arguments into running MDS",
-       "mds", "*", "cli,rest")
-COMMAND("config set " \
-       "name=key,type=CephString name=value,type=CephString",
-       "Set a configuration option at runtime (not persistent)",
-       "mds", "*", "cli,rest")
-COMMAND("config unset " \
-       "name=key,type=CephString",
-       "Unset a configuration option at runtime (not persistent)",
-       "mds", "*", "cli,rest")
-COMMAND("exit",
-       "Terminate this MDS",
-       "mds", "*", "cli,rest")
-COMMAND("respawn",
-       "Restart this MDS",
-       "mds", "*", "cli,rest")
-COMMAND("session kill " \
-        "name=session_id,type=CephInt",
-       "End a client session",
-       "mds", "*", "cli,rest")
-COMMAND("cpu_profiler " \
-       "name=arg,type=CephChoices,strings=status|flush",
-       "run cpu profiling on daemon", "mds", "rw", "cli,rest")
-COMMAND("session ls " \
-       "name=filters,type=CephString,n=N,req=false",
-       "List client sessions", "mds", "r", "cli,rest")
-COMMAND("client ls " \
-       "name=filters,type=CephString,n=N,req=false",
-       "List client sessions", "mds", "r", "cli,rest")
-COMMAND("session evict " \
-       "name=filters,type=CephString,n=N,req=false",
-       "Evict client session(s)", "mds", "rw", "cli,rest")
-COMMAND("client evict " \
-       "name=filters,type=CephString,n=N,req=false",
-       "Evict client session(s)", "mds", "rw", "cli,rest")
-COMMAND("damage ls",
-       "List detected metadata damage", "mds", "r", "cli,rest")
-COMMAND("damage rm name=damage_id,type=CephInt",
-       "Remove a damage table entry", "mds", "rw", "cli,rest")
-COMMAND("version", "report version of MDS", "mds", "r", "cli,rest")
-COMMAND("heap " \
-       "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \
-       "show heap usage info (available only if compiled with tcmalloc)", \
-       "mds", "*", "cli,rest")
-COMMAND("cache drop name=timeout,type=CephInt,range=1", "trim cache and optionally "
-       "request client to release all caps and flush the journal", "mds",
-       "r", "cli,rest")
+const std::vector<MDSDaemon::MDSCommand>& MDSDaemon::get_commands()
+{
+  static const std::vector<MDSCommand> commands = {
+    MDSCommand("injectargs name=injected_args,type=CephString,n=N", "inject configuration arguments into running MDS"),
+    MDSCommand("config set name=key,type=CephString name=value,type=CephString", "Set a configuration option at runtime (not persistent)"),
+    MDSCommand("config unset name=key,type=CephString", "Unset a configuration option at runtime (not persistent)"),
+    MDSCommand("exit", "Terminate this MDS"),
+    MDSCommand("respawn", "Restart this MDS"),
+    MDSCommand("session kill name=session_id,type=CephInt", "End a client session"),
+    MDSCommand("cpu_profiler name=arg,type=CephChoices,strings=status|flush", "run cpu profiling on daemon"),
+    MDSCommand("session ls name=filters,type=CephString,n=N,req=false", "List client sessions"),
+    MDSCommand("client ls name=filters,type=CephString,n=N,req=false", "List client sessions"),
+    MDSCommand("session evict name=filters,type=CephString,n=N,req=false", "Evict client session(s)"),
+    MDSCommand("client evict name=filters,type=CephString,n=N,req=false", "Evict client session(s)"),
+    MDSCommand("damage ls", "List detected metadata damage"),
+    MDSCommand("damage rm name=damage_id,type=CephInt", "Remove a damage table entry"),
+    MDSCommand("version", "report version of MDS"),
+    MDSCommand("heap "
+        "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats",
+        "show heap usage info (available only if compiled with tcmalloc)"),
+    MDSCommand("cache drop name=timeout,type=CephInt,range=1", "trim cache and optionally request client to release all caps and flush the journal"),
+  };
+  return commands;
 };
 
-
 int MDSDaemon::_handle_command(
     const cmdmap_t &cmdmap,
     const MCommand::const_ref &m,
@@ -763,13 +724,11 @@ int MDSDaemon::_handle_command(
     int cmdnum = 0;
     std::unique_ptr<JSONFormatter> f(std::make_unique<JSONFormatter>());
     f->open_object_section("command_descriptions");
-    for (MDSCommand *cp = mds_commands;
-        cp < &mds_commands[ARRAY_SIZE(mds_commands)]; cp++) {
-
+    for (auto& c : get_commands()) {
       ostringstream secname;
       secname << "cmd" << setfill('0') << std::setw(3) << cmdnum;
-      dump_cmddesc_to_json(f.get(), secname.str(), cp->cmdstring, cp->helpstring,
-                          cp->module, cp->perm, cp->availability, 0);
+      dump_cmddesc_to_json(f.get(), secname.str(), c.cmdstring, c.helpstring,
+                          c.module, "*", c.availability, 0);
       cmdnum++;
     }
     f->close_section();        // command_descriptions
index 745b4042816e1d5538a4e418cd175b4da50b66ea..5689924678ec04333e1ef18625775b7e28480cdc 100644 (file)
@@ -168,8 +168,20 @@ protected:
   void _handle_mds_map(const MDSMap &oldmap);
 
 private:
-    mono_time starttime = mono_clock::zero();
-};
+  struct MDSCommand {
+    MDSCommand(std::string_view signature, std::string_view help)
+        : cmdstring(signature), helpstring(help)
+    {}
+
+    std::string cmdstring;
+    std::string helpstring;
+    std::string module = "mds";
+    std::string availability = "cli,rest";
+  };
 
+  static const std::vector<MDSCommand>& get_commands();
+
+  mono_time starttime = mono_clock::zero();
+};
 
 #endif