Skip to content

Syntax and local vars usage fixes to OCF HA #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions scripts/rabbitmq-server-ha.ocf
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,23 @@ proc_kill()
{
local pid="${1}"
local service_name="${2}"
local signal=${3:-SIGTERM}
local count=${4:-5}
local process_sleep=${5:-2}
local signal="${3:-SIGTERM}"
local count="${4:-5}"
local process_sleep="${5:-2}"
local LH="${LL} proc_kill():"
local pgrp=$(ps -o pgid= ${pid} | tr -d '[[:space:]]')
local pgrp="$(ps -o pgid= ${pid} | tr -d '[[:space:]]')"

if [ "${pid}" -a "${pgrp}" = "1" ] ; then
ocf_log err "${LH} shall not kill by the bad pid 1 (init)!"
return 2
fi

if [ -z "${pid}" ]; then
ocf_log info "${LH} no pid provided, will try the ${service_name}"
ocf_run pkill -f -${signal} "${service_name}"
rc=$?
if [ $rc -eq 0 ] ; then
local matched
matched="$(pgrep -fla ${service_name})"
ocf_log info "${LH} no pid provided, will try the ${service_name}, matched list: ${matched}"
ocf_run pkill -f -"${signal}" "${service_name}"
if [ $? -eq 0 ] ; then
ocf_log warn "${LH} sent kill -${signal} to processes matched the ${service_name}"
return 0
else
Expand All @@ -348,23 +349,18 @@ proc_kill()
fi

while [ $count -gt 0 ]; do
if [ -d /proc/${pid} ]; then
ocf_log debug "${LH} Stopping ${service_name} with ${signal}..."
ocf_run pkill -${signal} -g "${pgrp}"
if [ ! -d /proc/${pid} ] ; then
ocf_log debug "${LH} Stopped ${service_name} with ${signal}"
return 0
fi
if [ ! -d "/proc/${pid}" ]; then
break
else
ocf_log debug "${LH} Stopped ${service_name} with ${signal}"
return 0
ocf_log debug "${LH} Stopping ${service_name} with ${signal}..."
ocf_run pkill -"${signal}" -g "${pgrp}"
fi
sleep $process_sleep
count=$(( count-1 ))
done

# Check if the process ended after the last sleep
if [ ! -d /proc/${pid} ] ; then
if [ ! -d "/proc/${pid}" ] ; then
ocf_log debug "${LH} Stopped ${service_name} with ${signal}"
return 0
fi
Expand Down Expand Up @@ -396,7 +392,7 @@ proc_stop()
{
local pid_param="${1}"
local service_name="${2}"
local timeout=${3:-15}
local timeout="${3:-15}"
local LH="${LL} proc_stop():"
local pid
local pidfile
Expand Down Expand Up @@ -761,11 +757,9 @@ update_cookie() {

# Stop rmq beam process by pid or rabbit node name match. Returns SUCCESS/ERROR
kill_rmq_and_remove_pid() {
local rc
local LH="${LL} kill_rmq_and_remove_pid():"
proc_stop "${OCF_RESKEY_pid_file}" "beam.*${RABBITMQ_NODENAME}" "${OCF_RESKEY_stop_time}"
rc=$?
if [ $rc -eq 0 ] ; then
if [ $? -eq 0 ] ; then
return $OCF_SUCCESS
else
return $OCF_ERR_GENERIC
Expand Down Expand Up @@ -1280,8 +1274,7 @@ check_timeouts() {

local count
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
if [ $? -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.

Expand Down Expand Up @@ -1633,8 +1626,7 @@ action_stop() {

# Ensure the actual status to be returned
get_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ] ; then
if [ $? -eq $OCF_NOT_RUNNING ] ; then
ocf_log info "${LH} RMQ-runtime (beam) not running."
ocf_log info "${LH} action end."
return $OCF_SUCCESS
Expand Down