Raise exception for orchestrateSystem if failed
It was observed that orchestrateSystem function results with
SUCCESS in any case - even though the orchestration step finishes
with failure. As of now result is being analized and exception is
raised if orchestration step fails
Change-Id: If822ab80bb23c4934253b750141b747b3f47788c
Related-PROD: PROD-22046
Related-PROD: PROD-19972
diff --git a/src/com/mirantis/mk/Salt.groovy b/src/com/mirantis/mk/Salt.groovy
index f7724a6..8afceb5 100644
--- a/src/com/mirantis/mk/Salt.groovy
+++ b/src/com/mirantis/mk/Salt.groovy
@@ -692,7 +692,22 @@
//Since the runSaltCommand uses "arg" (singular) for "runner" client this won`t work correctly on old salt 2016
//cause this version of salt used "args" (plural) for "runner" client, see following link for reference:
//https://github.com/saltstack/salt/pull/32938
- return runSaltCommand(saltId, 'runner', target, 'state.orchestrate', true, orchestrate, kwargs, 7200, 7200)
+ def common = new com.mirantis.mk.Common()
+ def result = runSaltCommand(saltId, 'runner', target, 'state.orchestrate', true, orchestrate, kwargs, 7200, 7200)
+ if(result != null){
+ if(result['return']){
+ def retcode = result['return'][0].get('retcode')
+ if (retcode != 0) {
+ throw new Exception("Orchestration state failed while running: "+orchestrate)
+ }else{
+ common.infoMsg("Orchestrate state "+orchestrate+" succeeded")
+ }
+ }else{
+ common.errorMsg("Salt result has no return attribute! Result: ${result}")
+ }
+ }else{
+ common.errorMsg("Cannot check salt result, given result is null")
+ }
}
/**