Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for devAttribs #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ 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 |

**Notice**

- 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.

Expand Down
3 changes: 3 additions & 0 deletions pkg/driver/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -156,6 +158,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
SourceSnapshotId: srcSnapshotId,
SourceVolumeId: srcVolumeId,
Protocol: protocol,
DevAttribs: devAttribs,
}

// idempotency
Expand Down
17 changes: 17 additions & 0 deletions pkg/dsm/service/dsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,30 @@ 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,
Description: spec.LunDescription,
Location: spec.Location,
Size: spec.Size,
Type: lunType,
DevAttribs: devAttribs,
}

log.Debugf("LunCreate spec: %v", lunSpec)
Expand Down
1 change: 1 addition & 0 deletions pkg/models/dsm_req_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type CreateK8sVolumeSpec struct {
SourceSnapshotId string
SourceVolumeId string
Protocol string
DevAttribs string
}

type K8sVolumeRespSpec struct {
Expand Down