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

Parse 409 error strings to determine retriable status #1552

Merged

Conversation

chrisst
Copy link
Contributor

@chrisst chrisst commented Mar 20, 2019

Fixes hashicorp/terraform-provider-google#3279


[all]

[terraform]

[terraform-beta]

[ansible]

[inspec]

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
This PR seems not to have generated downstream PRs before, as of e5cc236.

Pull request statuses

No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#544
depends: GoogleCloudPlatform/terraform-google-conversion#27
depends: hashicorp/terraform-provider-google#3285

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

You still seemed apprehensive about using this approach in the issue- have you changed your mind or do you think we can approach this another way? This approach LGTM though.

if gerr, ok := err.(*googleapi.Error); ok && (gerr.Code == 409 || gerr.Code == 429 || gerr.Code == 500 || gerr.Code == 502 || gerr.Code == 503) {
if gerr.Code == 409 && !strings.Contains(gerr.Body, "operationInProgress") {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Should this be broken out to a separate block? Needing to guard against nearly every 409 type makes me feel like we should have a block if gerr.Code == 409 && strings.Contains(gerr.Body, "operationInProgress".

@chrisst
Copy link
Contributor Author

chrisst commented Mar 20, 2019

Haha - TBH I do dislike this approach but the alternatives appear to be:
Change the client library to stop obfuscating the error
Fork the retryTimeDuration interface to allow specifying the retriable status codes
Parse the error strings

From what I can see the error reason which is 'operationInProgress' is jammed into the errror message and that's what I'm matching on. This is created from an Exception.operationInProgress so it's unlikely the reason code will change and as long as the client library isn't updated (or doesn't change it's error parsing when it is) then I find this acceptable for now.

@rileykarson
Copy link
Member

👍

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 7b808b5.

Pull request statuses

terraform-provider-google-beta already has an open PR.
terraform-google-conversion already has an open PR.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

chrisst and others added 3 commits March 22, 2019 17:30
Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec.
@modular-magician modular-magician merged commit 66c6e49 into GoogleCloudPlatform:master Mar 22, 2019
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.

4 participants