Skip to content

Conversation

@thaJeztah
Copy link
Member

relates to:

This reverts the changes made in 2a9c987 (#42623),
which moved the GetHTTPErrorStatusCode() utility to the errdefs package.

While it seemed to make sense at the time to have the errdefs package provide
conversion both from HTTP status codes errdefs and the reverse, a side-effect
of the move was that the errdefs package now had a dependency on various external
modules, to handle conversio of errors coming from those sub-systems, such as;

  • github.com/containerd/containerd
  • github.com/docker/distribution
  • google.golang.org/grpc

This patch moves the conversion from (errdef-) errors to HTTP status-codes to a
api/server/httpstatus package, which is only used by the API server, and should
not be needed by client-code using the errdefs package.

The MakeErrorHandler() utility was moved to the API server itself, as that's the
only place it's used. While the same applies to the GetHTTPErrorStatusCode func,
I opted for keeping that in its own package for a slightly cleaner interface.

Why not move it into the api/server/httputils package?

The api/server/httputils package is also imported in the client package, which
uses the httputils.ParseForm() and httputils.HijackConnection() functions as
part of the TestTLSCloseWriter() test. While this is only used in tests, I
wanted to avoid introducing the indirect depdencencies outside of the api/server
code.

- Description for the changelog

errdefs: remove dependency on grpc, containerd, and distribution

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added area/api API status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Mar 21, 2022
@thaJeztah thaJeztah added this to the 21.xx milestone Mar 21, 2022
@thaJeztah thaJeztah force-pushed the errdefs_reduce_client_deps_alternative branch from 462da2c to 47f778d Compare March 21, 2022 11:17
This reverts the changes made in 2a9c987, which
moved the GetHTTPErrorStatusCode() utility to the errdefs package.

While it seemed to make sense at the time to have the errdefs package provide
conversion both from HTTP status codes errdefs and the reverse, a side-effect
of the move was that the errdefs package now had a dependency on various external
modules, to handle conversio of errors coming from those sub-systems, such as;

- github.com/containerd/containerd
- github.com/docker/distribution
- google.golang.org/grpc

This patch moves the conversion from (errdef-) errors to HTTP status-codes to a
 api/server/httpstatus package, which is only used by the API server, and should
not be needed by client-code using the errdefs package.

The MakeErrorHandler() utility was moved to the API server itself, as that's the
only place it's used. While the same applies to the GetHTTPErrorStatusCode func,
I opted for keeping that in its own package for a slightly cleaner interface.

Why not move it into the api/server/httputils package?

The api/server/httputils package is also imported in the client package, which
uses the httputils.ParseForm() and httputils.HijackConnection() functions as
part of the TestTLSCloseWriter() test. While this is only used in tests, I
wanted to avoid introducing the indirect depdencencies outside of the api/server
code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the errdefs_reduce_client_deps_alternative branch from 47f778d to e82b7b2 Compare March 21, 2022 11:22
@dims
Copy link
Contributor

dims commented Mar 21, 2022

LGTM thanks @thaJeztah

@thaJeztah
Copy link
Member Author

Thanks for reviewing, @dims!

@cpuguy83 @ndeloof @rumpl PTAL

Failure is unrelated (known flaky test); #39352 I'll kick CI again;

=== RUN   TestDockerSuite/TestRunInteractiveWithRestartPolicy
    docker_cli_run_test.go:1795: assertion failed: 
        Command:  d:\CI\PR-43399\2\binary\docker.exe run -i --name test-inter-restart --restart=always busybox sh
        ExitCode: 0
        Stdout:   
        Stderr:   
        
        Failures:
        ExitCode was 0 expected 11
    --- FAIL: TestDockerSuite/TestRunInteractiveWithRestartPolicy (4.71s)

@thaJeztah thaJeztah requested a review from cpuguy83 March 21, 2022 13:26
@thaJeztah
Copy link
Member Author

✅ all green now 👍

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@thaJeztah
Copy link
Member Author

Gonna take a plunge and bring this one in 👍. Thanks for review, everyone!

@thaJeztah thaJeztah merged commit 301eba7 into moby:master Mar 22, 2022
@thaJeztah thaJeztah deleted the errdefs_reduce_client_deps_alternative branch March 22, 2022 10:05
@dims
Copy link
Contributor

dims commented Mar 22, 2022

thanks a ton @thaJeztah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants