Skip to content
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

Don't treat 409 response to conditional request as an error #20064

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Apr 2, 2021

Contributes to: #19982

@pakrym pakrym requested a review from KrzysztofCwalina as a code owner April 2, 2021 17:43
@ghost ghost added the Azure.Core label Apr 2, 2021
@@ -90,6 +90,10 @@ private async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPip

activity.AddTag("http.status_code", message.Response.Status.ToString(CultureInfo.InvariantCulture));
activity.AddTag("serviceRequestId", message.Response.Headers.RequestId);
if (message.ResponseClassifier.IsErrorResponse(message))
{
activity.AddTag("otel.status_code", "ERROR");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to remove the status calculation logic from the AppInsights. PR to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pakrym
Copy link
Contributor Author

pakrym commented Apr 5, 2021

I talked with @tg-msft and we agreed with a more targeted ResponseClassifier implementation in storage instead of changing the global one.

@pakrym
Copy link
Contributor Author

pakrym commented Apr 5, 2021

@kasobol-msft this change would reduce amount of error spans customers see in AppInsights/logs when making CreateIfNotExist calls.

Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very welcome fix.

header.Contains(HttpHeader.Names.IfNoneMatch) ||
header.Contains(HttpHeader.Names.IfModifiedSince) ||
header.Contains(HttpHeader.Names.IfUnmodifiedSince);
return !isConditional;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help new devs wondering what this is for with a comment like:

// We're not considering Container/BlobAlreadyExists as errors when the request has conditional headers.
// Convenience methods like BlobContainerClient.CreateIfNotExists will cause a lot of these responses and
// we don't want them polluting AppInsights with noise.  See RequestActivityPolicy for how this is applied.

@@ -50,7 +50,12 @@ public override bool IsErrorResponse(HttpMessage message)
switch (message.Response.Status)
{
case 409:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do 412 here as well? We've had requests around that as well, since we expect preconditions to fail during concurrent operations; it also isn't an exceptional situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://docs.microsoft.com/en-us/rest/api/storageservices/blob-service-error-codes I don't see anything I want to eagerly add for now.

…onal-request-as-an-error

# Conflicts:
#	sdk/core/Azure.Core/CHANGELOG.md
#	sdk/core/Azure.Core/src/Azure.Core.csproj
@pakrym pakrym merged commit ac5c483 into Azure:master Apr 12, 2021
@pakrym pakrym deleted the pakrym/Don-t-treat-409-response-to-conditional-request-as-an-error branch April 12, 2021 18:59
@RDavis3000
Copy link

Sorry if this is a stupid question but when do these changes get released? How can I tell if they are? Do I need to update anything on my end? Because I am still getting these errors in my ApplicationInsights for BlobBaseClient.Exists()

public void IsError_409_ConditionalResponse(string code, string header, bool isError)
{
var mockRequest = new MockRequest();
mockRequest.Headers.Add("x-ms-error-code", code);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test adds the error code to the request, when it should be on the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants