kudulab/dojo

Dump logs before cleaning docker-compose containers

tomzo opened this issue · 2 comments

tomzo commented

Here is a very common scenario when dojo with docker-compose driver is used:

Multiple server-like containers are linked together to setup a minimal infrastructure from the containers. The default container is used to execute tests against one or more linked containers. These tests often fail, either because one of the containers has died before tests could finish or there were some errors in the servers. The reasons for those failures are in the logs of the server-like containers. But the user cannot access these logs, because Dojo removes the containers immediately after non-zero exit status or as part of watching for failing containers.

As a user executing Dojo on a CI agent, I'd like to get a dump of logs from all containers when a there was a failure.


My idea of how to implement this:

Add option -print-logs <when> where when can be always|failure|never. This would be valid only for docker-compose driver. By default it would be failure.

Just before the containers are removed, dojo would print logs of each container to stderr by running docker logs <container-id> and redirecting it to stderr.

So the output from dojo "command" would look like this now:

Dojo init output [...]
command output [...]
Dojo info about the exit status and what's about to be printed and done [...]
Here are logs of container ABC, which is still running:
[...]
Here are logs of container XYZ, which has exited with status 7:
[...]
Dojo logs about cleaning up the containers [...]

So, above each of the logs there would be information about if the container is still running and if not then what exit status it had when stopped.

xmik commented

OK, I will definitely implement it. I'd like to treat your idea as the bare minimum and additionally, I'd like to add the possibility to save those logs to a file.

xmik commented

Implemented in 2 PRs:

Released as Dojo 0.8.0.