Skip to content

Commit e80fbbb

Browse files
dkharkwalDirk Hohndel
authored andcommitted
Implemented volume UNIX groupID PVC annotation support for NAS and flexgroup
--------- Co-authored-by: Dirk Hohndel <dirk.hohndel@est.te>
1 parent ac83d86 commit e80fbbb

24 files changed

Lines changed: 409 additions & 101 deletions

‎frontend/common/volumes.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func GetVolumeConfig(
153153
SnapshotDir: snapshotDir,
154154
ExportPolicy: collection.GetV(opts, "exportPolicy", ""),
155155
UnixPermissions: collection.GetV(opts, "unixPermissions", ""),
156+
UnixGroupID: collection.GetV(opts, "unixGroupID", ""),
156157
BlockSize: collection.GetV(opts, "blocksize", ""),
157158
Qos: collection.GetV(opts, "qos", ""),
158159
QosType: collection.GetV(opts, "type", ""),

‎frontend/csi/controller_helpers/kubernetes/config.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656
AnnSnapshotReserve = prefix + "/snapshotReserve"
5757
AnnSnapshotDir = prefix + "/snapshotDirectory"
5858
AnnUnixPermissions = prefix + "/unixPermissions"
59+
AnnUnixGroupID = prefix + "/unixGroupID"
5960
AnnExportPolicy = prefix + "/exportPolicy"
6061
AnnBlockSize = prefix + "/blockSize"
6162
AnnFileSystem = prefix + "/fileSystem"

‎frontend/csi/controller_helpers/kubernetes/helper.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ func getVolumeConfig(
925925
SnapshotDir: snapshotDirAnn,
926926
ExportPolicy: getAnnotation(annotations, AnnExportPolicy),
927927
UnixPermissions: getAnnotation(annotations, AnnUnixPermissions),
928+
UnixGroupID: getAnnotation(annotations, AnnUnixGroupID),
928929
StorageClass: storageClass.Name,
929930
BlockSize: getAnnotation(annotations, AnnBlockSize),
930931
FileSystem: getAnnotation(annotations, AnnFileSystem),

‎frontend/csi/controller_helpers/kubernetes/helper_test.go‎

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,17 @@ func TestProcessPVCAnnotations(t *testing.T) {
352352

353353
func TestGetVolumeConfig(t *testing.T) {
354354
tests := []struct {
355-
name string
356-
pvc *v1.PersistentVolumeClaim
357-
volumeName string
358-
size resource.Quantity
359-
annotations map[string]string
360-
storageClass *k8sstoragev1.StorageClass
361-
expectedName string
362-
expectedSize string
363-
expectedAccessMode config.AccessMode
364-
expectedVolumeMode config.VolumeMode
355+
name string
356+
pvc *v1.PersistentVolumeClaim
357+
volumeName string
358+
size resource.Quantity
359+
annotations map[string]string
360+
storageClass *k8sstoragev1.StorageClass
361+
expectedName string
362+
expectedSize string
363+
expectedAccessMode config.AccessMode
364+
expectedVolumeMode config.VolumeMode
365+
expectedUnixGroupID string
365366
}{
366367
{
367368
name: "Basic volume configuration",
@@ -410,6 +411,30 @@ func TestGetVolumeConfig(t *testing.T) {
410411
expectedAccessMode: config.ReadWriteOnce,
411412
expectedVolumeMode: config.VolumeMode(v1.PersistentVolumeBlock),
412413
},
414+
{
415+
name: "Volume with unixGroupID annotation",
416+
pvc: &v1.PersistentVolumeClaim{
417+
ObjectMeta: metav1.ObjectMeta{
418+
Name: "gid-pvc",
419+
Namespace: "default",
420+
UID: "gid-uid",
421+
},
422+
Spec: v1.PersistentVolumeClaimSpec{
423+
AccessModes: []v1.PersistentVolumeAccessMode{
424+
v1.ReadWriteOnce,
425+
},
426+
},
427+
},
428+
volumeName: "gid-volume",
429+
size: resource.MustParse("10Gi"),
430+
annotations: map[string]string{AnnUnixGroupID: "1234"},
431+
storageClass: &k8sstoragev1.StorageClass{},
432+
expectedName: "gid-volume",
433+
expectedSize: "10737418240",
434+
expectedAccessMode: config.ReadWriteOnce,
435+
expectedVolumeMode: config.VolumeMode(v1.PersistentVolumeFilesystem),
436+
expectedUnixGroupID: "1234",
437+
},
413438
}
414439

415440
for _, tt := range tests {
@@ -430,6 +455,7 @@ func TestGetVolumeConfig(t *testing.T) {
430455
assert.Equal(t, tt.expectedSize, result.Size)
431456
assert.Equal(t, tt.expectedAccessMode, result.AccessMode)
432457
assert.Equal(t, tt.expectedVolumeMode, result.VolumeMode)
458+
assert.Equal(t, tt.expectedUnixGroupID, result.UnixGroupID)
433459
})
434460
}
435461
}

‎mocks/mock_storage_drivers/mock_ontap/mock_ontap_rest_interface.go‎

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mocks/mock_storage_drivers/mock_ontap/mock_ontap_zapi_interface.go‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎storage/volume.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type VolumeConfig struct {
2929
SnapshotDir string `json:"snapshotDirectory,omitempty"`
3030
ExportPolicy string `json:"exportPolicy,omitempty"`
3131
UnixPermissions string `json:"unixPermissions,omitempty"`
32+
UnixGroupID string `json:"unixGroupID,omitempty"`
3233
StorageClass string `json:"storageClass,omitempty"`
3334
AccessMode config.AccessMode `json:"accessMode,omitempty"`
3435
VolumeMode config.VolumeMode `json:"volumeMode,omitempty"`

0 commit comments

Comments
 (0)