inveniosoftware / invenio-cli

CLI module for Invenio
https://invenio-cli.readthedocs.io
MIT License
10 stars 43 forks source link

docker helper: version not being obtained #359

Open dfdan opened 1 year ago

dfdan commented 1 year ago

Package version (if known): 1.1.0

Describe the bug

With docker 20.10 / docker-compose 1.25.0 (ubuntu 20.04) the docker helper is trying to run 'docker compose' but this command isn't available. It should still be docker-compose in this case.

This causes docker not to be able to start services etc when the helper fails here: https://github.com/inveniosoftware/invenio-cli/blob/40573024e8ad81430afdda8fc8ceb2acbd55d7d2/invenio_cli/helpers/docker_helper.py#L41

Steps to Reproduce

Bootstrap instance with Docker 20.10 (as packaged in Ubuntu 20.04), bootstrap an instance of ~12 and try to start services.

Expected behavior

services should start

Screenshots (if applicable)

(rdm12a) dan@id23:~/test2/rdm12a$ invenio-cli services setup
Traceback (most recent call last):
  File "/home/dan/.venv/rdm12a/bin/invenio-cli", line 33, in <module>
    sys.exit(load_entry_point('invenio-cli', 'console_scripts', 'invenio-cli')())
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/dan/.venv/rdm12a/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/dan/test2/invenio-cli/invenio_cli/cli/services.py", line 65, in setup
    commands = ServicesCommands(cli_config)
  File "/home/dan/test2/invenio-cli/invenio_cli/commands/services.py", line 29, in __init__
    self.docker_helper = docker_helper or DockerHelper(
  File "/home/dan/test2/invenio-cli/invenio_cli/helpers/docker_helper.py", line 29, in __init__
    self.container_prefix = self._normalize_name(project_shortname)
  File "/home/dan/test2/invenio-cli/invenio_cli/helpers/docker_helper.py", line 41, in _normalize_name
    dc_version = groups.group(0)
AttributeError: 'NoneType' object has no attribute 'group'

Additional context

chriz-uniba commented 1 year ago

I can confirm for debian - we had the same issue, which forced me to upgrade to a newer docker version. When checking the system-requirements with invenio-cli they failed due to docker.

In case that this is wanted behaviour due to end of life of the old docker version: we might want to adjust the documentation: https://inveniordm.docs.cern.ch/install/requirements/

ptamarit commented 11 months ago

EDIT: There are in fact two problems: the first one (described below) is related with obtaining the version of Docker. The second one is about obtaining the version of Docker Compose failing on environments where the command is docker-compose instead of docker compose (what is described above).

I am using Docker 20.10.22 (the minimum required Docker version for InvenioRDM is 20.10.10+ according to the documentation), and I am facing the same problem .

This is due to the fact that the command used in the requirements.py does return json instead of the expected version with Docker 20:

$ docker version --format json
json

The official Docker documentation mentions the value 'json' for the --format option , but later on an example shows the syntax docker version --format '{{json .}} to output JSON and this syntax works with Docker 20.

However, the best solution in our case which works will all versions would be to follow the examples on how to extract specific information, which is a much simpler since it does not require any JSON parsing:

$ docker version --format '{{.Client.Version}}'
20.10.22

I can create a pull request with this change if you want.

dfdan commented 11 months ago

@ptamarit Thanks for looking into this. We love PR's...

RoHei commented 6 months ago

Hi all, is there anything new on this issue? Currently users are running into this, see: https://invenio-talk.web.cern.ch/t/installation-error-of-invenio-rdm-in-local-machine-please-solve/351.

In my case, I ran into the second error mentioned by @ptamarit. So I just changed the code in docker_helper.py locally from: self.docker_compose = ["docker", "compose"] to: self.docker_compose = ["docker-compose"]

But this is clearly not a good workaround for all systems.