]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix dropping mgr metadata for active mgr 17635/head
authorJohn Spray <john.spray@redhat.com>
Thu, 7 Sep 2017 13:44:36 +0000 (09:44 -0400)
committerNathan Cutler <ncutler@suse.com>
Mon, 11 Sep 2017 09:50:13 +0000 (11:50 +0200)
drop_standby() was killing it and it was only getting added
back in certain locations.  Instead, make the metadata
drop conditional and only do it in the places we're
really dropping the daemon, not when we're promoting
it to active.

Fixes: http://tracker.ceph.com/issues/21260
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 29c6f9adf178f6611a625740f395e397cad9147b)

src/mon/MgrMonitor.cc
src/mon/MgrMonitor.h

index fc4f08d8d70c51ec41bf23a1943f0e79d876410f..3840b642b956cd9269522f8d172f0749690bf229 100644 (file)
@@ -332,7 +332,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op)
   } else if (pending_map.active_gid == 0) {
     // There is no currently active daemon, select this one.
     if (pending_map.standbys.count(m->get_gid())) {
-      drop_standby(m->get_gid());
+      drop_standby(m->get_gid(), false);
     }
     dout(4) << "selecting new active " << m->get_gid()
            << " " << m->get_name()
@@ -599,7 +599,8 @@ bool MgrMonitor::promote_standby()
     pending_map.available = false;
     pending_map.active_addr = entity_addr_t();
 
-    drop_standby(replacement_gid);
+    drop_standby(replacement_gid, false);
+
     return true;
   } else {
     return false;
@@ -624,10 +625,12 @@ void MgrMonitor::drop_active()
   cancel_timer();
 }
 
-void MgrMonitor::drop_standby(uint64_t gid)
+void MgrMonitor::drop_standby(uint64_t gid, bool drop_meta)
 {
-  pending_metadata_rm.insert(pending_map.standbys[gid].name);
-  pending_metadata.erase(pending_map.standbys[gid].name);
+  if (drop_meta) {
+    pending_metadata_rm.insert(pending_map.standbys[gid].name);
+    pending_metadata.erase(pending_map.standbys[gid].name);
+  }
   pending_map.standbys.erase(gid);
   if (last_beacon.count(gid) > 0) {
     last_beacon.erase(gid);
index 65451633dbefc0aa85c71bd4d65b50e222548922..563ae7c5de8de937626fdf2be61823809a7e6fb9 100644 (file)
@@ -43,7 +43,16 @@ class MgrMonitor: public PaxosService
    */
   bool promote_standby();
   void drop_active();
-  void drop_standby(uint64_t gid);
+
+  /**
+   * Remove this gid from the list of standbys.  By default,
+   * also remove metadata (i.e. forget the daemon entirely).
+   *
+   * Set `drop_meta` to false if you would like to keep
+   * the daemon's metadata, for example if you're dropping
+   * it as a standby before reinstating it as the active daemon.
+   */
+  void drop_standby(uint64_t gid, bool drop_meta=true);
 
   Context *digest_event = nullptr;
   void cancel_timer();