Apply fsGroup when accessMode is ReadWriteOncePod

This commit is contained in:
Hemant Kumar 2024-10-21 17:14:33 -04:00
parent 81ce66f059
commit 1e7b4406a3
4 changed files with 13 additions and 3 deletions

View File

@ -423,7 +423,7 @@ const (
// ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined
// to determine if the volume ownership and permissions
// should be modified. If a fstype is defined and the volume's access mode
// contains ReadWriteOnce, then the defined fsGroup will be applied.
// contains ReadWriteOnce or ReadWriteOncePod, then the defined fsGroup will be applied.
// This mode should be defined if it's expected that the
// fsGroup may need to be modified depending on the pod's SecurityPolicy.
// This is the default behavior if no other FSGroupPolicy is defined.

View File

@ -860,6 +860,15 @@ func TestMounterSetUpWithFSGroup(t *testing.T) {
setFsGroup: true,
fsGroup: 3000,
},
{
name: "fstype, fsgroup, RWOP provided (should apply fsgroup)",
accessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOncePod,
},
fsType: "ext4",
setFsGroup: true,
fsGroup: 3000,
},
{
name: "fstype, fsgroup, RWO provided, FSGroupPolicy ReadWriteOnceWithFSType (should apply fsgroup)",
accessModes: []corev1.PersistentVolumeAccessMode{

View File

@ -134,7 +134,8 @@ func hasReadWriteOnce(modes []api.PersistentVolumeAccessMode) bool {
return false
}
for _, mode := range modes {
if mode == api.ReadWriteOnce {
if mode == api.ReadWriteOnce ||
mode == api.ReadWriteOncePod {
return true
}
}

View File

@ -433,7 +433,7 @@ const (
// ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined
// to determine if the volume ownership and permissions
// should be modified. If a fstype is defined and the volume's access mode
// contains ReadWriteOnce, then the defined fsGroup will be applied.
// contains ReadWriteOnce or ReadWriteOncePod, then the defined fsGroup will be applied.
// This mode should be defined if it's expected that the
// fsGroup may need to be modified depending on the pod's SecurityPolicy.
// This is the default behavior if no other FSGroupPolicy is defined.