From 2986a1b70ebe6e98b27503f58c2afcc1ee81c32c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 8 Jan 2019 16:53:13 -0600 Subject: [PATCH] mon: respawn if rank addr changes If the address for our rank change, then respawn! Signed-off-by: Sage Weil --- src/ceph_mon.cc | 3 +++ src/mon/Monitor.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++ src/mon/Monitor.h | 4 ++++ 3 files changed, 64 insertions(+) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index e47cf22cc8c6d..a932a3b1b6725 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -775,6 +775,9 @@ int main(int argc, const char **argv) mon = new Monitor(g_ceph_context, g_conf()->name.get_id(), store, msgr, mgr_msgr, &monmap); + mon->orig_argc = argc; + mon->orig_argv = argv; + if (force_sync) { derr << "flagging a forced sync ..." << dendl; ostringstream oss; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index eb839bcaf81b2..880b39541e0b6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -30,6 +30,7 @@ #include "common/version.h" #include "common/blkdev.h" #include "common/cmdparse.h" +#include "common/signal.h" #include "osd/OSDMap.h" @@ -1021,6 +1022,54 @@ void Monitor::wait_for_paxos_write() } } +void Monitor::respawn() +{ + dout(0) << __func__ << dendl; + + char *new_argv[orig_argc+1]; + dout(1) << " e: '" << orig_argv[0] << "'" << dendl; + for (int i=0; i= 0 && + monmap->get_addrs(newrank) != messenger->get_myaddrs()) { + dout(0) << " monmap addrs for rank " << newrank << " changed, i am " + << messenger->get_myaddrs() + << ", monmap is " << monmap->get_addrs(newrank) << ", respawning" + << dendl; + respawn(); + } if (newrank != rank) { dout(0) << " my rank is now " << newrank << " (was " << rank << ")" << dendl; messenger->set_myname(entity_name_t::MON(newrank)); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index a2b17f77fe6c2..d0c662d74999a 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -125,6 +125,9 @@ public: class Monitor : public Dispatcher, public md_config_obs_t { public: + int orig_argc = 0; + const char **orig_argv = nullptr; + // me string name; int rank; @@ -593,6 +596,7 @@ private: void _reset(); ///< called from bootstrap, start_, or join_election void wait_for_paxos_write(); void _finish_svc_election(); ///< called by {win,lose}_election + void respawn(); public: void bootstrap(); void join_election(); -- 2.39.5