]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: notify_new_monmap in all the places we update our monmap
authorGreg Farnum <gfarnum@redhat.com>
Mon, 22 Mar 2021 20:56:14 +0000 (20:56 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Mon, 3 May 2021 21:49:43 +0000 (21:49 +0000)
We can adopt new monmaps while bootstrapping, or in election messages, in
addition to MonmapMonitor::update_from_paxos. Since we use the
notification to update our election strategy and such, we need to notify
from these locations as well!

Fixes: https://tracker.ceph.com/issues/47654
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
(cherry picked from commit 1d5f4e879e50a537ef6db51f7e519a03ab586cd5)

Fixes: https://tracker.ceph.com/issues/50087
src/mon/Elector.cc
src/mon/Elector.h
src/mon/Monitor.cc
src/mon/Monitor.h
src/mon/MonmapMonitor.cc

index cb1a675a5d978415de632198275044a3af027e73..79b227a9c653024231127fdb3d696b4a5775942f 100644 (file)
@@ -633,6 +633,7 @@ void Elector::dispatch(MonOpRequestRef op)
         mon->store->apply_transaction(t);
        //mon->monmon()->paxos->stash_latest(mon->monmap->epoch, em->monmap_bl);
        cancel_timer();
+       mon->notify_new_monmap(false);
        mon->bootstrap();
        return;
       }
index 1ecf566d9d6d981623bd04d42fd7ec881cd7506d..d14dbb5c4ce9f1d76ab53d1967dc48d159aab65a 100644 (file)
@@ -368,6 +368,8 @@ class Elector : public ElectionOwner, RankProvider {
   void notify_rank_changed(int new_rank);
   /**
    * A peer has been removed so we should clean up state related to it.
+   * This is safe to call even if we haven't joined or are currently
+   * in a quorum.
    */
   void notify_rank_removed(int rank_removed);
   void notify_strategy_maybe_changed(int strategy);
index 11677b562e033c82837427184594c07c463c7fa8..bc34069f39d8ca9563c1e3136014c96991f0c05f 100644 (file)
@@ -2000,6 +2000,7 @@ void Monitor::handle_probe_reply(MonOpRequestRef op)
               << ", mine was " << monmap->get_epoch() << dendl;
       delete newmap;
       monmap->decode(m->monmap_bl);
+      notify_new_monmap(false);
 
       bootstrap();
       return;
@@ -6504,7 +6505,7 @@ int Monitor::ms_handle_authentication(Connection *con)
   return ret;
 }
 
-void Monitor::notify_new_monmap()
+void Monitor::notify_new_monmap(bool can_change_external_state)
 {
   elector.notify_strategy_maybe_changed(monmap->strategy);
   dout(30) << __func__ << "we have " << monmap->removed_ranks.size() << " removed ranks" << dendl;
@@ -6524,7 +6525,7 @@ void Monitor::notify_new_monmap()
       set_degraded_stretch_mode();
     }
   }
-  set_elector_disallowed_leaders(true);
+  set_elector_disallowed_leaders(can_change_external_state);
 }
 
 void Monitor::set_elector_disallowed_leaders(bool allow_election)
index 19972c27631b192353768ac748be9f9b7cb06d3f..cd624f001f6d97c6a8c48975da620f63b1f6855b 100644 (file)
@@ -840,7 +840,10 @@ public:
   void waitlist_or_zap_client(MonOpRequestRef op);
 
   void send_mon_message(Message *m, int rank);
-  void notify_new_monmap();
+  /** can_change_external_state if we can do things like
+   *  call elections as a result of the new map.
+   */
+  void notify_new_monmap(bool can_change_external_state=false);
 
 public:
   struct C_Command : public C_MonOp {
index 5e9774704e5bceaf88ecc0271acf49c95cb3715b..80ca4de24e6a8fe5aae54ffab88b88475a3ef679 100644 (file)
@@ -121,7 +121,7 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap)
                           stringify(ceph_release()));
   }
 
-  mon.notify_new_monmap();
+  mon.notify_new_monmap(true);
 }
 
 void MonmapMonitor::create_pending()