]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_argparse, mon: make "tell <pgid>" work (duplicating "pg <pgid>")
authorDan Mick <dan.mick@inktank.com>
Wed, 24 Jul 2013 05:13:14 +0000 (22:13 -0700)
committerDan Mick <dan.mick@inktank.com>
Fri, 26 Jul 2013 23:11:12 +0000 (16:11 -0700)
It's a wad of special cases, but it implements "tell <pgid>" such that
it has the same effect as "pg <pgid>".

Signed-off-by: Dan Mick <dan.mick@inktank.com>
src/osd/OSD.cc
src/osd/ReplicatedPG.cc
src/pybind/ceph_argparse.py

index d611afdd08fb885ad02d65722703ea61f36432c9..ea13b25b38a9b46acc8f1e27a28e205c4ad145e8 100644 (file)
@@ -3858,6 +3858,7 @@ COMMAND("list_missing " \
 
 // tell <osd.n> commands.  Validation of osd.n must be special-cased in client
 
+// tell <osd.n> commands.  Validation of osd.n must be special-cased in client
 COMMAND("version", "report version of OSD", "osd", "r", "cli,rest")
 COMMAND("injectargs " \
        "name=injected_args,type=CephString,n=N",
@@ -3883,6 +3884,19 @@ COMMAND("dump_pg_recovery_stats", "dump pg recovery statistics",
        "osd", "r", "cli,rest")
 COMMAND("reset_pg_recovery_stats", "reset pg recovery statistics",
        "osd", "rw", "cli,rest")
+
+// experiment: restate pg commands as "tell <pgid>".  Validation of
+// pgid must be special-cased in client.
+COMMAND("query",
+       "show details of a specific pg", "osd", "r", "cli,rest")
+COMMAND("mark_unfound_lost revert " \
+       "name=mulcmd,type=CephChoices,strings=revert", \
+       "mark all unfound objects in this pg as lost, either removing or reverting to a prior version if one is available",
+       "osd", "rw", "cli,rest")
+COMMAND("list_missing " \
+       "name=offset,type=CephString,req=false",
+       "list missing objects on this pg, perhaps starting at an offset given in JSON",
+       "osd", "rw", "cli,rest")
 };
 
 void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist& data)
@@ -3897,6 +3911,7 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
   map<string, cmd_vartype> cmdmap;
   string prefix;
   string format;
+  string pgidstr;
   boost::scoped_ptr<Formatter> f;
 
   if (cmd.empty()) {
@@ -3963,9 +3978,16 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
     osd_lock.Lock();
   }
 
-  else if (prefix == "pg") {
+  // either 'pg <pgid> <command>' or
+  // 'tell <pgid>' (which comes in without any of that prefix)?
+
+  else if (prefix == "pg" ||
+          (cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr) &&
+            (prefix == "query" ||
+             prefix == "mark_unfound_lost" ||
+             prefix == "list_missing")
+          )) {
     pg_t pgid;
-    string pgidstr;
 
     if (!cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr)) {
       ss << "no pgid specified";
@@ -3974,13 +3996,14 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
       ss << "couldn't parse pgid '" << pgidstr << "'";
       r = -EINVAL;
     } else {
-      vector<string> args;
-      cmd_getval(g_ceph_context, cmdmap, "args", args);
       PG *pg = _lookup_lock_pg(pgid);
       if (!pg) {
        ss << "i don't have pgid " << pgid;
        r = -ENOENT;
       } else {
+       // simulate pg <pgid> cmd= for pg->do-command
+       if (prefix != "pg")
+         cmd_putval(g_ceph_context, cmdmap, "cmd", prefix);
        r = pg->do_command(cmdmap, ss, data, odata);
        pg->unlock();
       }
index 4a59a23cdb79498dcb67dab1cd23bf3354a1ae45..658ea7cb746333a138b13c0b5840ac46a5f8e69e 100644 (file)
@@ -275,12 +275,6 @@ int ReplicatedPG::do_command(cmdmap_t cmdmap, ostream& ss,
   string prefix;
   string format;
 
-  cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
-  if (prefix != "pg") {
-    ss << "ReplicatedPG::do_command: not pg command";
-    return -EINVAL;
-  }
-
   cmd_getval(g_ceph_context, cmdmap, "format", format);
   boost::scoped_ptr<Formatter> f(new_formatter(format));
   // demand that we have a formatter
index 855e21c25084e1bdc3e3af34ee0e61d2928f28bc..354459a2cd57a00c919dc97c28ab7016df3d93eb 100644 (file)
@@ -938,8 +938,15 @@ def send_command(cluster, target=('mon', ''), cmd=[], inbuf='', timeout=0,
                 cluster.osd_command(osdid, cmd, inbuf, timeout)
 
         elif target[0] == 'pg':
-            # leave it in cmddict for the OSD to use too
             pgid = target[1]
+            # pgid will already be in the command for the pg <pgid>
+            # form, but for tell <pgid>, we need to put it in
+            if cmd:
+                cmddict = json.loads(cmd[0])
+                cmddict['pgid'] = pgid
+            else:
+                cmddict = dict(pgid=pgid)
+            cmd = [json.dumps(cmddict)]
             if verbose:
                 print >> sys.stderr, 'submit {0} for pgid {1}'.\
                     format(cmd, pgid)