From 869d43d982697a3ab648b52d56dd0d4a15933425 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 3 Feb 2019 13:58:48 -0600 Subject: [PATCH] mon: prime MgrClient only after messengers are initialized If we do it earlier we may crash due to an uninitialised messenger auth_client. Signed-off-by: Sage Weil --- src/mon/MgrMonitor.cc | 10 +++++++++- src/mon/MgrMonitor.h | 2 ++ src/mon/Monitor.cc | 5 +++-- src/mon/Monitor.h | 6 ++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 5f2402fb08d82..94b5922cd0f24 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -213,7 +213,15 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) // pointers into our mgr_module_options (which we just rebuilt). mon->configmon()->load_config(); - // feed our pet MgrClient + if (!mon->is_init()) { + // feed our pet MgrClient, unless we are in Monitor::[pre]init() + prime_mgr_client(); + } +} + +void MgrMonitor::prime_mgr_client() +{ + dout(10) << __func__ << dendl; mon->mgr_client.ms_dispatch(new MMgrMap(map)); } diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index d8cfc0e5dd0c9..0fc031403b251 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -87,6 +87,8 @@ public: version_t get_trim_to() const override; + void prime_mgr_client(); + void create_initial() override; void get_store_prefixes(std::set& s) const override; void update_from_paxos(bool *need_bootstrap) override; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 7f271e8e37728..666eeacce3756 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -156,8 +156,6 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, gss_ktfile_client(cct->_conf.get_val("gss_ktab_client_file")), store(s), - state(STATE_PROBING), - elector(this), required_features(0), leader(0), @@ -882,10 +880,13 @@ int Monitor::init() // i'm ready! messenger->add_dispatcher_tail(this); + // kickstart pet mgrclient mgr_client.init(); mgr_messenger->add_dispatcher_tail(&mgr_client); mgr_messenger->add_dispatcher_tail(this); // for auth ms_* calls + mgrmon()->prime_mgr_client(); + state = STATE_PROBING; bootstrap(); // add features of myself into feature_map session_map.feature_map.add_mon(con_self->get_features()); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 6c528ab522f51..80d7b7ad11d86 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -195,14 +195,15 @@ public: // -- monitor state -- private: enum { - STATE_PROBING = 1, + STATE_INIT = 1, + STATE_PROBING, STATE_SYNCHRONIZING, STATE_ELECTING, STATE_LEADER, STATE_PEON, STATE_SHUTDOWN }; - int state; + int state = STATE_INIT; public: static const char *get_state_name(int s) { @@ -220,6 +221,7 @@ public: return get_state_name(state); } + bool is_init() const { return state == STATE_INIT; } bool is_shutdown() const { return state == STATE_SHUTDOWN; } bool is_probing() const { return state == STATE_PROBING; } bool is_synchronizing() const { return state == STATE_SYNCHRONIZING; } -- 2.39.5