@@ -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/storage/azfile/sas"
3232 "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service"
@@ -113,7 +113,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
113113 }
114114
115115 capacityBytes := req .GetCapacityRange ().GetRequiredBytes ()
116- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
116+ requestGiB := util .RoundUpGiB (capacityBytes )
117117 if requestGiB == 0 {
118118 requestGiB = defaultAzureFileQuota
119119 klog .Warningf ("no quota specified, set as default value(%d GiB)" , defaultAzureFileQuota )
@@ -631,7 +631,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
631631 // use uuid as vhd disk name if file share specified
632632 diskName = uuid .NewUUID ().String () + vhdSuffix
633633 }
634- diskSizeBytes := volumehelper .GiBToBytes (requestGiB )
634+ diskSizeBytes := util .GiBToBytes (requestGiB )
635635 klog .V (2 ).Infof ("begin to create vhd file(%s) size(%d) on share(%s) on account(%s) type(%s) rg(%s) location(%s)" ,
636636 diskName , diskSizeBytes , validFileShareName , account , sku , resourceGroup , location )
637637 if err := createDisk (ctx , accountName , accountKey , d .getStorageEndPointSuffix (), validFileShareName , diskName , diskSizeBytes ); err != nil {
@@ -898,7 +898,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
898898 klog .V (2 ).Infof ("snapshot(%s) already exists" , snapshotName )
899899 return & csi.CreateSnapshotResponse {
900900 Snapshot : & csi.Snapshot {
901- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
901+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
902902 SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
903903 SourceVolumeId : sourceVolumeID ,
904904 CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -968,7 +968,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
968968 }
969969 createResp := & csi.CreateSnapshotResponse {
970970 Snapshot : & csi.Snapshot {
971- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
971+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
972972 SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
973973 SourceVolumeId : sourceVolumeID ,
974974 CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -1099,21 +1099,21 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
10991099 klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
11001100
11011101 switch jobState {
1102- case volumehelper .AzcopyJobError , volumehelper .AzcopyJobCompleted :
1102+ case util .AzcopyJobError , util .AzcopyJobCompleted , util . AzcopyJobCompletedWithErrors , util . AzcopyJobCompletedWithSkipped , util . AzcopyJobCompletedWithErrorsAndSkipped :
11031103 return err
1104- case volumehelper .AzcopyJobRunning :
1104+ case util .AzcopyJobRunning :
11051105 err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
11061106 jobState , percent , err := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
11071107 klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
11081108 if err != nil {
11091109 return false , err
11101110 }
1111- if jobState == volumehelper .AzcopyJobRunning {
1111+ if jobState == util .AzcopyJobRunning {
11121112 return false , nil
11131113 }
11141114 return true , nil
11151115 })
1116- case volumehelper .AzcopyJobNotFound :
1116+ case util .AzcopyJobNotFound :
11171117 klog .V (2 ).Infof ("copy fileshare %s:%s to %s:%s" , srcAccountName , srcFileShareName , dstAccountName , dstFileShareName )
11181118 execAzcopyJob := func () error {
11191119 if out , err := d .execAzcopyCopy (srcPathAuth , dstPath , azcopyCopyOptions , authAzcopyEnv ); err != nil {
@@ -1125,13 +1125,16 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
11251125 jobState , percent , _ := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
11261126 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 )
11271127 }
1128- err = volumehelper .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1128+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
11291129 }
11301130
11311131 if err != nil {
11321132 klog .Warningf ("CopyFileShare(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstFileShareName , err )
11331133 } else {
11341134 klog .V (2 ).Infof ("copied fileshare %s to %s successfully" , srcFileShareName , dstFileShareName )
1135+ if out , err := d .azcopy .CleanJobs (); err != nil {
1136+ klog .Warningf ("clean azcopy jobs failed with error: %v, output: %s" , err , string (out ))
1137+ }
11351138 }
11361139 return err
11371140}
@@ -1156,7 +1159,7 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
11561159 if capacityBytes == 0 {
11571160 return nil , status .Error (codes .InvalidArgument , "volume capacity range missing in request" )
11581161 }
1159- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
1162+ requestGiB := util .RoundUpGiB (capacityBytes )
11601163 if err := d .ValidateControllerServiceRequest (csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ); err != nil {
11611164 return nil , status .Errorf (codes .InvalidArgument , "invalid expand volume request: %v" , req )
11621165 }
0 commit comments