Skip to content

Commit e97443f

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 946348b commit e97443f

File tree

217 files changed

+21701
-373
lines changed

Some content is hidden

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

217 files changed

+21701
-373
lines changed

Diff for: README.md

+12-1
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

Diff for: artifacts/default-csi-node-crs-airgap.yaml.template

+7-1
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

Diff for: go.mod

+8
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

Diff for: go.sum

+17
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
4747
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
4848
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
4949
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
50+
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
51+
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
5052
github.com/akutz/gofsutil v0.1.2 h1:aCdWrZdxajx8kllNQSKaMDpRJWSE2wcyKNy7eDMXkrI=
5153
github.com/akutz/gofsutil v0.1.2/go.mod h1:09JEF8dR0bTTZMQ1m3/+O1rqQyH2lG1ET34POnpzyxw=
5254
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -113,6 +115,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
113115
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
114116
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
115117
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
118+
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
116119
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
117120
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
118121
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -126,6 +129,9 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
126129
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
127130
github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc=
128131
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
132+
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
133+
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
134+
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
129135
github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8=
130136
github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
131137
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
@@ -237,6 +243,11 @@ github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
237243
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
238244
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
239245
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
246+
github.com/jaypipes/ghw v0.10.0 h1:UHu9UX08Py315iPojADFPOkmjTsNzHj4g4adsNKKteY=
247+
github.com/jaypipes/ghw v0.10.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g=
248+
github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8=
249+
github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk=
250+
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
240251
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
241252
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
242253
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -272,6 +283,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
272283
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
273284
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
274285
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
286+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
275287
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
276288
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
277289
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
@@ -315,6 +327,7 @@ github.com/peterhellberg/link v1.1.0 h1:s2+RH8EGuI/mI4QwrWGSYQCRz7uNgip9BaM04HKu
315327
github.com/peterhellberg/link v1.1.0/go.mod h1:gtSlOT4jmkY8P47hbTc8PTgiDDWpdPbFYl75keYyBB8=
316328
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
317329
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
330+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
318331
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
319332
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
320333
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -528,6 +541,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
528541
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
529542
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
530543
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
544+
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
531545
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
532546
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
533547
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -736,6 +750,7 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
736750
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
737751
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
738752
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
753+
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
739754
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
740755
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
741756
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -760,6 +775,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
760775
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
761776
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
762777
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
778+
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
779+
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
763780
k8s.io/api v0.22.1 h1:ISu3tD/jRhYfSW8jI/Q1e+lRxkR7w9UwQEZ7FgslrwY=
764781
k8s.io/api v0.22.1/go.mod h1:bh13rkTp3F1XEaLGykbyRD2QaTTzPm0e/BMd8ptFONY=
765782
k8s.io/apimachinery v0.22.1 h1:DTARnyzmdHMz7bFWFDDm22AM4pLWTQECMpRTFu2d2OM=

Diff for: manifests/csi-node-crs.yaml

+7-1
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

Diff for: manifests/csi-node-crs.yaml.template

+7-1
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

Diff for: manifests/csi-node.yaml

+7-1
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

Diff for: manifests/csi-node.yaml.template

+7-1
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

Diff for: pkg/csi/controller.go

+36-31
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)