Skip to content

Commit be9720b

Browse files
authored
Merge pull request #636 from andyzhangx/namespace-issue
fix: default secretNamespace should be pvc namespace
2 parents cee5012 + 16f8736 commit be9720b

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

docs/driver-parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tags | [tags](https://docs.microsoft.com/en-us/azure/azure-resource-manager/mana
2121
--- | **Following parameters are only for blobfuse** | --- | --- |
2222
storeAccountKey | whether store account key to k8s secret <br><br> Note: <br> `false` means driver would leverage kubelet identity to get account key | `true`,`false` | No | `true`
2323
secretName | specify secret name to store account key | | No |
24-
secretNamespace | specify the namespace of secret to store account key | `default`,`kube-system`, etc | No | `default`
24+
secretNamespace | specify the namespace of secret to store account key | `default`,`kube-system`, etc | No | pvc namespace
2525
isHnsEnabled | enable `Hierarchical namespace` for Azure DataLake storage account | `true`,`false` | No | `false`
2626
--- | **Following parameters are only for NFS protocol** | --- | --- |
2727
mountPermissions | mounted folder permissions | `0777` | No |
@@ -61,7 +61,7 @@ volumeAttributes.containerName | existing container name | existing container na
6161
volumeAttributes.protocol | specify blobfuse mount or NFSv3 mount | `fuse`, `nfs` | No | `fuse`
6262
--- | **Following parameters are only for blobfuse** | --- | --- |
6363
volumeAttributes.secretName | secret name that stores storage account name and key(only applies for SMB) | | No |
64-
volumeAttributes.secretNamespace | secret namespace | `default`,`kube-system`, etc | No | `default`
64+
volumeAttributes.secretNamespace | secret namespace | `default`,`kube-system`, etc | No | pvc namespace
6565
nodeStageSecretRef.name | secret name that stores(check below examples):<br>`azurestorageaccountkey`<br>`azurestorageaccountsastoken`<br>`msisecret`<br>`azurestoragespnclientsecret` | existing Kubernetes secret name | No |
6666
nodeStageSecretRef.namespace | secret namespace | k8s namespace | Yes |
6767
--- | **Following parameters are only for NFS protocol** | --- | --- |

pkg/blob/blob.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
310310
accountSasToken string
311311
secretName string
312312
secretNamespace string
313+
pvcNamespace string
313314
keyVaultURL string
314315
keyVaultSecretName string
315316
keyVaultSecretVersion string
@@ -337,10 +338,7 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
337338
case secretNamespaceField:
338339
secretNamespace = v
339340
case pvcNamespaceKey:
340-
if secretNamespace == "" {
341-
// respect `secretNamespace` field as first priority
342-
secretNamespace = v
343-
}
341+
pvcNamespace = v
344342
case getAccountKeyFromSecretField:
345343
getAccountKeyFromSecret = strings.EqualFold(v, trueValue)
346344
case "azurestorageauthtype":
@@ -369,9 +367,8 @@ func (d *Driver) GetAuthEnv(ctx context.Context, volumeID, protocol string, attr
369367
return rgName, accountName, accountKey, containerName, authEnv, err
370368
}
371369

372-
// backward compatibility, old CSI driver PV does not have secretNamespace field
373370
if secretNamespace == "" {
374-
secretNamespace = "default"
371+
secretNamespace = pvcNamespace
375372
}
376373

377374
if rgName == "" {

pkg/blob/controllerserver.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
6767
if parameters == nil {
6868
parameters = make(map[string]string)
6969
}
70-
var storageAccountType, resourceGroup, location, account, containerName, protocol, customTags, secretName, secretNamespace string
70+
var storageAccountType, resourceGroup, location, account, containerName, protocol, customTags, secretName, secretNamespace, pvcNamespace string
7171
var isHnsEnabled *bool
7272
var vnetResourceGroup, vnetName, subnetName string
7373
// set allowBlobPublicAccess as false by default
@@ -113,10 +113,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
113113
allowBlobPublicAccess = to.BoolPtr(true)
114114
}
115115
case pvcNamespaceKey:
116-
if secretNamespace == "" {
117-
// respect `secretNamespace` field as first priority
118-
secretNamespace = v
119-
}
116+
pvcNamespace = v
120117
case pvcNameKey:
121118
// no op
122119
case pvNameKey:
@@ -147,6 +144,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
147144
resourceGroup = d.cloud.ResourceGroup
148145
}
149146

147+
if secretNamespace == "" {
148+
secretNamespace = pvcNamespace
149+
}
150+
150151
if protocol == "" {
151152
protocol = fuse
152153
}

0 commit comments

Comments
 (0)