@@ -26,7 +26,7 @@ import (
2626 "strings"
2727 "time"
2828
29- volumehelper "sigs.k8s.io/azurefile-csi-driver/pkg/util"
29+ "sigs.k8s.io/azurefile-csi-driver/pkg/util"
3030
3131 "github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
3232 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
@@ -95,7 +95,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
9595 }
9696
9797 capacityBytes := req .GetCapacityRange ().GetRequiredBytes ()
98- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
98+ requestGiB := util .RoundUpGiB (capacityBytes )
9999 if requestGiB == 0 {
100100 requestGiB = defaultAzureFileQuota
101101 klog .Warningf ("no quota specified, set as default value(%d GiB)" , defaultAzureFileQuota )
@@ -642,7 +642,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
642642 // use uuid as vhd disk name if file share specified
643643 diskName = uuid .NewString () + vhdSuffix
644644 }
645- diskSizeBytes := volumehelper .GiBToBytes (requestGiB )
645+ diskSizeBytes := util .GiBToBytes (requestGiB )
646646 klog .V (2 ).Infof ("begin to create vhd file(%s) size(%d) on share(%s) on account(%s) type(%s) rg(%s) location(%s)" ,
647647 diskName , diskSizeBytes , validFileShareName , account , sku , resourceGroup , location )
648648 if err := createDisk (ctx , accountName , accountKey , d .getStorageEndPointSuffix (), validFileShareName , diskName , diskSizeBytes ); err != nil {
@@ -914,7 +914,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
914914 klog .V (2 ).Infof ("snapshot(%s) already exists" , snapshotName )
915915 return & csi.CreateSnapshotResponse {
916916 Snapshot : & csi.Snapshot {
917- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
917+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
918918 SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
919919 SourceVolumeId : sourceVolumeID ,
920920 CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -996,7 +996,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
996996
997997 createResp := & csi.CreateSnapshotResponse {
998998 Snapshot : & csi.Snapshot {
999- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
999+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
10001000 SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
10011001 SourceVolumeId : sourceVolumeID ,
10021002 CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -1134,21 +1134,21 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
11341134 klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
11351135
11361136 switch jobState {
1137- case volumehelper .AzcopyJobError , volumehelper .AzcopyJobCompleted :
1137+ case util .AzcopyJobError , util .AzcopyJobCompleted , util . AzcopyJobCompletedWithErrors , util . AzcopyJobCompletedWithSkipped , util . AzcopyJobCompletedWithErrorsAndSkipped :
11381138 return err
1139- case volumehelper .AzcopyJobRunning :
1139+ case util .AzcopyJobRunning :
11401140 err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
11411141 jobState , percent , err := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
11421142 klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
11431143 if err != nil {
11441144 return false , err
11451145 }
1146- if jobState == volumehelper .AzcopyJobRunning {
1146+ if jobState == util .AzcopyJobRunning {
11471147 return false , nil
11481148 }
11491149 return true , nil
11501150 })
1151- case volumehelper .AzcopyJobNotFound :
1151+ case util .AzcopyJobNotFound :
11521152 klog .V (2 ).Infof ("copy fileshare %s:%s to %s:%s" , srcAccountName , srcFileShareName , dstAccountName , dstFileShareName )
11531153 execAzcopyJob := func () error {
11541154 if out , err := d .execAzcopyCopy (srcPathAuth , dstPath , azcopyCopyOptions , authAzcopyEnv ); err != nil {
@@ -1160,13 +1160,16 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
11601160 jobState , percent , _ := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
11611161 return fmt .Errorf ("azcopy job status: %s, timeout waiting for copy fileshare %s:%s to %s:%s complete, current copy percent: %s%%" , jobState , srcAccountName , srcFileShareName , dstAccountName , dstFileShareName , percent )
11621162 }
1163- err = volumehelper .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1163+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
11641164 }
11651165
11661166 if err != nil {
11671167 klog .Warningf ("CopyFileShare(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstFileShareName , err )
11681168 } else {
11691169 klog .V (2 ).Infof ("copied fileshare %s to %s successfully" , srcFileShareName , dstFileShareName )
1170+ if out , err := d .azcopy .CleanJobs (); err != nil {
1171+ klog .Warningf ("clean azcopy jobs failed with error: %v, output: %s" , err , string (out ))
1172+ }
11701173 }
11711174 return err
11721175}
@@ -1191,7 +1194,7 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
11911194 if capacityBytes == 0 {
11921195 return nil , status .Error (codes .InvalidArgument , "volume capacity range missing in request" )
11931196 }
1194- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
1197+ requestGiB := util .RoundUpGiB (capacityBytes )
11951198 if err := d .ValidateControllerServiceRequest (csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ); err != nil {
11961199 return nil , status .Errorf (codes .InvalidArgument , "invalid expand volume request: %v" , req )
11971200 }
0 commit comments