Package: cluster-agents
Version: 1:1.0.2+hg1712-1~bpo50+1
Severity: normal
Tags: patch

ManageVE does not force a stop.  Patch attached (note - hard-coded VZ
location would break on other distros where openvz is in non-lsb location).

Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-openvz-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- ManageVE    2010-04-02 21:11:42.000000000 +0100
+++ /usr/lib/ocf/resource.d/heartbeat/ManageVE  2010-04-05 15:51:59.000000000 
+0100
@@ -149,15 +149,46 @@
 #
 stop_ve()
 {
-  declare -i retcode
-
-  $VZCTL stop $VEID >& /dev/null
-  retcode=$?
-
-  if [[ $retcode != 0 ]]; then
-    ocf_log err "vzctl stop $VEID returned: $retcode"
-    return $OCF_ERR_GENERIC
+  if status_ve; then
+    declare -i retcode
+    declare -i timeout
+    if [ -n "$OCF_RESKEY_shutdown_timeout" ]; then
+      timeout=$OCF_RESKEY_shutdown_timeout
+    elif [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
+      # Allow 2/3 of the action timeout for the orderly shutdown
+      # (The origin unit is ms, hence the conversion)
+      timeout=$((OCF_RESKEY_CRM_meta_timeout/1500))
+    else
+      timeout=60
+    fi
+
+    if [ "$timeout" -gt 0 ]; then
+      ocf_log info "OpenVZ VE $VEID will be stopped (timeout: ${timeout}s)"
+      $VZCTL stop $VEID >& /dev/null &
+      while status_ve && [ "$timeout" -gt 0 ]; do
+       ocf_log debug "${DOMAIN_NAME} still not stopped. Waiting..."
+       timeout=$((timeout-1))
+       sleep 1
+      done
+    fi
+
+    if [ "$timeout" -eq 0 ]; then
+      ocf_log warn "Orderly shutdown of OpenVZ VE ${VEID} failed. Sending 
processes SIGKILL..."
+      ( lsof -t /var/lib/vz/root/${VEID} | xargs vzpid | egrep -o 
"^[[:digit:]]+[[:space:]]+${VEID}" | egrep -o "^[[:digit:]]+" | xargs kill 
-KILL )2>/dev/null
+      while status_ve ; do
+       ocf_log debug "OpenVZ VEID ${VEID} still not stopped. Waiting..."
+       sleep 1
+      done
+      # Note: This does not give up. stop isn't allowed to to fail.
+      # If vzctl stop fails, stop will eventually timeout.
+      # This is the correct behaviour.
+    fi
+
+    ocf_log info "OpenVZ VEID ${VEID} stopped."
+  else
+    ocf_log info "OpenVZ VEID ${VEID} already stopped."
   fi
+  $VZCTL umount $VEID >& /dev/null &
 
   return $OCF_SUCCESS
 }

Reply via email to