integration: Remove tests for dropped features on Docker v29 - #3380
Conversation
The --squash flag is no longer supported with BuildKit. Signed-off-by: Ricardo Branco <rbranco@suse.de>
Container links have been replaced by user-defined networks, which provide better isolation and flexibility without injecting environment variables. https://docs.docker.com/engine/network/links/ Signed-off-by: Ricardo Branco <rbranco@suse.de>
c2c9f9a to
2339d3e
Compare
|
cc @thaJeztah |
There was a problem hiding this comment.
🟡 Changes recommended
The broadened exception assertion masks incorrect image-error classification and bypassed pull behavior.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Removes integration tests for Docker 29-dropped behavior and adjusts missing-image handling.
Changes:
- Removes BuildKit-incompatible squash tests.
- Removes a legacy container-link environment test.
- Broadens the expected missing-image exception.
File summaries
| File | Description |
|---|---|
tests/ssh/api_build_test.py |
Removes SSH squash coverage. |
tests/integration/models_containers_test.py |
Broadens missing-image exception assertion. |
tests/integration/api_container_test.py |
Removes legacy link environment coverage. |
tests/integration/api_build_test.py |
Removes squash coverage. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def test_run_with_image_that_does_not_exist(self): | ||
| client = docker.from_env(version=TEST_API_VERSION) | ||
| with pytest.raises(docker.errors.ImageNotFound): | ||
| with pytest.raises((docker.errors.ImageNotFound, docker.errors.NotFound)): |
| def test_run_with_image_that_does_not_exist(self): | ||
| client = docker.from_env(version=TEST_API_VERSION) | ||
| with pytest.raises(docker.errors.ImageNotFound): | ||
| with pytest.raises((docker.errors.ImageNotFound, docker.errors.NotFound)): |
There was a problem hiding this comment.
Looks like this isn't striclty needed? Or have you hit some issue without it @ricardobranco777 ?
There was a problem hiding this comment.
Looks like this isn't striclty needed? Or have you hit some issue without it @ricardobranco777 ?
Yes.
http://openqa-assets.opensuse.org/tests/6218379/file/python_docker-integration.txt
# Test messages # test_run_with_image_that_does_not_exist
# failure:
docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.45/images/create?tag=latest&fromImage=dockerpytest_does_not_exist: Not Found ("failed to resolve reference "docker.io/library/dockerpytest_does_not_exist:latest": docker.io/library/dockerpytest_does_not_exist:latest: not found")
docker/api/client.py:275: in _raise_for_status
response.raise_for_status()
/usr/lib/python3.13/site-packages/requests/models.py:1167: in raise_for_status
raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.45/containers/create
The above exception was the direct cause of the following exception:
docker/models/containers.py:877: in run
container = self.create(image=image, command=command,
docker/models/containers.py:936: in create
resp = self.client.api.create_container(**create_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker/api/container.py:440: in create_container
return self.create_container_from_config(config, name, platform)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker/api/container.py:457: in create_container_from_config
return self._result(res, True)
^^^^^^^^^^^^^^^^^^^^^^^
docker/api/client.py:281: in _result
self._raise_for_status(response)
docker/api/client.py:277: in _raise_for_status
raise create_api_error_from_http_exception(e) from e
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker/errors.py:39: in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation) from e
E docker.errors.ImageNotFound: 404 Client Error for http+docker://localhost/v1.45/containers/create: Not Found ("No such image: dockerpytest_does_not_exist:latest")
During handling of the above exception, another exception occurred:
docker/api/client.py:275: in _raise_for_status
response.raise_for_status()
/usr/lib/python3.13/site-packages/requests/models.py:1167: in raise_for_status
raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.45/images/create?tag=latest&fromImage=dockerpytest_does_not_exist
The above exception was the direct cause of the following exception:
tests/integration/models_containers_test.py:40: in test_run_with_image_that_does_not_exist
client.containers.run("dockerpytest_does_not_exist")
docker/models/containers.py:880: in run
self.client.images.pull(image, platform=platform)
docker/models/images.py:464: in pull
pull_log = self.client.api.pull(
docker/api/image.py:429: in pull
self._raise_for_status(response)
docker/api/client.py:277: in _raise_for_status
raise create_api_error_from_http_exception(e) from e
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker/errors.py:39: in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation) from e
E docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.45/images/create?tag=latest&fromImage=dockerpytest_does_not_exist: Not Found ("failed to resolve reference "docker.io/library/dockerpytest_does_not_exist:latest": docker.io/library/dockerpytest_does_not_exist:latest: not found")
There was a problem hiding this comment.
Hmm, how about actually fixing the error classification? Like:
diff --git docker/errors.py docker/errors.py
index d03e10f6..308d6b62 100644
--- docker/errors.py
+++ docker/errors.py
@@ -31,8 +31,14 @@ def create_api_error_from_http_exception(e):
cls = APIError
if response.status_code == 404:
explanation_msg = (explanation or '').lower()
- if any(fragment in explanation_msg
- for fragment in _image_not_found_explanation_fragments):
+ if (
+ any(fragment in explanation_msg
+ for fragment in _image_not_found_explanation_fragments)
+ or (
+ explanation_msg.startswith('failed to resolve reference ')
+ and explanation_msg.endswith(': not found')
+ )
+ ):
cls = ImageNotFound
else:
cls = NotFound?
There was a problem hiding this comment.
Dropped commit and fixing it in docker/errors.py by updating the _image_not_found_explanation_fragments list with the message returned by Docker v29.
There was a problem hiding this comment.
Ah, that looks good enough indeed! Thanks!
Docker 29's containerd-backed image store returns 404s with the message 'failed to resolve reference "...": ...: not found' instead of 'No such image' when an image can't be found. This caused ContainerCollection.run()'s pull-retry path to raise a generic NotFound instead of the documented ImageNotFound, breaking callers that catch ImageNotFound specifically. Signed-off-by: Ricardo Branco <rbranco@suse.de>
2339d3e to
4c28d01
Compare
Remove tests for dropped features on Docker v29