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

Implement retry logic in read requests for services and service integrations #191

Merged
merged 2 commits into from
Mar 26, 2020

Conversation

mLupine
Copy link
Contributor

@mLupine mLupine commented Mar 20, 2020

Ever since we started using Terraform to manage our PagerDuty configuration at @nordcloud, we've been facing an issue with state refreshing calls failing during the execution of the terraform plan command.

Our configuration contains a few thousand services and service integrations, and almost every time the command was ran, it (probably) started reaching the PD API webserver's rate limits, failing with the following error messages:

Error: Error reading: PXXXXXX: Get https://api.pagerduty.com/services/PXXXXXX: http2: server sent GOAWAY and closed the connection; LastStreamID=1999, ErrCode=NO_ERROR, debug=""

Error: Error reading: PXXXXXX: Get https://api.pagerduty.com/services/PXXXXXX: http2: server sent GOAWAY and closed the connection; LastStreamID=1999, ErrCode=NO_ERROR, debug=""

After some debugging, I found out that if the failing calls are executed again, even with no delay, they actually go through without any issues.

This change introduces Terraform's retry mechanism to the "Read" command of pagerduty_service and pagerduty_service_integrations, making it return RetryableError every time an HTTP request to the API server fails with a status code other than 404.

I've implemented the updated provider in our CI/CD flow and it's been running flawlessly ever since.

Please keep in mind that it's my first ever encounter with Golang, so don't be too harsh on me if the code isn't perfect 😉

@ghost ghost added the size/L label Mar 20, 2020
Copy link
Contributor

@stmcallister stmcallister left a comment

Choose a reason for hiding this comment

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

Looks great! Nice job! Thanks for contributing this!

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

Successfully merging this pull request may close these issues.

2 participants