Commit Graph

3389 Commits

Author SHA1 Message Date
Aarni Koskela 3948540c89 Fix or noqa B003 (assigning to os.environ doesn't do what you expect)
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 0566f1260c Fix missing asserts or assignments
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela cc76c9c20d Fix B082 (no explicit stacklevel for warnings)
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 09f12f2046 Fix B005 (probably an actual bug too)
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 6aec90a41b Fix Ruff B904s (be explicit about exception causes)
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 8447f7b0f0 Enable Ruff B rules and autofix
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 601476733c Enable Ruff C rules and autofix
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela ec58856ee3 Clean up unnecessary noqa comments
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela fad792bfc7 Get rid of star import
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 9313536601 Switch linting from flake8 to ruff
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Aarni Koskela 8a3402c049 Replace string formatting with f-strings
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Sebastiaan van Stijn ee2310595d
test: remove APT_MIRROR from Dockerfile (#3145)
The official Python images on Docker Hub switched to debian bookworm,
which is now the current stable version of Debian.

However, the location of the apt repository config file changed, which
causes the Dockerfile build to fail;

    Loaded image: emptyfs:latest
    Loaded image ID: sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43
    INFO: Building docker-sdk-python3:5.0.3...
    tests/Dockerfile:6
    --------------------
       5 |     ARG APT_MIRROR
       6 | >>> RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
       7 | >>>     && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
       8 |
    --------------------
    ERROR: failed to solve: process "/bin/sh -c sed -ri \"s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g\" /etc/apt/sources.list     && sed -ri \"s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g\" /etc/apt/sources.list" did not complete successfully: exit code: 2

The APT_MIRROR build-arg was originally added when the Debian package
repositories were known to be unreliable, but that hasn't been the
case for quite a while, so let's remove this altogether.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2023-08-14 15:12:44 -04:00
dependabot[bot] dbc061f4fa
build(deps): Bump requests from 2.28.1 to 2.31.0 (#3136)
Bumps [requests](https://github.com/psf/requests) from 2.28.1 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.28.1...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-14 15:08:38 -04:00
VincentLeeMax 4571f7f9b4
feat: add pause option to commit api (#3159)
add commit pause option

Signed-off-by: VincentLeeMax <lichlee@yeah.net>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2023-08-14 14:52:38 -04:00
Mehmet Nuri Deveci 0618951093
fix: use response.text to get string rather than bytes (#3156)
Signed-off-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2023-08-14 14:43:31 -04:00
Milas Bowman 806d36a8cd
Merge pull request #3167 from thaJeztah/fix_ci_badge
README: fix link for CI status badge
2023-08-14 09:59:38 -04:00
Milas Bowman 79c4c38b42
Merge pull request #3165 from thaJeztah/tests_relax
tests/integration: update some tests for updated error-messages
2023-08-14 09:52:37 -04:00
Sebastiaan van Stijn 62b4bb8489
README: fix link for CI status badge
The default branch was renamed from master to main, but the badge was still
linking to the status for the master branch.

Remove the branch-name so that the badge always refers to the "default"
branch

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 14:58:34 +02:00
Sebastiaan van Stijn 5064995bc4
tests/integration: update some tests for updated error-messages
I was in the process of cleaning up some error-messages, and it looks like
the docker-py tests were depending on strings that will be removed;

    =================================== FAILURES ===================================
    _____________ CreateContainerTest.test_create_with_restart_policy ______________
    tests/integration/api_container_test.py:126: in test_create_with_restart_policy
        assert 'You cannot remove ' in err
    E   AssertionError: assert 'You cannot remove ' in 'cannot remove container d11580f6078108691096ec8a23404a6bda9ad1d1b2bafe88b17d127a67728833: container is restarting: stop the container before removing or force remove'
    ____________________ ErrorsTest.test_api_error_parses_json _____________________
    tests/integration/errors_test.py:13: in test_api_error_parses_json
        assert 'You cannot remove a running container' in explanation
    E   AssertionError: assert 'You cannot remove a running container' in 'cannot remove container 4b90ce2e907dd0f99d0f561619b803e7a2a31809ced366c537874dd13f8a47ec: container is running: stop the container before removing or force remove'

This updates the tests to match on a string that will be present in both the
old and new error-messages, but added a "lower()", so that matching will be
done case-insensitive (Go errors generally should be lowercase).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 14:52:58 +02:00
Milas Bowman 54ec0c6bf7
Merge pull request #3166 from thaJeztah/fix_flake8_failures
tests/integration: fix flake8 failures (E721 do not compare types), and fix Dockerfile for debian "bookworm"
2023-08-14 08:37:58 -04:00
Sebastiaan van Stijn 83e93228ea
tests/Dockerfile: fix Dockerfile for debian bookworm
The Dockerfile failed to build due to the base-image having switched to "bookworm";

    Dockerfile:8
    --------------------
       7 |     ARG APT_MIRROR
       8 | >>> RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
       9 | >>>     && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
      10 |
    --------------------
    ERROR: failed to solve: process "/bin/sh -c sed -ri \"s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g\" /etc/apt/sources.list     && sed -ri \"s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g\" /etc/apt/sources.list" did not complete successfully: exit code: 2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 10:32:04 +02:00
Sebastiaan van Stijn fb974de27a
tests/integration: fix flake8 failures (E721 do not compare types)
Run flake8 docker/ tests/
      flake8 docker/ tests/
      shell: /usr/bin/bash -e {0}
      env:
        DOCKER_BUILDKIT: 1
        pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
        PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
        Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    tests/integration/api_container_test.py:1395:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_container_test.py:1408:24: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_image_test.py:35:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_image_test.py:46:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    Error: Process completed with exit code 1.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 10:26:36 +02:00
Jay Turner f0d38fb7f4
Add health property to Containers model
Signed-off-by: Jay Turner <jay.turner@kayenta.io>
2023-06-27 12:51:40 +01:00
Hao Yu 84414e343e
fix user_guides/multiplex.rst (#3130)
Signed-off-by: Longin-Yu <longinyh@gmail.com>
2023-06-06 14:28:15 -04:00
Mathieu Virbel 78439ebbe1
fix: eventlet compatibility (#3132)
Check if poll attribute exists on select module instead of win32 platform check

The implementation done in #2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (https://github.com/eventlet/eventlet/issues/608#issuecomment-612359458), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.

Fixes #3131

Signed-off-by: Mathieu Virbel <mat@meltingrocks.com>
2023-06-01 10:19:01 -04:00
Mariano Scazzariello 0318ad8e7e
Fix blank line
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-15 14:51:44 +02:00
Mariano Scazzariello 8ca9c6394f
Merge branch 'docker:main' into main 2023-05-15 12:57:02 +02:00
Milas Bowman bc4c0d7cf4 ci: empty commit to trigger readthedocs
Fixing integration

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-05-11 16:05:16 -04:00
Milas Bowman 14e8d07d45
docs: update changelog (#3127)
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-05-11 15:35:42 -04:00
loicleyendecker c5e582c413
api: avoid socket timeouts when executing commands (#3125)
Only listen to read events when polling a socket in order
to avoid incorrectly trying to read from a socket that is
not actually ready.

Signed-off-by: Loïc Leyendecker <loic.leyendecker@gmail.com>
2023-05-11 13:36:37 -04:00
Imogen 9cadad009e
api: respect timeouts on Windows named pipes (#3112)
Signed-off-by: Imogen <59090860+ImogenBits@users.noreply.github.com>
2023-05-08 13:01:19 -04:00
RazCrimson 443a35360f
Fix container.stats infinite blocking on stream mode (#3120)
fix: api - container.stats infinite blocking on stream mode

Includes additional test for no streaming

Signed-off-by: Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com>
2023-05-07 19:51:24 -04:00
Mariano Scazzariello e011ff5be8
More sanity checking of EndpointConfig params
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-07 12:40:08 +02:00
Mariano Scazzariello 7870503c52
Fix case when "network_config" is not passed
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-07 12:15:32 +02:00
Mariano Scazzariello a18f91bf08
Fix long line
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-07 11:49:59 +02:00
Mariano Scazzariello a662d5a305
Fix pytests
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-07 11:47:07 +02:00
Mariano Scazzariello 1d697680d2
Full support to networking config during container creation
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-05-07 11:46:58 +02:00
John Yang 576e47aaac
api: update return type of `diff` method (#3115)
Signed-off-by: John Yang <john.yang20@berkeley.edu>
2023-05-05 16:21:46 -04:00
Felix Fontein 3178c8d48b
deps: compatiblity with requests ≥ 2.29.0 and urllib3 2.x (#3116)
Requirements are the same, so it's still possible to use `urllib3 < 2`
or `requests == 2.28.2` for example.

Signed-off-by: Felix Fontein <felix@fontein.de>
2023-05-05 11:39:31 -04:00
I-question-this a02ba74333
socket: use poll() instead of select() except on Windows (#2865)
Fixes #2278, which was originally addressed in #2279, but was not
properly merged. Additionally it did not address the problem
of poll not existing on Windows. This patch falls back on the
more limited select method if host system is Windows.

Signed-off-by: Tyler Westland <tylerofthewest@gmail.com>
2023-04-21 17:53:58 -04:00
Aarni Koskela aaf68b7f98
api: note the data arg may also be a stream in `put_archive` (#2478)
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-02-22 14:05:19 -05:00
Milas Bowman f84623225e
socket: fix for errors on pipe close in Windows (#3099)
Need to return data, not size. By returning an empty
string, EOF will be detected properly since `len()`
will be `0`.

Fixes #3098.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-22 12:00:47 -05:00
Lorin Bucher 7cd7458f2f
api: add `status` parameter to services list (#3093)
Signed-off-by: Lorin Bucher <lorin@lbtec.dev>
2023-02-16 10:38:52 -05:00
Andy Roxby e9d4ddfaec
api: add `one-shot` option to container `stats` (#3089)
Signed-off-by: Andy Roxby <107427605+aroxby-wayscript@users.noreply.github.com>
2023-02-16 10:27:45 -05:00
Milas Bowman aca129dd69 Merge branch 'master'
(Old PR unintentionally went to the `master` branch.)
2023-01-27 09:27:42 -05:00
Mariano Scazzariello ee9151f336
client: add `network_driver_opt` to container run and create (#3083)
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-01-27 09:26:21 -05:00
Peter Wu 34e6829dd4
exec: fix file handle leak with container.exec_* APIs (#2320)
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)

Signed-off-by: Peter Wu <pwu@cloudflare.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2023-01-13 15:41:01 -05:00
Yanlong Wang 22718ba59a
fix(store): warn on init instead of throw (#3080)
Signed-off-by: yanlong.wang <yanlong.wang@naiver.org>
2023-01-10 17:45:25 -05:00
dependabot[bot] d38b41a13c
build(deps): Bump setuptools from 63.2.0 to 65.5.1 (#3082)
Bumps [setuptools](https://github.com/pypa/setuptools) from 63.2.0 to 65.5.1.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/CHANGES.rst)
- [Commits](https://github.com/pypa/setuptools/compare/v63.2.0...v65.5.1)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-10 17:25:12 -05:00
Maxim Mironyuk 3afb4b61c3
docs: fix wrong command syntax in code annotation (#3081)
Signed-off-by: Maxim Mironyuk <serieznyi@gmail.com>
2023-01-10 16:58:51 -05:00