@@ -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/azcore/to"
32
32
"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)
95
95
}
96
96
97
97
capacityBytes := req .GetCapacityRange ().GetRequiredBytes ()
98
- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
98
+ requestGiB := util .RoundUpGiB (capacityBytes )
99
99
if requestGiB == 0 {
100
100
requestGiB = defaultAzureFileQuota
101
101
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)
642
642
// use uuid as vhd disk name if file share specified
643
643
diskName = uuid .NewString () + vhdSuffix
644
644
}
645
- diskSizeBytes := volumehelper .GiBToBytes (requestGiB )
645
+ diskSizeBytes := util .GiBToBytes (requestGiB )
646
646
klog .V (2 ).Infof ("begin to create vhd file(%s) size(%d) on share(%s) on account(%s) type(%s) rg(%s) location(%s)" ,
647
647
diskName , diskSizeBytes , validFileShareName , account , sku , resourceGroup , location )
648
648
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
914
914
klog .V (2 ).Infof ("snapshot(%s) already exists" , snapshotName )
915
915
return & csi.CreateSnapshotResponse {
916
916
Snapshot : & csi.Snapshot {
917
- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
917
+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
918
918
SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
919
919
SourceVolumeId : sourceVolumeID ,
920
920
CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -996,7 +996,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
996
996
997
997
createResp := & csi.CreateSnapshotResponse {
998
998
Snapshot : & csi.Snapshot {
999
- SizeBytes : volumehelper .GiBToBytes (int64 (itemSnapshotQuota )),
999
+ SizeBytes : util .GiBToBytes (int64 (itemSnapshotQuota )),
1000
1000
SnapshotId : sourceVolumeID + "#" + itemSnapshot ,
1001
1001
SourceVolumeId : sourceVolumeID ,
1002
1002
CreationTime : timestamppb .New (itemSnapshotTime ),
@@ -1134,21 +1134,21 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
1134
1134
klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
1135
1135
1136
1136
switch jobState {
1137
- case volumehelper .AzcopyJobError , volumehelper .AzcopyJobCompleted :
1137
+ case util .AzcopyJobError , util .AzcopyJobCompleted , util . AzcopyJobCompletedWithErrors , util . AzcopyJobCompletedWithSkipped , util . AzcopyJobCompletedWithErrorsAndSkipped :
1138
1138
return err
1139
- case volumehelper .AzcopyJobRunning :
1139
+ case util .AzcopyJobRunning :
1140
1140
err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
1141
1141
jobState , percent , err := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
1142
1142
klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
1143
1143
if err != nil {
1144
1144
return false , err
1145
1145
}
1146
- if jobState == volumehelper .AzcopyJobRunning {
1146
+ if jobState == util .AzcopyJobRunning {
1147
1147
return false , nil
1148
1148
}
1149
1149
return true , nil
1150
1150
})
1151
- case volumehelper .AzcopyJobNotFound :
1151
+ case util .AzcopyJobNotFound :
1152
1152
klog .V (2 ).Infof ("copy fileshare %s:%s to %s:%s" , srcAccountName , srcFileShareName , dstAccountName , dstFileShareName )
1153
1153
execAzcopyJob := func () error {
1154
1154
if out , err := d .execAzcopyCopy (srcPathAuth , dstPath , azcopyCopyOptions , authAzcopyEnv ); err != nil {
@@ -1160,13 +1160,16 @@ func (d *Driver) copyFileShareByAzcopy(srcFileShareName, dstFileShareName, srcPa
1160
1160
jobState , percent , _ := d .azcopy .GetAzcopyJob (dstFileShareName , authAzcopyEnv )
1161
1161
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 )
1162
1162
}
1163
- err = volumehelper .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1163
+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execAzcopyJob , timeoutFunc )
1164
1164
}
1165
1165
1166
1166
if err != nil {
1167
1167
klog .Warningf ("CopyFileShare(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstFileShareName , err )
1168
1168
} else {
1169
1169
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
+ }
1170
1173
}
1171
1174
return err
1172
1175
}
@@ -1191,7 +1194,7 @@ func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.Controller
1191
1194
if capacityBytes == 0 {
1192
1195
return nil , status .Error (codes .InvalidArgument , "volume capacity range missing in request" )
1193
1196
}
1194
- requestGiB := volumehelper .RoundUpGiB (capacityBytes )
1197
+ requestGiB := util .RoundUpGiB (capacityBytes )
1195
1198
if err := d .ValidateControllerServiceRequest (csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ); err != nil {
1196
1199
return nil , status .Errorf (codes .InvalidArgument , "invalid expand volume request: %v" , req )
1197
1200
}
0 commit comments