Some callers might like to make decisions based on the http server error
that was returned.
In particular we would like c/common/pkg/retry to match this error so it
can retry image pulls/pushes on 5XX errors as they seems to be a quite
common problem[1].
[1] https://github.com/containers/common/issues/2299
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
... when checking for missing images.
In particular, this is necessary for use-sigstore-attachments not to
cause failures when pulling from registry.redhat.io.
Red Hat internal reference: RITM1310318
Signed-off-by: Miloslav Trmač <mitr@redhat.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>
We should have been doing that from the start, in order to
get server-reported errors correctly.
NOTE: This can break existing clients, notably (skopeo inspect)
which greps the error string for 401 and 403. See the corresponding
skopeo PR for documentation of what we do about that.
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>
In particular, add specific errcode.ErrorCoder values, which is
what callers are actually looking for.
Also allow for special cases.
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>
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>
It's high time we started collecting error samples and
documenting what happens.
NOTE: This is NOT an API commitment, we can change the error
types and messages any time.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>