Skip to content

Commit 7d3055a

Browse files
committed
Allow users to define poliies and parameters in OCF script for HA
By mistake OpenStack policies were copied into the initial version of the script. The policies are removed by this change. Instead users are provided with ability to set their own policies in a new set_rabbitmq_policy.sh file. Also now users can extend parameters list with their own ones. For now extended parameters can be used only in the policy file, but later new places to hook into could appear.
1 parent 1be1da5 commit 7d3055a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

packaging/common/rabbitmq-server-ha.ocf

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#
1414
# See usage() function below for more details ...
1515
#
16+
# Note that the script uses set_rabbitmq_policy.sh script located in the
17+
# same directory to setup RabbitMQ policies.
18+
#
1619
#######################################################################
1720
# Initialization:
1821

@@ -92,6 +95,11 @@ UEND
9295
}
9396

9497
meta_data() {
98+
# The EXTENDED_OCF_PARAMS parameter below does not exist by default
99+
# and hence converted to an empty string unless overridden. It
100+
# could be used by an extention script to add new parameters. For
101+
# example see https://review.openstack.org/#/c/249180/10
102+
95103
cat <<END
96104
<?xml version="1.0"?>
97105
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
@@ -268,6 +276,8 @@ If too many timeouts happen in a raw, the monitor call will return with error.
268276
<content type="string" default="${OCF_RESKEY_max_rabbitmqctl_timeouts_default}" />
269277
</parameter>
270278
279+
$EXTENDED_OCF_PARAMS
280+
271281
</parameters>
272282
273283
<actions>
@@ -1721,11 +1731,10 @@ action_promote() {
17211731
ocf_log info "${LH} action end."
17221732
exit $OCF_FAILED_MASTER
17231733
fi
1724-
ocf_log info "${LH} Setting HA policy for all queues"
1725-
${OCF_RESKEY_ctl} set_policy ha-all "." '{"ha-mode":"all", "ha-sync-mode":"automatic"}' --apply-to all --priority 0
1726-
${OCF_RESKEY_ctl} set_policy heat_rpc_expire "^heat-engine-listener\\." '{"expires":3600000,"ha-mode":"all","ha-sync-mode":"automatic"}' --apply-to all --priority 1
1727-
${OCF_RESKEY_ctl} set_policy results_expire "^results\\." '{"expires":3600000,"ha-mode":"all","ha-sync-mode":"automatic"}' --apply-to all --priority 1
1728-
${OCF_RESKEY_ctl} set_policy tasks_expire "^tasks\\." '{"expires":3600000,"ha-mode":"all","ha-sync-mode":"automatic"}' --apply-to all --priority 1
1734+
1735+
local set_policy_path="$(dirname $0)/set_rabbitmq_policy.sh"
1736+
. $set_policy_path
1737+
17291738
# create timestamp file
17301739
ocf_log info "${LH} Updating start timestamp"
17311740
ocf_run crm_attribute -N $THIS_PCMK_NODE -l reboot --name 'rabbit-start-time' --update $(now)

scripts/set_rabbitmq_policy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This script is called by rabbitmq-server-ha.ocf during RabbitMQ
2+
# cluster start up. It is a convenient place to set your cluster
3+
# policy here, for example:
4+
# ${OCF_RESKEY_ctl} set_policy ha-all "." '{"ha-mode":"all", "ha-sync-mode":"automatic"}' --apply-to all --priority 0
5+

0 commit comments

Comments
 (0)