api/types/container: remove StateStatus, NewStateStatus#50493
Draft
thaJeztah wants to merge 3 commits intomoby:masterfrom
Draft
api/types/container: remove StateStatus, NewStateStatus#50493thaJeztah wants to merge 3 commits intomoby:masterfrom
thaJeztah wants to merge 3 commits intomoby:masterfrom
Conversation
thaJeztah
commented
Jul 23, 2025
| } | ||
|
|
||
| // StateStatus is used to return container wait results. | ||
| // Implements exec.ExitCode interface. |
Member
Author
There was a problem hiding this comment.
Still double-checking, but the only interface I found was ExitCoder in swarmkit;
moby/vendor/github.com/moby/swarmkit/v2/agent/exec/errors.go
Lines 39 to 43 in 3c8ba15
Which is matched here;
https://github.com/moby/moby/blob/master/vendor/github.com/moby/swarmkit/v2/agent/exec/controller.go#L195-L198
Which doesn't consume the response directly, but uses a exitError to satisfy the interface;
moby/daemon/cluster/executor/container/controller.go
Lines 316 to 324 in afd6487
39cd61f to
ae17cf3
Compare
Member
Author
|
OK; this needs some work. I may go back to my original plan, which was to move the type back to |
These types used to be internal to the container package, but were moved to the API in 1001021. However, the `StateStatus` type is only used internally; it's used as an intermediate type because [`container.State`] contains a sync.Mutex field which would make copying it unsafe (see [moby/moby@2998945]). But, `StateStatus` is not the type returned by the API, which is [`container.WaitResponse`], so now we ended up changing the type yet again in [`containerRouter.postContainersWait`] to convert it to the API response type and marshal it as JSON. The whole process of converting meant that we were also changing error-message strings to errors, and back again. This patch rewrites the backend to use the `container.WaitResponse` type directly. While the type isn't "pretty" (the nested `WaitExitError` should probably be swapped for our common [`types.ErrorResponse`]), at least it removes a confusing type in the API (that's only used internally), and the aforementioned conversions. [`container.State`]: https://github.com/moby/moby/blob/19e79906cb347ab12deaade16bf9d82c41d777c4/container/state.go#L15-L23 [moby/moby@2998945]: moby@2998945 [`container.WaitResponse`]: https://github.com/moby/moby/blob/496c555d7528755a97455f58f99e73ebaf433c2c/api/types/container/wait_response.go#L6-L18 [`containerRouter.postContainersWait`]: https://github.com/moby/moby/blob/496c555d7528755a97455f58f99e73ebaf433c2c/daemon/server/router/container/container_routes.go#L381-L399 [`types.ErrorResponse`]: https://github.com/moby/moby/blob/496c555d7528755a97455f58f99e73ebaf433c2c/api/types/error_response.go#L6-L13 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
ae17cf3 to
f4c43eb
Compare
Member
Author
|
Yeah, this needs more work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These types used to be internal to the container package, but were moved to the API in 1001021.
However, the
StateStatustype is only used internally; it's used as an intermediate type becausecontainer.Statecontains a sync.Mutex field which would make copying it unsafe (see moby@2998945).But,
StateStatusis not the type returned by the API, which iscontainer.WaitResponse, so now we ended up changing the type yet again incontainerRouter.postContainersWaitto convert it to the API response type and marshal it as JSON. The whole process of converting meant that we were also changing error-message strings to errors, and back again.This patch rewrites the backend to use the
container.WaitResponsetype directly. While the type isn't "pretty" (the nestedWaitExitErrorshould probably be swapped for our commontypes.ErrorResponse), at least it removes a confusing type in the API (that's only used internally), and the aforementioned conversions.- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)