diff options
| author | Alexey Lebedeff <alebedev@mirantis.com> | 2016-08-26 14:35:26 +0300 |
|---|---|---|
| committer | Alexey Lebedeff <alebedev@mirantis.com> | 2016-08-26 14:35:26 +0300 |
| commit | 2ac267a2351ec90ffa5014762ed2fef0caed7a00 (patch) | |
| tree | b689c9c65e9569a3d5a240799b3b98c9668e6e57 /scripts | |
| parent | 57622a4c7a0c4021de522f0e7eebf2382d1a7311 (diff) | |
| download | rabbitmq-server-git-2ac267a2351ec90ffa5014762ed2fef0caed7a00.tar.gz | |
Perform partition checks from OCF HA script
Partitioned nodes are ordered to restart by master. It may sound like
`autoheal`, but the problem is that OCF script and `autoheal` are not
compatible because concepts of master in pacemaker and winner in
autoheal are completely unrelated.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/rabbitmq-server-ha.ocf | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf index 9b3acd9803..2c01f7142e 100755 --- a/scripts/rabbitmq-server-ha.ocf +++ b/scripts/rabbitmq-server-ha.ocf @@ -812,10 +812,45 @@ get_master_name_but() done } +erl_eval() { + local fmt="${1:?}" + shift + + ${OCF_RESKEY_ctl} eval "$(printf "$fmt" "$@")" +} + # Returns 0 if we are clustered with provideded node is_clustered_with() { - get_running_nodes | grep -q $(rabbit_node_name $1); + local LH="${LH}: is_clustered_with: " + local node_name + local rc + node_name=$(rabbit_node_name $1) + + local seen_as_running + seen_as_running=$(erl_eval "lists:member('%s', rabbit_mnesia:cluster_nodes(running))." "$node_name") + rc=$? + if [ "$rc" -ne 0 ]; then + ocf_log err "${LH} Failed to check whether '$node_name' is considered running by us" + # XXX Or should we give remote node benefit of a doubt? + return 1 + elif [ "$seen_as_running" != true ]; then + ocf_log info "${LH} Node $node_name is not running, considering it not clustered with us" + return 1 + fi + + local seen_as_partitioned + seen_as_partitioned=$(erl_eval "lists:member('%s', rabbit_node_monitor:partitions())." "$node_name") + rc=$? + if [ "$rc" -ne 0 ]; then + ocf_log err "${LH} Failed to check whether '$node_name' is partitioned with us" + # XXX Or should we give remote node benefit of a doubt? + return 1 + elif [ "$seen_as_partitioned" != false ]; then + ocf_log info "${LH} Node $node_name is partitioned from us" + return 1 + fi + return $? } |
