NonZeroResultCode: Remote command failed with exit status 3

3,127 views
Skip to first unread message

PiCo

unread,
Oct 26, 2017, 11:26:33 AM10/26/17
to rundeck-discuss

I'm trying to execute a remote command via SSH on Linux machine.
This command is used to control SAP instance and is called "sapcontrol".
sapcontrol, normally have 5 possible exit state (0, 1, 2, 3, 4):

EXITCODES
0 Last webmethod call successful
1 Last webmethod call failed, invalid parameter
2 StartWait, StopWait, WaitforStarted, WaitforStopped, RestartServiceWait
timed out
3 GetProcessList succeeded, all processes running correctly
4 GetProcessList succeeded, all processes stopped

In this case if I run the command from the remote host, I have exit code 0, but if I run the same command from rundeck console I have the right output, followed by an error message:

Remote command failed with exit status 3
--
23:09:31 |   | Failed: NonZeroResultCode: Remote command failed with exit status 3
23:09:31 | localhost | Execution failed: 47 in project MYPROJECTNAME: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [myhostname: NonZeroResultCode: Remote command failed with exit status 3 + {dataContext=MultiDataContextImpl(map={ContextView(node:myhostname)=BaseDataContext{{exec={exitCode=3}}}, ContextView(step:1, node:myhostname)=BaseDataContext{{exec={exitCode=3}}}}, base=null)} ]}, Node failures: {myhostname=[NonZeroResultCode: Remote command failed with exit status 3 + {dataContext=MultiDataContextImpl(map={ContextView(node:myhostname)=BaseDataContext{{exec={exitCode=3}}}, ContextView(step:1, node:myhostname)=BaseDataContext{{exec={exitCode=3}}}}, base=null)} ]}, status: failed]


The error "Failed: NonZeroResultCode: Result code was 3" is due to the return code of the OS command I'm running that is != 0.


Any Idea ?

Alex Honor

unread,
Oct 26, 2017, 11:47:48 AM10/26/17
to rundeck...@googlegroups.com
Hi Pico,

You can approach this problem in one of two ways: 

1) Use an error-handler around that step (eg, use a script step) to evaluate the context variable result.resultCode. For example, the error-handler script might be this: 
[[ "@result.resultCode@" == 3 ]] && exit 0. 
You would also configure the error handler to continue upon success. 

2) The other approach is to catch and evaluate the exit code in your own command. For example, the command string might be instead
sapcontrol || { [[ $? == 3 ]] && exit 0 }

Thanks

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/00e569d2-ad5f-4f1e-b15c-f2f189053641%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Reply all
Reply to author
Forward
0 new messages