Skip to content

Commit 2008b42

Browse files
Support for additional Bus Types
- Adds support for busType: nvme, sata, scsi_paravirtual, scsi_lsi_logic_parallel, scsi_lsi_logic_sas, scsi_buslogic
1 parent 8bd7760 commit 2008b42

File tree

216 files changed

+21661
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+21661
-253
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,21 @@ kubectl apply -f https://raw.githubusercontent.com/vmware/cloud-director-named-d
7878
| Storage Type | Independent Shareable Named Disks of VCD |
7979
|Provisioning|<ul><li>Static Provisioning</li><li>Dynamic Provisioning</li></ul>|
8080
|Access Modes|<ul><li>ReadOnlyMany</li><li>ReadWriteOnce</li></ul>|
81-
|Volume|Block|
81+
|Volume|<ul><li>Block</ul></li>|
8282
|VolumeMode|<ul><li>FileSystem</li></ul>|
8383
|Topology|<ul><li>Static Provisioning: reuses VCD topology capabilities</li><li>Dynamic Provisioning: places disk in the OVDC of the `ClusterAdminUser` based on the StorageProfile specified.</li></ul>|
8484

85+
## Supported Bus Types
86+
| Bus Type | `bustype` Parameter in `StorageClass` |
87+
| :--------- | :----------------------- |
88+
| Paravirtual (SCSI) | `scsi_paravirtual` (default) |
89+
| LSI Logic Parallel (SCSI) | `scsi_lsi_logic_parallel` |
90+
| LSI Logic SAS (SCSI) | `scsi_lsi_logic_sas` |
91+
| Bus Logic (SCSI) | `scsi_buslogic` |
92+
| SATA | `sata` |
93+
| NVME | `nvme` |
94+
95+
8596
## Contributing
8697
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
8798

artifacts/default-csi-node-crs-airgap.yaml.template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ spec:
116116
mountPath: /etc/kubernetes/vcloud
117117
- name: vcloud-basic-auth-volume
118118
mountPath: /etc/kubernetes/vcloud/basic-auth
119+
- mountPath: /run
120+
name: host-run-dir
121+
mountPropagation: "HostToContainer"
119122
volumes:
120123
- name: socket-dir
121124
hostPath:
@@ -147,4 +150,7 @@ spec:
147150
- name: vcloud-basic-auth-volume
148151
secret:
149152
secretName: vcloud-basic-auth
150-
---
153+
- name: host-run-dir
154+
hostPath:
155+
path: /run
156+
type: Directory

go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@ require (
2323
)
2424

2525
require (
26+
github.com/jaypipes/ghw v0.10.0
2627
github.com/onsi/ginkgo v1.16.5
2728
github.com/onsi/gomega v1.19.0
2829
k8s.io/api v0.22.1
2930
k8s.io/apimachinery v0.22.1
3031
)
3132

3233
require (
34+
github.com/StackExchange/wmi v1.2.1 // indirect
3335
github.com/antihax/optional v1.0.0 // indirect
3436
github.com/apparentlymart/go-cidr v1.1.0 // indirect
3537
github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195 // indirect
3638
github.com/davecgh/go-spew v1.1.1 // indirect
3739
github.com/fsnotify/fsnotify v1.6.0 // indirect
40+
github.com/ghodss/yaml v1.0.0 // indirect
3841
github.com/go-logr/logr v0.4.0 // indirect
42+
github.com/go-ole/go-ole v1.2.6 // indirect
3943
github.com/go-openapi/errors v0.20.2 // indirect
4044
github.com/gogo/protobuf v1.3.2 // indirect
4145
github.com/golang/protobuf v1.5.2 // indirect
@@ -45,13 +49,16 @@ require (
4549
github.com/hashicorp/go-version v1.2.0 // indirect
4650
github.com/imdario/mergo v0.3.5 // indirect
4751
github.com/inconshreveable/mousetrap v1.0.0 // indirect
52+
github.com/jaypipes/pcidb v1.0.0 // indirect
4853
github.com/json-iterator/go v1.1.11 // indirect
4954
github.com/kr/pretty v0.2.1 // indirect
5055
github.com/kr/text v0.2.0 // indirect
56+
github.com/mitchellh/go-homedir v1.1.0 // indirect
5157
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5258
github.com/modern-go/reflect2 v1.0.1 // indirect
5359
github.com/nxadm/tail v1.4.8 // indirect
5460
github.com/peterhellberg/link v1.1.0 // indirect
61+
github.com/pkg/errors v0.9.1 // indirect
5562
github.com/pmezard/go-difflib v1.0.0 // indirect
5663
github.com/sirupsen/logrus v1.8.1 // indirect
5764
golang.org/x/net v0.7.0 // indirect
@@ -63,6 +70,7 @@ require (
6370
google.golang.org/protobuf v1.26.0 // indirect
6471
gopkg.in/inf.v0 v0.9.1 // indirect
6572
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
73+
howett.net/plist v1.0.0 // indirect
6674
k8s.io/client-go v0.22.1 // indirect
6775
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 // indirect
6876
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect

go.sum

Lines changed: 95 additions & 4 deletions
Large diffs are not rendered by default.

manifests/csi-node-crs.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ spec:
116116
mountPath: /etc/kubernetes/vcloud
117117
- name: vcloud-basic-auth-volume
118118
mountPath: /etc/kubernetes/vcloud/basic-auth
119+
- mountPath: /run
120+
name: host-run-dir
121+
mountPropagation: "HostToContainer"
119122
volumes:
120123
- name: socket-dir
121124
hostPath:
@@ -147,4 +150,7 @@ spec:
147150
- name: vcloud-basic-auth-volume
148151
secret:
149152
secretName: vcloud-basic-auth
150-
---
153+
- name: host-run-dir
154+
hostPath:
155+
path: /run
156+
type: Directory

manifests/csi-node-crs.yaml.template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ spec:
116116
mountPath: /etc/kubernetes/vcloud
117117
- name: vcloud-basic-auth-volume
118118
mountPath: /etc/kubernetes/vcloud/basic-auth
119+
- mountPath: /run
120+
name: host-run-dir
121+
mountPropagation: "HostToContainer"
119122
volumes:
120123
- name: socket-dir
121124
hostPath:
@@ -147,4 +150,7 @@ spec:
147150
- name: vcloud-basic-auth-volume
148151
secret:
149152
secretName: vcloud-basic-auth
150-
---
153+
- name: host-run-dir
154+
hostPath:
155+
path: /run
156+
type: Directory

manifests/csi-node.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ spec:
111111
mountPath: /etc/kubernetes/vcloud
112112
- name: vcloud-basic-auth-volume
113113
mountPath: /etc/kubernetes/vcloud/basic-auth
114+
- mountPath: /run
115+
name: host-run-dir
116+
mountPropagation: "HostToContainer"
114117
volumes:
115118
- name: socket-dir
116119
hostPath:
@@ -142,4 +145,7 @@ spec:
142145
- name: vcloud-basic-auth-volume
143146
secret:
144147
secretName: vcloud-basic-auth
145-
---
148+
- name: host-run-dir
149+
hostPath:
150+
path: /run
151+
type: Directory

manifests/csi-node.yaml.template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ spec:
111111
mountPath: /etc/kubernetes/vcloud
112112
- name: vcloud-basic-auth-volume
113113
mountPath: /etc/kubernetes/vcloud/basic-auth
114+
- mountPath: /run
115+
name: host-run-dir
116+
mountPropagation: "HostToContainer"
114117
volumes:
115118
- name: socket-dir
116119
hostPath:
@@ -142,4 +145,7 @@ spec:
142145
- name: vcloud-basic-auth-volume
143146
secret:
144147
secretName: vcloud-basic-auth
145-
---
148+
- name: host-run-dir
149+
hostPath:
150+
path: /run
151+
type: Directory

pkg/csi/controller.go

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package csi
88
import (
99
"context"
1010
"fmt"
11+
"math"
12+
1113
"github.com/container-storage-interface/spec/lib/go/csi"
1214
"github.com/vmware/cloud-director-named-disk-csi-driver/pkg/util"
1315
"github.com/vmware/cloud-director-named-disk-csi-driver/pkg/vcdcsiclient"
@@ -16,7 +18,6 @@ import (
1618
"google.golang.org/grpc/codes"
1719
"google.golang.org/grpc/status"
1820
"k8s.io/klog"
19-
"math"
2021
)
2122

2223
const (
@@ -27,7 +28,6 @@ const (
2728

2829
const (
2930
BusTypeParameter = "busType"
30-
BusSubTypeParameter = "busSubType"
3131
StorageProfileParameter = "storageProfile"
3232
FileSystemParameter = "filesystem"
3333
EphemeralVolumeContext = "csi.storage.k8s.io/ephemeral"
@@ -36,15 +36,8 @@ const (
3636
VMFullNameAttribute = "vmID"
3737
DiskUUIDAttribute = "diskUUID"
3838
FileSystemAttribute = "filesystem"
39-
)
40-
41-
var (
42-
// BusTypesFromValues is a map of different possible BusTypes from id to string
43-
BusTypesFromValues = map[string]string{
44-
"5": "IDE",
45-
"6": "SCSI",
46-
"20": "SATA",
47-
}
39+
DefaultFSType = "ext4"
40+
DefaultBusType = "scsi_paravirtual"
4841
)
4942

5043
type controllerServer struct {
@@ -97,7 +90,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context,
9790
}
9891

9992
volumeCapabilities := req.GetVolumeCapabilities()
100-
if volumeCapabilities == nil || len(volumeCapabilities) == 0 {
93+
if len(volumeCapabilities) == 0 { // should omit nil check; len() for []*github.com/container-storage-interface/spec/lib/go/csi.VolumeCapability is defined as zero (S1009)
10194
return nil, status.Error(codes.InvalidArgument, "CreateVolume: VolumeCapabilities should be provided")
10295
}
10396
for _, volumeCapability := range volumeCapabilities {
@@ -117,39 +110,51 @@ func (cs *controllerServer) CreateVolume(ctx context.Context,
117110
klog.Infof("CreateVolume: requesting volume [%s] with size [%d] MiB, shareable [%v]",
118111
diskName, sizeMB, shareable)
119112

120-
busType := vcdcsiclient.VCDBusTypeSCSI
121-
busSubType := vcdcsiclient.VCDBusSubTypeVirtualSCSI
113+
var (
114+
storageProfile string
115+
fsType string
116+
busType string
117+
tuple vcdcsiclient.BusTuple
118+
ok bool
119+
)
122120

123-
storageProfile, _ := req.Parameters[StorageProfileParameter]
121+
if busType, ok = req.Parameters[BusTypeParameter]; !ok {
122+
busType = DefaultBusType
123+
klog.Infof("No parameter [%s] specified for raw disk [%s]. Hence defaulting to [%s].", BusTypeParameter, diskName, DefaultBusType)
124+
}
124125

125-
disk, err := cs.DiskManager.CreateDisk(diskName, sizeMB, busType,
126-
busSubType, cs.DiskManager.ClusterID, storageProfile, shareable)
126+
tuple, ok = vcdcsiclient.BusTypesSet[busType]
127+
if !ok {
128+
return nil, fmt.Errorf("invalid busType: [%s]", busType)
129+
}
127130

131+
if storageProfile, ok = req.Parameters[StorageProfileParameter]; !ok {
132+
klog.Infof("No parameter [%s] specified for raw disk [%s]. ", StorageProfileParameter, diskName)
133+
}
134+
135+
if fsType, ok = req.Parameters[FileSystemParameter]; !ok {
136+
fsType = DefaultFSType
137+
klog.Infof("No parameter [%s] specified for raw disk [%s]. Hence defaulting to [%s].", FileSystemParameter, diskName, DefaultFSType)
138+
}
139+
140+
disk, err := cs.DiskManager.CreateDisk(diskName, sizeMB, tuple.BusType, tuple.BusSubType, "", storageProfile, shareable)
128141
if err != nil {
129142
if rdeErr := cs.DiskManager.AddToErrorSet(util.DiskCreateError, "", diskName, map[string]interface{}{"Detailed Error": err.Error()}); rdeErr != nil {
130143
klog.Errorf("unable to add error [%s] into [CSI.Errors] in RDE [%s], %v", util.DiskCreateError, cs.DiskManager.ClusterID, rdeErr)
131144
}
132-
return nil, fmt.Errorf("unable to create disk [%s] with sise [%d]MB: [%v]",
133-
diskName, sizeMB, err)
145+
return nil, fmt.Errorf("unable to create disk [%s] with size [%d]MB: [%v]", diskName, sizeMB, err)
134146
}
135147
if removeErrorRdeErr := cs.DiskManager.RemoveFromErrorSet(util.DiskCreateError, "", diskName); removeErrorRdeErr != nil {
136148
klog.Errorf("unable to remove error [%s] from [CSI.Errors] in RDE [%s]", util.DiskCreateError, cs.DiskManager.ClusterID)
137149
}
138150
klog.Infof("Successfully created disk [%s] of size [%d]MB", diskName, sizeMB)
139151

140-
attributes := make(map[string]string)
141-
attributes[BusTypeParameter] = BusTypesFromValues[disk.BusType]
142-
attributes[BusSubTypeParameter] = disk.BusSubType
143-
attributes[StorageProfileParameter] = disk.StorageProfile.Name
144-
attributes[DiskIDAttribute] = disk.Id
145-
146-
fsType := ""
147-
ok := false
148-
if fsType, ok = req.Parameters[FileSystemParameter]; !ok {
149-
fsType = "ext4"
150-
klog.Infof("No FS specified for raw disk [%s]. Hence defaulting to [%s].", diskName, fsType)
152+
attributes := map[string]string{
153+
BusTypeParameter: vcdcsiclient.BusSubTypesFromValues[disk.BusSubType], // BusSubType defines better the busType since SATA and NVME share the same ID=20
154+
StorageProfileParameter: disk.StorageProfile.Name,
155+
DiskIDAttribute: disk.Id,
156+
FileSystemParameter: fsType,
151157
}
152-
attributes[FileSystemParameter] = fsType
153158

154159
resp := &csi.CreateVolumeResponse{
155160
Volume: &csi.Volume{

0 commit comments

Comments
 (0)