-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving 500 server timeouts on append blob appends #2430
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
452d965
Code to validate range md5 on 500 followed by 412
gapra-msft 55a677d
added tests for the policy and refactored common code
gapra-msft ada230a
added tests
gapra-msft b61b2ea
do not care about benchmark failure
gapra-msft d823e38
added more tests
gapra-msft b89ee3d
added local file read
gapra-msft 62095d0
compare right int type
gapra-msft 42481d0
implement more methods
gapra-msft 6d8fc7a
Added a test
gapra-msft e99a4d0
Merge branch 'dev' into gapra/resolve500Timeout
gapra-msft 2279a9e
fix errors
gapra-msft 805bbc1
Merge branch 'dev' into gapra/resolve500Timeout
gapra-msft 07896d4
fixed build issue
gapra-msft a990bc4
fix codespell
gapra-msft 00f13d2
Fix build after merge
gapra-msft 44841fc
Tested GCP and fixed issue with test
gapra-msft 1c7bae3
Merge branch 'dev' into gapra/resolve500Timeout
gapra-msft 70b5ac0
Merge branch 'dev' into gapra/resolve500Timeout
gapra-msft d3a5fc9
try to fix test
gapra-msft bdac5b0
fixed test
gapra-msft 5e8ce3b
added dest client creation
gapra-msft 710d7a6
get tests working
gapra-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package ste | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to" | ||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/appendblob" | ||
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob" | ||
blobsas "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas" | ||
blobservice "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/service" | ||
"github.com/Azure/azure-storage-azcopy/v10/common" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
"time" | ||
) | ||
|
||
type appendErrorInjectionPolicy struct { | ||
timedOut bool | ||
} | ||
|
||
func (r *appendErrorInjectionPolicy) Do(req *policy.Request) (*http.Response, error) { | ||
if req.Raw().URL.Query().Get("comp") == "appendblock" && !r.timedOut { | ||
req.Next() | ||
var headers http.Header = make(map[string][]string) | ||
headers.Add("x-ms-error-code", "OperationTimedOut") | ||
r.timedOut = true | ||
return &http.Response{StatusCode: 500, Header: headers}, nil | ||
} | ||
return req.Next() | ||
} | ||
|
||
func Test500FollowedBy412Logic(t *testing.T) { | ||
a := assert.New(t) | ||
|
||
// Setup source and destination | ||
accountName, accountKey := getAccountAndKey() | ||
rawURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) | ||
|
||
credential, err := blob.NewSharedKeyCredential(accountName, accountKey) | ||
a.Nil(err) | ||
|
||
client, err := blobservice.NewClientWithSharedKeyCredential(rawURL, credential, &blobservice.ClientOptions{ | ||
ClientOptions: azcore.ClientOptions{ | ||
Transport: NewAzcopyHTTPClient(0), | ||
}}) | ||
a.Nil(err) | ||
|
||
cName := generateContainerName() | ||
cc := client.NewContainerClient(cName) | ||
_, err = cc.Create(context.Background(), nil) | ||
a.Nil(err) | ||
defer cc.Delete(context.Background(), nil) | ||
|
||
sourceName := generateBlobName() | ||
sourceClient := cc.NewBlockBlobClient(sourceName) | ||
size := 1024 * 1024 * 10 | ||
dataReader, _ := getDataAndReader(t.Name(), size) | ||
_, err = sourceClient.Upload(context.Background(), streaming.NopCloser(dataReader), nil) | ||
a.Nil(err) | ||
|
||
sasURL, err := cc.NewBlobClient(sourceName).GetSASURL( | ||
blobsas.BlobPermissions{Read: true}, | ||
time.Now().Add(1*time.Hour), | ||
nil) | ||
a.Nil(err) | ||
|
||
destName := generateBlobName() | ||
destClient := cc.NewAppendBlobClient(destName) | ||
destClient.Create(context.Background(), nil) | ||
a.Nil(err) | ||
|
||
jptm := testJobPartTransferManager{ | ||
info: to.Ptr(TransferInfo{ | ||
Source: sasURL, | ||
SrcContainer: cName, | ||
SrcFilePath: sourceName, | ||
}), | ||
fromTo: common.EFromTo.BlobBlob(), | ||
} | ||
blobSIP, err := newBlobSourceInfoProvider(jptm) | ||
a.Nil(err) | ||
|
||
injectionPolicy := &appendErrorInjectionPolicy{timedOut: false} | ||
destClient, err = appendblob.NewClientWithSharedKeyCredential(destClient.URL(), credential, &appendblob.ClientOptions{ | ||
ClientOptions: azcore.ClientOptions{ | ||
PerRetryPolicies: []policy.Policy{newRetryNotificationPolicy(), injectionPolicy}, | ||
Transport: NewAzcopyHTTPClient(0), | ||
}, | ||
}) | ||
a.Nil(err) | ||
base := appendBlobSenderBase{jptm: jptm, destAppendBlobClient: destClient, sip: blobSIP} | ||
|
||
// Get MD5 range within service calculation | ||
offset := int64(0) | ||
count := int64(common.MaxRangeGetSize) | ||
var timeoutFromCtx bool | ||
ctx := withTimeoutNotification(context.Background(), &timeoutFromCtx) | ||
_, err = base.destAppendBlobClient.AppendBlockFromURL(ctx, sasURL, | ||
&appendblob.AppendBlockFromURLOptions{ | ||
Range: blob.HTTPRange{Offset: offset, Count: count}, | ||
AppendPositionAccessConditions: &appendblob.AppendPositionAccessConditions{AppendPosition: &offset}, | ||
}) | ||
errString, err := base.transformAppendConditionMismatchError(timeoutFromCtx, offset, count, err) | ||
a.Nil(err) | ||
a.Empty(errString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need context with timeout here, in older code its different right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually a notifier that a 500 status code was returned during the append block retries so we can check below. This is not adding a request timeout