Skip to content

Commit a6e25a7

Browse files
committed
CB-25305: Fixed a crash caused by Azure sometimes not reporting exact progress
1 parent 47f94b4 commit a6e25a7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

main.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func poll(cmd string) (int, int, error) {
2525
return 0, 0, errors.New(fmt.Sprintf("ERROR: output: %s, err: %s", out, err.Error()))
2626
}
2727

28+
if strings.Contains(string(out), "ErrorCode:PendingCopyOperation") {
29+
return 0, 100, nil
30+
}
31+
2832
parts := strings.Split(string(out), "/")
2933
if len(parts) != 2 {
3034
return 0, 0, errors.New(fmt.Sprintf("Command should have returned <actual>/<total> instead it was: %s", out))
@@ -89,7 +93,11 @@ func main() {
8993
time.Sleep(time.Second * 1)
9094
}
9195
}
92-
log.Printf("Blob size of vhd in Storage Account of %s is: %f GB", storageAccount, float64(sum)/math.Pow(1024, 3))
96+
if sum < 1024 {
97+
log.Println("Azure didn't return exact numbers, but reported that the blob is being copied... (fingers crossed)")
98+
} else {
99+
log.Printf("Blob size of vhd in Storage Account of %s is: %f GB", storageAccount, float64(sum)/math.Pow(1024, 3))
100+
}
93101
}(storageAccount, cmd)
94102
}
95103
wg.Wait()
@@ -110,7 +118,11 @@ func main() {
110118
return
111119
}
112120
} else {
113-
log.Printf("Copy status to Storage Account of %s is: (%d/%d) %.2f%% ", storageAccount, act, sum, (float64(act)/float64(sum))*100)
121+
if sum < 1024 {
122+
log.Println("Azure didn't return exact numbers, but reported that the blob is still being copied... (fingers crossed)")
123+
} else {
124+
log.Printf("Copy status to Storage Account of %s is: (%d/%d) %.2f%% ", storageAccount, act, sum, (float64(act)/float64(sum))*100)
125+
}
114126
}
115127
time.Sleep(time.Second * 10)
116128
}

0 commit comments

Comments
 (0)