@@ -142,11 +142,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
142
142
return nil , fmt .Errorf ("%s does not support block volume provisioning" , a .plugin .GetPluginName ())
143
143
}
144
144
145
- var sku , resourceGroup , location , account string
145
+ var sku , resourceGroup , location , account , shareName string
146
146
147
- // File share name has a length limit of 63, and it cannot contain two consecutive '-'s.
148
- name := util .GenerateVolumeName (a .options .ClusterName , a .options .PVName , 63 )
149
- name = strings .Replace (name , "--" , "-" , - 1 )
150
147
capacity := a .options .PVC .Spec .Resources .Requests [v1 .ResourceName (v1 .ResourceStorage )]
151
148
requestGiB := int (volumehelpers .RoundUpToGiB (capacity ))
152
149
secretNamespace := a .options .PVC .Namespace
@@ -164,6 +161,8 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
164
161
secretNamespace = v
165
162
case "resourcegroup" :
166
163
resourceGroup = v
164
+ case "sharename" :
165
+ shareName = v
167
166
default :
168
167
return nil , fmt .Errorf ("invalid option %q for volume plugin %s" , k , a .plugin .GetPluginName ())
169
168
}
@@ -173,12 +172,18 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
173
172
return nil , fmt .Errorf ("claim.Spec.Selector is not supported for dynamic provisioning on Azure file" )
174
173
}
175
174
175
+ if shareName == "" {
176
+ // File share name has a length limit of 63, and it cannot contain two consecutive '-'s.
177
+ name := util .GenerateVolumeName (a .options .ClusterName , a .options .PVName , 63 )
178
+ shareName = strings .Replace (name , "--" , "-" , - 1 )
179
+ }
180
+
176
181
// when use azure file premium, account kind should be specified as FileStorage
177
182
accountKind := string (storage .StorageV2 )
178
183
if strings .HasPrefix (strings .ToLower (sku ), "premium" ) {
179
184
accountKind = string (storage .FileStorage )
180
185
}
181
- account , key , err := a .azureProvider .CreateFileShare (name , account , sku , accountKind , resourceGroup , location , requestGiB )
186
+ account , key , err := a .azureProvider .CreateFileShare (shareName , account , sku , accountKind , resourceGroup , location , requestGiB )
182
187
if err != nil {
183
188
return nil , err
184
189
}
@@ -206,7 +211,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
206
211
PersistentVolumeSource : v1.PersistentVolumeSource {
207
212
AzureFile : & v1.AzureFilePersistentVolumeSource {
208
213
SecretName : secretName ,
209
- ShareName : name ,
214
+ ShareName : shareName ,
210
215
SecretNamespace : & secretNamespace ,
211
216
},
212
217
},
0 commit comments