Skip to content

Commit

Permalink
prevent EOF errors in Azure objstore
Browse files Browse the repository at this point in the history
Signed-off-by: Will Hegedus <wbhegedus@liberty.edu>
  • Loading branch information
wbh1 committed Sep 17, 2019
1 parent b7739b7 commit 71d38f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/objstore/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ func (b *Bucket) getBlobReader(ctx context.Context, name string, offset, length
}

var size int64
if length > 0 {
// If a length is specified and it won't go past the end of the file,
// then set it as the size.
if length > 0 && length <= props.ContentLength()-offset {
size = length
level.Debug(b.logger).Log("msg", "set size to length", "size", size, "length", length, "offset", offset, "name", name)
} else {
size = props.ContentLength() - offset
level.Debug(b.logger).Log("msg", "set size to go to EOF", "contentlength", props.ContentLength(), "size", size, "length", length, "offset", offset, "name", name)
}

destBuffer := make([]byte, size)

if err := blob.DownloadBlobToBuffer(context.Background(), blobURL.BlobURL, offset, length,
if err := blob.DownloadBlobToBuffer(context.Background(), blobURL.BlobURL, offset, size,
destBuffer, blob.DownloadFromBlobOptions{
BlockSize: blob.BlobDefaultDownloadBlockSize,
Parallelism: uint16(3),
Expand Down

0 comments on commit 71d38f7

Please sign in to comment.