From 9e4e607de3a4f8112fecc1d9a4a1af9c5e1cfd83 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Wed, 21 Oct 2015 10:43:16 +0200 Subject: Fix the timeout arg for the su_rabbit_cmd And fix local bashisms as a little bonus (Fuel related bug) Related-bug: #1464637 Signed-off-by: Bogdan Dobrelya --- packaging/common/rabbitmq-server-ha.ocf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'packaging') diff --git a/packaging/common/rabbitmq-server-ha.ocf b/packaging/common/rabbitmq-server-ha.ocf index 5ccda7b745..a3ed1e0f3c 100755 --- a/packaging/common/rabbitmq-server-ha.ocf +++ b/packaging/common/rabbitmq-server-ha.ocf @@ -286,7 +286,7 @@ END su_rabbit_cmd() { local timeout if [ "$1" = "-t" ]; then - timeout=="/usr/bin/timeout ${OCF_RESKEY_command_timeout} $2" + timeout="/usr/bin/timeout ${OCF_RESKEY_command_timeout} $2" shift 2 else timeout=$COMMAND_TIMEOUT @@ -404,7 +404,8 @@ rmq_setup_env() { # user for dir in ${PID_DIR} "${OCF_RESKEY_mnesia_base}" "${OCF_RESKEY_log_dir}"; do if test -e ${dir}; then - local files=$(su -s /bin/sh - $OCF_RESKEY_username -c "find ${dir} ! -writable") + local files + files=$(su -s /bin/sh - $OCF_RESKEY_username -c "find ${dir} ! -writable") if [ "${files}" ]; then ocf_log warn "Directory ${dir} is not writable by ${OCF_RESKEY_username}, chowning." chown -R ${OCF_RESKEY_username}:${OCF_RESKEY_groupname} "${dir}" @@ -1135,8 +1136,8 @@ wait_sync() { wait_time=$1 queues="${COMMAND_TIMEOUT} ${OCF_RESKEY_ctl} list_queues name state" - su_rabbit_cmd -t "${wait_time}s" "sh -c \"while $queues | grep -q 'syncing,'; \ - do sleep 1; done\"" + su_rabbit_cmd -t "${wait_time}" "sh -c \"while ${queues} | grep -q 'syncing,'; \ + do sleep 2; done\"" return $? } -- cgit v1.2.1 From 6427aaf46b97fca26adda03b0f2b6acb5282f599 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Wed, 21 Oct 2015 10:46:51 +0200 Subject: Fix piped exit codes expectations and count processing * Fix return code of the get_all_pacemaker_nodes() and get_alive_pacemaker_nodes_but() to be not provided as ignored anyway. * Fix return code expectation of the fetched count attribute in the check_timeouts(). (Fuel related bug) Closes-bug: #1506440 Signed-off-by: Bogdan Dobrelya --- packaging/common/rabbitmq-server-ha.ocf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packaging') diff --git a/packaging/common/rabbitmq-server-ha.ocf b/packaging/common/rabbitmq-server-ha.ocf index a3ed1e0f3c..6404a7dbd2 100755 --- a/packaging/common/rabbitmq-server-ha.ocf +++ b/packaging/common/rabbitmq-server-ha.ocf @@ -540,7 +540,6 @@ get_running_nodes() { get_all_pacemaker_nodes() { echo `crm_node -l | awk '{print $2}' | grep -v "^$" | sed -e '/(null)/d'` - return $? } # Get alive cluster nodes in visible partition, but the specified one @@ -551,7 +550,6 @@ get_alive_pacemaker_nodes_but() else echo `crm_node -l -p | sed -e "s/${1}//g" | sed -e '/(null)/d'` fi - return $? } check_need_join_to() { @@ -1109,13 +1107,15 @@ check_timeouts() { fi local count - count=`crm_attribute -N $THIS_PCMK_NODE -l reboot --name $crm_attr_name --query 2>/dev/null | awk '{print $3}' | awk -F "=" '{print $2}' | sed -e '/(null)/d'` - if [ $? -ne 0 ]; then + count=`crm_attribute -N $THIS_PCMK_NODE -l reboot --name $crm_attr_name --query 2>/dev/null` + op_rc=$? + if [ $op_rc -ne 0 ]; then # the crm_attribute 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=$((count+1)) # There is a slight chance that this piece of code will be executed twice simultaneously. -- cgit v1.2.1