#413 use python-docker instead of python-docker-py
Closed: Fixed Opened by ttomecek.

I opened this page: https://fedoraproject.org/wiki/CI/Tests/stat

I was quite shocked, that python-docker-py is on the list. We have renamed the package to python-docker after the big API changes happened in version 2. Right now I'm trying to get rid of python-docker-py.

Would it be possible to include python-docker in Atomic Host compose instead of python-docker-py? The package is probably pulled by atomic CLI, but the fact is that on rawhide atomic RPM requires python3-docker:

$ rpm -q --requires atomic | grep docker                                                                                                                         
python3-docker >= 1.7.2

RHEL and CentOS still include python-docker-py because no one requested the newest upstream release yet.


on f27 atomic:

[root@vanilla-f27atomic ~]# rpm-ostree status
State: idle
Deployments:
 fedora-atomic:fedora/27/x86_64/atomic-host
                   Version: 27.61 (2018-01-17 15:52:47)
                    Commit: 772ab185b0752b0d6bc8b2096d08955660d80ed95579e13e136e6a54e3559ca9
              GPGSignature: Valid signature by 860E19B0AFA800A1751881A6F55E7430F5282EE4
[root@vanilla-f27atomic ~]# rpm -q --whatrequires python-docker-py 
no package requires python-docker-py

I opened a PR to get this pulled out of rawhide. Pending merge I'll do this in f27 too.

Metadata Update from @dustymabe:
- Issue assigned to dustymabe

@ttomecek - quick question. Do we know what python docker library ansible uses?

Docs note

Using the docker modules requires having docker-py installed on the host running Ansible. You will need to have >= 1.7.0 installed.

$ pip install 'docker-py>=1.7.0'

The docker_service module also requires docker-compose

$ pip install 'docker-compose>=1.7.0'

In terms of rpm I don't think it's a requirement as it's a module to be used but I could be wrong there.

Right, I'm pretty sure we had this for ansible.

$ echo -n "$(basename $(pwd)): " && git describe --tags --always --abbrev=42
openshift-ansible: openshift-ansible-3.9.0-0.23.0-26-gdd5c2a24872490f34be8516e4f03a4076be35789
$ git grep python-docker
roles/openshift_health_checker/openshift_checks/docker_image_availability.py:    # we use python-docker-py to check local docker for images, and skopeo
roles/openshift_health_checker/openshift_checks/docker_image_availability.py:    dependencies = ["python-docker-py", "skopeo"]
roles/openshift_health_checker/openshift_checks/docker_storage.py:    dependencies = ["python-docker-py"]
$

In fact a quick git log --grep docker-py instantly turns up: https://pagure.io/fedora-atomic/c/2b9e4ac6ebf779a8d699e17ea2e889721c54e773

Do you know if those ansible modules & roles require the version 1 of docker-py or do they work with the newest version & API? I can totally help porting those.

Metadata Update from @ttomecek:
- Assignee reset

@ttomecek - can you try removing that library from an f27 instance and then run the ansible modules against it to see if anything complains? Here is how to do that:

[root@vanilla-f27atomic ~]# rpm-ostree ex override remove python-docker-py
Checking out tree 86727cd... done
Resolving dependencies... done
Applying 1 override... done
Writing rpmdb... done
Writing OSTree commit... done
Copying /etc changes: 21 modified, 0 removed, 52 added
Transaction complete; bootconfig swap: yes deployment count change: 1
Removed:
  python-docker-py-1:1.10.6-5.fc27.noarch
Run "systemctl reboot" to start a reboot
[root@vanilla-f27atomic ~]# 
[root@vanilla-f27atomic ~]# reboot

I just ran a quick test of this and running through openshift-ansible with that package removed seems to work ok.

54.205.218.164 | SUCCESS | rc=0 >>
State: idle; auto updates disabled
Deployments:
 ostree://fedora-atomic:fedora/27/x86_64/atomic-host
                   Version: 27.93 (2018-02-25 20:49:19)
                BaseCommit: da0bd968610aa1e29c5bb37065649407fbbfffa53e63831afdadbd34a3b05327
              GPGSignature: Valid signature by 860E19B0AFA800A1751881A6F55E7430F5282EE4
       RemovedBasePackages: python-docker-py-1:1.10.6-5.fc27.noarch

@ttomecek can you inspect the ansible modules to make sure none of them in the ansible core library use python-docker-py ?

I just verified it works just fine:

$ vagrant ssh
Last login: Tue Feb 27 16:32:13 2018 from 192.168.121.1
[vagrant@localhost ~]$ rpm-ostree status
State: idle; auto updates disabled
Deployments:
● ostree://fedora-atomic:fedora/27/x86_64/atomic-host
                   Version: 27.93 (2018-02-25 20:49:19)
                BaseCommit: da0bd968610aa1e29c5bb37065649407fbbfffa53e63831afdadbd34a3b05327
              GPGSignature: Valid signature by 860E19B0AFA800A1751881A6F55E7430F5282EE4
       RemovedBasePackages: python-docker-py-1:1.10.6-5.fc27.noarch
           LayeredPackages: python2-docker

  ostree://fedora-atomic:fedora/27/x86_64/atomic-host
                   Version: 27.93 (2018-02-25 20:49:19)
                    Commit: da0bd968610aa1e29c5bb37065649407fbbfffa53e63831afdadbd34a3b05327
              GPGSignature: Valid signature by 860E19B0AFA800A1751881A6F55E7430F5282EE4

I used this simple playbook:

---
- hosts: all
  become: true
  tasks:
  - docker_image:
      name: fedora:27
      state: present
  - docker_container:
      image: fedora:27
      name: hello
      command: 'echo "hello atomic!"'
  - command: docker logs hello
    register: out
  - assert:
      that: "'hello atomic!' in out.stdout"

with this Vagrantfile:

Vagrant.configure("2") do |config|
    hostname = "F27-AH"
    locale = "en_US.UTF.8"

    # Box
    config.vm.box = "F27-atomic"

    config.vm.provision "ansible" do |ansible|
      ansible.playbook = "playbook.yml"
    end
end

The play passed:

$ vagrant provision
==> default: Running provisioner: ansible...
Vagrant has automatically selected the compatibility mode '2.0'
according to the Ansible version installed (2.4.3.0).

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [docker_image] ************************************************************
changed: [default]

TASK [docker_container] ********************************************************
changed: [default]

TASK [command] *****************************************************************
changed: [default]

TASK [assert] ******************************************************************
ok: [default] => {
    "changed": false,
    "msg": "All assertions passed"
}

PLAY RECAP *********************************************************************
default                    : ok=5    changed=3    unreachable=0    failed=0

Please let me know if you run into some issues with the openshift roles you were mentioning.

openshift was good. we'll remove this.

Metadata Update from @dustymabe:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Log in to comment on this ticket.

Metadata