diff options
author | Dan Mick <dan.mick@inktank.com> | 2013-07-23 22:13:14 -0700 |
---|---|---|
committer | Dan Mick <dan.mick@inktank.com> | 2013-07-26 16:11:12 -0700 |
commit | 8985e1c9e80d1e0a646e4ae7d0e0d89c6b622068 (patch) | |
tree | 9c5496b917817c0bb3756e9d4311a6c77f7e685c | |
parent | 7b42deef3810e207f0e044769e7c70175993954a (diff) | |
download | ceph-8985e1c9e80d1e0a646e4ae7d0e0d89c6b622068.tar.gz |
ceph_argparse, mon: make "tell <pgid>" work (duplicating "pg <pgid>")
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>
-rw-r--r-- | src/osd/OSD.cc | 31 | ||||
-rw-r--r-- | src/osd/ReplicatedPG.cc | 6 | ||||
-rw-r--r-- | src/pybind/ceph_argparse.py | 9 |
3 files changed, 35 insertions, 11 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d611afdd08f..ea13b25b38a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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(); } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4a59a23cdb7..658ea7cb746 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -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 diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 855e21c2508..354459a2cd5 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -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) |