From 0b6194a3755b8b210f0ebab075816ddf5fc8965e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 22 Oct 2019 11:36:06 -0500 Subject: [PATCH] mon: shunt old tell commands from cli interface to asok 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 --- src/common/admin_socket.cc | 27 +++++++++++++++++++++++++++ src/common/admin_socket.h | 3 +++ src/mon/Monitor.cc | 12 ++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/common/admin_socket.cc b/src/common/admin_socket.cc index 60812caf5bf20..c3b0681622c9f 100644 --- a/src/common/admin_socket.cc +++ b/src/common/admin_socket.cc @@ -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> q; + std::list> 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 m) tell_queue.push_back(std::move(m)); wakeup(); } +void AdminSocket::queue_tell_command(ref_t 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, diff --git a/src/common/admin_socket.h b/src/common/admin_socket.h index d9e100e006e47..3ac5f140e1cd5 100644 --- a/src/common/admin_socket.h +++ b/src/common/admin_socket.h @@ -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 m); + void queue_tell_command(ref_t m); // for compat private: @@ -148,6 +150,7 @@ private: std::mutex tell_lock; std::list> tell_queue; + std::list> tell_legacy_queue; struct hook_info { AdminSocketHook* hook; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 6e9a817f7f723..166f85f172775 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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; -- 2.39.5