docker_compose: Fix idempotence#1054
Closed
sboyd-m wants to merge 1 commit into
Closed
Conversation
When the module checks for running containers, it runs something like
the following:
```
/usr/bin/docker ps --format '{{.Label "com.docker.compose.service"}}-{{.Image}}' --filter label=com.docker.compose.project=name_of_resource
```
The output of which appears similar to as follows:
```
web-name_of_resource-web
celery-name_of_resource-celery
celery-beat-name_of_resource-celery-beat
flower-mher/flower:2.0
postgres-postgres:15-alpine
redis-redis:7-alpine
```
However, when getting the *expected* name of the image to check, the
module hardcodes an underscore, resulting in things like
`web-name_of_resource_web`.
When the counting is done to check for existence, this does not match,
so nothing is found, so the module tries to recreate the whole
composition.
Contributor
|
Duplicate of #990. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When the module checks for running containers, it runs something like the following:
The output of which appears similar to as follows:
However, when getting the expected name of the image to check, the module hardcodes an underscore, resulting in things like
web-name_of_resource_web.When the counting is done to check for existence, this does not match, so nothing is found, so the module tries to recreate the whole composition.
Root cause
The root cause is simply a change on Docker's side. On Ubuntu 24.04, when installing from Canonical's packages, Docker compose is v1.29 and the separator is an underscore. If you install with the this module, you get much newer versions, and the separator is a hyphen.
Checklist
puppet apply)Reproduce:
On any Ubuntu (I tested on 18.04, 20.04, 22.04, 24.04):
Dockerfile:
app.py:
compose.yaml:
test.pp
puppet module install puppetlabs-docker --version 10.4.0puppet apply test.ppsed -i.bak 's,image = "#{name}_#{service_name}",image = "#{name}-#{service_name}",' /etc/puppetlabs/code/environments/production/modules/docker/lib/puppet/provider/docker_compose/ruby.rb