-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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-py listing of images was failing. #12656
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The following script was blowing up against the podman socket ``` cat images.py import docker client=docker.from_env() print(client.images.list(all=True)) ``` This seems to be working with the release, but when I try to run it against the main branch it blows up. ``` export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock $ python images.py Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 268, in _raise_for_status response.raise_for_status() File "/usr/lib/python3.10/site-packages/requests/models.py", line 953, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.40/images/sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18/json During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/dwalsh/Documents/book/images.py", line 3, in <module> print(client.images.list(all=True)) File "/usr/lib/python3.10/site-packages/docker/models/images.py", line 362, in list return [self.get(r["Id"]) for r in resp] File "/usr/lib/python3.10/site-packages/docker/models/images.py", line 362, in <listcomp> return [self.get(r["Id"]) for r in resp] File "/usr/lib/python3.10/site-packages/docker/models/images.py", line 314, in get return self.prepare_model(self.client.api.inspect_image(name)) File "/usr/lib/python3.10/site-packages/docker/utils/decorators.py", line 19, in wrapped return f(self, resource_id, *args, **kwargs) File "/usr/lib/python3.10/site-packages/docker/api/image.py", line 251, in inspect_image return self._result( File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 274, in _result self._raise_for_status(response) File "/usr/lib/python3.10/site-packages/docker/api/client.py", line 270, in _raise_for_status raise create_api_error_from_http_exception(e) File "/usr/lib/python3.10/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception raise cls(e, response=response, explanation=explanation) docker.errors.ImageNotFound: 404 Client Error for http+docker://localhost/v1.40/images/sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18/json: Not Found ("failed to find image sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18: docker.io/library/sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18: No such image") ``` Signed-off-by: Daniel J Walsh <[email protected]>
@@ -381,19 +381,22 @@ func GetImage(w http.ResponseWriter, r *http.Request) { | |||
// 404 no such | |||
// 500 internal | |||
name := utils.GetName(r) | |||
possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) | |||
newImage, err := utils.GetImage(r, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must normalize all input to the Docker endpoints. A short-name would otherwise not be normalized to docker.io.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's likely a bug in the normalization code that we must fix instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue I am seeing is it is getting screwed up with it looks for sha256:UUID.
It is getting normalized to:
docker.io/library/sha256:c059bfaa849c4d8e4aecaeb3a10c2d9b3d85f5165c66ad3a4d937758128c4d18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update NormalizeToDockerHub
to handle that but no caller to NormalizeToDockerHub
should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if it starts with sha256:
, the name should be returned as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
Could you fix this, since I am supposed to be on PTO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following script was blowing up against the podman socket
This seems to be working with the release, but when I try to run it
against the main branch it blows up.
Signed-off-by: Daniel J Walsh [email protected]