Merge pull request #9808 from thephoenixofthevoid/issue-9650-fixed

[NO TESTS NEEDED] Fix rootless volume plugins
This commit is contained in:
OpenShift Merge Robot
2021-03-24 17:21:24 -07:00
committed by GitHub
2 changed files with 6 additions and 13 deletions

View File

@ -1577,8 +1577,6 @@ func WithVolumeLabels(labels map[string]string) VolumeCreateOption {
} }
// WithVolumeOptions sets the options of the volume. // WithVolumeOptions sets the options of the volume.
// If the "local" driver has been selected, options will be validated. There are
// currently 3 valid options for the "local" driver - o, type, and device.
func WithVolumeOptions(options map[string]string) VolumeCreateOption { func WithVolumeOptions(options map[string]string) VolumeCreateOption {
return func(volume *Volume) error { return func(volume *Volume) error {
if volume.valid { if volume.valid {
@ -1587,13 +1585,6 @@ func WithVolumeOptions(options map[string]string) VolumeCreateOption {
volume.config.Options = make(map[string]string) volume.config.Options = make(map[string]string)
for key, value := range options { for key, value := range options {
switch key {
case "type", "device", "o", "UID", "GID":
volume.config.Options[key] = value
default:
return errors.Wrapf(define.ErrInvalidArg, "unrecognized volume option %q is not supported with local driver", key)
}
volume.config.Options[key] = value volume.config.Options[key] = value
} }

View File

@ -32,8 +32,10 @@ func (v *Volume) mount() error {
return nil return nil
} }
// We cannot mount volumes as rootless. // We cannot mount 'local' volumes as rootless.
if rootless.IsRootless() { if !v.UsesVolumeDriver() && rootless.IsRootless() {
// This check should only be applied to 'local' driver
// so Volume Drivers must be excluded
return errors.Wrapf(define.ErrRootless, "cannot mount volumes without root privileges") return errors.Wrapf(define.ErrRootless, "cannot mount volumes without root privileges")
} }
@ -137,8 +139,8 @@ func (v *Volume) unmount(force bool) error {
return nil return nil
} }
// We cannot unmount volumes as rootless. // We cannot unmount 'local' volumes as rootless.
if rootless.IsRootless() { if !v.UsesVolumeDriver() && rootless.IsRootless() {
// If force is set, just clear the counter and bail without // If force is set, just clear the counter and bail without
// error, so we can remove volumes from the state if they are in // error, so we can remove volumes from the state if they are in
// an awkward configuration. // an awkward configuration.