Merge pull request #108662 from dobsonj/issue89290

CSI inline volumes should support fsGroup
This commit is contained in:
Kubernetes Prow Robot 2022-03-14 09:34:10 -07:00 committed by GitHub
commit 9642a1f84b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 12 deletions

View File

@ -404,10 +404,7 @@ func (c *csiMountMgr) supportsFSGroup(fsType string, fsGroup *int64, driverPolic
return false
}
if c.spec.PersistentVolume == nil {
klog.V(4).Info(log("mounter.SetupAt Warning: skipping fsGroup permission change, no access mode available. The volume may only be accessible to root users."))
return false
}
if c.spec.PersistentVolume != nil {
if c.spec.PersistentVolume.Spec.AccessModes == nil {
klog.V(4).Info(log("mounter.SetupAt WARNING: skipping fsGroup, access modes not provided"))
return false
@ -417,6 +414,17 @@ func (c *csiMountMgr) supportsFSGroup(fsType string, fsGroup *int64, driverPolic
return false
}
return true
} else if c.spec.Volume != nil && c.spec.Volume.CSI != nil {
if !utilfeature.DefaultFeatureGate.Enabled(features.CSIInlineVolume) {
klog.V(4).Info(log("mounter.SetupAt WARNING: skipping fsGroup, CSIInlineVolume feature required"))
return false
}
// Inline CSI volumes are always mounted with RWO AccessMode by SetUpAt
return true
}
klog.V(4).Info(log("mounter.SetupAt WARNING: skipping fsGroup, unsupported volume type"))
return false
}
// isDirMounted returns the !notMounted result from IsLikelyNotMountPoint check

View File

@ -1201,6 +1201,24 @@ func Test_csiMountMgr_supportsFSGroup(t *testing.T) {
},
want: true,
},
{
name: "driverPolicy is ReadWriteOnceWithFSTypeFSGroupPolicy with CSI inline volume",
args: args{
fsGroup: new(int64),
fsType: "ext4",
driverPolicy: storage.ReadWriteOnceWithFSTypeFSGroupPolicy,
},
fields: fields{
spec: volume.NewSpecFromVolume(&api.Volume{
VolumeSource: api.VolumeSource{
CSI: &api.CSIVolumeSource{
Driver: testDriver,
},
},
}),
},
want: true,
},
}
for _, tt := range tests {