Merge pull request #83747 from JohnStrunk/csi-fsgroup-fix

Improve efficiency of csiMountMgr.GetAttributes
This commit is contained in:
Kubernetes Prow Robot 2019-10-15 07:11:52 -07:00 committed by GitHub
commit 245189b8a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,6 +67,7 @@ type csiMountMgr struct {
volumeID string
specVolumeID string
readOnly bool
supportsSELinux bool
spec *volume.Spec
pod *api.Pod
podUID types.UID
@ -259,6 +260,11 @@ func (c *csiMountMgr) SetUpAt(dir string, mounterArgs volume.MounterArgs) error
return errors.New(log("mounter.SetupAt failed: %v", err))
}
c.supportsSELinux, err = c.kubeVolHost.GetHostUtil().GetSELinuxSupport(dir)
if err != nil {
klog.V(2).Info(log("error checking for SELinux support: %s", err))
}
// apply volume ownership
// The following logic is derived from https://github.com/kubernetes/kubernetes/issues/66323
// if fstype is "", then skip fsgroup (could be indication of non-block filesystem)
@ -328,18 +334,10 @@ func (c *csiMountMgr) podAttributes() (map[string]string, error) {
}
func (c *csiMountMgr) GetAttributes() volume.Attributes {
path := c.GetPath()
hu := c.kubeVolHost.GetHostUtil()
supportSelinux, err := hu.GetSELinuxSupport(path)
if err != nil {
klog.V(2).Info(log("error checking for SELinux support: %s", err))
// Best guess
supportSelinux = false
}
return volume.Attributes{
ReadOnly: c.readOnly,
Managed: !c.readOnly,
SupportsSELinux: supportSelinux,
SupportsSELinux: c.supportsSELinux,
}
}