mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #108662 from dobsonj/issue89290
CSI inline volumes should support fsGroup
This commit is contained in:
commit
9642a1f84b
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user