From: John Spray Date: Mon, 30 Apr 2018 13:32:43 +0000 (-0400) Subject: mgr/MgrClient: add mgr_optional mode X-Git-Tag: v13.1.1~51^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5a45110785bc6d3c975f6bd56750bb50cd9b1820;p=ceph-ci.git mgr/MgrClient: add mgr_optional mode This is for use when talking to pre-luminous clusters, where we should not block waiting for MgrMap because it might never come. Fixes: https://tracker.ceph.com/issues/23627 Signed-off-by: John Spray (cherry picked from commit bae47183c2621577ba564d29c82a0517ab8a7f54) --- diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 6e1e5391d8d..804c9d639e7 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -413,7 +413,7 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, ldout(cct, 20) << "cmd: " << cmd << dendl; - if (map.epoch == 0) { + if (map.epoch == 0 && mgr_optional) { ldout(cct,20) << " no MgrMap, assuming EACCES" << dendl; return -EACCES; } @@ -429,6 +429,8 @@ int MgrClient::start_command(const vector& cmd, const bufferlist& inbl, // Leaving fsid argument null because it isn't used. MCommand *m = op.get_message({}); session->con->send_message(m); + } else { + ldout(cct, 4) << "start_command: no mgr session, waiting" << dendl; } return 0; } diff --git a/src/mgr/MgrClient.h b/src/mgr/MgrClient.h index 4a044b5d5e3..8f490fc537b 100644 --- a/src/mgr/MgrClient.h +++ b/src/mgr/MgrClient.h @@ -88,6 +88,10 @@ protected: void reconnect(); void _send_open(); + // In pre-luminous clusters, the ceph-mgr service is absent or optional, + // so we must not block in start_command waiting for it. + bool mgr_optional = false; + public: MgrClient(CephContext *cct_, Messenger *msgr_); @@ -96,6 +100,8 @@ public: void init(); void shutdown(); + void set_mgr_optional(bool optional_) {mgr_optional = optional_;} + bool ms_dispatch(Message *m) override; bool ms_handle_reset(Connection *con) override; void ms_handle_remote_reset(Connection *con) override {}