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

docker_image module TypeError: build() got an unexpected keyword argument 'stream' #35612

Closed
geerlingguy opened this issue Feb 1, 2018 · 8 comments · Fixed by #36973
Closed
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. cloud docker module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community.

Comments

@geerlingguy
Copy link
Contributor

geerlingguy commented Feb 1, 2018

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_image module

ANSIBLE VERSION
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
CONFIGURATION

N/A

OS / ENVIRONMENT

Ubuntu 16.04 Xenial

SUMMARY

In what is perhaps the simplest Docker image creation playbook I've ever made (the docker example playbook from A4D), automated builds started failing last night.

I confirmed the issue locally, when run under a Docker container running Ubuntu 16.04 Xenial.

Example failed build: https://travis-ci.org/geerlingguy/ansible-for-devops/jobs/335923274

It has pip-installed docker for Python, version 3.0.0:

# pip show docker
---
Metadata-Version: 2.0
Name: docker
Version: 3.0.0
Summary: A Python library for the Docker Engine API.
Home-page: https://github.com/docker/docker-py
Author: Joffrey F
Author-email: joffrey@docker.com
Installer: pip

It looks like the problem is the 3.0.0 release—short term fix is to lock into a 2.x release, using pip install docker==2.7.0. The 3.0.0 release notes mention, under removed:

stream in APIClient.build

STEPS TO REPRODUCE
  1. Grab the Docker example playbook from my A4D repo.
  2. Ensure you have Docker and Docker python installed pip install docker, 3.0.0 or later.
  3. Run ansible-playbook -i '127.0.0.1,' main.yml
EXPECTED RESULTS

Docker image would be built from the provided Dockerfile, then run.

ACTUAL RESULTS

The docker_image task fails with TypeError: build() got an unexpected keyword argument 'stream'.

TASK [Ensure Docker image is built from the test Dockerfile.] ******************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: build() got an unexpected keyword argument 'stream'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_X1O9eJ/ansible_module_docker_image.py\", line 602, in <module>\n    main()\n  File \"/tmp/ansible_X1O9eJ/ansible_module_docker_image.py\", line 597, in main\n    ImageManager(client, results)\n  File \"/tmp/ansible_X1O9eJ/ansible_module_docker_image.py\", line 295, in __init__\n    self.present()\n  File \"/tmp/ansible_X1O9eJ/ansible_module_docker_image.py\", line 323, in present\n    self.results['image'] = self.build_image()\n  File \"/tmp/ansible_X1O9eJ/ansible_module_docker_image.py\", line 520, in build_image\n    for line in self.client.build(**params):\nTypeError: build() got an unexpected keyword argument 'stream'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
@ansibot
Copy link
Contributor

ansibot commented Feb 1, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Feb 1, 2018

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report cloud docker module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Feb 1, 2018
@geerlingguy
Copy link
Contributor Author

FYI a build locking in docker-py version 2.7.0 passed (https://travis-ci.org/geerlingguy/ansible-for-devops/jobs/336149216), after three failed test builds with 3.0.0.

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Feb 1, 2018
teddyphreak added a commit to nephelaiio/cookiecutter-ansible-role that referenced this issue Feb 1, 2018
teddyphreak added a commit to nephelaiio/ansible-role-vim that referenced this issue Feb 1, 2018
teddyphreak added a commit to nephelaiio/ansible-role-tmux that referenced this issue Feb 1, 2018
@skylerbunny
Copy link
Contributor

Ansible is relying on (presumably) an older API, including among other things the stream parameter.

See https://docker-py.readthedocs.io/en/stable/change-log.html ( specifically, https://docker-py.readthedocs.io/en/stable/change-log.html#breaking-changes ).

@skylerbunny
Copy link
Contributor

This is a major breaking problem that will affect all Ansible releases that use the docker library.

A quick fix to this would be an edit to documentation of Docker related module pages, specifying requirements of:
docker>=X,<3.0.0

where X may vary depending upon the specific version of Ansible and its respective documentation of a minimum version, but in all cases this major maximum version must be specified.

Obviously the longer term forward looking solution, especially for 2.5, is to update the calls so they work with 3.0, and I don't know how difficult that will be for it and other supported branches.

In any case, I propose based on the scope and severity that Docker module documentation be updated for supported Ansible versions, at a high priority.

freemanjp added a commit to gantsign/ansible-role-intellij that referenced this issue Feb 3, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-intellij that referenced this issue Feb 3, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
keithnoguchi pushed a commit to keithnoguchi/do-in-action that referenced this issue Feb 6, 2018
To work around ansible docker-image bug, as explained below:

ansible/ansible#35612
msheiny added a commit to freedomofpress/ansible-role-grsecurity-build that referenced this issue Feb 7, 2018
freemanjp added a commit to gantsign/ansible-role-visual-studio-code that referenced this issue Feb 10, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-visual-studio-code that referenced this issue Feb 10, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-golang that referenced this issue Feb 10, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-golang that referenced this issue Feb 10, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
achaussier added a commit to infOpen/ansible-role-bacula-fd that referenced this issue Feb 12, 2018
@agustinruatta
Copy link

Quick Fix on ArchLinux

I had the same issue on ArchLinux. I've made a downgrade of python-docker package with downgrade software to 2.7.0-1 and all works fine now:

$ downgrade python-docker
Paquetes disponibles:

*  1) python-docker-3.0.1-1-any.pkg.tar.xz (remoto)
*  2) python-docker-2.7.0-1-any.pkg.tar.xz (remoto)
*  3) python-docker-2.6.1-1-any.pkg.tar.xz (remoto)
*  4) python-docker-2.5.1-1-any.pkg.tar.xz (remoto)
   5) python-docker-2.5.0-1-any.pkg.tar.xz (remoto)
*  6) python-docker-2.4.2-1-any.pkg.tar.xz (remoto)
*  7) python-docker-2.4.0-1-any.pkg.tar.xz (remoto)
*  8) python-docker-2.3.0-1-any.pkg.tar.xz (remoto)
*  9) python-docker-2.2.1-1-any.pkg.tar.xz (remoto)
  10) python-docker-2.2.0-1-any.pkg.tar.xz (remoto)
* 11) python-docker-2.1.0-1-any.pkg.tar.xz (remoto)
  12) python-docker-2.0.2-1-any.pkg.tar.xz (remoto)
  13) python-docker-2.0.1-1-any.pkg.tar.xz (remoto)

Selecciona un paquete por su número: 2

As @skylerbunny mentioned, Docker SDK 3.0 update has broken that build function removing stream param (More info: https://docker-py.readthedocs.io/en/stable/change-log.html#breaking-changes):

The following parameters have been removed:
* stream in APIClient.build

@decentral1se
Copy link
Contributor

Thanks for #35612 (comment) @geerlingguy!

I added the following to my requirements.txt (following gantsign/ansible-role-intellij@ab07d23):

+  # Limit version as workaround for: https://github.com/ansible/ansible/issues/35612
+  - pip install 'docker<3.0'

freemanjp added a commit to gantsign/ansible-role-xdesktop that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-xdesktop that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible_role_zram_config that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible_role_zram_config that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-keyboard that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-keyboard that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-inotify that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-inotify that referenced this issue Apr 14, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-gnome-proxy that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-gnome-proxy that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-apt that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-apt that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-atom-packages that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-atom-packages that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-audio that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-audio that referenced this issue Apr 15, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-molecule that referenced this issue Apr 16, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
freemanjp added a commit to gantsign/ansible-role-molecule that referenced this issue Apr 16, 2018
Ansible is incompatible with version 3.0.0 of the Python Docker library (see ansible/ansible#35612).
@kladiv
Copy link

kladiv commented May 3, 2018

Hello,
on Ubuntu 16.04 i still get this Error message using Python 3.5.2 and docker 3.3.0.
Using the workaround above (docker<3.0) is works.

Is it correct that this Issue has been closed? No support for latest version of docker module?
Thank you

@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
popstas added a commit to viasite-ansible/ansible-role-zsh that referenced this issue Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. cloud docker module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants