Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize error message when docker compose version returns not supported version format #825

Closed
koutoftimer opened this issue Mar 27, 2024 · 7 comments · Fixed by #826
Closed
Labels
docker-compose-v2 Docker Compose v2

Comments

@koutoftimer
Copy link

koutoftimer commented Mar 27, 2024

Issue

Currently (2024-03-27) Arch repo contains version of docker compose which reports its version as "dev" instead of something like "2.26.0", which causes

$ pacman -Q docker-compose
docker-compose 2.26.0-1
$ docker compose version
Docker Compose version dev
Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 47, in invoke_module
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 638, in <module>
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 631, in main
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose_v2.py", line 419, in __init__
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible_collections/community/docker/plugins/module_utils/compose_v2.py", line 521, in __init__
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible/module_utils/compat/version.py", line 60, in __lt__
  File "/tmp/ansible_community.docker.docker_compose_v2_payload_9tu8jd7j/ansible_community.docker.docker_compose_v2_payload.zip/ansible/module_utils/compat/version.py", line 338, in _cmp
TypeError: '<' not supported between instances of 'str' and 'int'

when using module

- name: Tear down existing services
  community.docker.docker_compose_v2:
    project_src: "{{ project_src }}"
    project_name: accounts
    state: absent

Affected version:

$ ansible-galaxy collection install community.docker:3.8.1

Feature

Respond with proper error message.

@felixfontein felixfontein added the docker-compose-v2 Docker Compose v2 label Mar 27, 2024
@felixfontein
Copy link
Collaborator

This looks like a packaging error in Arch. You should report it as a bug to Arch and stick to an earlier version of Docker Compose until it gets fixed.

We need the correct version to determine the behavior of the module.

@koutoftimer
Copy link
Author

@felixfontein this is why it is feature request, not bug fix.

@iamwacko
Copy link

This looks like a packaging error in Arch. You should report it as a bug to Arch and stick to an earlier version of Docker Compose until it gets fixed.

We need the correct version to determine the behavior of the module.

https://gitlab.archlinux.org/archlinux/packaging/packages/docker-compose/-/issues/1

The issue is now reported to Arch

@felixfontein
Copy link
Collaborator

Thanks for reporting it! (I also can confirm that the previous Compose release on Arch did output the version correctly, it's only the latest one that outputs dev instead.)

@iamwacko
Copy link

Christian Heusel fixed the Arch error.

Might still be a good idea to have a specific error for version weirdness.

@felixfontein
Copy link
Collaborator

dev is the default string that's used when the version isn't set: https://github.com/docker/compose/blob/main/internal/variables.go#L21. Self-built versions using the build process in the project's Makefile usually have versions like v2.26.0-5-g6fe69b25, but the Arch build isn't using that build mechanism (for other reasons).

@felixfontein
Copy link
Collaborator

#826 improves the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-compose-v2 Docker Compose v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants