Repository navigation
mountutil: apply default propagation to shorthand bind mounts - #5366
Conversation
|
|
||
| options, res.Opts, err = getVolumeOptions(src, res.Type, rawOpts, ociRuntime) | ||
| // Bind mounts need default options even when the mode is omitted. | ||
| if res.Type == Bind || len(split) == 3 { |
There was a problem hiding this comment.
We can remove the if condition. The getVolumeOptions has a default which gets applied.
| @@ -128,13 +128,13 @@ func ProcessFlagV(s string, volStore volumestore.VolumeStore, createDir bool, oc | |||
| AnonymousVolume: volSpec.AnonymousVolume, | |||
There was a problem hiding this comment.
Can we add the failed case as integ test.
|
|
||
| func TestRunShorthandBindMountPropagation(t *testing.T) { | ||
| testCase := nerdtest.Setup() | ||
| testCase.Require = require.All(nerdtest.Rootful, require.Not(nerdtest.Docker)) |
There was a problem hiding this comment.
The test creates a shared bind mount on the host, so I’ll keep the rootful requirement. Linux Docker Engine supports the propagation modes this test checks. I’ll remove the Docker exclusion and verify the test against the Docker target.
| github.com/moby/moby/api v1.57.0 // indirect | ||
| //gomodjail:unconfined | ||
| github.com/moby/sys/mountinfo v0.7.3 // indirect | ||
| github.com/moby/sys/mountinfo v0.7.3 |
There was a problem hiding this comment.
Direct dependencies have to be moved to the first require() block
There was a problem hiding this comment.
Thanks, I’ll move github.com/moby/sys/mountinfo to the first require block, next to github.com/moby/sys/mount, and keep the existing gomodjail:unconfined annotation.
|
Please squash the commits |
Parse bind mount options even when the mode is omitted so two-field volume specs use the same default propagation as other bind mount forms. Cover shorthand bind mounts with absolute and relative source paths. Signed-off-by: qwe962 <1903740562@qq.com>
8b549d8 to
ff4b45a
Compare
|
Fixes #5349
Summary
nerdctl run -v SRC:DSTskips volume option parsing when the mode is omitted. On Linux, this can cause the bind mount to inherit shared propagation when another mount in the same container requestsrshared.Use the existing option parser for shorthand bind mounts so they get the default
rprivatepropagation. Cover both absolute and relative source paths inTestProcessFlagV.Testing
pkg/mountutilandpkg/cmd/containerpassed on Linux./proc/self/mountinfo, the shorthand mount was shared on the baseline and private with this patch. The mount explicitly configured withrsharedremained shared in all five cases.