From: Sage Weil Date: Wed, 4 Sep 2019 20:56:51 +0000 (-0500) Subject: mgr/MgrClient: send MMgrCommand for octopus+ mgrs X-Git-Tag: v15.1.0~1620^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0019005e87a0f0f31fbd5351fc9e82d56689cdfd;p=ceph-ci.git mgr/MgrClient: send MMgrCommand for octopus+ mgrs This allows us to (eventually) leave MCommand for tell-style commands only. Signed-off-by: Sage Weil --- diff --git a/src/common/CommandTable.h b/src/common/CommandTable.h index fb40101e3ca..419988f7748 100644 --- a/src/common/CommandTable.h +++ b/src/common/CommandTable.h @@ -16,6 +16,7 @@ #define COMMAND_TABLE_H_ #include "messages/MCommand.h" +#include "messages/MMgrCommand.h" class CommandOp { @@ -29,14 +30,22 @@ class CommandOp ceph::buffer::list *outbl; std::string *outs; - ceph::ref_t get_message(const uuid_d &fsid) const + MessageRef get_message(const uuid_d &fsid, + bool mgr=false) const { - auto m = make_message(fsid); - m->cmd = cmd; - m->set_data(inbl); - m->set_tid(tid); - - return m; + if (mgr) { + auto m = make_message(fsid); + m->cmd = cmd; + m->set_data(inbl); + m->set_tid(tid); + return m; + } else { + auto m = make_message(fsid); + m->cmd = cmd; + m->set_data(inbl); + m->set_tid(tid); + return m; + } } CommandOp(const ceph_tid_t t) : tid(t), on_finish(nullptr), diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 428f511196c..1f6d0cf6f5c 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -24,6 +24,8 @@ #include "messages/MMgrConfigure.h" #include "messages/MCommand.h" #include "messages/MCommandReply.h" +#include "messages/MMgrCommand.h" +#include "messages/MMgrCommandReply.h" #include "messages/MPGStats.h" using std::string; @@ -98,7 +100,16 @@ bool MgrClient::ms_dispatch2(const ref_t& m) return handle_mgr_close(ref_cast(m)); case MSG_COMMAND_REPLY: if (m->get_source().type() == CEPH_ENTITY_TYPE_MGR) { - handle_command_reply(ref_cast(m)); + MCommandReply *c = static_cast(m.get()); + handle_command_reply(c->get_tid(), c->get_data(), c->rs, c->r); + return true; + } else { + return false; + } + case MSG_MGR_COMMAND_REPLY: + if (m->get_source().type() == CEPH_ENTITY_TYPE_MGR) { + MMgrCommandReply *c = static_cast(m.get()); + handle_command_reply(c->get_tid(), c->get_data(), c->rs, c->r); return true; } else { return false; @@ -174,7 +185,9 @@ void MgrClient::reconnect() // resend any pending commands for (const auto &p : command_table.get_commands()) { - auto m = p.second.get_message({}); + auto m = p.second.get_message( + {}, + HAVE_FEATURE(map.active_mgr_features, SERVER_OCTOPUS)); ceph_assert(session); ceph_assert(session->con); session->con->send_message2(std::move(m)); @@ -439,7 +452,9 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, if (session && session->con) { // Leaving fsid argument null because it isn't used. - auto m = op.get_message({}); + auto m = op.get_message( + {}, + HAVE_FEATURE(map.active_mgr_features, SERVER_OCTOPUS)); session->con->send_message2(std::move(m)); } else { ldout(cct, 5) << "no mgr session (no running mgr daemon?), waiting" << dendl; @@ -447,30 +462,33 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, return 0; } -bool MgrClient::handle_command_reply(ref_t m) +bool MgrClient::handle_command_reply( + uint64_t tid, + bufferlist& data, + const std::string& rs, + int r) { ceph_assert(ceph_mutex_is_locked_by_me(lock)); - ldout(cct, 20) << *m << dendl; + ldout(cct, 20) << "tid " << tid << " r " << r << dendl; - const auto tid = m->get_tid(); if (!command_table.exists(tid)) { - ldout(cct, 4) << "handle_command_reply tid " << m->get_tid() + ldout(cct, 4) << "handle_command_reply tid " << tid << " not found" << dendl; return true; } auto &op = command_table.get_command(tid); if (op.outbl) { - op.outbl->claim(m->get_data()); + op.outbl->claim(data); } if (op.outs) { - *(op.outs) = m->rs; + *(op.outs) = rs; } if (op.on_finish) { - op.on_finish->complete(m->r); + op.on_finish->complete(r); } command_table.erase(tid); diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index f3bb74a4b17..b6be89c187d 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -120,7 +120,11 @@ public: bool handle_mgr_map(ceph::ref_t m); bool handle_mgr_configure(ceph::ref_t m); bool handle_mgr_close(ceph::ref_t m); - bool handle_command_reply(ceph::ref_t m); + bool handle_command_reply( + uint64_t tid, + bufferlist& data, + const std::string& rs, + int r); void set_perf_metric_query_cb( std::function