braintree / runbook

A framework for gradual system automation
MIT License
730 stars 43 forks source link

Dealing with errors #30

Closed pitosalas closed 4 years ago

pitosalas commented 4 years ago

What if the command fails?

Exception while executing as rails@174.138.58.21: git exit status: 128 (SSHKit::Runner::ExecuteError)
git stdout: Nothing written
git stderr: fatal: destination path 'soa_demo' already exists and is not an empty directory. 

What's the recommended way to handle this situation?

pblesi commented 4 years ago

Typically if an error occurs while executing a command it is an unexpected state and it is safest to exit the runbook and have a manual operator assess the situation. If it is expected that a command can fail and it should not be a critical error that halts the runbook, you can append || true to the command and this will prevent the command from returning a fatal error (non-zero status code).

In some cases you may want to use the assert statement to test for a specific state multiple times if you expect that will not return a failure after some period of time or number of tries.

pitosalas commented 4 years ago

Thanks