volume: remove the short RRO forms in favor of the long forms

"ro-non-recursive", "ro-force-recursive", and "rro" are
now removed from the legacy mount API.

CLI may still support them via the new mount API (if we want).

Follow-up to PR 45278

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2023-06-29 08:41:36 +09:00
parent 49dce504bf
commit 483a1933a2
No known key found for this signature in database
GPG key ID: 49524C6F9F638F1A
4 changed files with 21 additions and 61 deletions

View file

@ -480,7 +480,6 @@ func TestContainerBindMountRecursivelyReadOnly(t *testing.T) {
ReadOnlyNonRecursive: true,
Propagation: mounttypes.PropagationRPrivate,
}
nonRecursiveAsStr := nonRecursive.Source + ":" + nonRecursive.Target + ":ro-non-recursive,rprivate"
// Force recursive
forceRecursive := ro
@ -488,7 +487,6 @@ func TestContainerBindMountRecursivelyReadOnly(t *testing.T) {
ReadOnlyForceRecursive: true,
Propagation: mounttypes.PropagationRPrivate,
}
forceRecursiveAsStr := forceRecursive.Source + ":" + forceRecursive.Target + ":ro-force-recursive,rprivate"
ctx := context.Background()
client := testEnv.APIClient()
@ -498,13 +496,11 @@ func TestContainerBindMountRecursivelyReadOnly(t *testing.T) {
container.Run(ctx, t, client, container.WithBindRaw(roAsStr), container.WithCmd(roVerifier...)),
container.Run(ctx, t, client, container.WithMount(nonRecursive), container.WithCmd(nonRecursiveVerifier...)),
container.Run(ctx, t, client, container.WithBindRaw(nonRecursiveAsStr), container.WithCmd(nonRecursiveVerifier...)),
}
if rroSupported {
containers = append(containers,
container.Run(ctx, t, client, container.WithMount(forceRecursive), container.WithCmd(forceRecursiveVerifier...)),
container.Run(ctx, t, client, container.WithBindRaw(forceRecursiveAsStr), container.WithCmd(forceRecursiveVerifier...)),
)
}

View file

@ -198,7 +198,7 @@ func (p *linuxParser) ReadWrite(mode string) bool {
}
for _, o := range strings.Split(mode, ",") {
if o == "ro" || strings.HasPrefix(o, "ro-") || o == "rro" {
if o == "ro" {
return false
}
}
@ -266,24 +266,6 @@ func (p *linuxParser) ParseMountRaw(raw, volumeDriver string) (*MountPoint, erro
}
}
for _, m := range strings.Split(mode, ",") {
m = strings.TrimSpace(m)
if strings.HasPrefix(m, "ro-") || m == "rro" {
if spec.Type != mount.TypeBind {
return nil, fmt.Errorf("mount mode %q requires a bind mount: %w", mode, errInvalidSpec(raw))
}
if spec.BindOptions == nil {
spec.BindOptions = &mount.BindOptions{}
}
switch m {
case "ro-non-recursive":
spec.BindOptions.ReadOnlyNonRecursive = true
case "ro-force-recursive", "rro":
spec.BindOptions.ReadOnlyForceRecursive = true
}
}
}
mp, err := p.parseMountSpec(spec, false)
if mp != nil {
mp.Mode = mode
@ -353,9 +335,6 @@ func (p *linuxParser) ParseVolumesFrom(spec string) (string, string, error) {
if !linuxValidMountMode(mode) {
return "", "", errInvalidMode(mode)
}
if strings.HasPrefix(mode, "ro-") || mode == "rro" {
return "", "", fmt.Errorf("mount mode %q is not supported for volumes-from mounts: %w", mode, errInvalidMode(mode))
}
// For now don't allow propagation properties while importing
// volumes from data container. These volumes will inherit
// the same propagation property as of the original volume

View file

@ -99,30 +99,25 @@ func TestLinuxParseMountRaw(t *testing.T) {
func TestLinuxParseMountRawSplit(t *testing.T) {
cases := []struct {
bind string
driver string
expType mount.Type
expDest string
expSource string
expName string
expDriver string
expRW bool
expNonRRO bool
expForceRRO bool
fail bool
bind string
driver string
expType mount.Type
expDest string
expSource string
expName string
expDriver string
expRW bool
fail bool
}{
{"/tmp:/tmp1", "", mount.TypeBind, "/tmp1", "/tmp", "", "", true, false, false, false},
{"/tmp:/tmp2:ro", "", mount.TypeBind, "/tmp2", "/tmp", "", "", false, false, false, false},
{"/tmp:/tmp3:rw", "", mount.TypeBind, "/tmp3", "/tmp", "", "", true, false, false, false},
{"/tmp:/tmp4:foo", "", mount.TypeBind, "", "", "", "", false, false, false, true},
{"/tmp:/tmp5:ro-non-recursive", "", mount.TypeBind, "/tmp5", "/tmp", "", "", false, true, false, false},
{"/tmp:/tmp6:ro-force-recursive,rprivate", "", mount.TypeBind, "/tmp6", "/tmp", "", "", false, false, true, false},
{"/tmp:/tmp7:rro", "", mount.TypeBind, "/tmp7", "/tmp", "", "", false, false, true, false},
{"name:/named1", "", mount.TypeVolume, "/named1", "", "name", "", true, false, false, false},
{"name:/named2", "external", mount.TypeVolume, "/named2", "", "name", "external", true, false, false, false},
{"name:/named3:ro", "local", mount.TypeVolume, "/named3", "", "name", "local", false, false, false, false},
{"local/name:/tmp:rw", "", mount.TypeVolume, "/tmp", "", "local/name", "", true, false, false, false},
{"/tmp:tmp", "", mount.TypeBind, "", "", "", "", true, false, false, true},
{"/tmp:/tmp1", "", mount.TypeBind, "/tmp1", "/tmp", "", "", true, false},
{"/tmp:/tmp2:ro", "", mount.TypeBind, "/tmp2", "/tmp", "", "", false, false},
{"/tmp:/tmp3:rw", "", mount.TypeBind, "/tmp3", "/tmp", "", "", true, false},
{"/tmp:/tmp4:foo", "", mount.TypeBind, "", "", "", "", false, true},
{"name:/named1", "", mount.TypeVolume, "/named1", "", "name", "", true, false},
{"name:/named2", "external", mount.TypeVolume, "/named2", "", "name", "external", true, false},
{"name:/named3:ro", "local", mount.TypeVolume, "/named3", "", "name", "local", false, false},
{"local/name:/tmp:rw", "", mount.TypeVolume, "/tmp", "", "local/name", "", true, false},
{"/tmp:tmp", "", mount.TypeBind, "", "", "", "", true, true},
}
parser := NewLinuxParser()
@ -146,13 +141,6 @@ func TestLinuxParseMountRawSplit(t *testing.T) {
assert.Equal(t, m.Driver, c.expDriver)
assert.Equal(t, m.RW, c.expRW)
assert.Equal(t, m.Type, c.expType)
var nonRRO, forceRRO bool
if m.Spec.BindOptions != nil {
nonRRO = m.Spec.BindOptions.ReadOnlyNonRecursive
forceRRO = m.Spec.BindOptions.ReadOnlyForceRecursive
}
assert.Equal(t, nonRRO, c.expNonRRO)
assert.Equal(t, forceRRO, c.expForceRRO)
})
}
}

View file

@ -13,11 +13,8 @@ var ErrVolumeTargetIsRoot = errors.New("invalid specification: destination can't
// read-write modes
var rwModes = map[string]bool{
"rw": true,
"ro": true, // attempts recursive read-only if possible
"ro-non-recursive": true, // makes the mount non-recursively read-only, but still leaves the mount recursive
"ro-force-recursive": true, // raises an error if the mount cannot be made recursively read-only
"rro": true, // alias for ro-force-recursive
"rw": true,
"ro": true, // attempts recursive read-only if possible
}
// Parser represents a platform specific parser for mount expressions