celery / kombu

Messaging library for Python.
http://kombu.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
2.81k stars 920 forks source link

New tox-docker >= 5.0.0 fails docker depending tests results in connectionRefused errors #2015

Closed FrankK-1234 closed 1 month ago

FrankK-1234 commented 1 month ago

HI all,

I was testing using tox and somehow docker related test failed with a connectionRefused. After some investigation I figured it was because of the port assignments. They looked like this:

$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c51939bd3f05 01887177def0 "docker-entrypoint.s…" 29 seconds ago Up 28 seconds (healthy) 0.0.0.0:32784->4369/tcp, :::32784->4369/tcp, 0.0.0.0:32783->5671/tcp, :::32783->5671/tcp, 0.0.0.0:32782->5672/tcp, :::32782->5672/tcp, 0.0.0.0:32781->15691/tcp, :::32781->15691/tcp, 0.0.0.0:32780->15692/tcp, :::32780->15692/tcp, 0.0.0.0:32779->25672/tcp, :::32779->25672/tcp rabbitmq-tox-88338

But they should look like this, basically port 5672 could was not mapped and could not be reached: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6b5aed859997 01887177def0 "docker-entrypoint.s…" 5 seconds ago Up 4 seconds (health: starting) 4369/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp rabbitmq-tox-113404

The issue seems to be related with a none backwards compatible change in tox-docker release > 5.0.0 (released recently on 25-05-2024) . The support of ports parameter in the docker section of tox.ini has been removed. See release history and upgrade/changelog. This mentions the removal of the ports command and suggest that the ability to map is removed. See following snapshot

Upgrading

Some configuration options were removed:

New in 5.0:

ports

This directive was removed in tox-docker version 5.0. Use expose instead. The ability to map a container port to a specific host port was completely removed.

Change Log

5.0.0

  • Remove support for tox 3
  • Removed support for Python 3.7 and earlier
  • Remove ports; add expose and host_var
  • Support docker (the Python module) 7.x

The workaround which worked for me was to llimit the installed tox-docker version within tox.ini as follows: requires = tox-docker>=3.0,tox-docker<5.0 The above installed tox-docker 4.1.0 which worked again.

I'm not sure how to use the new expose and environment variable within tox and testscripts, it seems like they basically have to connect a random (stored in env) port rather than a fixed port now. I might be missing somehting here? It is not clear to me why this fixed port assignement was removed.

Any thoughts on this? Perhaps sticking to the old version is the cheapest approach.

Regards,

Frank

FrankK-1234 commented 1 month ago

I see some of the latest pull request with failing the integration tests. To me it looks like that those failures are related to this issue.

Nusnus commented 1 month ago

Hey @FrankK-1234 , thank you for reporting. This is a known issue at the moment that is caused due to this bug: https://github.com/docker/docker-py/issues/3256

Unfortunately the best outcome we have right now is to limit upgrading to the buggy versions until additional packages upgrades accordingly.

Edit: The limit was applied here: https://github.com/celery/kombu/pull/2011

FrankK-1234 commented 1 month ago

Hey @Nusnus thanks for your response. Are you sure this is the same issue? The tox-docker change (>=5.0.0) clearly states the ports is not supported anymore. The output seen in recent pull request (fails on integration with docker use) show the same error i investigated. Reverting to tox-docker prior to 5.0.0 resolved my test cases. I did not had to mingle with requests nor docker. I suppose the connectionRefused error is caused by the fact the docker does not listen anymore on the fixed mapped port. Perhaps there are multiple isues causing problems. Could you have a second look?

Thanx in advance, Regards,

Frank Re

FrankK-1234 commented 1 month ago

I see the tox-docker is now limited to <=4.1 (by #2011) which will indeed solve the issue. Closing this issue.