Skip to content

Commit

Permalink
Added error handling when a chuck is not downloaded from an Azure blob
Browse files Browse the repository at this point in the history
- To download a file from an azure blob we use the libraries
"github.com/Azure/azure-pipeline-go/pipeline" and
"github.com/Azure/azure-storage-blob-go/azblob". We divide the file
into chunks and download it chunk by chunk until we download the
whole file. For each chunk, we can retry up to 20 times. However,
if the download of a chunk fails in all of 20 times (for example
due to connectivity issues), we do not handle
and report the error. This patch stores all the errors when downloading
a chunk and in case all 20 retries have failed it stops the download
and reports the error.

Signed-off-by: Ioannis Sfakianakis <[email protected]>
  • Loading branch information
Ioannis Sfakianakis committed Jan 8, 2024
1 parent 666ed23 commit d84ba7d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion zedUpload/azureutil/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,20 @@ func DownloadAzureBlob(accountURL, accountName, accountKey, containerName, remot
if err != nil {
return err
}
body := dr.Body(azblob.RetryReaderOptions{MaxRetryRequests: maxRetries})
var retryErrorStr []string
body := dr.Body(azblob.RetryReaderOptions{
MaxRetryRequests: maxRetries,
NotifyFailedRead: func(failureCount int, lastError error, offset int64, count int64, willRetry bool) {
retryError := fmt.Errorf("total read failures: %d, offset: %d, error: %v", failureCount, offset, lastError)
retryErrorStr = append(retryErrorStr, retryError.Error())
if !willRetry {
err = fmt.Errorf(strings.Join(retryErrorStr, "\n"))
}
},
})
if err != nil {
return err
}
rangeProgress := int64(0)
body = pipeline.NewResponseBodyProgress(
body,
Expand Down

0 comments on commit d84ba7d

Please sign in to comment.