]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: shunt old tell commands from cli interface to asok
authorSage Weil <sage@redhat.com>
Tue, 22 Oct 2019 16:36:06 +0000 (11:36 -0500)
committerSage Weil <sage@redhat.com>
Wed, 23 Oct 2019 00:46:14 +0000 (19:46 -0500)
Pre-octopus clients will send tell commands as CLI commands.  Explicitly
identify those and send them to the asok infrastructure.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/admin_socket.cc
src/common/admin_socket.h
src/mon/Monitor.cc

index 60812caf5bf20461a281c84e3cf495930b2dcf6f..c3b0681622c9fefb69ec87e8eda530c26a4f581f 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "messages/MCommand.h"
 #include "messages/MCommandReply.h"
+#include "messages/MMonCommand.h"
+#include "messages/MMonCommandAck.h"
 
 // re-include our assert to clobber the system one; fix dout:
 #include "include/ceph_assert.h"
@@ -385,9 +387,11 @@ void AdminSocket::do_tell_queue()
 {
   ldout(m_cct,10) << __func__ << dendl;
   std::list<ref_t<MCommand>> q;
+  std::list<ref_t<MMonCommand>> lq;
   {
     std::lock_guard l(tell_lock);
     q.swap(tell_queue);
+    lq.swap(tell_legacy_queue);
   }
   for (auto& m : q) {
     bufferlist outbl;
@@ -400,6 +404,22 @@ void AdminSocket::do_tell_queue()
        reply->set_data(outbl);
 #ifdef WITH_SEASTAR
 #warning "fix message send with crimson"
+#else
+       m->get_connection()->send_message(reply);
+#endif
+      });
+  }
+  for (auto& m : lq) {
+    bufferlist outbl;
+    execute_command(
+      m->cmd,
+      m->get_data(),
+      [m](int r, const std::string& err, bufferlist& outbl) {
+       auto reply = new MMonCommandAck(m->cmd, r, err, 0);
+       reply->set_tid(m->get_tid());
+       reply->set_data(outbl);
+#ifdef WITH_SEASTAR
+#warning "fix message send with crimson"
 #else
        m->get_connection()->send_message(reply);
 #endif
@@ -512,6 +532,13 @@ void AdminSocket::queue_tell_command(ref_t<MCommand> m)
   tell_queue.push_back(std::move(m));
   wakeup();
 }
+void AdminSocket::queue_tell_command(ref_t<MMonCommand> m)
+{
+  ldout(m_cct,10) << __func__ << " " << *m << dendl;
+  std::lock_guard l(tell_lock);
+  tell_legacy_queue.push_back(std::move(m));
+  wakeup();
+}
 
 int AdminSocket::register_command(std::string_view cmddesc,
                                  AdminSocketHook *hook,
index d9e100e006e475602894414a69370ec343f22d4c..3ac5f140e1cd52149b1816fe1ac58c6491ffa109 100644 (file)
@@ -28,6 +28,7 @@
 class AdminSocket;
 class CephContext;
 class MCommand;
+class MMonCommand;
 
 using namespace std::literals;
 
@@ -117,6 +118,7 @@ public:
     bufferlist *outbl);
 
   void queue_tell_command(ref_t<MCommand> m);
+  void queue_tell_command(ref_t<MMonCommand> m); // for compat
 
 private:
 
@@ -148,6 +150,7 @@ private:
 
   std::mutex tell_lock;
   std::list<ref_t<MCommand>> tell_queue;
+  std::list<ref_t<MMonCommand>> tell_legacy_queue;
 
   struct hook_info {
     AdminSocketHook* hook;
index 6e9a817f7f7230297423573ec89bb2df2d6d185c..166f85f17277506f8df327225514557da56b5b76 100644 (file)
@@ -3258,6 +3258,18 @@ void Monitor::handle_command(MonOpRequestRef op)
     return;
   }
 
+  // compat kludge for legacy clients trying to tell commands that are new
+  if (!HAVE_FEATURE(m->get_connection()->get_features(), SERVER_OCTOPUS) &&
+      (prefix == "injectargs" ||
+       prefix == "smart" ||
+       prefix == "mon_status" ||
+       prefix == "sync_force" ||
+       prefix == "heap")) {
+    dout(5) << __func__ << " passing command to tell/asok" << dendl;
+    cct->get_admin_socket()->queue_tell_command(m);
+    return;
+  }
+
   string module;
   string err;