fix: linked/depends-on container restarting #1103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Restarting of dependency containers has been something that has seemed broken in watchtower for some time, but there hasn't been any easy way to reproduce/verify it.
So, the first part of this PR is an e2e test that actually tests whether the "implicit restarts" actually work:
https://asciinema.org/a/444312 (spoiler: they don't)
Unfortunately, I don't think running this test in CI is viable (or even possible), but for now it serves it's purpose and can be run locally when needed.
The second part is actually fixing the problem (mutating the actual array struct instead of a copy):
https://asciinema.org/a/444307
The test script creates two images which run a small webserver that only returns the image version number, and pushes them to a local docker registry (which can be created using
scripts/du-cli.sh registry start
). Then it creates two containers, with one of them being dependent on the other (through depends-on label or--linked
) using their corresponding images.Next, it creates another revision of the "parent" containers image and pushes it to the local registry and runs watchtower.
After watchtower has ran, it queries the two containers to see if the start time has changed (meaning that the container was at least restarted), and if the version number returned from the service inside the containers have changed (meaning that the container was updated).
Test script usage:
This will run watchtower by building it from the source. To instead run a released image in docker, set the environment variable
WATCHTOWER_TAG
tolatest
orlatest-dev
.Example:
The first argument is whether the containers should be linked using
--link
or--label
. All other arguments will be passed to the watchtower executable/container.