Implement retry logic in read requests for services and service integrations #191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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
andpagerduty_service_integrations
, making it returnRetryableError
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 😉