Skip to content

Commit

Permalink
mon: return error on forwarded "tell version" command
Browse files Browse the repository at this point in the history
For not a leader, if a received monitor command is not supported
locally, but is supported by the leader, it is forwarded to the
leader. For "ceph tell mon.x version" it gives a confusing behavior:
if the mon.x is not a leader and does not support "version" command
yet, but the leader does, the user will receive the version of the
leader, so the user can't be actually sure about a non leader version.

Fix this by checking if the received "version" command is forwarded
and return error in this case.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
  • Loading branch information
Mykola Golub committed Jan 18, 2015
1 parent a76e537 commit 98f8353
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/mon/Monitor.cc
Expand Up @@ -2690,17 +2690,27 @@ void Monitor::handle_command(MMonCommand *m)
r = -EINVAL;
}
} else if (prefix == "version") {
if (f) {
f->open_object_section("version");
f->dump_string("version", pretty_version_to_str());
f->close_section();
f->flush(ds);
if (session->proxy_con) {
// It looks the command is forwarded from an older mon that does not
// recognize "version" command. As it is very likely the client is
// expecting to see the version of the initial mon, better return an
// error here.
rs = "too old";
r = -ENOTSUP;
} else {
ds << pretty_version_to_str();
if (f) {
dout(0) << "dump" << dendl;
f->open_object_section("version");
f->dump_string("version", pretty_version_to_str());
f->close_section();
f->flush(ds);
} else {
ds << pretty_version_to_str();
}
rdata.append(ds);
rs = "";
r = 0;
}
rdata.append(ds);
rs = "";
r = 0;
}

out:
Expand Down

0 comments on commit 98f8353

Please sign in to comment.