Skip to content

Commit 4a215e1

Browse files
authored
Merge pull request #160 from andyzhangx/sc-param
feat: add Premium_LRS support
2 parents 322a5b1 + 81c3cd6 commit 4a215e1

13 files changed

+57
-48
lines changed

deploy/example/pv-blobfuse-csi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
csi:
1616
driver: blobfuse.csi.azure.com
1717
readOnly: false
18-
volumeHandle: arbitrary-volumeid
18+
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in whole cluster
1919
volumeAttributes:
2020
containerName: EXISTING_CONTAINER_NAME
2121
nodeStageSecretRef:

deploy/example/storageclass-blobfuse-csi-mountoptions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: blobfuse.csi.azure.com
66
provisioner: blobfuse.csi.azure.com
77
parameters:
8-
skuName: Standard_LRS # available values: Standard_LRS, Standard_GRS, Standard_RAGRS
8+
skuName: Standard_LRS # available values: Standard_LRS, Premium_LRS, Standard_GRS, Standard_RAGRS
99
reclaimPolicy: Retain # if set as "Delete" container would be removed after pvc deletion
1010
volumeBindingMode: Immediate
1111
mountOptions:

deploy/example/storageclass-blobfuse-csi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ metadata:
55
name: blobfuse.csi.azure.com
66
provisioner: blobfuse.csi.azure.com
77
parameters:
8-
skuName: Standard_LRS # available values: Standard_LRS, Standard_GRS, Standard_RAGRS
8+
skuName: Standard_LRS # available values: Standard_LRS, Premium_LRS, Standard_GRS, Standard_RAGRS
99
reclaimPolicy: Retain # if set as "Delete" container would be removed after pvc deletion
1010
volumeBindingMode: Immediate

docs/driver-parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
99
> get a `mountOptions` example [here](../deploy/example/storageclass-blobfuse-csi-mountoptions.yaml)
1010
11-
Name | Meaning | Example | Mandatory | Default value
11+
Name | Meaning | Example | Mandatory | Default value
1212
--- | --- | --- | --- | ---
13-
skuName | blobfuse storage account type (alias: `storageAccountType`) | `Standard_LRS`, `Standard_GRS`, `Standard_RAGRS` | No | `Standard_LRS`
13+
skuName | blobfuse storage account type (alias: `storageAccountType`) | `Standard_LRS`, `Premium_LRS`, `Standard_GRS`, `Standard_RAGRS` | No | `Standard_LRS`
1414
location | specify the location in which blobfuse share will be created | `eastus`, `westus`, etc. | No | if empty, driver will use the same location name as current k8s cluster
1515
resourceGroup | specify the existing resource group name where the container is | existing resource group name | No | if empty, driver will use the same resource group name as current k8s cluster
1616
storageAccount | specify the storage account name in which blobfuse share will be created | STORAGE_ACCOUNT_NAME | No | if empty, driver will find a suitable storage account that matches `skuName` in the same resource group; if a storage account name is provided, it means that storage account must exist otherwise there would be error

pkg/blobfuse/controllerserver.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
7979
resourceGroup = d.cloud.ResourceGroup
8080
}
8181

82-
account, accountKey, err := d.cloud.EnsureStorageAccount(accountName, storageAccountType, string(storage.StorageV2), resourceGroup, location, blobfuseAccountNamePrefix)
82+
accountKind := string(storage.StorageV2)
83+
if strings.EqualFold(storageAccountType, "Premium_LRS") {
84+
accountKind = string(storage.BlockBlobStorage)
85+
}
86+
account, accountKey, err := d.cloud.EnsureStorageAccount(accountName, storageAccountType, accountKind, resourceGroup, location, blobfuseAccountNamePrefix)
8387
if err != nil {
8488
return nil, fmt.Errorf("could not get storage key for storage account %s: %v", accountName, err)
8589
}

test/e2e/driver/blobfuse_csi_driver.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,3 @@ func (d *blobFuseCSIDriver) GetPreProvisionStorageClass(parameters map[string]st
100100
generateName := fmt.Sprintf("%s-%s-pre-provisioned-sc-", namespace, provisioner)
101101
return getStorageClass(generateName, provisioner, parameters, mountOptions, reclaimPolicy, bindingMode, nil)
102102
}
103-
104-
func GetParameters() map[string]string {
105-
return map[string]string{
106-
"skuName": "Standard_LRS",
107-
}
108-
}

test/e2e/dynamic_provisioning_test.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
6767
},
6868
}
6969
test := testsuites.DynamicallyProvisionedCmdVolumeTest{
70-
CSIDriver: testDriver,
71-
Pods: pods,
70+
CSIDriver: testDriver,
71+
Pods: pods,
72+
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
7273
}
7374
test.Run(cs, ns)
7475
})
@@ -94,6 +95,7 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
9495
Cmd: []string{"cat", "/mnt/test-1/data"},
9596
ExpectedString: "hello world\nhello world\n", // pod will be restarted so expect to see 2 instances of string
9697
},
98+
StorageClassParameters: map[string]string{"skuName": "Premium_LRS"},
9799
}
98100
test.Run(cs, ns)
99101
})
@@ -117,8 +119,9 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
117119
},
118120
}
119121
test := testsuites.DynamicallyProvisionedReadOnlyVolumeTest{
120-
CSIDriver: testDriver,
121-
Pods: pods,
122+
CSIDriver: testDriver,
123+
Pods: pods,
124+
StorageClassParameters: map[string]string{"skuName": "Standard_GRS"},
122125
}
123126
test.Run(cs, ns)
124127
})
@@ -153,9 +156,10 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
153156
},
154157
}
155158
test := testsuites.DynamicallyProvisionedCollocatedPodTest{
156-
CSIDriver: testDriver,
157-
Pods: pods,
158-
ColocatePods: true,
159+
CSIDriver: testDriver,
160+
Pods: pods,
161+
ColocatePods: true,
162+
StorageClassParameters: map[string]string{"skuName": "Standard_RAGRS"},
159163
}
160164
test.Run(cs, ns)
161165
})
@@ -170,8 +174,9 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
170174
},
171175
}
172176
test := testsuites.DynamicallyProvisionedReclaimPolicyTest{
173-
CSIDriver: testDriver,
174-
Volumes: volumes,
177+
CSIDriver: testDriver,
178+
Volumes: volumes,
179+
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
175180
}
176181
test.Run(cs, ns)
177182
})
@@ -186,9 +191,10 @@ var _ = ginkgo.Describe("[blobfuse-csi-e2e] Dynamic Provisioning", func() {
186191
},
187192
}
188193
test := testsuites.DynamicallyProvisionedReclaimPolicyTest{
189-
CSIDriver: testDriver,
190-
Volumes: volumes,
191-
Blobfuse: blobfuseDriver,
194+
CSIDriver: testDriver,
195+
Volumes: volumes,
196+
Blobfuse: blobfuseDriver,
197+
StorageClassParameters: map[string]string{"skuName": "Standard_GRS"},
192198
}
193199
test.Run(cs, ns)
194200
})

test/e2e/testsuites/dynamically_provisioned_cmd_volume_tester.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import (
2828
// Waiting for the PV provisioner to create a new PV
2929
// Testing if the Pod(s) Cmd is run with a 0 exit code
3030
type DynamicallyProvisionedCmdVolumeTest struct {
31-
CSIDriver driver.DynamicPVTestDriver
32-
Pods []PodDetails
31+
CSIDriver driver.DynamicPVTestDriver
32+
Pods []PodDetails
33+
StorageClassParameters map[string]string
3334
}
3435

3536
func (t *DynamicallyProvisionedCmdVolumeTest) Run(client clientset.Interface, namespace *v1.Namespace) {
3637
for _, pod := range t.Pods {
37-
tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver)
38+
tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver, t.StorageClassParameters)
3839
// defer must be called here for resources not get removed before using them
3940
for i := range cleanup {
4041
defer cleanup[i]()

test/e2e/testsuites/dynamically_provisioned_collocated_pod_tester.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ import (
2828
// Waiting for the PV provisioner to create a new PV
2929
// Testing if multiple Pod(s) can write simultaneously
3030
type DynamicallyProvisionedCollocatedPodTest struct {
31-
CSIDriver driver.DynamicPVTestDriver
32-
Pods []PodDetails
33-
ColocatePods bool
31+
CSIDriver driver.DynamicPVTestDriver
32+
Pods []PodDetails
33+
ColocatePods bool
34+
StorageClassParameters map[string]string
3435
}
3536

3637
func (t *DynamicallyProvisionedCollocatedPodTest) Run(client clientset.Interface, namespace *v1.Namespace) {
3738
nodeName := ""
3839
for _, pod := range t.Pods {
39-
tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver)
40+
tpod, cleanup := pod.SetupWithDynamicVolumes(client, namespace, t.CSIDriver, t.StorageClassParameters)
4041
if t.ColocatePods && nodeName != "" {
4142
tpod.SetNodeSelector(map[string]string{"name": nodeName})
4243
}

test/e2e/testsuites/dynamically_provisioned_delete_pod_tester.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ import (
2828
// Testing if the Pod can write and read to mounted volumes
2929
// Deleting a pod, and again testing if the Pod can write and read to mounted volumes
3030
type DynamicallyProvisionedDeletePodTest struct {
31-
CSIDriver driver.DynamicPVTestDriver
32-
Pod PodDetails
33-
PodCheck *PodExecCheck
31+
CSIDriver driver.DynamicPVTestDriver
32+
Pod PodDetails
33+
PodCheck *PodExecCheck
34+
StorageClassParameters map[string]string
3435
}
3536

3637
type PodExecCheck struct {
@@ -39,7 +40,7 @@ type PodExecCheck struct {
3940
}
4041

4142
func (t *DynamicallyProvisionedDeletePodTest) Run(client clientset.Interface, namespace *v1.Namespace) {
42-
tDeployment, cleanup := t.Pod.SetupDeployment(client, namespace, t.CSIDriver)
43+
tDeployment, cleanup := t.Pod.SetupDeployment(client, namespace, t.CSIDriver, t.StorageClassParameters)
4344
// defer must be called here for resources not get removed before using them
4445
for i := range cleanup {
4546
defer cleanup[i]()

0 commit comments

Comments
 (0)