diff options
| author | Diana Corbacho <diana@rabbitmq.com> | 2016-08-19 12:26:10 +0100 |
|---|---|---|
| committer | Diana Corbacho <diana@rabbitmq.com> | 2016-08-19 12:26:10 +0100 |
| commit | e08e2b960dc48873c56a6f98b527d99cf52db90f (patch) | |
| tree | c2c86c4f36a020b60b8218f87facbb36e14c26b3 /scripts | |
| parent | 80efcc7258bcf9ae9ca62a8509a76f56b2fc6c5c (diff) | |
| parent | d4020f5f50f118f870ead1d1180f79e75032f6f7 (diff) | |
| download | rabbitmq-server-git-e08e2b960dc48873c56a6f98b527d99cf52db90f.tar.gz | |
Merge branch 'stable'
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/rabbitmq-server-ha.ocf | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/scripts/rabbitmq-server-ha.ocf b/scripts/rabbitmq-server-ha.ocf index 8f9cb16aa5..84baaba825 100755 --- a/scripts/rabbitmq-server-ha.ocf +++ b/scripts/rabbitmq-server-ha.ocf @@ -1362,25 +1362,18 @@ check_timeouts() { local op_name=$3 if [ $op_rc -ne 124 -a $op_rc -ne 137 ]; then - ocf_run attrd_updater -p --name $timeouts_attr_name --update 0 + ocf_update_private_attr $timeouts_attr_name 0 return 0 fi local count - count=`attrd_updater --name $timeouts_attr_name --query 2>/dev/null` - if [ $? -ne 0 ]; then - # the attrd_updater exited with error. In that case most probably it printed garbage - # instead of the number we need. So defensively assume that it is zero. - - count=0 - fi - count=`echo "${count}" | awk '{print $3}' | awk -F "=" '{print $2}' | sed -e '/(null)/d'` + count=$(ocf_get_private_attr $timeouts_attr_name 0) count=$((count+1)) # There is a slight chance that this piece of code will be executed twice simultaneously. # As a result, $timeouts_attr_name's value will be one less than it should be. But we don't need # precise calculation here. - ocf_run attrd_updater -p --name $timeouts_attr_name --update $count + ocf_update_private_attr $timeouts_attr_name $count if [ $count -lt $OCF_RESKEY_max_rabbitmqctl_timeouts ]; then ocf_log warn "${LH} 'rabbitmqctl $op_name' timed out $count of max. $OCF_RESKEY_max_rabbitmqctl_timeouts time(s) in a row. Doing nothing for now." @@ -1634,6 +1627,18 @@ get_monitor() { return $rc } +ocf_get_private_attr() { + local attr_name="${1:?}" + local attr_default_value="${2:?}" + local count + count=$(attrd_updater -p --name "$attr_name" --query) + if [ $? -ne 0 ]; then + echo $attr_default_value + else + echo "$count" | awk -vdef_val="$attr_default_value" '{ gsub(/"/, "", $3); split($3, vals, "="); if (vals[2] != "(null)") print vals[2]; else print def_val }' + fi +} + ocf_update_private_attr() { local attr_name="${1:?}" local attr_value="${2:?}" |
