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

fix: avoid wrapping RawError twice #718

Merged

Conversation

marwanad
Copy link
Member

@marwanad marwanad commented Jul 22, 2021

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
The sender decorator builds a local Error type that embeds the RawError returned from the Azure service. However, in the client's sendRequest method it wraps this error again under the Error type.

retry.GetError(response, err)

This would return a double-wrapped error the consumers:

Retriable: false, RetryAfter: 0s, HTTPStatusCode: 409, RawError: Retriable: false, RetryAfter: 0s, HTTPStatusCode: 409, RawError: {"error":{"code":"ReadOnlyDisabledSubscription","message":"The subscription 'xxx' is disabled and therefore marked as read only. You cannot perform any write actions on this subscription until it is re-enabled."}}
 

Initially was thinking of safe guarding the behaviour but because Error doesn't implement the error interface, it seemed to be a bit of hassle.

With the fix in place, the top-level consumers will get the expected error body:

Retriable: false, RetryAfter: 0s, HTTPStatusCode: 409, RawError: {​​​​​​​"error":{​​​​​​​"code":"ReadOnlyDisabledSubscription","message":"The subscription 'xxx' is disabled and therefore marked as read only. You cannot perform any write actions on this subscription until it is re-enabled."}​​​​​​​}​​​​​​​

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Release note:

N/A

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 22, 2021
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 22, 2021
@marwanad
Copy link
Member Author

@feiskyer any reason we don't embed the ServiceError type instead of RawError? It seems that every code-path should return this.
https://github.com/Azure/go-autorest/blob/82fc42f340cec32d30ce97f9277f9b8aaf8885df/autorest/azure/azure.go#L50-L57

@marwanad marwanad force-pushed the avoid-emebdding-raw-error-twice branch from cebcf5c to 7d447e2 Compare July 22, 2021 19:11
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 80.695% when pulling 7d447e2 on marwanad:avoid-emebdding-raw-error-twice into cb84088 on kubernetes-sigs:master.

Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

looks good

/retest

@feiskyer
Copy link
Member

any reason we don't embed the ServiceError type instead of RawError?

ideally, every azure api should report ServiceError, but we're not actually sure about that. So even with a ServiceError, we would still need another RawError if the responded error type couldn't be serialized to ServiceError.

Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 27, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feiskyer, marwanad

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 27, 2021
@k8s-ci-robot k8s-ci-robot merged commit b942924 into kubernetes-sigs:master Jul 27, 2021
k8s-ci-robot added a commit that referenced this pull request Sep 14, 2021
cherry-pick of #718: avoid wrapping RawError twice
k8s-ci-robot added a commit that referenced this pull request Sep 14, 2021
cherry-pick of #718: avoid wrapping RawError twice
marwanad added a commit to marwanad/autoscaler that referenced this pull request Oct 13, 2021
better categorize errors on CA operations

(depednent on: kubernetes-sigs/cloud-provider-azure#718 - will bump vendor/cherry-pick in a follow-up)
gandhipr pushed a commit to gandhipr/autoscaler that referenced this pull request Apr 2, 2024
better categorize errors on CA operations

(depednent on: kubernetes-sigs/cloud-provider-azure#718 - will bump vendor/cherry-pick in a follow-up)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants