Make minion restart timeout configurable
This patch makes configurable sleep timeout in waitForMinion function.
minionRestartWaitTimeout parameter is added to waitForMinion and
enforceState with default to 10s, which was hardcoded.
Change-Id: I0662c528b6a1162b607d0f6bc1951d82cc86cb06
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index 0f81287..46f27a6 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -162,9 +162,10 @@
* @param retries Retry count for salt state. (optional, default -1 - no retries)
* @param queue salt queue parameter for state.sls calls (optional, default true) - CANNOT BE USED WITH BATCH
* @param saltArgs additional salt args eq. ["runas=aptly", exclude="opencontrail.database"]
+ * @param minionRestartWaitTimeout specifies timeout that we should wait after minion restart.
* @return output of salt command
*/
-def enforceState(saltId, target, state, output = true, failOnError = true, batch = null, optional = false, read_timeout=-1, retries=-1, queue=true, saltArgs = []) {
+def enforceState(saltId, target, state, output = true, failOnError = true, batch = null, optional = false, read_timeout=-1, retries=-1, queue=true, saltArgs = [], minionRestartWaitTimeout=10) {
def common = new com.mirantis.mk.Common()
// add state to salt args
if (state instanceof String) {
@@ -196,7 +197,7 @@
out = runSaltCommand(saltId, 'local', ['expression': target, 'type': 'compound'], 'state.sls', batch, saltArgs.reverse(), kwargs, -1, read_timeout)
checkResult(out, failOnError, output)
}
- waitForMinion(out)
+ waitForMinion(out, minionRestartWaitTimeout)
return out
} else {
common.infoMsg("No Minions matched the target given, but 'optional' param was set to true - Pipeline continues. ")
@@ -801,7 +802,7 @@
*
* @param result Parsed response of Salt API
*/
-def waitForMinion(result) {
+def waitForMinion(result, minionRestartWaitTimeout=10) {
def common = new com.mirantis.mk.Common()
//In order to prevent multiple sleeps use bool variable to catch restart for any minion.
def isMinionRestarted = false
@@ -843,8 +844,8 @@
}
}
if (isMinionRestarted){
- common.infoMsg("Salt minion service restart detected. Sleep 10 seconds to wait minion restart")
- sleep(10)
+ common.infoMsg("Salt minion service restart detected. Sleep ${minionRestartWaitTimeout} seconds to wait minion restart")
+ sleep(minionRestartWaitTimeout)
}
}