ansible-community / molecule-plugins

Collection on molecule plugins
MIT License
101 stars 67 forks source link

Docker: doesn't work with requests-2.32.1 #256

Open ollie1 opened 1 month ago

ollie1 commented 1 month ago

A new version of the requests library has been released on pypi - https://pypi.org/project/requests/2.32.1/ . This seems incompatible with the docker molecule plugin. When trying to run molecule converge on a project using the docker plugin, I get a message as follows:

INFO     Sanity checks: 'docker'
CRITICAL Unable to contact the Docker daemon. Please refer to https://docs.docker.com/config/daemon/ for managing the daemon

Downgrading to a version of the requests library <2.32 resolves the issue and molecule works as normal:

python -m pip install 'requests<2.32'

Output of molecule --version

molecule 6.0.3 using python 3.9 
    ansible:2.15.12
    azure:23.5.3 from molecule_plugins
    containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:6.0.3 from molecule
    docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    ec2:23.5.3 from molecule_plugins
    gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.3 from molecule_plugins
guidograzioli commented 1 month ago

Same here with:

molecule 24.2.0 using python 3.11 
    ansible:2.17.0
    azure:23.5.3 from molecule_plugins
    containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:24.2.0 from molecule
    docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    ec2:23.5.3 from molecule_plugins
    gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.3 from molecule_plugins
konstruktoid commented 1 month ago

Related:

https://github.com/ansible-collections/community.docker/issues/860

https://github.com/docker/docker-py/issues/3256

felixfontein commented 1 month ago

Please make sure to install community.docker 3.10.2 or newer (right now that's the latest version). It contains a fix for this issue.

mcdonnnj commented 1 month ago

Please make sure to install community.docker 3.10.2 or newer (right now that's the latest version). It contains a fix for this issue.

I believe https://github.com/ansible-community/molecule-plugins/blob/b48ead5d12d80eb90ead14f1958d0e9ef79b8752/src/molecule_plugins/docker/driver.py#L270-L273 is still a problem however.

felixfontein commented 1 month ago

Ouch, yes, if it forces community.docker to 3.4.11, then well, you're totally out of luck. Then you need to stick to requests < 2.32.0.

jcox10 commented 4 weeks ago

Installing the community.docker collection at 3.10.2 manually before running molecule seems to work around the issue. Molecule doesn't force downgrade thankfully.

MaxBidlingmaier commented 3 weeks ago

manually updating community.docker did not fix it for me, had to downgrade requests to 2.30.0 (2.31.0 did not work either) So working config for me: pip:

Also tried: pip:

After updating above config to requests 2.32.0 issue reoccured

felixfontein commented 3 weeks ago

@MaxBidlingmaier which parts of community.docker are you using (and which aren't working for you)? If you are using the Swarm modules, you must upgrade Docker SDK for Python as well.

Also I have never heard of problems with requests 2.31.0 so far. What are the exact problems you have with it?

(Also note that requests 2.32.0 has been yanked from PyPI. You should either use a version before that, or after that.)

MaxBidlingmaier commented 3 weeks ago

@felixfontein : Just "normal" docker part (no swarm), see my molecule.yml below

 ---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: "sles15sp4"
    image: somerepo:mytag
    pre_build_image: true
    tmpfs:
      - /run
      - /tmp
    volumes:
      - '/sys/fs/cgroup:/sys/fs/cgroup:ro'
    command: ""
    # NET_* capabilities required for iptables + ipset stuff
    capabilities:
      - SYS_ADMIN
      - NET_ADMIN
      - NET_RAW
provisioner:
  name: ansibl
verifier:
  name: ansible