fix timeout for aws create stack
Change-Id: If845644f67c9d6c7256c257c5d52b5b331a853bd
diff --git a/src/com/mirantis/mk/Aws.groovy b/src/com/mirantis/mk/Aws.groovy
index c6d73a7..d19a493 100644
--- a/src/com/mirantis/mk/Aws.groovy
+++ b/src/com/mirantis/mk/Aws.groovy
@@ -69,29 +69,22 @@
def common = new com.mirantis.mk.Common()
def python = new com.mirantis.mk.Python()
- timeout = timeout * 1000
- Date date = new Date()
- def time_start = date.getTime() // in seconds
+ timeout(time: timeout, unit: 'SECONDS') {
+ withEnv(env_vars) {
+ while (true) {
+ // get stack state
+ def stack_info = aws.describeStack(venv_path, env_vars, stack_name)
+ common.infoMsg('Stack status is ' + stack_info['StackStatus'])
- withEnv(env_vars) {
- while (true) {
- // get stack state
- def stack_info = aws.describeStack(venv_path, env_vars, stack_name)
- common.infoMsg('Stack status is ' + stack_info['StackStatus'])
+ if (stack_info['StackStatus'] == state) {
+ common.successMsg("Stack ${stack_name} in in state ${state}")
+ common.prettyPrint(stack_info)
+ break
+ }
- if (stack_info['StackStatus'] == state) {
- common.successMsg("Stack ${stack_name} in in state ${state}")
- common.prettyPrint(stack_info)
- break
+ // wait for next loop
+ sleep(loop_sleep)
}
-
- // check for timeout
- if (time_start + timeout < date.getTime()) {
- throw new Exception("Timeout while waiting for state ${state} for stack ${stack}")
- }
-
- // wait for next loop
- sleep(loop_sleep)
}
}
}