From bed3c4723c9c7d985e95c394a3fc7a37ac2dbf5a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 22 Nov 2011 10:08:48 -0800 Subject: [PATCH] mon: handle rank change in bootstrap The rank can change either because we probe and get a new monmap, or because we get one via paxos. Move the checks to bootstrap() to catch both cases. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 11 ++++++++++- src/mon/MonmapMonitor.cc | 11 ----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 538dff529d595..f45b4edc0a0fc 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -234,7 +234,16 @@ void Monitor::bootstrap() cancel_probe_timeout(); // note my rank - rank = monmap->get_rank(name); + int newrank = monmap->get_rank(name); + if (newrank < 0 && rank >= 0) { + dout(0) << " removed from monmap, suicide." << dendl; + exit(0); + } + if (newrank != rank) { + dout(0) << " my rank is now " << newrank << " (was " << rank << ")" << dendl; + messenger->set_myname(entity_name_t::MON(newrank)); + rank = newrank; + } // reset state = STATE_PROBING; diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index f4f2aa6b2f20a..4d30561e1da10 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -84,17 +84,6 @@ bool MonmapMonitor::update_from_paxos() mon->store->erase_ss("mkfs", "monmap"); } - int rank = mon->monmap->get_rank(mon->name); - if (rank < 0 && mon->rank >= 0) { - dout(0) << " removed from monmap, suicide." << dendl; - exit(0); - } - if (rank != mon->rank) { - dout(0) << " my rank is now " << rank << " (was " << mon->rank << ")" << dendl; - mon->messenger->set_myname(entity_name_t::MON(rank)); - mon->rank = rank; - } - if (need_restart) mon->bootstrap(); return true; -- 2.39.5