8000 client: use containerd errdefs checks by vvoland · Pull Request #50019 · moby/moby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

client: use containerd errdefs checks #50019

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

Merged
merged 19 commits into from
May 19, 2025
Merged

Conversation

vvoland
Copy link
Contributor
@vvoland vvoland commented May 16, 2025

@vvoland vvoland self-assigned this May 16, 2025
@vvoland vvoland added area/testing kind/refactor PR's that refactor, or clean-up code labels May 16, 2025
@vvoland vvoland force-pushed the client-cerrdefs branch from b613d7d to 98f768e Compare May 19, 2025 12:16
@vvoland vvoland changed the title client/volume: use containerd cerrdefs client: use containerd errdefs checks May 19, 2025
@vvoland vvoland marked this pull request as ready for review May 19, 2025 13:01
@vvoland vvoland force-pushed the client-cerrdefs branch 2 times, most recently from b23ea21 to 0cc4fcf Compare May 19, 2025 14:57
@vvoland vvoland requested a review from dmcgowan May 19, 2025 17:54
@thaJeztah
Copy link
Member

🙈 needs a rebase

vvoland added 13 commits May 19, 2025 20:32
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
vvoland added 6 commits May 19, 2025 20:36
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@thaJeztah
Copy link
Member

Did a quick rebase; mostly adjacent lines due to #50027 being merged.

Copy link
Member
@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

return "", errdefs.InvalidParameter(fmt.Errorf("invalid platform: %v", err))
return "", fmt.Errorf("%w: invalid platform: %v", cerrdefs.ErrInvalidArgument, err)
Copy link
Member

Choose a reason for hiding this comment

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

Fine for now, but wondering if containerd/errdefs has a good way to type the error without that meaning that the literal invalid argument is part of the message 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I guess something like;

Suggested change
return "", errdefs.InvalidParameter(fmt.Errorf("invalid platform: %v", err))
return "", fmt.Errorf("%w: invalid platform: %v", cerrdefs.ErrInvalidArgument, err)
return "", cerrdefs.ErrInvalidArgument.WithMessage(fmt.Sprint("invalid platform: %v", err))

But that would discard the underlying error (which would be fine for this case, but perhaps not for others 🤔

Copy link
Member

Choose a reason for hiding this comment

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

WithMessage is useful if you "need" a specific message, I would say "invalid argument: invalid platform" would be fine as it goes to more specific still. To keep the original error, multiple %w can be provided as well.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's just that in many cases, adding the literal some-error-type to the message is just noise; at least for the user (these tend to be printed / presented to the user). Where it's relevant to us to determine the error type for code flow, ideally that implementation detail shouldn't have to make its way to the user.

e.g. want to avoid things like;

failed to create container: invalid-argument: network some-network was not found: not-found

@thaJeztah thaJeztah merged commit dfcf955 into moby:master May 19, 2025
141 checks passed
6D47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/refactor PR's that refactor, or clean-up code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0