Conditional statements in workflow, exiting job

3,910 views
Skip to first unread message

Russell Jones

unread,
May 20, 2014, 5:32:01 PM5/20/14
to rundeck...@googlegroups.com
Hi all,

I am evaluating Rundeck, and have faced an issue I am not sure how to resolve.

In my workflow, I need to be able to check if a file exists in a certain folder, and if so, run the file and do "other things" in the next workflow steps. I can do everything in bash scripts just fine within the workflow, but I cannot seem to figure out how to make the job exit in a non-error state if my conditional statement at the beginning fails. If a file doesn't exist in the folder it is checking, and I do an "exit 0" in my first workflow step, as expected Rundeck continues on with the next steps in the workflow. If I do an "exit 1", also as expected it stops the job but places it in an error state.

I need to stop the job, but *not* be in an error state. The job did not really fail out, it just didn't have anything to do at the time it was scheduled to run so I don't need to clutter the dashboard with false failure states.

Any ideas?

Thanks!

Alex Honor

unread,
May 22, 2014, 2:03:30 PM5/22/14
to rundeck...@googlegroups.com
Hi Russel,

You might try using an error-handler step that catches the non-zero exit of the file test. The error handler code can decide to return control back to the job as if it was successful, or fail at that step.
    

Error handlers can be any kind of step. Some people use error handlers to define idempotent style wrappers.

Russell Jones

unread,
May 28, 2014, 11:18:42 AM5/28/14
to rundeck...@googlegroups.com
Thanks Alex!

I tried utilizing an error handler to get it to return a 0 back to the script. It shows "OK" status for that workflow step now, but the job still shows in a "Failed" state. 

What I am doing as a test is having a step end in "exit 1", then the error handler do "exit 0". Clearly this isn't correct to get what I want. Any ideas how to get the error handler to both stop the job at that failed workflow step, but also make the job show as "successful"?

vadyochik

unread,
Aug 25, 2016, 12:06:08 PM8/25/16
to rundeck-discuss
Hi Russell!

set both "Halt" and "Fail" to true (checkbox enabled) and "Status" leave blank in Flow Control error-handler. The job execution then will be successful.
I was trying to find this myself and found it only via source code:


here is descriptions:


So "Fail" sets the exit code if no status message set.

Halt

void Halt(boolean success)
execution halts with success or failure


среда, 28 мая 2014 г., 18:18:42 UTC+3 пользователь Russell Jones написал:

Eugene Sajine

unread,
Aug 25, 2016, 5:51:29 PM8/25/16
to rundeck-discuss

We had the same issue and the best solution we were able to find is to not exit the job that looks for the file unless it found the file or "really failed" to do so. IMHO There are many benefits from this approach. Most of the time one could expect that there is a particular time window in which the file in question should appear. You could schedule the job to start at the beginning of such window and make it poll continuously (sleep 5 min, poll for the file) and then set a timeout on the job in rundeck so that it covers the window. The benefits are: you will see in rundeck that you're "actively" waiting for the file, the job will not produce false negative result if the file didn't appear there yet, all the actual failures of getting the file will be 100% valid to fail the workflow and finally you will know that you didn't receive the file when the job will timeout.

I hope that helps.

Eugene

runde...@gmail.com

unread,
Jun 1, 2018, 2:12:54 PM6/1/18
to rundeck-discuss
Hi vad pravdoroob!!

seeking about this functionality to control execution of each workflow step, I've read this post and I'm so interested in knowing how could I take advantage of the flow-control plugin and use it in rundeck.
thanks in advance for your help. 
Reply all
Reply to author
Forward
0 new messages