-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add equivalent of bind-recursive option to the Mount type class #3242
Open
sairon
wants to merge
1
commit into
docker:main
Choose a base branch
from
sairon:add-mount-bind-recursive-option
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Looks good.
The CLI also does some validation, not sure if we should do those too? 🤔
https://github.com/docker/cli/blob/v25.0.5/opts/mount.go#L183-L196
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.
I'm not sure - some other options are also validated loosely here or not at all, so I'm sticking with that, only added this
InvalidArgument
error for unknown options since we need to enumerate the possible values to map them to mount config options anyway.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.
(disclaimer: I'm a maintainer for the docker CLI, but I'm not very good at Python, or very familiar with existing code in this repository for that matter).
In general (in docker/cli), we try to keep client-side validation "light" where possible, so that we can defer to the API as source of truth (also accounting for situations where only the daemon can fully validate, as well as preventing the CLI from disallowing options that may be supported at some point in future).
That said, for some cases we do some validation on the client side, either where we are sure (or "very confident") certain validation would never change, or for situations where performing the API request (when invalid) would be much more "heavyweight" than a local check, and where a client-side validation can provide a better experience to the user (e.g. producing a more specific error message).
All of the above out of the way, it would be good to verify the behavior when using one of those invalid combinations; the API should validate those, but it'd be good to check if it does, and if so, if the error-message is useful enough to the user to resolve the problem.
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.
Cool, thanks for the insights, @thaJeztah. For me the only concern is this:
I think it's the case for the referred checks done in CLI for the bind options, and the check in Python will have minimal overhead, so I'm fine with adding it here. Let's see what others have to say.
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.
Just to emphasize; If the API already responds with a reasonable error, then I'm (personally) perfectly fine with keeping it light.
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.
Yeah, I mean trade-offs: Validate more means more maintenance. But I'd rather prefer checks in this library than on users side 😅. I guess in our use case it doesn't matter all that much as we won't have this options user controlled, but just use sensible value/combinations. But I agree, it mostly depends on if/how errors are raised if invalid combinations hit the API directly.
On the other hand, since we don't have such validation so far, probably better to skip them too for consistency. 🤷♂️