From bae47183c2621577ba564d29c82a0517ab8a7f54 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 30 Apr 2018 09:32:43 -0400 Subject: [PATCH] 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 --- src/mgr/MgrClient.cc | 4 +++- src/mgr/MgrClient.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 6e1e5391d8def..804c9d639e712 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 4a044b5d5e3c9..8f490fc537ba1 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 {} -- 2.39.5