-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Implement support for mount options in PVs #41906
Implement support for mount options in PVs #41906
Conversation
Let's just add options to ReadWriteMany volume types (e.g. nfs and glusterfs) for now, and wait till provisioner is able to provision volumes and format into a desired fs type. Otherwise, PD/EBS/Cinder/etc volumes could be formatted into either xfs or extX, the mount options won't be meaningful if fs type mismatches. |
@rootfs can you elaborate more? For attachable volume types - if file system on volume source and actual file system on device doesn't match - then mounting itself will fail regardless of supplied mount options. The formatting is only attempted when device is not formatted to any file system type. And in that case - whatever mounting options specified in PV should work. |
5bba0f4
to
502f971
Compare
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.
As discussed offline, let's switch to annotation and target beta for 1.6
pkg/volume/volume.go
Outdated
@@ -121,6 +121,9 @@ type Mounter interface { | |||
SetUpAt(dir string, fsGroup *int64) error | |||
// GetAttributes returns the attributes of the mounter. | |||
GetAttributes() Attributes | |||
|
|||
// SupportsMountOption returns if volume plugins support Mount options |
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.
nit: Comment could be more descriptive =) Interface method comments should be descriptive enough that it is very clear to someone new coming in trying to implement it what they need to do (without having to look at other implementations).
@@ -383,6 +383,8 @@ func (og *operationGenerator) GenerateMountVolumeFunc( | |||
newMounterErr) | |||
} | |||
|
|||
checkMountOptionSupport(og, volumeToMount, volumeMounter) |
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 think error handling should be explicit: where possible, we should avoid silently swallowing a user's intention and, instead, explicitly fail their request to indicate that we are not doing what was asked and tell them what they can do to rectify it. So I would prefer to fail the mount call here if these options are passed in and the volume doesn't support it.
Additionally, I would add validation at API object creation time, if that is not too painful.
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.
will do.
@@ -354,3 +354,29 @@ func UnmountViaEmptyDir(dir string, host VolumeHost, volName string, volSpec Spe | |||
} | |||
return wrapped.TearDownAt(dir) | |||
} | |||
|
|||
// MountOptionFromSpec extracts and joins mount options from volume spec with supplied options | |||
func MountOptionFromSpec(spec *Spec, options ...string) []string { |
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.
Please add unit tests for these methods.
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.
done
pkg/volume/util.go
Outdated
|
||
// JoinMountOptions joins mount options eliminating duplicates | ||
func JoinMountOptions(userOptions []string, systemOptions []string) []string { | ||
allMountOptions := map[string]string{} |
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.
Really what you need here is a set not a map. Maybe use https://github.com/kubernetes/kubernetes/tree/master/pkg/util/sets for clarity.
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.
fixed
b69e96b
to
82f1c8e
Compare
what happens with this change if it is not ready before 1.6 freeze? will it be pushed to 1.7? |
@humblec there is no need of that now. We got rid of whitelisting requirements. Admins can specify whatever they want in |
9dc1db6
to
3e0e702
Compare
9306dcc
to
af8fed3
Compare
Thanks, lgtm from API side |
Also updated release notes etc to reflect new |
af8fed3
to
f4759a7
Compare
I had to rebase this PR to accommodate master changes. cc @saad-ali @smarterclayton |
@k8s-bot test this |
Add support for mount options via annotations on PVs
f4759a7
to
2d3008f
Compare
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: gnufied, k8s-merge-robot, saad-ali, smarterclayton Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue |
Automatic merge from submit-queue Implement support for mount options in PVs **What this PR does / why we need it**: This PR implements support for mount options in PersistentVolume via `volume.beta.kubernetes.io/mount-options` annotation. **Which issue this PR fixes** Fixes kubernetes/enhancements#168 **Release note**: ``` Enable additional, custom mount options to be passed to PersistentVolume objects via volume.beta.kubernetes.io/mount-options annotation. ```
What this PR does / why we need it:
This PR implements support for mount options in PersistentVolume via
volume.beta.kubernetes.io/mount-options
annotation.Which issue this PR fixes
Fixes kubernetes/enhancements#168
Release note: