@@ -435,6 +435,22 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
435
435
GetLatestAccountKey : getLatestAccountKey ,
436
436
}
437
437
438
+ var volumeID string
439
+ requestName := "controller_create_volume"
440
+ if req .GetVolumeContentSource () != nil {
441
+ switch req .VolumeContentSource .Type .(type ) {
442
+ case * csi.VolumeContentSource_Snapshot :
443
+ requestName = "controller_create_volume_from_snapshot"
444
+ case * csi.VolumeContentSource_Volume :
445
+ requestName = "controller_create_volume_from_volume"
446
+ }
447
+ }
448
+ mc := metrics .NewMetricContext (azureFileCSIDriverName , requestName , d .cloud .ResourceGroup , subsID , d .Name )
449
+ isOperationSucceeded := false
450
+ defer func () {
451
+ mc .ObserveOperationWithResult (isOperationSucceeded , VolumeID , volumeID )
452
+ }()
453
+
438
454
var accountKey , lockKey string
439
455
accountName := account
440
456
if len (req .GetSecrets ()) == 0 && accountName == "" {
@@ -522,22 +538,6 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
522
538
RootSquash : rootSquashType ,
523
539
}
524
540
525
- var volumeID string
526
- requestName := "controller_create_volume"
527
- if req .GetVolumeContentSource () != nil {
528
- switch req .VolumeContentSource .Type .(type ) {
529
- case * csi.VolumeContentSource_Snapshot :
530
- requestName = "controller_create_volume_from_snapshot"
531
- case * csi.VolumeContentSource_Volume :
532
- requestName = "controller_create_volume_from_volume"
533
- }
534
- }
535
- mc := metrics .NewMetricContext (azureFileCSIDriverName , requestName , d .cloud .ResourceGroup , subsID , d .Name )
536
- isOperationSucceeded := false
537
- defer func () {
538
- mc .ObserveOperationWithResult (isOperationSucceeded , VolumeID , volumeID )
539
- }()
540
-
541
541
klog .V (2 ).Infof ("begin to create file share(%s) on account(%s) type(%s) subID(%s) rg(%s) location(%s) size(%d) protocol(%s)" , validFileShareName , accountName , sku , subsID , resourceGroup , location , fileShareSize , shareProtocol )
542
542
if err := d .CreateFileShare (ctx , accountOptions , shareOptions , secret ); err != nil {
543
543
if strings .Contains (err .Error (), accountLimitExceedManagementAPI ) || strings .Contains (err .Error (), accountLimitExceedDataPlaneAPI ) {
0 commit comments