
florian.haas at linbit
Aug 10, 2009, 8:48 AM
Post #1 of 1
(413 views)
Permalink
|
|
[PATCH 2 of 2] Medium: RA: VirtualDomain: destroy domain shortly before timeout expiry
|
|
# HG changeset patch # User Florian Haas <florian.haas [at] linbit> # Date 1249915342 -7200 # Node ID 7c7b63f9961d10222b0199450875da88205c2b16 # Parent ed7c50f07c92f30484008f6d8a7ccbd24261b06b Medium: RA: VirtualDomain: destroy domain shortly before timeout expiry As lmb pointed out in private email, the VirtualDomain RA is not as persistent on stop as it should be. This patch employs the following logic: - If force_stop is unset and a stop operation is issued, invoke "virsh shutdown" and loop on monitor for (x-5) seconds, where x is the operation timeout passed received from the CRM. If the domain is still alive by then, kill it with "virsh destroy". - If force_stop is set and a stop operation is issued, invoke "virsh destroy" outright. diff -r ed7c50f07c92 -r 7c7b63f9961d heartbeat/VirtualDomain --- a/heartbeat/VirtualDomain Mon Aug 10 15:45:33 2009 +0200 +++ b/heartbeat/VirtualDomain Mon Aug 10 16:42:22 2009 +0200 @@ -181,19 +181,36 @@ } VirtualDomain_Stop() { + local i + local shutdown_timeout if VirtualDomain_Status ${DOMAIN_NAME}; then case $OCF_RESKEY_force_stop in [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) - op="destroy" ;; *) - op="shutdown" + # Issue a graceful shutdown request + ocf_log info "Issuing graceful shutdown request for domain ${DOMAIN_NAME}." + virsh $VIRSH_OPTIONS shutdown ${DOMAIN_NAME} + # The "shutdown_timeout" we use here is the operation + # timeout specified in the CIB, minus 5 seconds + shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5)) + # Loop on status for $shutdown_timeout seconds + for i in `seq $shutdown_timeout`; do + VirtualDomain_Status || break + sleep 1 + done ;; esac - virsh $VIRSH_OPTIONS $op ${DOMAIN_NAME} - while VirtualDomain_Status; do - sleep 1 - done + # OK. Now if the above graceful shutdown hasn't worked, kill + # off the domain with destroy. If that too does not work, give + # up and have the LRM time us out. + if VirtualDomain_Status; then + ocf_log info "Issuing forced shutdown (destroy) request for domain ${DOMAIN_NAME}." + virsh $VIRSH_OPTIONS destroy ${DOMAIN_NAME} + while VirtualDomain_Status; do + sleep 1 + done + fi return $OCF_SUCCESS else ocf_log info "Domain $DOMAIN_NAME already stopped." _______________________________________________________ Linux-HA-Dev: Linux-HA-Dev [at] lists http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/
|