-
Notifications
You must be signed in to change notification settings - Fork 301
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
intermittent failure to create service principal #581
Comments
I've actually run into a different problem before I could reproduce with debug logs...
This seems surprising, since I am destroying everything that I create. Not sure whether this is also an azuread bug, or is something funny on Azure where deleted applications aren't "really" deleted for a while... |
re the above: it turns out that deleted applications aren't permanently deleted but hang around for thirty days. And I can't find a programmatic way to delete them permanently, one seems to have to do it one by one through the portal. Which is extremely slow and tedious work. Which is to say that I may not have a repro that includes the debug logs so soon after all. |
Hi @dimbleby, you are correct that deleted applications (also users and groups) are only soft deleted. This has been the case for a long time but recently API support has been added to list/purge/restore these deleted object types. We're hoping to add support for this in the provider in the near future. For the original error, please post a debug log when you next encounter it. The error you pasted occurs in various misleading circumstances, including when the application can't be found - this most commonly occurs during replication delays and we're trying to work around these wherever feasible to avoid erroring out in cases where we can safely retry. A debug log will be extremely helpful as many of these corner cases only occur in relatively rare circumstances (as you found out when trying to reproduce!). Thanks! |
(I've learned how to delete the soft-deleted applications. But even though I now have none of those left, I still have no quota! I suspect that I also have a pile of soft-deleted service principals: but I don't find a way to delete, or even see, those. So I'm kinda stuck for reproducing this for now). |
If you're keen to keep going, you can always create a new tenant for testing, and delete it once you have exhausted the quota :D (Portal > Create a Resource > Azure Active Directory) |
So although I was failing to reproduce this with the small clean configuration above, I started saving off the debug logs from our pipelines - and this morning we have a repro. Unfortunately the repro happening in our pipeline means that I can't share our full terraform definitions with you, and also that the logs are noisier than they would have been from the minimal repro. But the application / principal that failed are configured very much like the ones in the fragment above. If there are specific things about the configuration that it would be useful to know please ask. Logs are at https://gist.github.com/dimbleby/c4a453c26e83d7e535a76a6fb3e25d74.
Although our whole configuration and therefore the log file also has a bunch of AzureRM stuff going on, the section from lines 4000-5000 or thereabouts looks to be mostly AzureAD activity only, so hopefully you'll be able to make sense of it... |
@dimbleby That's great, many thanks for posting the log. I can see from the requests that the application was created in the preceding two seconds (:54), and then returned by the API (:55), before the request to create the service principal was sent and rejected (:56). So it looks very much like an eventual consistency issue. Usually in this scenario we'll see an error response that contains a message like In terms of the time delay between the error response and the apply operation failing, I'd say this is expected. Terraform is doing a lot of things in parallel and it will try to complete any operations in progress at the same time before aborting, to avoid state corruption. |
Super, thanks! |
This functionality has been released in v2.5.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform (and AzureAD Provider) Version
terraform v1.0.5, azuread v2.3.0
Affected Resource(s)
azuread_service_principal
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
No error
Actual Behavior
Steps to Reproduce
I ran a little shell script which keeps going until something fails:
Important Factoids
References
This is basically a re-opening of #535.
The first time I ran this it failed very quickly, but I didn't have debug logging turned on. I have now turned debug logging on and, as if to spite me, am not seeing failures. But I expect I'll get one sooner or later and upload the logs when I do.
The text was updated successfully, but these errors were encountered: