Skip to content

Commit 1e7b440

Browse files
committed
Apply fsGroup when accessMode is ReadWriteOncePod
1 parent 81ce66f commit 1e7b440

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

pkg/apis/storage/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ const (
423423
// ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined
424424
// to determine if the volume ownership and permissions
425425
// should be modified. If a fstype is defined and the volume's access mode
426-
// contains ReadWriteOnce, then the defined fsGroup will be applied.
426+
// contains ReadWriteOnce or ReadWriteOncePod, then the defined fsGroup will be applied.
427427
// This mode should be defined if it's expected that the
428428
// fsGroup may need to be modified depending on the pod's SecurityPolicy.
429429
// This is the default behavior if no other FSGroupPolicy is defined.

pkg/volume/csi/csi_mounter_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,15 @@ func TestMounterSetUpWithFSGroup(t *testing.T) {
860860
setFsGroup: true,
861861
fsGroup: 3000,
862862
},
863+
{
864+
name: "fstype, fsgroup, RWOP provided (should apply fsgroup)",
865+
accessModes: []corev1.PersistentVolumeAccessMode{
866+
corev1.ReadWriteOncePod,
867+
},
868+
fsType: "ext4",
869+
setFsGroup: true,
870+
fsGroup: 3000,
871+
},
863872
{
864873
name: "fstype, fsgroup, RWO provided, FSGroupPolicy ReadWriteOnceWithFSType (should apply fsgroup)",
865874
accessModes: []corev1.PersistentVolumeAccessMode{

pkg/volume/csi/csi_util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ func hasReadWriteOnce(modes []api.PersistentVolumeAccessMode) bool {
134134
return false
135135
}
136136
for _, mode := range modes {
137-
if mode == api.ReadWriteOnce {
137+
if mode == api.ReadWriteOnce ||
138+
mode == api.ReadWriteOncePod {
138139
return true
139140
}
140141
}

staging/src/k8s.io/api/storage/v1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ const (
433433
// ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined
434434
// to determine if the volume ownership and permissions
435435
// should be modified. If a fstype is defined and the volume's access mode
436-
// contains ReadWriteOnce, then the defined fsGroup will be applied.
436+
// contains ReadWriteOnce or ReadWriteOncePod, then the defined fsGroup will be applied.
437437
// This mode should be defined if it's expected that the
438438
// fsGroup may need to be modified depending on the pod's SecurityPolicy.
439439
// This is the default behavior if no other FSGroupPolicy is defined.

0 commit comments

Comments
 (0)