@@ -26,7 +26,7 @@ import (
26
26
"strings"
27
27
"time"
28
28
29
- volumehelper "sigs.k8s.io/azurefile-csi-driver/pkg/util"
29
+ "sigs.k8s.io/azurefile-csi-driver/pkg/util"
30
30
31
31
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage"
32
32
"github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/sas"
@@ -96,7 +96,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
96
96
}
97
97
98
98
capacityBytes := req .GetCapacityRange ().GetRequiredBytes ()
99
- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
99
+ requestGiB := util .RoundUpGiB (capacityBytes )
100
100
if requestGiB == 0 {
101
101
requestGiB = defaultAzureFileQuota
102
102
klog .Warningf ("no quota specified, set as default value(%d GiB)" , defaultAzureFileQuota )
@@ -634,7 +634,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
634
634
// use uuid as vhd disk name if file share specified
635
635
diskName = uuid .NewString () + vhdSuffix
636
636
}
637
- diskSizeBytes := volumehelper .GiBToBytes (requestGiB )
637
+ diskSizeBytes := util .GiBToBytes (requestGiB )
638
638
klog .V (2 ).Infof ("begin to create vhd file(%s) size(%d) on share(%s) on account(%s) type(%s) rg(%s) location(%s)" ,
639
639
diskName , diskSizeBytes , validFileShareName , account , sku , resourceGroup , location )
640
640
if err := createDisk (ctx , accountName , accountKey , d .getStorageEndPointSuffix (), validFileShareName , diskName , diskSizeBytes ); err != nil {
@@ -906,7 +906,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
906
906
klog .V (2 ).Infof ("snapshot(%s) already exists" , snapshotName )
907
907
return & csi.CreateSnapshotResponse {
908
908
Snapshot : & csi.Snapshot {
909
- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
909
+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
910
910
SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
911
911
SourceVolumeId : sourceVolumeID ,
912
912
CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -977,7 +977,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
977
977
978
978
createResp := & csi.CreateSnapshotResponse {
979
979
Snapshot : & csi.Snapshot {
980
- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
980
+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
981
981
SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
982
982
SourceVolumeId : sourceVolumeID ,
983
983
CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -1108,21 +1108,21 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
1108
1108
klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
1109
1109
1110
1110
switch jobState {
1111
- case volumehelper .AzcopyJobError , volumehelper .AzcopyJobCompleted :
1111
+ case util .AzcopyJobError , util .AzcopyJobCompleted , util . AzcopyJobCompletedWithErrors , util . AzcopyJobCompletedWithSkipped , util . AzcopyJobCompletedWithErrorsAndSkipped :
1112
1112
return err
1113
- case volumehelper .AzcopyJobRunning :
1113
+ case util .AzcopyJobRunning :
1114
1114
err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
1115
1115
jobState , percent , err := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
1116
1116
klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
1117
1117
if err != nil {
1118
1118
return false , err
1119
1119
}
1120
- if jobState == volumehelper .AzcopyJobRunning {
1120
+ if jobState == util .AzcopyJobRunning {
1121
1121
return false , nil
1122
1122
}
1123
1123
return true , nil
1124
1124
})
1125
- case volumehelper .AzcopyJobNotFound :
1125
+ case util .AzcopyJobNotFound :
1126
1126
klog .V (2 ).Infof ("copy fileshare %s:%s to %s:%s" , srcAccountName , srcFileShareName , dstAccountName , dstFileShareName )
1127
1127
execAzcopyJob := func () error {
1128
1128
if out , err := d .execAzcopyCopy (srcPathAuth , dstPath , azcopyCopyOptions , authAzcopyEnv ); err != nil {
@@ -1134,13 +1134,16 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
1134
1134
jobState , percent , _ := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
1135
1135
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 )
1136
1136
}
1137
- err = volumehelper .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1137
+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1138
1138
}
1139
1139
1140
1140
if err != nil {
1141
1141
klog .Warningf ("CopyFileShare(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstFileShareName , err )
1142
1142
} else {
1143
1143
klog .V (2 ).Infof ("copied fileshare %s to %s successfully" , srcFileShareName , dstFileShareName )
1144
+ if out , err := d .azcopy .CleanJobs (); err != nil {
1145
+ klog .Warningf ("clean azcopy jobs failed with error: %v, output: %s" , err , string (out ))
1146
+ }
1144
1147
}
1145
1148
return err
1146
1149
}
@@ -1165,7 +1168,7 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
1165
1168
if capacityBytes == 0 {
1166
1169
return nil , status .Error (codes .InvalidArgument , "volume capacity range missing in request" )
1167
1170
}
1168
- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
1171
+ requestGiB := util .RoundUpGiB (capacityBytes )
1169
1172
if err := d .ValidateControllerServiceRequest (csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ); err != nil {
1170
1173
return nil , status .Errorf (codes .InvalidArgument , "invalid expand volume request: %v" , req )
1171
1174
}
0 commit comments