Don't hide Traefik errors

When stopping or starting Traefik, don't hide important errors.

Docker doesn't return an error when starting a started container or
stopping a stopped container.

When rebooting we want to know about errors during run as we've just
stopped and removed the previous container.

When booting, we want to leave the running container if it exists,
restart a stopped container and run a new one if none exists.

We can implement this with `docker start ... || docker run ...`:
- if the container is started, `docker start` will exit with 0
- if the container is stopped, `docker start` will start it and exit with 0
- if the container doesn't exist, `docker start` will return a non zero
exit code and `docker run` will create a new container. Any errors in
`docker run` will be returned.
This commit is contained in:
Donal McBreen
2023-08-08 15:16:02 +01:00
parent aa89ededde
commit c2d7fd775f
3 changed files with 24 additions and 6 deletions

View File

@@ -1,7 +1,21 @@
require_relative "integration_test"
class TraefikTest < IntegrationTest
test "boot, stop, start, restart, logs, remove" do
test "boot, reboot, stop, start, restart, logs, remove" do
mrsk :traefik, :boot
assert_traefik_running
mrsk :traefik, :reboot
assert_traefik_running
mrsk :traefik, :boot
assert_traefik_running
# Check booting when booted doesn't raise an error
mrsk :traefik, :stop
assert_traefik_not_running
# Check booting when stopped works
mrsk :traefik, :boot
assert_traefik_running