From: Sage Weil Date: Fri, 11 Oct 2019 00:03:08 +0000 (-0500) Subject: mon: allow asok commands to return an error code X-Git-Tag: v15.1.0~1178^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5b83aa779ac87cf54d36caf6bf88286c30bb09b2;p=ceph-ci.git mon: allow asok commands to return an error code Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 534b85cad80..a4f6def716c 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -271,13 +271,13 @@ public: std::ostream& errss, bufferlist& out) override { stringstream outss; - mon->do_admin_command(command, cmdmap, f, errss, outss); + int r = mon->do_admin_command(command, cmdmap, f, errss, outss); out.append(outss); - return 0; + return r; } }; -void Monitor::do_admin_command( +int Monitor::do_admin_command( std::string_view command, const cmdmap_t& cmdmap, Formatter *f, @@ -286,6 +286,7 @@ void Monitor::do_admin_command( { std::lock_guard l(lock); + int r = 0; string args; for (auto p = cmdmap.begin(); p != cmdmap.end(); ++p) { @@ -405,7 +406,7 @@ void Monitor::do_admin_command( << "entity='admin socket' " << "cmd=" << command << " " << "args=" << args << ": finished"; - return; + return r; abort: (read_only ? audit_clog->debug() : audit_clog->info()) @@ -413,6 +414,7 @@ abort: << "entity='admin socket' " << "cmd=" << command << " " << "args=" << args << ": aborted"; + return r; } void Monitor::handle_signal(int signum) diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 81a653edfdf..294fbe3b7e6 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -988,10 +988,10 @@ private: int write_fsid(); int write_fsid(MonitorDBStore::TransactionRef t); - void do_admin_command(std::string_view command, const cmdmap_t& cmdmap, - Formatter *f, - std::ostream& err, - std::ostream& out); + int do_admin_command(std::string_view command, const cmdmap_t& cmdmap, + Formatter *f, + std::ostream& err, + std::ostream& out); private: // don't allow copying