This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 5b2c5aa31093a58c3c41155b07c86b78d339454d Author: Alex Heneveld <[email protected]> AuthorDate: Thu Oct 20 17:41:49 2022 +0100 ensure ssh workflow step fails if non-zero exit code --- .../org/apache/brooklyn/core/workflow/steps/SshWorkflowStep.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/SshWorkflowStep.java b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/SshWorkflowStep.java index 8db28cbd51..ba03791962 100644 --- a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/SshWorkflowStep.java +++ b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/SshWorkflowStep.java @@ -86,7 +86,11 @@ public class SshWorkflowStep extends WorkflowStepDefinition { } protected static void checkExitCode(ProcessTaskWrapper<?> ptw, DslPredicates.DslPredicate<Integer> exitcode) { - if (exitcode==null) return; + if (exitcode==null) { + if (ptw.getExitCode()!=0) throw new IllegalStateException("Invalid exit code '"+ptw.getExitCode()+"'"); + return; + } + if (exitcode instanceof DslPredicates.DslPredicateBase) { Object implicit = ((DslPredicates.DslPredicateBase) exitcode).implicitEquals; if (implicit!=null) { @@ -99,7 +103,7 @@ public class SshWorkflowStep extends WorkflowStepDefinition { // ranges still require `exit-code: { range: [0, 4] }`, same with `exit-code: { less-than: 5 }`. } if (!exitcode.apply(ptw.getExitCode())) { - throw new IllegalStateException("Invalid exit code '"+ptw.getExitCode()+"'"); + throw new IllegalStateException("Invalid exit code '"+ptw.getExitCode()+"'; does not match explicit exit-code requirement"); } }
