detect image changes and recreate affected containers#1484
Conversation
916f40f to
a177c77
Compare
| self.run_subprocess_assert_returncode([ | ||
| "podman", | ||
| "pull", | ||
| "docker.io/library/alpine:latest", |
There was a problem hiding this comment.
Better create nopush/podman-compose-test2. Each pull uses docker free user quota. When running tests many times it's possible to exhaust it.
There was a problem hiding this comment.
@p12tic: I added another nopush image to the tests, next to the current one, did you want it like this, or as part of the unittest itself?
p12tic
left a comment
There was a problem hiding this comment.
Thanks. Several small nitpicks, but otherwise looks good.
| @@ -0,0 +1 @@ | |||
| FROM busybox:latest | |||
There was a problem hiding this comment.
Would FROM nopush/podman-compose-test work here?
| @@ -0,0 +1,7 @@ | |||
| FROM docker.io/library/debian:bookworm-slim | |||
There was a problem hiding this comment.
Would FROM nopush/podman-compose-test work here?
|
|
||
| # modify the Dockerfile to produce a different image | ||
| with open(dockerfile, "w") as f: | ||
| f.write("FROM busybox:latest\nRUN touch /marker\n") |
There was a problem hiding this comment.
FROM nopush/podman-compose-test
|
|
||
| finally: | ||
| # restore original Dockerfile | ||
| with open(dockerfile, "w") as f: |
There was a problem hiding this comment.
I would rather not change files committed to repository, because in this case the source of truth for the file is original_content variable, not what's committed to repository.
Better create the file at the beginning of the test, change however you want and then remove at the end.
p12tic
left a comment
There was a problem hiding this comment.
Looks good overall, thank you very much and sorry for delayed review. I had only nitpicks regarding test images, otherwise everything is good.
|
I've updated to code according to your suggestions, or at least how I understood them, if still goes in a wrong direction can you please elaborate? |
podman-compose up currently only compares the YAML config hash to decide whether a container needs to be recreated. This misses the case where an image has been updated (e.g. after a pull) while the compose file itself stays the same — the container keeps running the old image. Add an image_id field to ExistingContainer, populated from the ImageID returned by podman ps. Before the recreation loop, resolve the current local image ID for each service via podman inspect and compare it against the running container's image ID. When they differ, mark the service for recreation. Fixes: containers#1453, containers#466 Signed-off-by: Alexander Dreweke <alexander@dreweke.net>
bca11ab to
c17268b
Compare
podman-compose up currently only compares the YAML config hash to decide whether a container needs to be recreated. This misses the case where an image has been updated (e.g. after a pull) while the compose file itself stays the same — the container keeps running the old image.
Add an image_id field to ExistingContainer, populated from the ImageID returned by podman ps. Before the recreation loop, resolve the current local image ID for each service via podman inspect and compare it against the running container's image ID. When they differ, mark the service for recreation.
Fixes: #1453, #466