Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c9b... Commit: c9bbf4f12402c5e38e51e21d38682712c18ab5ee Parent: 3153871877e05f94570c444b17761b0027f36241 Author: Lon Hohberger lhh@redhat.com AuthorDate: Mon Jun 21 12:22:23 2010 -0400 Committer: Lon Hohberger lhh@redhat.com CommitterDate: Tue Jun 22 08:24:39 2010 -0400
resource-agents: Make vm.sh use stop/start timeouts
Startup timeouts are handled by calling the status_program (if specified) every few seconds until either the timeout is reached or the status program returns a successful result.
Because the combined VM boot + application time was the basis for the 5 minute check interval for depth=10 (where the status_program is called), it has been reduced to 1 minute intervals.
The startup timeout, since it may now be waiting for services within the VM, has been increased to 5 minutes from 20 seconds to match the previous status check timing functionality.
Resolves: bz606754
Signed-off-by: Lon Hohberger lhh@redhat.com --- rgmanager/src/resources/vm.sh | 65 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh index 08fd097..dee7564 100644 --- a/rgmanager/src/resources/vm.sh +++ b/rgmanager/src/resources/vm.sh @@ -261,15 +261,15 @@ meta_data() </parameters>
<actions> - <action name="start" timeout="20"/> + <action name="start" timeout="300"/> <action name="stop" timeout="120"/> <action name="status" timeout="10" interval="30"/> <action name="monitor" timeout="10" interval="30"/>
<!-- depth 10 calls the status_program --> - <action name="status" depth="10" timeout="10" interval="300"/> - <action name="monitor" depth="10" timeout="10" interval="300"/> + <action name="status" depth="10" timeout="20" interval="60"/> + <action name="monitor" depth="10" timeout="20" interval="60"/>
<!-- reconfigure - reconfigure with new OCF parameters. NOT OCF COMPATIBLE AT ALL --> @@ -351,6 +351,31 @@ do_xm_start() }
+get_timeout() +{ + declare -i default_timeout=60 + declare -i tout + + if [ -n "$OCF_RESKEY_RGMANAGER_meta_timeout" ]; then + tout=$OCF_RESKEY_RGMANAGER_meta_timeout + elif [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then + tout=$OCF_RESKEY_CRM_meta_timeout + fi + + if [ "$tout" -eq "0" ]; then + echo $default_timeout + return 0 + fi + if [ $tout -lt 0 ]; then + echo $default_timeout + return 0 + fi + + echo $tout + return 0 +} + + # # Start a virtual machine given the parameters from # the environment. @@ -428,7 +453,7 @@ do_xm_stop() # do_virsh_stop() { - declare -i timeout=60 + declare -i timeout=$(get_timeout) declare -i ret=1 declare state
@@ -443,7 +468,7 @@ do_virsh_stop() echo virsh $op $OCF_RESKEY_name ... virsh $op $OCF_RESKEY_name
- timeout=60 + timeout=$(get_timeout) while [ $timeout -gt 0 ]; do sleep 5 ((timeout -= 5)) @@ -913,6 +938,30 @@ migrate() return $rv }
+ +wait_start() +{ + declare -i timeout_remaining=$(get_timeout) + + if [ -z "$OCF_RESKEY_status_program" ]; then + return 0 + fi + + while [ $timeout_remaining -gt 0 ]; do + bash -c "$OCF_RESKEY_status_program" &> /dev/null + if [ $? -eq 0 ]; then + return 0 + fi + sleep 5 + ((timeout_remaining -= 5)) + done + + ocf_log err "Start of $OCF_RESOURCE_INSTANCE has failed" + ocf_log err "Timeout exceeded while waiting for "$OCF_RESKEY_status_program"" + + return 1 +} + # # # @@ -921,6 +970,12 @@ case $1 in start) validate_all || exit $OCF_ERR_ARGS do_start + rv=$? + if [ $rv -ne 0 ]; then + exit $rv + fi + + wait_start exit $? ;; stop)