community.docker/plugins/module_utils
Felix Fontein 983b2b4783
exec: fix file handle leak with container.exec_* APIs (https://github.com/docker/docker-py/pull/2320) (#582)
Requests with stream=True MUST be closed or else the connection will
never be returned to the connection pool. Both ContainerApiMixin.attach
and ExecApiMixin.exec_start were leaking in the stream=False case.
exec_start was modified to follow attach for the stream=True case as
that allows the caller to close the stream when done (untested).

Tested with:

    # Test exec_run (stream=False) - observe one less leak
    make integration-test-py3 file=models_containers_test.py' -k test_exec_run_success -vs -W error::ResourceWarning'
    # Test exec_start (stream=True, fully reads from CancellableStream)
    make integration-test-py3 file=api_exec_test.py' -k test_execute_command -vs -W error::ResourceWarning'

After this change, one resource leak is removed, the remaining resource
leaks occur because none of the tests call client.close().

Fixes https://github.com/docker/docker-py/issues/1293
(Regression from https://github.com/docker/docker-py/pull/1130)

Cherry-picked from 34e6829dd4

Co-authored-by: Peter Wu <pwu@cloudflare.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2023-02-12 08:29:28 +01:00
..
_api exec: fix file handle leak with container.exec_* APIs (https://github.com/docker/docker-py/pull/2320) (#582) 2023-02-12 08:29:28 +01:00
module_container fix: fix tmpfs_size and tmpfs_mode not being set (#580) 2023-02-10 14:05:09 +01:00
_scramble.py Add docker_container_copy_into module (#545) 2023-01-09 11:52:29 +01:00
common_api.py Remove unneccessary imports (#575) 2023-02-09 15:25:45 +01:00
common.py Remove unneccessary imports (#575) 2023-02-09 15:25:45 +01:00
copy.py Add docker_container_copy_into module (#545) 2023-01-09 11:52:29 +01:00
image_archive.py Make image archive/save idempotent, using image id and repo tags as keys (#500) 2022-11-30 23:45:36 +01:00
socket_handler.py Remove unneccessary imports (#575) 2023-02-09 15:25:45 +01:00
socket_helper.py Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#430) 2022-07-20 07:45:33 +02:00
swarm.py Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#430) 2022-07-20 07:45:33 +02:00
util.py Remove unneccessary imports (#575) 2023-02-09 15:25:45 +01:00
version.py Remove unneccessary imports (#575) 2023-02-09 15:25:45 +01:00