From f94254b8daa3d6891e2464faa1b5c5524d977097 Mon Sep 17 00:00:00 2001 From: Evan Elias Date: Thu, 4 Apr 2013 16:41:43 -0400 Subject: [PATCH] jetpants_collins: Pool#after_master_promotion! should also eject any slaves that are no longer slaving --- plugins/jetpants_collins/pool.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/jetpants_collins/pool.rb b/plugins/jetpants_collins/pool.rb index c46a1b7..7a6d80a 100644 --- a/plugins/jetpants_collins/pool.rb +++ b/plugins/jetpants_collins/pool.rb @@ -128,6 +128,18 @@ def after_master_promotion!(promoted, enslave_old_master=true) end end end + + # Clean up any slaves that are no longer slaving (again only looking at current datacenter) + assets = Jetpants.topology.server_node_assets(@name, :slave) + assets.reject! {|a| a.location && a.location.upcase != Plugin::JetCollins.datacenter} + assets.map(&:to_db).each do |db| + if !db.running? || db.pool != self + db.output "Not replicating from new master, removing from pool #{self}" + db.collins_pool = '' + db.collins_secondary_role = '' + db.collins_status = 'Unallocated' + end + end end