@@ -793,7 +793,17 @@ func (d *Driver) copyBlobContainer(ctx context.Context, req *csi.CreateVolumeReq
793793 case util .AzcopyJobError , util .AzcopyJobCompleted :
794794 return err
795795 case util .AzcopyJobRunning :
796- return fmt .Errorf ("wait for the existing AzCopy job to complete, current copy percentage is %s%%" , percent )
796+ err = wait .PollImmediate (20 * time .Second , time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , func () (bool , error ) {
797+ jobState , percent , err := d .azcopy .GetAzcopyJob (dstContainerName , authAzcopyEnv )
798+ klog .V (2 ).Infof ("azcopy job status: %s, copy percent: %s%%, error: %v" , jobState , percent , err )
799+ if err != nil {
800+ return false , err
801+ }
802+ if jobState == util .AzcopyJobRunning {
803+ return false , nil
804+ }
805+ return true , nil
806+ })
797807 case util .AzcopyJobNotFound :
798808 klog .V (2 ).Infof ("copy blob container %s:%s to %s:%s" , srcAccountName , srcContainerName , dstAccountName , dstContainerName )
799809 execFunc := func () error {
@@ -806,13 +816,12 @@ func (d *Driver) copyBlobContainer(ctx context.Context, req *csi.CreateVolumeReq
806816 _ , percent , _ := d .azcopy .GetAzcopyJob (dstContainerName , authAzcopyEnv )
807817 return fmt .Errorf ("timeout waiting for copy blob container %s to %s complete, current copy percent: %s%%" , srcContainerName , dstContainerName , percent )
808818 }
809- copyErr := util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execFunc , timeoutFunc )
810- if copyErr != nil {
811- klog .Warningf ("CopyBlobContainer(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstContainerName , copyErr )
812- } else {
813- klog .V (2 ).Infof ("copied blob container %s to %s successfully" , srcContainerName , dstContainerName )
814- }
815- return copyErr
819+ err = util .WaitUntilTimeout (time .Duration (d .waitForAzCopyTimeoutMinutes )* time .Minute , execFunc , timeoutFunc )
820+ }
821+ if err != nil {
822+ klog .Warningf ("CopyBlobContainer(%s, %s, %s) failed with error: %v" , accountOptions .ResourceGroup , dstAccountName , dstContainerName , err )
823+ } else {
824+ klog .V (2 ).Infof ("copied blob container %s to %s successfully" , srcContainerName , dstContainerName )
816825 }
817826 return err
818827}
0 commit comments