]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/MgrClient: send MMgrCommand for octopus+ mgrs
authorSage Weil <sage@redhat.com>
Wed, 4 Sep 2019 20:56:51 +0000 (15:56 -0500)
committerSage Weil <sage@redhat.com>
Fri, 6 Sep 2019 02:29:56 +0000 (21:29 -0500)
This allows us to (eventually) leave MCommand for tell-style commands
only.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/CommandTable.h
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index fb40101e3ca0445fc3c48de5d5810ec518677718..419988f7748b8c6463e82a29a87761175989c0d6 100644 (file)
@@ -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<MCommand> get_message(const uuid_d &fsid) const
+  MessageRef get_message(const uuid_d &fsid,
+                        bool mgr=false) const
   {
-    auto m = make_message<MCommand>(fsid);
-    m->cmd = cmd;
-    m->set_data(inbl);
-    m->set_tid(tid);
-
-    return m;
+    if (mgr) {
+      auto m = make_message<MMgrCommand>(fsid);
+      m->cmd = cmd;
+      m->set_data(inbl);
+      m->set_tid(tid);
+      return m;
+    } else {
+      auto m = make_message<MCommand>(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),
index 428f511196ce3efb2bdf8aed31af9cbd77c31806..1f6d0cf6f5cac768393c719fe4289b88aaec3e0f 100644 (file)
@@ -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<Message>& m)
     return handle_mgr_close(ref_cast<MMgrClose>(m));
   case MSG_COMMAND_REPLY:
     if (m->get_source().type() == CEPH_ENTITY_TYPE_MGR) {
-      handle_command_reply(ref_cast<MCommandReply>(m));
+      MCommandReply *c = static_cast<MCommandReply*>(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<MMgrCommandReply*>(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<string>& 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<string>& cmd, const bufferlist& inbl,
   return 0;
 }
 
-bool MgrClient::handle_command_reply(ref_t<MCommandReply> 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);
index f3bb74a4b170433cc4d0696e40ba7f06fca58683..b6be89c187db47159841650ceae1cbb57392037f 100644 (file)
@@ -120,7 +120,11 @@ public:
   bool handle_mgr_map(ceph::ref_t<MMgrMap> m);
   bool handle_mgr_configure(ceph::ref_t<MMgrConfigure> m);
   bool handle_mgr_close(ceph::ref_t<MMgrClose> m);
-  bool handle_command_reply(ceph::ref_t<MCommandReply> m);
+  bool handle_command_reply(
+    uint64_t tid,
+    bufferlist& data,
+    const std::string& rs,
+    int r);
 
   void set_perf_metric_query_cb(
     std::function<void(const std::map<OSDPerfMetricQuery,