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

[WIP] Docker connection plugin: allow to use Docker SDK for Python #66114

Closed

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Allows the docker connection plugin to use Docker SDK for Python (aka docker-py) to communicate with the docker daemon, as opposed to using the docker CLI program. By default, it auto-detects whether to use the cli driver (i.e. use the docker CLI program) or the docker-py driver (i.e. the Docker SDK for Python), but the user can force the decision.

Fixes #17692.

There are currently some problems / things not implemented / working:

  1. Up- and downloading files requires the files to fit into memory. It would be nice to stream them, to reduce memory usage. That will definitely require some more work.

  2. sudo seems to work (haven't tested other become plugins), but pipelining right now isn't: it looks like passing larger amounts of data via stdin is not working, and it hangs after sending the data.

  3. There's no way to configure how to talk to the docker daemon yet. That's the easiest to add :)

I also had to touch the synchronize module; it won't work with the new Docker SDK for Python driver, as opposed to the docker CLI driver, since there's no docker executable we can just use.

CC @ssbarnea

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/plugins/connection/docker.py

@ansibot
Copy link
Contributor

ansibot commented Dec 29, 2019

@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. affects_2.10 This issue/PR affects Ansible v2.10 cloud docker feature This issue/PR relates to a feature request. has_issue needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 29, 2019
@ansibot ansibot removed the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Dec 31, 2019
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 3, 2020
@felixfontein
Copy link
Contributor Author

felixfontein commented Jan 4, 2020

For me, right now, everything is working as follows:

Method Python 2 Python 3
unix socket
SSH + unix
TCP
TCP + TLS

For SSH transport, it's hanging after sending the first block of input (maybe select doesn't work on that socket?). For TCP+TLS, I have no idea of how to indicate end of stdin , and I get a SSLError when reading.

@felixfontein
Copy link
Contributor Author

I managed to fix SSH transport compatibility (the main problem was that select() for writing doesn't work because of paramiko/paramiko#695).

@felixfontein
Copy link
Contributor Author

I have no idea how to fix the remaining problem (write connection shutdown for TCP+TLS); somehow related: urllib3/urllib3#1626.

@felixfontein
Copy link
Contributor Author

Ok, I also got TCP+TLS support working, with a pretty ugly workaround though. Next I'll try to figure out why on earth CI produces these UnicodeEncodeErrors...

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Jan 9, 2020
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 19, 2020
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Mar 8, 2020
@ansibot ansibot added new_plugin This PR includes a new plugin. test This PR relates to tests. labels Mar 24, 2020
@Akasurde
Copy link
Member

Hi @felixfontein, Thank you very much for your interest in Ansible. This plugin/module is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/community.general

If you have further questions please stop by IRC or the mailing list:

* IRC: #ansible on irc.freenode.net
* mailing list: https://groups.google.com/forum/#!forum/ansible-project

needs_info

@Akasurde Akasurde closed this Aug 19, 2020
@ansible ansible locked as resolved and limited conversation to collaborators Aug 19, 2020
@felixfontein felixfontein deleted the docker-connection-docker-py branch December 30, 2020 07:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 cloud collection:ansible.posix collection:community.general collection Related to Ansible Collections work docker feature This issue/PR relates to a feature request. has_issue needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker connection plugin - could we use docker-py ?
4 participants