From f727d0e3e905964c542e9c60b70204d9b925f3a9 Mon Sep 17 00:00:00 2001 From: Pavel Sorejs Date: Tue, 19 Dec 2023 17:54:49 +0100 Subject: [PATCH] Support for devAttribs --- README.md | 2 ++ pkg/driver/controllerserver.go | 3 +++ pkg/dsm/service/dsm.go | 17 +++++++++++++++++ pkg/models/dsm_req_spec.go | 1 + 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 1f1d8c6..441dcd0 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ Create and apply StorageClasses with the properties you want. | *fsType* | string | The formatting file system of the *PersistentVolumes* when you mount them on the pods. This parameter only works with iSCSI. For SMB, the fsType is always ‘cifs‘. | 'ext4' | iSCSI | | *protocol* | string | The storage backend protocol. Enter ‘iscsi’ to create LUNs or ‘smb‘ to create shared folders on DSM. | 'iscsi' | iSCSI, SMB | | *formatOptions* | string | Additional options/arguments passed to `mkfs.*` command. See a linux manual that corresponds with your FS of choice. | - | iSCSI | + | *devAttribs* | string | Additional device attributes passed to LUN create API. | - | iSCSI | | *csi.storage.k8s.io/node-stage-secret-name* | string | The name of node-stage-secret. Required if DSM shared folder is accessed via SMB. | - | SMB | | *csi.storage.k8s.io/node-stage-secret-namespace* | string | The namespace of node-stage-secret. Required if DSM shared folder is accessed via SMB. | - | SMB | @@ -174,6 +175,7 @@ Create and apply StorageClasses with the properties you want. - If you leave the parameter *location* blank, the CSI driver will choose a volume on DSM with available storage to create the volumes. - All iSCSI volumes created by the CSI driver are Thin Provisioned LUNs on DSM. This will allow you to take snapshots of them. + - `devAttribs` is string of parameters separated with `,`. If the parameter name ends with `-`, the `-` sign is stripped and parameter is explicitly set to `Enabled: 0`. 3. Apply the YAML files to the Kubernetes cluster. diff --git a/pkg/driver/controllerserver.go b/pkg/driver/controllerserver.go index a60ffd5..b240d44 100644 --- a/pkg/driver/controllerserver.go +++ b/pkg/driver/controllerserver.go @@ -132,6 +132,8 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // used only in NodeStageVolume though VolumeContext formatOptions := params["formatOptions"] + devAttribs := params["devAttribs"] + lunDescription := "" if _, ok := params["csi.storage.k8s.io/pvc/name"]; ok { // if the /pvc/name is present, the namespace is present too @@ -156,6 +158,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol SourceSnapshotId: srcSnapshotId, SourceVolumeId: srcVolumeId, Protocol: protocol, + DevAttribs: devAttribs, } // idempotency diff --git a/pkg/dsm/service/dsm.go b/pkg/dsm/service/dsm.go index 122a545..a65719d 100644 --- a/pkg/dsm/service/dsm.go +++ b/pkg/dsm/service/dsm.go @@ -222,6 +222,22 @@ func (service *DsmService) createVolumeByDsm(dsm *webapi.DSM, spec *models.Creat status.Errorf(codes.InvalidArgument, fmt.Sprintf("Unknown volume fs type: %s, location: %s", dsmVolInfo.FsType, spec.Location)) } + devAttribs := []webapi.LunDevAttrib{} + for _, attrib := range strings.Split(spec.DevAttribs,",") { + attrib = strings.TrimSpace(attrib) + if(len(attrib) < 1) { continue } + enabled := 1 + if strings.HasSuffix(attrib, "-") { + attrib = strings.TrimSuffix(attrib,"-") + enabled = 0 + } + + devAttribs = append(devAttribs, webapi.LunDevAttrib{ + DevAttrib: attrib, + Enable: enabled, + }) + } + // 3. Create LUN lunSpec := webapi.LunCreateSpec{ Name: spec.LunName, @@ -229,6 +245,7 @@ func (service *DsmService) createVolumeByDsm(dsm *webapi.DSM, spec *models.Creat Location: spec.Location, Size: spec.Size, Type: lunType, + DevAttribs: devAttribs, } log.Debugf("LunCreate spec: %v", lunSpec) diff --git a/pkg/models/dsm_req_spec.go b/pkg/models/dsm_req_spec.go index 3ef0571..f6ce555 100644 --- a/pkg/models/dsm_req_spec.go +++ b/pkg/models/dsm_req_spec.go @@ -23,6 +23,7 @@ type CreateK8sVolumeSpec struct { SourceSnapshotId string SourceVolumeId string Protocol string + DevAttribs string } type K8sVolumeRespSpec struct {