-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
I get this error in the error output but no exception is raised:
{"status":"The push refers to repository [485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy]"}
{"errorDetail":{"message":"An image does not exist locally with the tag: 485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy"},"error":"An image does not exist locally with the tag: 485757098324.dkr.ecr.us-east-1.amazonaws.com/ssh_proxy"}
Unlike related issue #1772 there's really no excuse here, since this error can be detected even if trying to push to a black box, while #1772 requires understanding the output of a repo server.
Also worth mentioning that the docker push
command WILL return an error code in this case. So actually the docker push command gives MORE info than the SDK function. Since the docker push command gives output + error code. While the SDK function only gives output :(
(Not saying the function needs to BC break and return two values, just that it needs to raise exceptions when appropriate)
Ark-kun, sgsollie and DaemonDude23
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
paulcdejean commentedon Jan 11, 2019
Working with programmerq on irc we've discovered that when you do a docker push of a non existent tag, that the docker http API gives a 200 return code.
shin- commentedon Jan 11, 2019
Yeah, it's the same as #1772 - the error isn't detected at the moment the request is made, meaning it only appears in the output stream after the HTTP status has already been set. The high-level
DockerClient
implementation actually does that kind of error detection for builds, and that could be extended to apply to push / pulls as well. OTOH I don't think we should change the design of the low-levelAPIClient
to process the output beyond what we're currently doing.Also, as far as this specific error is concerned, the Docker Engine really should do some trivial validation and detect if a tag doesn't exist locally and send a 4xx HTTP response rather than attempt a push anyway.
paulcdejean commentedon Jan 14, 2019
Well as is we basically need to write a docker push wrapper function that attempts the push, parses the output. Then throws an exception if there's an error key in any of the json dictionary lines of the output.
That type of logic could be brought into the SDK as a stopgap before something more elegant is implemented. If performance is a concern, then it could be implemented as an alternative push function even?
As is people are either writing this sort of wrapper function, avoiding using the SDK, or just crossing their fingers and hoping none of their docker pushes ever error out.
paulcdejean commentedon Jan 14, 2019
I'll add a code example of this sort of wrapper function soon (once I write it, probably before the end of the day), as is I'm using the finger crossing method).
paulcdejean commentedon Jan 14, 2019
Here's the wrapper I wrote to workaround this issue.
It's not super tested due to many push errors being difficult to reproduce (the rate limit one is one I've been struggling with with amazon ECR in particular).
chris-crone commentedon Jan 16, 2019
There is some work being done on the engine to provide richer errors so that they're easier to manage. Not exactly this but related: moby/moby#38467
thaJeztah commentedon Jan 31, 2019
@chris-crone moby/moby#38467 likely won't help in this case, because the daemon sent a 200 status before it detects the error; moby/moby#38467 will make the client return the status code (instead of just a plain error).
I can try if waiting to send the "The push refers to repository" message until after the initial error detection was done could allow us to send a proper status code (and prevent the 200 status from being sent before that).
FWIW, I do think we still need the python sdk to detect errors if an
errorDetail
arrives; even though this initial error check could make it possible to send a 4xx status code, there may be situations where an error occurs further down the push (e.g. push is in progress, but the registry returns a failure). Due to this endpoint returning a stream, the status code cannot be updated at that point.Also see the above; in this case it looks like the validation is actually done before the actual push happens (but the initial message was already sent; I'll try and see if that particular case can be resolved)
caeus commentedon Dec 13, 2022
So? nobody checking this?
milas commentedon Dec 16, 2022
@caeus There is no update on this behavior in
docker-py
. Currently, the library exposes the Engine API as-is here. The engine will return a200
if the push is able to start, and then streams push status back in the response. If an error is hit during push, that will be reflected in the events. Thepush_wrapper
example from this comment shows how to handle this API response.