-
Notifications
You must be signed in to change notification settings - Fork 18.9k
errdefs: remove dependency on grpc, containerd, and distribution #42624
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
Conversation
|
|
||
| containerderrors "github.com/containerd/containerd/errdefs" | ||
| "github.com/docker/distribution/registry/api/errcode" | ||
| "github.com/sirupsen/logrus" |
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 should get rid of logrus here
|
@thaJeztah as long as |
|
@thaJeztah bad news ... |
|
@thaJeztah one more problem after applying the commit in this PR |
ac75bbd to
464f248
Compare
|
@thaJeztah the new commit works well! ( 464f248 ) thanks. i don't see this problem any more |
cpuguy83
left a comment
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.
Having anything other than the base definitions in errdefs seems wrong.
I don't remember the change that moved stuff around, but none of this seems correct and a generic Adapter seems like too much abstraction.
In client/ we should only be outputting for the most part, errors that implement something in errdefs and we should generally only be consuming errors that come across the API.
In api/ we should only be receiving errors that implement something from errdefs and outputing the relavent status code + messages.
I think that may have been my doing. We had code to convert from/to errdefs and to/from HTTP status code in various locations, and (from that perspective) it seemed to make sense to have the errdefs package be the canonical place to provide conversions in both directions.
So currently the client uses errdefs to convert HTTP status codes returned by the API back to errdefs errors (added in #38689). I think that makes sense (I recall string matching in various code using the client because it returned no information whatsoever).
So conversion from other subsystems was added over time;
For those above, perhaps they should live in a client specific to each (e.g. |
| conn, _, errHijack := hijacker.Hijack() | ||
| if errHijack == nil { | ||
| statusCode := errdefs.GetHTTPErrorStatusCode(err) | ||
| statusCode := errdefs.GetHTTPErrorStatusCode(err, adapter.All()...) |
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.
Is there any reason why the adapters are not hidden inside GetHTTPErrorStatusCode? other than that LGTM
|
@thaJeztah let's please reach consensus on this one (with a hopefully quick tag/release!). this is holding up a long-dependency-update-chain in kubernetes.
|
464f248 to
1efa7ca
Compare
1efa7ca to
5cdb258
Compare
The errdefs package is used both to generate errors, but also has utilities to convert errors originating from subsystems into a suitable HTTP error. The API should always return a suitable HTTP error, and Conversion of errors originating from subsystems will (generally) only be needed in the API server (not the client). This patch prevents the client from depending on grpc, containerd and distribution, by moving the code to convert those errors to a separate "adapters" package. The api/server/httputils.GetHTTPErrorStatusCode was un-deprecated, and modified to include the default set of adapters. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Unfortunately, the previous change didn't produce the desired result,
because the client uses httputils in a test:
github.com/google/cadvisor/container/docker imports
github.com/docker/docker/client tested by
github.com/docker/docker/client.test imports
github.com/docker/docker/api/server/httputils imports
github.com/docker/docker/errdefs/adapter imports
github.com/containerd/containerd/errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
5cdb258 to
c44b11e
Compare
|
I had a draft alternative to this one, which does not include the |
|
Replaced by #43399, which was just merged 👍 |
|
thanks a ton @thaJeztah |
relates to #42623
The errdefs package is used both to generate errors, but also has utilities
to convert errors originating from subsystems into a suitable HTTP error.
The API should always return a suitable HTTP error, and Conversion of errors
originating from subsystems will (generally) only be needed in the API server
(not the client).
This patch prevents the client from depending on grpc, containerd and distribution,
by moving the code to convert those errors to a separate "adapters" package.
The api/server/httputils.GetHTTPErrorStatusCode was un-deprecated, and modified
to include the default set of adapters.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)