diff --git a/files/fuel-ha-utils/ocf/ceilometer-agent-central b/files/fuel-ha-utils/ocf/ceilometer-agent-central index a7fb1521ad..6dcfcf031d 100644 --- a/files/fuel-ha-utils/ocf/ceilometer-agent-central +++ b/files/fuel-ha-utils/ocf/ceilometer-agent-central @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) @@ -27,6 +27,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -277,56 +279,20 @@ ceilometer_agent_central_start() { ceilometer_agent_central_stop() { local rc - local pid - - ceilometer_agent_central_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) already stopped" - return $OCF_SUCCESS - fi - - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-central) couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 + local shutdown_timeout=15 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - ceilometer_agent_central_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-central) still hasn't stopped yet. Waiting ..." - done ceilometer_agent_central_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "OpenStack Ceilometer Central Agent (${OCF_RESKEY_binary}) already stopped" + return "${OCF_SUCCESS}" fi - ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat $OCF_RESKEY_pid)" - rm -f $OCF_RESKEY_pid - - return $OCF_SUCCESS + proc_stop "${OCF_RESKEY_pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/ceilometer-agent-compute b/files/fuel-ha-utils/ocf/ceilometer-agent-compute index 2d1df85f33..98c0adb366 100644 --- a/files/fuel-ha-utils/ocf/ceilometer-agent-compute +++ b/files/fuel-ha-utils/ocf/ceilometer-agent-compute @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # OpenStack Ceilometer Compute Agent Service (ceilometer-agent-compute) @@ -27,6 +27,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -266,55 +268,20 @@ ceilometer_agent_compute_start() { ceilometer_agent_compute_stop() { local rc - local pid - - ceilometer_agent_compute_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "OpenStack Compute Compute Agent (ceilometer-agent-compute) already stopped" - return $OCF_SUCCESS - fi - - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "OpenStack Ceilometer Compute Agent (ceilometer-agent-compute) couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 + local shutdown_timeout=15 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - ceilometer_agent_compute_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Ceilometer Compute Agent (ceilometer-agent-compute) still hasn't stopped yet. Waiting ..." - done ceilometer_agent_compute_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Ceilometer Compute Agent (ceilometer-agent-compute) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "OpenStack Compute Compute Agent (${OCF_RESKEY_binary}) already stopped" + return "${OCF_SUCCESS}" fi - ocf_log info "OpenStack Ceilometer Compute Agent (ceilometer-agent-compute) stopped" - - rm -f $OCF_RESKEY_pid - - return $OCF_SUCCESS + proc_stop "${OCF_RESKEY_pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/ceilometer-alarm-evaluator b/files/fuel-ha-utils/ocf/ceilometer-alarm-evaluator index 8969e29c65..383e046bc8 100644 --- a/files/fuel-ha-utils/ocf/ceilometer-alarm-evaluator +++ b/files/fuel-ha-utils/ocf/ceilometer-alarm-evaluator @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # OpenStack Ceilometer Alarm Evaluator Service (ceilometer-alarm-evaluator) @@ -26,6 +26,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -264,56 +266,20 @@ ceilometer_alarm_evaluator_start() { ceilometer_alarm_evaluator_stop() { local rc - local pid - - ceilometer_alarm_evaluator_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "OpenStack Ceilometer Alarm Evaluator (ceilometer-alarm-evaluator) already stopped" - return $OCF_SUCCESS - fi - - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "OpenStack Ceilometer Alarm Evaluator (ceilometer-alarm-evaluator) couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 + local shutdown_timeout=15 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - ceilometer_alarm_evaluator_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Ceilometer Alarm Evaluator (ceilometer-alarm-evaluator) still hasn't stopped yet. Waiting ..." - done ceilometer_alarm_evaluator_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Ceilometer Alarm Evaluator (ceilometer-alarm-evaluator) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "OpenStack Ceilometer Alarm Evaluator (${OCF_RESKEY_binary}) already stopped" + return "${OCF_SUCCESS}" fi - ocf_log info "OpenStack Ceilometer Alarm Evaluator (ceilometer-alarm-evaluator) stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" - rm -f $OCF_RESKEY_pid - - return $OCF_SUCCESS + proc_stop "${OCF_RESKEY_pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/haproxy b/files/fuel-ha-utils/ocf/haproxy index b6574ed2db..9e93c823dd 100755 --- a/files/fuel-ha-utils/ocf/haproxy +++ b/files/fuel-ha-utils/ocf/haproxy @@ -37,6 +37,8 @@ OCF_RESKEY_binpath_default="/usr/sbin/haproxy" : ${OCF_RESKEY_binpath=${OCF_RESKEY_binpath_default}} : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat} . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs USAGE="Usage: $0 {start|stop|status|monitor|validate-all|meta-data}"; @@ -196,24 +198,23 @@ haproxy_reload() haproxy_stop() { - get_variables - if haproxy_status ; then - PID="`cat ${PIDFILE}`" - if [ -n "${PID}" ] ; then - kill "${PID}" - if [ $? -ne 0 ]; then - kill -SIGKILL "${PID}" - if [ $? -ne 0 ]; then - ocf_log err "Error. Could not stop haproxy daemon." - return $OCF_ERR_GENERIC - fi - fi - ocf_log debug "Delete pid file: ${PIDFILE} with content ${PID}" - rm -f "${PIDFILE}" - fi - fi - ocf_log info "Stopped haproxy daemon." - exit $OCF_SUCCESS + local rc + local LH="${LL} haproxy_stop():" + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi + + get_variables + haproxy_status + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} haproxy already stopped" + return "${OCF_SUCCESS}" + fi + + proc_stop "${OCF_RESKEY_pidfile}" "haproxy" $shutdown_timeout + return "${?}" } haproxy_monitor() diff --git a/files/fuel-ha-utils/ocf/heat_engine_centos b/files/fuel-ha-utils/ocf/heat_engine_centos index 77bac58a99..b385bad46c 100644 --- a/files/fuel-ha-utils/ocf/heat_engine_centos +++ b/files/fuel-ha-utils/ocf/heat_engine_centos @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # OpenStack Heat Engine OCF script # @@ -23,6 +23,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -278,55 +280,21 @@ service_start() { service_stop() { local rc - local pid - - service_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "${SERVICE_NAME} is already stopped" - return $OCF_SUCCESS - fi - - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "${SERVICE_NAME} couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 + local LH="${LL} service_stop():" + local shutdown_timeout=15 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - service_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "${SERVICE_NAME} still hasn't stopped yet. Waiting ..." - done service_status - rc=$? - if [ "${rc}" -ne "${OCF_NOT_RUNNING}" ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "${SERVICE_NAME} failed to stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL "${pid}" + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} ${SERVICE_NAME} already stopped" + return "${OCF_SUCCESS}" fi - ocf_log info "${SERVICE_NAME} stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" - rm -f "${OCF_RESKEY_pid}" - - return "${OCF_SUCCESS}" + proc_stop "${OCF_RESKEY_pid}" "${SERVICE_NAME}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/heat_engine_ubuntu b/files/fuel-ha-utils/ocf/heat_engine_ubuntu index 3a93d3b1bb..60ff96df51 100644 --- a/files/fuel-ha-utils/ocf/heat_engine_ubuntu +++ b/files/fuel-ha-utils/ocf/heat_engine_ubuntu @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # OpenStack Heat Engine OCF script # @@ -23,6 +23,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -279,55 +281,21 @@ service_start() { service_stop() { local rc - local pid - - service_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "${SERVICE_NAME} is already stopped" - return $OCF_SUCCESS - fi - - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "${SERVICE_NAME} couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 + local LH="${LL} service_stop():" + local shutdown_timeout=15 if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - service_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "${SERVICE_NAME} still hasn't stopped yet. Waiting ..." - done service_status - rc=$? - if [ "${rc}" -ne "${OCF_NOT_RUNNING}" ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "${SERVICE_NAME} failed to stop after ${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL "${pid}" + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} ${SERVICE_NAME} already stopped" + return "${OCF_SUCCESS}" fi - ocf_log info "${SERVICE_NAME} stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" - rm -f "${OCF_RESKEY_pid}" - - return "${OCF_SUCCESS}" + proc_stop "${OCF_RESKEY_pid}" "${SERVICE_NAME}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/nova-compute b/files/fuel-ha-utils/ocf/nova-compute index 9677c8a59c..3a7ef013d6 100644 --- a/files/fuel-ha-utils/ocf/nova-compute +++ b/files/fuel-ha-utils/ocf/nova-compute @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # # OpenStack Nova Compute (nova-compute) @@ -27,6 +27,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -291,56 +293,20 @@ nova_compute_start() { nova_compute_stop() { local rc - local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi nova_compute_status rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - ocf_log info "OpenStack Nova Compute (nova-compute) already stopped" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "OpenStack Nova Compute (${OCF_RESKEY_binary}) already stopped" return $OCF_SUCCESS fi - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "OpenStack Nova Compute (nova-compute) couldn't be stopped" - exit $OCF_ERR_GENERIC - fi - - # stop waiting - shutdown_timeout=15 - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) - fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - nova_compute_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Nova Compute (nova-compute) still hasn't stopped yet. Waiting ..." - done - - nova_compute_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Nova Compute (nova-compute) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid - fi - - ocf_log info "OpenStack Nova Compute (nova-compute) stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" - rm -f $OCF_RESKEY_pid - - return $OCF_SUCCESS + proc_stop "${OCF_RESKEY_pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + return "${?}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/nova-network b/files/fuel-ha-utils/ocf/nova-network index 0a9897b096..489bdf8d02 100644 --- a/files/fuel-ha-utils/ocf/nova-network +++ b/files/fuel-ha-utils/ocf/nova-network @@ -32,6 +32,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -479,61 +481,31 @@ nova_network_start() { nova_network_stop() { local rc - local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi nova_network_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then nova_network_cleanup sleep 2 - ocf_log info "OpenStack Nova Network (nova-network) already stopped" - return $OCF_SUCCESS + ocf_log info "OpenStack Nova Network (${OCF_RESKEY_binary}) already stopped" + return "${OCF_SUCCESS}" fi - # Try SIGTERM - pid=`cat $OCF_RESKEY_pid` - ocf_run kill -s TERM $pid - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "OpenStack Nova Network (nova-network) couldn't be stopped" - exit $OCF_ERR_GENERIC + proc_stop "${OCF_RESKEY_pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + rc="${?}" + if [ "${rc}" -ne "${OCF_SUCCESS}" ]; then + ocf_log err "OpenStack Nova Network (${OCF_RESKEY_binary}) couldn't be stopped" + return "${rc}" fi - # stop waiting - shutdown_timeout=15 - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) - fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - nova_network_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Nova Network (nova-network) still hasn't stopped yet. Waiting ..." - done - - nova_network_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Nova Network (nova-network) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid - fi - - ocf_log info "OpenStack Nova Network (nova-network) stopped" - - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" - rm -f $OCF_RESKEY_pid - nova_network_cleanup sleep 2 - return $OCF_SUCCESS + return "${OCF_SUCCESS}" } ####################################################################### diff --git a/files/fuel-ha-utils/ocf/ns_dns b/files/fuel-ha-utils/ocf/ns_dns index d8bfa834bf..8f1c76b924 100644 --- a/files/fuel-ha-utils/ocf/ns_dns +++ b/files/fuel-ha-utils/ocf/ns_dns @@ -5,7 +5,7 @@ # Description: Manages dnsmasq daemon as an OCF resource in # an High Availability setup inside a namespace # -# HAProxy OCF script's Author: Mirantis +# dnsmasq OCF script's Author: Mirantis # License: GNU General Public License (GPL) # # usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data} @@ -46,6 +46,8 @@ OCF_RESKEY_extraconf_default="" : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat} . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs USAGE="Usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}"; @@ -211,23 +213,23 @@ dnsmasq_start() dnsmasq_stop() { - get_variables - if dnsmasq_status ; then - PID="`${RUN} cat ${PIDFILE}`" - if [ -n "${PID}" ] ; then - kill "${PID}" - if [ $? -ne 0 ]; then - kill -SIGKILL "${PID}" - if [ $? -ne 0 ]; then - ocf_log err "Error. Could not stop dnsmasq daemon." - return $OCF_ERR_GENERIC - fi - fi - rm -f "${PIDFILE}" + local rc + local LH="${LL} dnsmasq_stop():" + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - fi - ocf_log info "Stopped dnsmasq daemon." - return $OCF_SUCCESS + + get_variables + dnsmasq_status + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} dnsmasq already stopped" + return "${OCF_SUCCESS}" + fi + + proc_stop "${PIDFILE}" "dnsmasq" $shutdown_timeout + return "${?}" } dnsmasq_monitor() @@ -272,6 +274,8 @@ if [ $# -ne 1 ]; then exit $OCF_ERR_ARGS fi +export LL="${OCF_RESOURCE_INSTANCE}:" + case $1 in start) dnsmasq_start ;; diff --git a/files/fuel-ha-utils/ocf/ns_haproxy b/files/fuel-ha-utils/ocf/ns_haproxy index 0d0504b322..33580c8ff4 100755 --- a/files/fuel-ha-utils/ocf/ns_haproxy +++ b/files/fuel-ha-utils/ocf/ns_haproxy @@ -71,6 +71,8 @@ OCF_RESKEY_debug_default=false : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat} . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs USAGE="Usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}"; @@ -484,61 +486,25 @@ haproxy_reload() fi } -# Try to kill (SIGTERM) specified pid 5 times by 2 sec interval -haproxy_kill() -{ - local rc - local PID="$1" - local count=5 - local LH="${LL} haproxy_kill():" - local pgrp=$(ps -o pgid= ${pid} | tr -d '[[:space:]]') - - while [ $count -gt 0 ]; do - if [ -d /proc/${PID}/ ]; then - ocf_log debug "${LH} Stopping haproxy daemon with SIGTERM... " - ocf_run pkill -g "${pgrp}" - if [ ! -d /proc/${PID}/ ]; then - ocf_log debug "${LH} Stopped haproxy daemon with SIGTERM" - return 0 - fi - else - return 0 - fi - sleep 2 - count=$(( count-1 )) - done - ocf_log debug "${LH} Failed to stop haproxy daemon with SIGTERM" - return 1 -} - haproxy_stop() { - local rc - local LH="${LL} haproxy_stop():" - get_variables - local pid=$(cat $PIDFILE 2>/dev/null) - local pgrp=$(ps -o pgid= ${pid} | tr -d '[[:space:]]') - if haproxy_status ; then - if [ -z "${pid}" -o "${pgrp}" -eq "1" -o ! -d /proc/${pid}/ ]; then - ocf_log err "${LH} Cannot stop haproxy (PID=${pid})" - return $OCF_ERR_GENERIC - fi - haproxy_kill "${pid}" - rc=$? - if [ $rc -ne 0 -a -d /proc/${pid}/ ]; then - ocf_run pkill -SIGKILL -g "${pgrp}" - ocf_log err "${LH} Failed to stop haproxy daemon gracefully. Killed with SIGKILL" - rc=$? - if [ $rc -ne 0 ]; then - ocf_log err "${LH} Error. Could not stop haproxy daemon." - return $OCF_ERR_GENERIC - fi - fi - ocf_log debug "Delete pid file: ${PIDFILE} with content ${pgrp}" - rm -f "${PIDFILE}" - fi - ocf_log info "Stopped haproxy daemon." - return $OCF_SUCCESS + local rc + local LH="${LL} haproxy_stop():" + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi + + get_variables + haproxy_status + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} haproxy already stopped." + return "${OCF_SUCCESS}" + fi + + proc_stop "${PIDFILE}" "haproxy" $shutdown_timeout + return "${?}" } haproxy_monitor() diff --git a/files/fuel-ha-utils/ocf/ns_ntp b/files/fuel-ha-utils/ocf/ns_ntp index 5f5b37a4d3..77abbf0eb1 100644 --- a/files/fuel-ha-utils/ocf/ns_ntp +++ b/files/fuel-ha-utils/ocf/ns_ntp @@ -46,6 +46,8 @@ OCF_RESKEY_extraconf_default="" : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/heartbeat} . ${OCF_FUNCTIONS_DIR}/.ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs USAGE="Usage: $0 {start|stop|restart|status|monitor|validate-all|meta-data}"; @@ -201,25 +203,22 @@ ntp_start() ntp_stop() { - get_variables - ntp_status - rc="${?}" - if [ "${rc}" -eq "${OCF_SUCCESS}" -o "${rc}" -eq "${OCF_ERR_GENERIC}" ]; then - PID="`cat ${PIDFILE}`" - if [ -n "${PID}" ] ; then - kill "${PID}" - if [ "${?}" -ne "0" ]; then - kill -SIGKILL "${PID}" - if [ "${?}" -ne "0" ]; then - ocf_log err "Error. Could not stop ntp daemon." - return "${OCF_ERR_GENERIC}" - fi - fi - rm -f "${PIDFILE}" + local rc + local LH="${LL} haproxy_stop():" + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) fi - fi - ocf_log info "Stopped ntp daemon." - return "${OCF_SUCCESS}" + get_variables + ntp_status + rc="${?}" + if [ "${rc}" -eq "${OCF_NOT_RUNNING}" ]; then + ocf_log info "${LH} ntp already stopped." + return "${OCF_SUCCESS}" + fi + + proc_stop "${PIDFILE}" "ntp" $shutdown_timeout + return "${?}" } ntp_monitor() @@ -264,6 +263,7 @@ if [ $# -ne 1 ]; then exit "${OCF_ERR_ARGS}" fi +export LL="${OCF_RESOURCE_INSTANCE}:" case $1 in start) ntp_start ;; diff --git a/files/fuel-ha-utils/ocf/ocf-fuel-funcs b/files/fuel-ha-utils/ocf/ocf-fuel-funcs new file mode 100644 index 0000000000..27459875e7 --- /dev/null +++ b/files/fuel-ha-utils/ocf/ocf-fuel-funcs @@ -0,0 +1,150 @@ +#!/bin/bash +# +# Copyright 2015 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# +# Shared resource script for common functions (ocf-fuel-funcs) +# +# Authors: Alex Schultz +# + +########################################################### +# Attempts to kill a process with retries and checks procfs +# to make sure the process is stopped. +# +# Globals: +# LL +# Arguments: +# $1 - pid of the process to try and kill +# $2 - service name used for logging +# $3 - signal to use, defaults to SIGTERM +# $4 - number of retries, defaults to 5 +# $5 - time to sleep between retries, defaults to 2 +# Returns: +# 0 - if successful +# 1 - if process is still running according to procfs +# 2 - if invalid parameters passed in +########################################################### +proc_kill() +{ + local pid="${1}" + local service_name="${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:]]') + + if [ -z "${pid}" -o "${pgrp}" -eq "1" ]; then + ocf_log info "${LH} pid provided to kill was empty or for init" + return 2 + 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 + else + ocf_log debug "${LH} Stopped ${service_name} with ${signal}" + return 0 + fi + sleep $process_sleep + count=$(( count-1 )) + done + + # Check if the process ended after the last sleep + if [ ! -d /proc/${pid} ] ; then + ocf_log debug "${LH} Stopped ${service_name} with ${signal}" + return 0 + fi + + ocf_log debug "${LH} Failed to stop ${service_name} with ${signal}" + return 1 +} + +########################################################### +# Attempts to kill a process with the given pid or pid file +# using proc_kill and will retry with sigkill if sigterm is +# unsuccessful. +# +# Globals: +# OCF_ERR_GENERIC +# OCF_SUCCESS +# LL +# Arguments: +# $1 - pidfile or pid +# $2 - service name used for logging +# $3 - stop process timeout (in sec), used to determine how many times we try +# SIGTERM and an upper limit on how long this function should try and +# stop the process. Defaults to 15. +# Returns: +# OCF_SUCCESS - if successful +# OCF_ERR_GENERIC - if process is still running according to procfs +########################################################### +proc_stop() +{ + local pid_param="${1}" + local service_name="${2}" + local timeout=${3:-15} + local LH="${LL} proc_stop():" + local pid + local pidfile + # check if provide just a number + echo "${pid_param}" | egrep -q '^[0-9]+$' + if [ $? -eq 0 ]; then + pid="${pid_param}" + elif [ -e "${pid_param}" ]; then # check if passed in a pid file + pidfile="${pid_param}" + pid=$(cat "${pidfile}" 2>/dev/null) + else + # nothing to do here... + ocf_log err "${LH} ERROR: pid param ${pid_param} is not a file or a number" + return "${OCF_ERR_GENERIC}" + fi + # number of times to try a SIGTEM is (timeout - 5 seconds) / 2 seconds + local stop_count=$(( ($timeout-5)/2 )) + + # make sure we stop at least once + if [ $stop_count -le 0 ]; then + stop_count=1 + fi + + if [ -n "${pid}" ]; then + ocf_log info "${LH} Stopping ${service_name}" + proc_kill "${pid}" "${service_name}" $stop_count + if [ $? -ne 0 ]; then + # SIGTERM failed, send a single SIGKILL + proc_kill "${pid}" "${service_name}" SIGKILL 1 2 + if [ $? -ne 0 ]; then + ocf_log err "${LH} ERROR: could not stop ${service_name}" + return "${OCF_ERR_GENERIC}" + fi + fi + else + ocf_log warn "${LH} unable to get PID from ${pidfile}" + fi + + # Remove the pid file here which will remove empty pid files as well + if [ -n "${pidfile}" ]; then + rm -f "${pidfile}" + fi + + ocf_log info "${LH} Stopped ${service_name}" + return "${OCF_SUCCESS}" +} diff --git a/files/fuel-ha-utils/ocf/ocf-neutron-dhcp-agent b/files/fuel-ha-utils/ocf/ocf-neutron-dhcp-agent index b2052c3951..7dbbacbae5 100644 --- a/files/fuel-ha-utils/ocf/ocf-neutron-dhcp-agent +++ b/files/fuel-ha-utils/ocf/ocf-neutron-dhcp-agent @@ -30,6 +30,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -418,6 +420,11 @@ neutron_dhcp_agent_start() { neutron_dhcp_agent_stop() { local rc local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi + # This variable is overridden by reload operation # to perform fast resource restart local remove_artifacts_on_stop_start=${1:-$OCF_RESKEY_remove_artifacts_on_stop_start} @@ -434,38 +441,13 @@ neutron_dhcp_agent_stop() { # Terminate agent daemon pid=`get_worker_pid` - shutdown_timeout=15 - iteration_time=1 - - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-6)) + proc_stop "${pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + rc=$? + if [ "${rc}" -eq "${OCF_ERR_GENERIC}" ]; then + ocf_log err "OpenStack DHCP Agent (${OCF_RESKEY_binary}) stop failed" + return $OCF_ERR_GENERIC fi - clock=0 - - # Try to terminate gracefully - while [ -d /proc/${pid}/ ] && [ $clock -lt $shutdown_timeout ]; do - ocf_log debug "Stopping DHCP Agent (${OCF_RESKEY_binary}) gracefully with SIGTERM" - ocf_run kill -s TERM ${pid} - - sleep $iteration_time - ((clock+=$iteration_time)) - done - - # Send kill signal if process is still up - if [ -d /proc/${pid}/ ] ; then - ocf_log debug "Killing DHCP Agent (${OCF_RESKEY_binary}) with SIGKILL" - ocf_run kill -s KILL ${pid} - - sleep 1 - if [ -d /proc/${pid}/ ] ; then - ocf_log err "OpenStack DHCP Agent (${OCF_RESKEY_binary}) stop failed" - return $OCF_ERR_GENERIC - fi - fi - - ocf_log info "OpenStack DHCP Agent (${OCF_RESKEY_binary}) stopped" - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" rm -f $OCF_RESKEY_pid diff --git a/files/fuel-ha-utils/ocf/ocf-neutron-l3-agent b/files/fuel-ha-utils/ocf/ocf-neutron-l3-agent index 48f758f297..17d7a96dea 100644 --- a/files/fuel-ha-utils/ocf/ocf-neutron-l3-agent +++ b/files/fuel-ha-utils/ocf/ocf-neutron-l3-agent @@ -31,6 +31,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -415,6 +417,10 @@ neutron_l3_agent_start() { neutron_l3_agent_stop() { local rc local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi # This variable is overridden by reload operation # to perform fast resource restart local remove_artifacts_on_stop_start=${1:-$OCF_RESKEY_remove_artifacts_on_stop_start} @@ -431,34 +437,11 @@ neutron_l3_agent_stop() { # Terminate agent daemon pid=`get_worker_pid` - shutdown_timeout=15 - iteration_time=1 - - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-6)) - fi - - clock=0 - - # Try to terminate gracefully - while [ -d /proc/${pid}/ ] && [ $clock -lt $shutdown_timeout ]; do - ocf_log debug "Stopping L3 agent (${OCF_RESKEY_binary}) gracefully with SIGTERM" - ocf_run kill -s TERM ${pid} - - sleep $iteration_time - ((clock+=$iteration_time)) - done - - # Send kill signal if process is still up - if [ -d /proc/${pid}/ ] ; then - ocf_log debug "Killing L3 agent (${OCF_RESKEY_binary}) with SIGKILL" - ocf_run kill -s KILL ${pid} - - sleep 1 - if [ -d /proc/${pid}/ ] ; then - ocf_log err "OpenStack L3 agent (${OCF_RESKEY_binary}) stop failed" - return $OCF_ERR_GENERIC - fi + proc_stop "${pid}" "${OCF_RESKEY_binary}" $shutdown_timeout + rc=$? + if [ "${rc}" -eq "${OCF_ERR_GENERIC}" ]; then + ocf_log err "OpenStack L3 agent (${OCF_RESKEY_binary}) stop failed" + return $OCF_ERR_GENERIC fi ocf_log info "OpenStack L3 agent ($OCF_RESKEY_binary) stopped" diff --git a/files/fuel-ha-utils/ocf/ocf-neutron-metadata-agent b/files/fuel-ha-utils/ocf/ocf-neutron-metadata-agent index 5adfd24206..968c83cb63 100644 --- a/files/fuel-ha-utils/ocf/ocf-neutron-metadata-agent +++ b/files/fuel-ha-utils/ocf/ocf-neutron-metadata-agent @@ -19,6 +19,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -286,6 +288,10 @@ neutron_metadata_agent_start() { neutron_metadata_agent_stop() { local rc local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi neutron_metadata_agent_status rc=$? @@ -296,46 +302,13 @@ neutron_metadata_agent_stop() { # Try SIGTERM pid=`get_worker_pid` - if [ "xxx$pid" == "xxx" ] ; then - ocf_log warn "OpenStack Neutron Metadata Agent (${OCF_RESKEY_binary}) not running." - #return $OCF_NOT_RUNNING - return $OCF_SUCCESS - fi - ocf_run kill -s TERM $pid + proc_stop "${pid}" "${OCF_RESKEY_binary}" $shutdown_timeout rc=$? - if [ $rc -ne 0 ]; then + if [ "${rc}" -eq "${OCF_ERR_GENERIC}" ]; then ocf_log err "OpenStack Neutron Metadata Agent (${OCF_RESKEY_binary}) couldn't be stopped" exit $OCF_ERR_GENERIC fi - # stop waiting - shutdown_timeout=15 - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) - fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - neutron_metadata_agent_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack Neutron Metadata Agent (${OCF_RESKEY_binary}) still hasn't stopped yet. Waiting ..." - done - - neutron_metadata_agent_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack Neutron Metadata Agent (${OCF_RESKEY_binary}) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid - fi - - ocf_log info "OpenStack Neutron Metadata Agent (${OCF_RESKEY_binary}) stopped" - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" rm -f $OCF_RESKEY_pid diff --git a/files/fuel-ha-utils/ocf/ocf-neutron-ovs-agent b/files/fuel-ha-utils/ocf/ocf-neutron-ovs-agent index f113be0731..3d3811019c 100644 --- a/files/fuel-ha-utils/ocf/ocf-neutron-ovs-agent +++ b/files/fuel-ha-utils/ocf/ocf-neutron-ovs-agent @@ -26,6 +26,8 @@ : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs +: ${OCF_FUEL_FUNCTIONS_DIR=${OCF_ROOT}/resource.d/fuel} +. ${OCF_FUEL_FUNCTIONS_DIR}/ocf-fuel-funcs ####################################################################### @@ -318,6 +320,10 @@ neutron_ovs_agent_start() { neutron_ovs_agent_stop() { local rc local pid + local shutdown_timeout=15 + if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + shutdown_timeout=$(( ($OCF_RESKEY_CRM_meta_timeout/1000) )) + fi neutron_ovs_agent_status rc=$? @@ -330,49 +336,15 @@ neutron_ovs_agent_stop() { # Try SIGTERM pid=`get_worker_pid` - if [ "xxx$pid" == "xxx" ] ; then - ocf_log warn "OpenStack Neutron agent '$OCF_RESKEY_binary' not running." - #return $OCF_NOT_RUNNING - return $OCF_SUCCESS - fi - - ocf_run kill -s TERM $pid + proc_stop "${pid}" "${OCF_RESKEY_binary}" $shutdown_timeout rc=$? - if [ $rc -ne 0 ]; then + if [ "${rc}" -eq "${OCF_ERR_GENERIC}" ]; then ocf_log err "OpenStack OVS agent (${OCF_RESKEY_binary}) couldn't be stopped" exit $OCF_ERR_GENERIC fi - # stop waiting - shutdown_timeout=15 - if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then - shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) - fi - count=0 - while [ $count -lt $shutdown_timeout ]; do - neutron_ovs_agent_status - rc=$? - if [ $rc -eq $OCF_NOT_RUNNING ]; then - break - fi - count=`expr $count + 1` - sleep 1 - ocf_log debug "OpenStack OVS agent (${OCF_RESKEY_binary}) still hasn't stopped yet. Waiting ..." - done - - neutron_ovs_agent_status - rc=$? - if [ $rc -ne $OCF_NOT_RUNNING ]; then - # SIGTERM didn't help either, try SIGKILL - ocf_log info "OpenStack OVS agent (${OCF_RESKEY_binary}) failed to stop after ${shutdown_timeout}s \ - using SIGTERM. Trying SIGKILL ..." - ocf_run kill -s KILL $pid - fi - cleanup_agents_ovs_bridges - ocf_log info "OpenStack OVS agent (${OCF_RESKEY_binary}) stopped" - ocf_log debug "Delete pid file: ${OCF_RESKEY_pid} with content $(cat ${OCF_RESKEY_pid})" rm -f $OCF_RESKEY_pid diff --git a/specs/fuel-library8.0.spec b/specs/fuel-library8.0.spec index 6183070b81..b576ae0efa 100644 --- a/specs/fuel-library8.0.spec +++ b/specs/fuel-library8.0.spec @@ -98,6 +98,7 @@ install -m 0755 %{files_source}/fuel-ha-utils/ocf/ceilometer-alarm-evaluator %{b install -m 0755 %{files_source}/fuel-ha-utils/ocf/nova-compute %{buildroot}/usr/lib/ocf/resource.d/fuel/nova-compute install -m 0755 %{files_source}/fuel-ha-utils/ocf/nova-network %{buildroot}/usr/lib/ocf/resource.d/fuel/nova-network install -m 0755 %{files_source}/fuel-ha-utils/ocf/ceilometer-agent-compute %{buildroot}/usr/lib/ocf/resource.d/fuel/ceilometer-agent-compute +install -m 0755 %{files_source}/fuel-ha-utils/ocf/ocf-fuel-funcs %{buildroot}/usr/lib/ocf/resource.d/fuel/ocf-fuel-funcs install -m 0755 %{files_source}/fuel-ha-utils/tools/galeracheck %{buildroot}/usr/bin/galeracheck install -m 0755 %{files_source}/fuel-ha-utils/tools/swiftcheck %{buildroot}/usr/bin/swiftcheck install -m 0644 %{files_source}/fuel-ha-utils/tools/wsrepclustercheckrc %{buildroot}/etc/wsrepclustercheckrc