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

Add Exponential Backoff When adding Heroku Domain #71

Closed
davidji99 opened this issue Jun 13, 2018 · 10 comments
Closed

Add Exponential Backoff When adding Heroku Domain #71

davidji99 opened this issue Jun 13, 2018 · 10 comments

Comments

@davidji99
Copy link
Collaborator

davidji99 commented Jun 13, 2018

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

  • v0.11.7

Affected Resource(s)

  • heroku_domain

Terraform Configuration Files

resource "heroku_app" "app" {
  name = "meh"

  region = "validregion"
  space  = "validspace"
}

resource "heroku_domain" "app" {
  app      = "${heroku_app.app.name}"
  hostname = "validfqdn"
}

Output

heroku_domain.app: 1 error(s) occurred:

Expected Behavior

It should wait until the app completes provisioning before trying to apply the domain change

Actual Behavior

Failed apply

@davidji99
Copy link
Collaborator Author

Proposed solution will be add some exponential backoff potentially.

@talbright
Copy link
Contributor

talbright commented Jul 27, 2018

I ran into a form of this the other week as well. In my case the app already existed in the statefile, but I was adding a heroku_domain. Of course re-running apply can get one past the problem, but that's far from ideal and not expected.

The aws provider client has some built-in retry/backoff mechanism, we might look to see if that can be extracted. I've also use https://github.com/cenkalti/backoff before, but I would like to get some additional 👀 on it to see if that looks like a dependency we want to bring in.

Ideally, I'd like to see retry logic built into the client, that way we get this for free across all our API calls and don't have to retrofit retry logic everywhere. I'll open a discussion in https://github.com/heroku/heroku-go.

@talbright
Copy link
Contributor

Actually perhaps the right thing to do here is use this: https://godoc.org/github.com/hashicorp/terraform/helper/resource#StateRefreshFunc

@bernerdschaefer
Copy link
Contributor

I think using StateRefreshFunc is the more appropriate solution for this case, rather than baking retries into the client.

@talbright
Copy link
Contributor

Agreed, the more I think about it the more that seems like the right thing to do.

@bernerdschaefer
Copy link
Contributor

@talbright Thinking about this more, I think the refresh should be done on the app after creation. By waiting there for the app to be ready, we would also fix https://github.com/terraform-providers/terraform-provider-heroku/issues/37 and anything else which depends on the app being provisioned for resources to be added. It would be a smarter version of the work-around that we've been using of introducing a sleep after app creation (https://github.com/terraform-providers/terraform-provider-heroku/issues/37#issuecomment-356378747).

@talbright
Copy link
Contributor

That makes sense to me as well. There's an issue with a couple of tests, I'm waiting to hear back from @davidji99 on and get those cleared out. If this hasn't been worked on by the time I get that cleaned up, I will implement the fix suggested here on the app resource.

@talbright
Copy link
Contributor

Hitting this up next.

@talbright
Copy link
Contributor

talbright commented Aug 15, 2018

@bernerdschaefer I don't see anything in the production API for checking app status. I could hit the webhook API and look for past events, but that seems dodgy. There's a status field for the domain endpoint (https://devcenter.heroku.com/articles/platform-api-reference#domain) but that wouldn't fix the original issue here:

heroku_domain.app: Post https://api.heroku.com/apps/meh/domains: App meh is being provisioned. Please try again later.

Now I can fix this in the heroku resource by greping for this error message. That would not however fix if for the broader scenerios we have discussed here.

@talbright
Copy link
Contributor

Addressed by #142

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

No branches or pull requests

3 participants