Skip to content

Commit

Permalink
closes rabbitmq#432
Browse files Browse the repository at this point in the history
This adds some helper functions to allow a wrapper cookbook to implement removing a node from a cluster in 2 sceneries:
- removing self from cluster (helpful for normal decommission)
- removing any node from cluster (helpful for abruptly terminated machines)

These both should not be actually consumed in this cookbook and simply be provided for wrappers to use as they see fit. This should be implemented only after careful thought, design, testing, etc.
  • Loading branch information
majormoses committed Apr 19, 2017
1 parent e5e1543 commit 9ae91c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ rabbitmq_cluster '[{"name":"rabbit@rabbit1","type":"disc"},{"name":"rabbit@rabbi
end
```

#### Removing nodes from cluster

This cookbook provides the primitives to remove a node from a cluster via helper functions but do not include these in any recipes. This is something that is potentially very dangerous and different deployments will have different needs and IF you decide you need this it should be implemented in your wrapper with EXTREME caution. There are 2 helper methods for 2 different sceneries:
- removing self from cluster. This should likely only be considered for machines on a normal decommission.
- removing another node from cluster. This should only be done once you are sure the machine is gone and won't come back.

## Limitations

Expand Down
22 changes: 22 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module RabbitMQCookbook
module Helpers
require 'mixlib/shellout'

def remove_self_from_cluster
# stop rmq
stop_rmq = Mixlib::ShellOut.new('rabbitmqctl stop_app')
stop_rmq.run_command
stop_rmq.error!
# remove self from cluster
remove_from_cluster = Mixlib::ShellOut.new('rabbitmqctl reset')
remove_from_cluster.run_command
remove_from_cluster.error!
end

def remove_remote_node_from_cluster(rmq_node)
remove_from_cluster = Mixlib::ShellOut.new("rabbitmqctl forget_cluster_node #{rmq_node}")
remove_from_cluster.run_command
remove_from_cluster.error!
end
end
end

0 comments on commit 9ae91c7

Please sign in to comment.