@@ -806,7 +806,17 @@ func (d *Driver) copyBlobContainer(ctx context.Context, req *csi.CreateVolumeReq
806
806
case util .AzcopyJobError , util .AzcopyJobCompleted :
807
807
return err
808
808
case util .AzcopyJobRunning :
809
- return fmt .Errorf ("wait for the existing AzCopy job to complete, current copy percentage is %s%%" , percent )
809
+ err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
810
+ jobState , percent , err := d .azcopy .GetAzcopyJob (dstContainerName , authAzcopyEnv )
811
+ klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
812
+ if err != nil {
813
+ return false , err
814
+ }
815
+ if jobState == util .AzcopyJobRunning {
816
+ return false , nil
817
+ }
818
+ return true , nil
819
+ })
810
820
case util .AzcopyJobNotFound :
811
821
klog .V (2 ).Infof ("copy blob container %s:%s to %s:%s" , srcAccountName , srcContainerName , dstAccountName , dstContainerName )
812
822
execFunc := func () error {
@@ -819,13 +829,12 @@ func (d *Driver) copyBlobContainer(ctx context.Context, req *csi.CreateVolumeReq
819
829
_ , percent , _ := d .azcopy .GetAzcopyJob (dstContainerName , authAzcopyEnv )
820
830
return fmt .Errorf ("timeout waiting for copy blob container %s to %s complete, current copy percent: %s%%" , srcContainerName , dstContainerName , percent )
821
831
}
822
- copyErr := util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execFunc , timeoutFunc )
823
- if copyErr != nil {
824
- klog .Warningf ("CopyBlobContainer(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstContainerName , copyErr )
825
- } else {
826
- klog .V (2 ).Infof ("copied blob container %s to %s successfully" , srcContainerName , dstContainerName )
827
- }
828
- return copyErr
832
+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execFunc , timeoutFunc )
833
+ }
834
+ if err != nil {
835
+ klog .Warningf ("CopyBlobContainer(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstContainerName , err )
836
+ } else {
837
+ klog .V (2 ).Infof ("copied blob container %s to %s successfully" , srcContainerName , dstContainerName )
829
838
}
830
839
return err
831
840
}
0 commit comments