-
Notifications
You must be signed in to change notification settings - Fork 212
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
pagerduty_service eventual consistency issue on CREATE #273
Comments
I ran into this issue too, except with First, I saw that the service integration (in my case, a CloudWatch integration) was indeed created. I looked at the tfstate of a different integration that happened to succeed:
Next, I tried to manually import that state. Note, I had to adjust my plan and comment out any resources that depended on this just to get the import to successfully run:
This produced a failure that states import IDs for pagerduty_service_integration should be in the format of
So, try the import
Now, you can uncomment any other resources that you had commented out and continue with |
I am facing this same issue while trying to dynamically create multiple
I see that all of the services were actually created successfully in PagerDuty despite this error message. However, since the terraform state is now "out of sync", any subsequent
I have also tried a workaround, similar to the one mentioned above, to query the API for all service IDs and manually bring them into the terraform state using the
My assumption here is that this is not handling that the Any help in resolving this issue or assitance with a temporary workaround would be greatly appreciated. |
Look through your state file and see what remote object is claiming the ID. I have a suspicion that you have the incorrect ID. Failing that, you might have to go state file hacking. Create a count of something else and study its structure to see if you can manually create the right state. The attributes/values don't have to be perfect, as the next apply will generally bring them into sync. All YMMY, of course. Also, this may be obvious -- but if you're creating something with count, you're remembering to put something to differentiate each instance of the object, right? The error says that the name was claimed -- make sure you're using the index or something so that your nth service isn't conflicting in name with your 1st. |
…can return a 404 on create
…rduty services retry.
…p, user contact, and notifications rules to have similar safeguards against eventual consistent reads.
I am experiencing an intermittent issue with the PagerDuty Terraform provider where the creation of a
pagerduty_service
orpagerduty_escalation_policy
resource often results in the following messageThis appears to be a result of the PagerDuty API being eventually consistent. When running Terraform Apply with the environment variable
TF_LOG=DEBUG
set, I can observe that the resource is created successfully (204 Created after a POST call). However, the PagerDuty Provider immediately issues a GET for the resource that was just created and the API returns a 404 Not Found. However, manually making the same GET request some time later, returns the expected result with a 200 response.I dug into the provider code a bit and found that there are retries built in to all resource GETs:
terraform-provider-pagerduty/pagerduty/resource_pagerduty_escalation_policy.go
Line 128 in e8c18e2
However, in the event that the API returns a 404, it doesn't bother to retry:
terraform-provider-pagerduty/pagerduty/provider.go
Line 85 in 8bdde9b
I think that's where the issue lies. Since the PagerDuty API seems to be eventually consistent, the provider should retry with some delay even in the event of a 404 Not Found, in the event that the resource was created, but isn't yet available to be read.
I've created the following PR as an example of adding a number of retries in the event of a 404 Not Found.
#274
I'm not a GO developer so this functionality could probably be done in a cleaner way. But I was able to build and verify that this does solve the issue described above.
Terraform Version
Terraform v0.12.8
Affected Resource(s)
Terraform Configuration Files
Debug Output
https://gist.github.com/jwlusby/db83a25e0e40fe641c1fa2c7366bf817
Expected Behavior
Provider should have retried after a short delay to retrieve the resource.
Actual Behavior
Provider received a 404 and gave up immediately
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
The text was updated successfully, but these errors were encountered: