diff options
Diffstat (limited to 'extras/ganesha/ocf')
| -rw-r--r-- | extras/ganesha/ocf/Makefile.am | 1 | ||||
| -rw-r--r-- | extras/ganesha/ocf/ganesha_grace | 58 | ||||
| -rw-r--r-- | extras/ganesha/ocf/ganesha_mon | 63 | ||||
| -rw-r--r-- | extras/ganesha/ocf/ganesha_nfsd | 15 |
4 files changed, 93 insertions, 44 deletions
diff --git a/extras/ganesha/ocf/Makefile.am b/extras/ganesha/ocf/Makefile.am index 6aed9548a0f..990a609f254 100644 --- a/extras/ganesha/ocf/Makefile.am +++ b/extras/ganesha/ocf/Makefile.am @@ -9,4 +9,3 @@ ocfdir = $(prefix)/lib/ocf radir = $(ocfdir)/resource.d/heartbeat ra_SCRIPTS = ganesha_grace ganesha_mon ganesha_nfsd - diff --git a/extras/ganesha/ocf/ganesha_grace b/extras/ganesha/ocf/ganesha_grace index a82c9af417a..825f7164597 100644 --- a/extras/ganesha/ocf/ganesha_grace +++ b/extras/ganesha/ocf/ganesha_grace @@ -30,17 +30,17 @@ . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs if [ -n "$OCF_DEBUG_LIBRARY" ]; then - . $OCF_DEBUG_LIBRARY + . $OCF_DEBUG_LIBRARY else - : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} -. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} + . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs fi OCF_RESKEY_grace_active_default="grace-active" : ${OCF_RESKEY_grace_active=${OCF_RESKEY_grace_active_default}} ganesha_meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ganesha_grace"> @@ -93,9 +93,23 @@ esac ganesha_grace_start() { - rc=${OCF_ERR_GENERIC} + local rc=${OCF_ERR_GENERIC} + local host=$(hostname -s) + ocf_log debug "ganesha_grace_start()" - attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active}) + # give ganesha_mon RA a chance to set the crm_attr first + # I mislike the sleep, but it's not clear that looping + # with a small sleep is necessarily better + # start has a 40sec timeout, so a 5sec sleep here is okay + sleep 5 + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + host=$(hostname) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null ) + if [ $? -ne 0 ]; then + ocf_log info "grace start: crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} failed" + fi + fi # Three possibilities: # 1. There is no attribute at all and attr_updater returns @@ -116,7 +130,7 @@ ganesha_grace_start() fi # case 2 - if [[ "${attr}" = *"value=\"1\"" ]]; then + if [[ "${attr}" = *"value=1" ]]; then return ${OCF_SUCCESS} fi @@ -133,10 +147,11 @@ ganesha_grace_stop() ganesha_grace_notify() { + # since this is a clone RA we should only ever see pre-start + # or post-stop mode="${OCF_RESKEY_CRM_meta_notify_type}-${OCF_RESKEY_CRM_meta_notify_operation}" - case "$mode" in - post-stop) - ocf_log debug "stop_uname:${OCF_RESKEY_CRM_meta_notify_stop_uname}" + case "${mode}" in + pre-start | post-stop) dbus-send --print-reply --system --dest=org.ganesha.nfsd /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace string:${OCF_RESKEY_CRM_meta_notify_stop_uname} if [ $? -ne 0 ]; then ocf_log info "dbus-send --print-reply --system --dest=org.ganesha.nfsd /org/ganesha/nfsd/admin org.ganesha.nfsd.admin.grace string:${OCF_RESKEY_CRM_meta_notify_stop_uname} failed" @@ -149,10 +164,18 @@ ganesha_grace_notify() ganesha_grace_monitor() { - rc=${OCF_ERR_GENERIC} + local host=$(hostname -s) + ocf_log debug "monitor" - attr=$(attrd_updater -Q -n ${OCF_RESKEY_grace_active}) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + host=$(hostname) + attr=$(crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} 2> /dev/null) + if [ $? -ne 0 ]; then + ocf_log info "crm_attribute --query --node=${host} --name=${OCF_RESKEY_grace_active} failed" + fi + fi # if there is no attribute (yet), maybe it's because # this RA started before ganesha_mon (nfs-mon) has had @@ -162,11 +185,11 @@ ganesha_grace_monitor() return ${OCF_SUCCESS} fi - if [[ "${attr}" = *"value=\"1\"" ]]; then - rc=${OCF_SUCCESS} + if [[ "${attr}" = *"value=1" ]]; then + return ${OCF_SUCCESS} fi - return ${rc} + return ${OCF_NOT_RUNNING} } ganesha_grace_validate() @@ -187,8 +210,8 @@ status|monitor) ganesha_grace_monitor notify) ganesha_grace_notify ;; *) ganesha_grace_usage - exit ${OCF_ERR_UNIMPLEMENTED} - ;; + exit ${OCF_ERR_UNIMPLEMENTED} + ;; esac rc=$? @@ -196,4 +219,3 @@ rc=$? # The resource agent may optionally log a debug message ocf_log debug "${OCF_RESOURCE_INSTANCE} ${__OCF_ACTION} returned $rc" exit $rc - diff --git a/extras/ganesha/ocf/ganesha_mon b/extras/ganesha/ocf/ganesha_mon index f55cf7f2af3..2b4a9d6da84 100644 --- a/extras/ganesha/ocf/ganesha_mon +++ b/extras/ganesha/ocf/ganesha_mon @@ -30,10 +30,10 @@ . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs if [ -n "${OCF_DEBUG_LIBRARY}" ]; then - . ${OCF_DEBUG_LIBRARY} + . ${OCF_DEBUG_LIBRARY} else - : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} -. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} + . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs fi # Defaults @@ -46,7 +46,7 @@ OCF_RESKEY_grace_delay_default="5" : ${OCF_RESKEY_grace_delay=${OCF_RESKEY_grace_delay_default}} ganesha_meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ganesha_mon"> @@ -113,40 +113,60 @@ ganesha_mon_start() { ocf_log debug "ganesha_mon_start" ganesha_mon_monitor - return $OCF_SUCCESS + return $OCF_SUCCESS } ganesha_mon_stop() { ocf_log debug "ganesha_mon_stop" - return $OCF_SUCCESS + return $OCF_SUCCESS } ganesha_mon_monitor() { - local short_host=$(hostname -s) - local pid_file="/var/run/ganesha.nfsd.pid" + local host=$(hostname -s) + local pid_file="/var/run/ganesha.pid" + local rhel6_pid_file="/var/run/ganesha.nfsd.pid" + local proc_pid="/proc/" # RHEL6 /etc/init.d/nfs-ganesha adds -p /var/run/ganesha.nfsd.pid # RHEL7 systemd does not. Would be nice if all distros used the # same pid file. - if [ -e /usr/lib/systemd/system/nfs-ganesha.service ]; then - pid_file="/var/run/ganesha.pid" + if [ -e ${rhel6_pid_file} ]; then + pid_file=${rhel6_pid_file} + fi + if [ -e ${pid_file} ]; then + proc_pid="${proc_pid}$(cat ${pid_file})" fi - if [ -e ${pid_file} -a \ - -d /proc/$(cat ${pid_file} ) ]; then + if [ "x${proc_pid}" != "x/proc/" -a -d ${proc_pid} ]; then attrd_updater -n ${OCF_RESKEY_ganesha_active} -v 1 if [ $? -ne 0 ]; then ocf_log info "warning: attrd_updater -n ${OCF_RESKEY_ganesha_active} -v 1 failed" fi + # ganesha_grace (nfs-grace) RA follows grace-active attr + # w/ constraint location attrd_updater -n ${OCF_RESKEY_grace_active} -v 1 if [ $? -ne 0 ]; then ocf_log info "warning: attrd_updater -n ${OCF_RESKEY_grace_active} -v 1 failed" fi + # ganesha_mon (nfs-mon) and ganesha_grace (nfs-grace) + # track grace-active crm_attr (attr != crm_attr) + # we can't just use the attr as there's no way to query + # its value in RHEL6 pacemaker + + crm_attribute --node=${host} --lifetime=forever --name=${OCF_RESKEY_grace_active} --update=1 2> /dev/null + if [ $? -ne 0 ]; then + host=$(hostname) + crm_attribute --node=${host} --lifetime=forever --name=${OCF_RESKEY_grace_active} --update=1 2> /dev/null + if [ $? -ne 0 ]; then + ocf_log info "mon monitor warning: crm_attribute --node=${host} --lifetime=forever --name=${OCF_RESKEY_grace_active} --update=1 failed" + fi + fi + return ${OCF_SUCCESS} fi @@ -155,8 +175,8 @@ ganesha_mon_monitor() # # Meanwhile the ganesha_grace notify() runs when its # nfs-grace resource is disabled on a node; which - # is triggered by clearing the ganesha-grace node - # attribute on this node. + # is triggered by clearing the grace-active attribute + # on this node. # # We need to allow time for it to run and put # the remaining ganesha.nfsds into grace before @@ -167,6 +187,16 @@ ganesha_mon_monitor() ocf_log info "warning: attrd_updater -D -n ${OCF_RESKEY_grace_active} failed" fi + host=$(hostname -s) + crm_attribute --node=${host} --name=${OCF_RESKEY_grace_active} --update=0 2> /dev/null + if [ $? -ne 0 ]; then + host=$(hostname) + crm_attribute --node=${host} --name=${OCF_RESKEY_grace_active} --update=0 2> /dev/null + if [ $? -ne 0 ]; then + ocf_log info "mon monitor warning: crm_attribute --node=${host} --name=${OCF_RESKEY_grace_active} --update=0 failed" + fi + fi + sleep ${OCF_RESKEY_grace_delay} attrd_updater -D -n ${OCF_RESKEY_ganesha_active} @@ -193,8 +223,8 @@ stop) ganesha_mon_stop status|monitor) ganesha_mon_monitor ;; *) ganesha_mon_usage - exit ${OCF_ERR_UNIMPLEMENTED} - ;; + exit ${OCF_ERR_UNIMPLEMENTED} + ;; esac rc=$? @@ -202,4 +232,3 @@ rc=$? # The resource agent may optionally log a debug message ocf_log debug "${OCF_RESOURCE_INSTANCE} ${__OCF_ACTION} returned $rc" exit $rc - diff --git a/extras/ganesha/ocf/ganesha_nfsd b/extras/ganesha/ocf/ganesha_nfsd index a9d3e4d860f..f91e8b6b8f7 100644 --- a/extras/ganesha/ocf/ganesha_nfsd +++ b/extras/ganesha/ocf/ganesha_nfsd @@ -30,17 +30,17 @@ . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs if [ -n "${OCF_DEBUG_LIBRARY}" ]; then - . ${OCF_DEBUG_LIBRARY} + . ${OCF_DEBUG_LIBRARY} else - : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} -. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} + . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs fi -OCF_RESKEY_ha_vol_mnt_default="/var/run/gluster/shared_storage" +OCF_RESKEY_ha_vol_mnt_default="/run/gluster/shared_storage" : ${OCF_RESKEY_ha_vol_mnt=${OCF_RESKEY_ha_vol_mnt_default}} ganesha_meta_data() { - cat <<END + cat <<END <?xml version="1.0"?> <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> <resource-agent name="ganesha_nfsd"> @@ -156,8 +156,8 @@ stop) ganesha_nfsd_stop status|monitor) ganesha_nfsd_monitor ;; *) ganesha_nfsd_usage - exit ${OCF_ERR_UNIMPLEMENTED} - ;; + exit ${OCF_ERR_UNIMPLEMENTED} + ;; esac rc=$? @@ -165,4 +165,3 @@ rc=$? # The resource agent may optionally log a debug message ocf_log debug "${OCF_RESOURCE_INSTANCE} ${__OCF_ACTION} returned $rc" exit $rc - |
