ruphin / mech

An open container orchestration framework
MIT License
2 stars 0 forks source link

Check for failures and don't swallow stdout when shelling out to commands #2

Open FooBarWidget opened 9 years ago

FooBarWidget commented 9 years ago

You shell out to commands in many places in the codebase. For example in carbon-writer-manager/carbon_writer.rb:

`docker pull #{IMAGE}`

Or in rabbitmq-manager/rabbitmq.rb:

`docker exec -it #{TASK}-#{Mech::ID}-worker gosu rabbitmq rabbitmqctl stop`

Statements like these ignore command failures. You should check for errors and handle them appropriately.

Another problem is that these statements swallow stdout. You never do anything with stdout, which may contain relevant information. If you're not doing anything with them, you should at least let them pass thru.

I think that for your purposes, it is better to use system(). That function lets stdout and stderr pass thru. It returns true if the command succeeds (exit status 0), false if the command fails (exit status non-zero).