Skip to content

Commit bcf1af7

Browse files
Use RetryReader when reading from Azure
1 parent 883ad72 commit bcf1af7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pbm/storage/azure/azure.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ func (b *Blob) SourceReader(name string) (io.ReadCloser, error) {
221221
return nil, errors.Wrap(err, "download object")
222222
}
223223

224-
return o.Body, nil
224+
rr := o.NewRetryReader(context.TODO(), &azblob.RetryReaderOptions{
225+
EarlyCloseAsError: true,
226+
OnFailedRead: func(failureCount int32, lastError error, rnge azblob.HTTPRange, willRetry bool) {
227+
// failureCount is reset on each call to Read(), so repeats of "attempt 1" are expected
228+
b.log.Debug("Read from Azure failed (attempt %d): %v, retrying: %v\n", failureCount, lastError, willRetry)
229+
},
230+
})
231+
return rr, nil
225232
}
226233

227234
func (b *Blob) Delete(name string) error {

0 commit comments

Comments
 (0)