Skip to content

Commit 97b600d

Browse files
authored
Merge pull request #456 from andyzhangx/ephemeralVolMountOptions
feat: add mountOptions for inline volume
2 parents b82b127 + 695f865 commit 97b600d

File tree

10 files changed

+31
-12
lines changed

10 files changed

+31
-12
lines changed

deploy/example/e2e_usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spec:
9292
csi:
9393
driver: blob.csi.azure.com
9494
readOnly: false
95-
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
95+
volumeHandle: unique-volumeid # make sure this volumeid is unique in the cluster
9696
volumeAttributes:
9797
containerName: EXISTING_CONTAINER_NAME
9898
nodeStageSecretRef:

deploy/example/nginx-blobfuse-inline-volume.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ spec:
2323
volumeAttributes:
2424
containerName: EXISTING_CONTAINER_NAME
2525
secretName: azure-secret
26+
mountOptions: "-o allow_other --file-cache-timeout-in-seconds=120"

deploy/example/pv-blobfuse-auth.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ spec:
1515
csi:
1616
driver: blob.csi.azure.com
1717
readOnly: false
18-
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
18+
# make sure this volumeid is unique in the cluster
19+
# `#` is not allowed in self defined volumeHandle
20+
volumeHandle: unique-volumeid
1921
volumeAttributes:
2022
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
2123
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME

deploy/example/pv-blobfuse-csi-keyvault.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ spec:
1212
csi:
1313
driver: blob.csi.azure.com
1414
readOnly: false
15-
volumeHandle: arbitrary-volumeid
15+
# make sure this volumeid is unique in the cluster
16+
# `#` is not allowed in self defined volumeHandle
17+
volumeHandle: unique-volumeid
1618
volumeAttributes:
1719
containerName: EXISTING_CONTAINER_NAME
1820
storageAccountName: EXISTING_STORAGE_ACCOUNT_NAME

deploy/example/pv-blobfuse-csi.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ spec:
1515
csi:
1616
driver: blob.csi.azure.com
1717
readOnly: false
18-
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
18+
# make sure this volumeid is unique in the cluster
19+
# `#` is not allowed in self defined volumeHandle
20+
volumeHandle: unique-volumeid
1921
volumeAttributes:
2022
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
2123
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME

deploy/example/pv-blobfuse-nfs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ spec:
1212
csi:
1313
driver: blob.csi.azure.com
1414
readOnly: false
15-
volumeHandle: uniqe-volumeid # make sure this volumeid is unique in the cluster
15+
# make sure this volumeid is unique in the cluster
16+
# `#` is not allowed in self defined volumeHandle
17+
volumeHandle: unique-volumeid
1618
volumeAttributes:
1719
resourceGroup: EXISTING_RESOURCE_GROUP_NAME
1820
storageAccount: EXISTING_STORAGE_ACCOUNT_NAME

pkg/blob/blob.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ const (
6666
keyVaultSecretNameField = "keyvaultsecretname"
6767
keyVaultSecretVersionField = "keyvaultsecretversion"
6868
storageAccountNameField = "storageaccountname"
69+
ephemeralField = "csi.storage.k8s.io/ephemeral"
70+
podNamespaceField = "csi.storage.k8s.io/pod.namespace"
71+
mountOptionsField = "mountoptions"
6972
falseValue = "false"
7073
trueValue = "true"
7174
defaultSecretAccountName = "azurestorageaccountname"
@@ -270,9 +273,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
270273
case secretNamespaceField:
271274
secretNamespace = v
272275
case getAccountKeyFromSecretField:
273-
if v == trueValue {
274-
getAccountKeyFromSecret = true
275-
}
276+
getAccountKeyFromSecret = strings.EqualFold(v, trueValue)
276277
case "azurestorageauthtype":
277278
authEnv = append(authEnv, "AZURE_STORAGE_AUTH_TYPE="+v)
278279
case "azurestorageidentityclientid":

pkg/blob/controllerserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
9393
case secretNamespaceField:
9494
secretNamespace = v
9595
case storeAccountKeyField:
96-
if v == falseValue {
96+
if strings.EqualFold(v, falseValue) {
9797
storeAccountKey = false
9898
}
9999
case pvcNamespaceKey:

pkg/blob/nodeserver.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
6969
}
7070

7171
context := req.GetVolumeContext()
72-
if context != nil && context["csi.storage.k8s.io/ephemeral"] == trueValue {
73-
context[secretNamespaceField] = context["csi.storage.k8s.io/pod.namespace"]
72+
if context != nil && strings.EqualFold(context[ephemeralField], trueValue) {
73+
context[secretNamespaceField] = context[podNamespaceField]
7474
// only get storage account from secret
7575
context[getAccountKeyFromSecretField] = trueValue
7676
context[storageAccountField] = ""
@@ -210,7 +210,8 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
210210
attrib := req.GetVolumeContext()
211211
secrets := req.GetSecrets()
212212

213-
var serverAddress, storageEndpointSuffix, protocol string
213+
var serverAddress, storageEndpointSuffix, protocol, ephemeralVolMountOptions string
214+
var ephemeralVol bool
214215
for k, v := range attrib {
215216
switch strings.ToLower(k) {
216217
case serverNameField:
@@ -219,6 +220,10 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
219220
protocol = v
220221
case storageEndpointSuffixField:
221222
storageEndpointSuffix = v
223+
case ephemeralField:
224+
ephemeralVol = strings.EqualFold(v, trueValue)
225+
case mountOptionsField:
226+
ephemeralVolMountOptions = v
222227
}
223228
}
224229

@@ -263,6 +268,9 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
263268

264269
// Get mountOptions that the volume will be formatted and mounted with
265270
mountOptions := util.JoinMountOptions(mountFlags, []string{"--use-https=true"})
271+
if ephemeralVol {
272+
mountOptions = util.JoinMountOptions(mountOptions, []string{ephemeralVolMountOptions})
273+
}
266274

267275
// set different tmp-path with time info
268276
tmpPath := fmt.Sprintf("%s/%s#%d", "/mnt", volumeID, time.Now().Unix())

test/e2e/testsuites/testsuites.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ func (t *TestPod) SetupInlineVolume(name, mountPath, secretName, containerName s
545545
"secretName": secretName,
546546
"secretNamespace": "default",
547547
"containerName": containerName,
548+
"mountOptions": "-o allow_other --file-cache-timeout-in-seconds=240",
548549
},
549550
ReadOnly: to.BoolPtr(readOnly),
550551
},

0 commit comments

Comments
 (0)