So that callers can actually check the status code of all requests if
needed. This changes error text slightly but I think it still carries
the same meaning.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
The ping v1 happens when the ping v2 fails, however, it causes the ping
v2 error to be skipped and not output to the user. As result, when a
registry has v1 and v2 enabled, and there are, for example, intermittent
connectivity issues making the ping v2 fail, the user is presented with
a misleading error saying "can't talk to V1 registry."
Since the only use of v1 is for the search API as a workaround for
docker.io, and new container registries setups are very unlikely to be
v1-only, there is little utility in keeping this v1 detection in the
attempt to help the user realize their setup is v1-only, hence not
compatible. On the contratry, it just presents the user with a
misleading error in certain circumstances.
Signed-off-by: Carlos Rodriguez-Fernandez <carlosrodrifernandez@gmail.com>
E.g. use "authentication required" instead of "unauthorized: authentication required".
See the tests for more examples.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... through errors.Unwrap(). Should not change the user-visible
text of the error; this is only to make the internal error type
usable through registryHTTPResponseToError, as a matter of general
cleanliness.
The unexpectedHTTPResponseError type is private anyway, so this
is not externally-observable.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... to simplify user-visible error messages, and to make the
errors less ambiguous for errcode.ErrorCoder testing.
NOTE: This may break callers that expect the full errcode.Errors.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
... so that we can modify the handleErrorResponse consumption
logic in one place.
Note that this may change the user-visible error message.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Using the github.com/docker/distribution/registry/client package will
import many huge prometheus dependencies, e.g.
* github.com/prometheus/client_golang/prometheus/promhttp
* github.com/prometheus/client_golang/prometheus
* github.com/prometheus/procfs
and even more...
All of these dependencies are completely unused AFAICT but will still end
up in a binary because they are imported transitive.
github.com/docker/distribution/registry/client is only used to check
http errors so I think it makes sense to copy only the required code
into the docker package.
I vendored this commit into podman and it saves over 700KB in binary
size.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This means we won't save the stack, which is cheaper
(and possibly might break callers' format strings that
want to print the stack, but we never promised the stack
to be available).
Use either fmt.Errorf, or errors.New (usually as a local
edit, not carring about errors.new vs. pkg/errors.New;
that's going to be cleaned up later).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
No point in handling them in generic code, and callers that
aren't expecting StatusPartialContent could be confused.
Should not change behavior of GetBlobAt; might in change behavior of
other callers if they unexpectedly received the relevant HTTP status
codes.
This ~mechanically moves the code without much restructuring.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
github.com/docker/distribution is not using the github.com/pkg/errors
wrapping mechanism, and we don't expect them to start.
Should not change behavior.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
just to minimize repetition; the Reponse qualifier applies to
everything in that function, so it doesn't help.
Should not change behavior.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Format the error message use the response body if the original error is returned as client.UnexpectedHTTPResponseError type
Signed-off-by: Qi Wang <qiwan@redhat.com>
E.g.
- Capitalize log messages
- Add a bit more context to the log messages
- Don't commit to specific fallback behavior in the API, only say that it may automatically retry.
- Fix some typos
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Consolidate checking the http-status codes to allow for a more uniform
error handling. Also treat code 429 (too many requests) as a known
error instead of an invalid status code.
When hitting 429, perform an exponential back off starting a 2 seconds
for at most 5 iterations. If the http.Response set the `Retry-Header`
then use the provided value or date to compute the delay until the
next attempt. Note that the maximum delay is 60 seconds.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>