-
Notifications
You must be signed in to change notification settings - Fork 278
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
digitalocean_database_connection_pool for_each 422 error #925
Comments
Hi there, Thank you so much for this write up and including the request id. We were able to look up the logs via the request id and found that this seems to be a standard name conflict. It seems the plan is failing because one of the two pool names specified already existed. This surfaces that the error message could have been more clear and possibly a more appropriate response code (more like a 409) could have been returned. We'll discuss as a team how we can surface a clearer error up to the user in this kind of situation. Thank you so much, |
@danaelhe The problem is that those pool names are unique. And if they exist in state it shouldn't produce any error. If they don't then they should be created successfully. It more looks like that digitalocean API return inconsistent responses and therefore provider thinks that some resources don't exist or should be recreated. Since in terraform debug logs I often find Maybe it's connected with #493 So I think best option here is to create a proper idempotent API and use |
I've also found one more bug with this. So the provider should be fixed to handle such states. |
@SkeLLLa Can you show any additional info on how you've defined the environments? I've been unsuccessful at reproducing it using: variable "environments" {
type = set(string)
default = ["test", "stage"]
}
resource "digitalocean_database_cluster" "pg" {
name = "cluster-pg-test"
engine = "pg"
version = "15"
size = "db-s-1vcpu-2gb"
region = "nyc3"
node_count = 1
}
resource "digitalocean_database_connection_pool" "foo_db_pool" {
for_each = var.environments
name = "pool_${each.value}"
cluster_id = digitalocean_database_cluster.pg.id
mode = "transaction"
size = 5
db_name = "defaultdb"
user = "doadmin"
} Are the number of pools and their names correct in the plan? |
@andrewsomething yes, that's correct. But it not happen every time, just as bug described in #493 or, for example, when 5XX error appear. But for me it never appeared for resources that don't use for_each template for some reason. I'd say once in 50 times. And the issue it that provider couldn't properly handle such errors or undefined state after 5XX error. So, for example, when I've got the issue last time it was like that:
So it would be nice if in provider we will have an option like |
Bug Report
Describe the bug
While creating DB pools DO API returns error, but the actual resource is created. In current example 2 DB pools should be created.
Terraform issues 2 requests with different POST data to create 2 env polls pear each value of
var.environemts
, e.g.[test, stage]
. And one of requests is completed with 201 code. Other fails with 422.While pool is actually created successfully with given name.
Affected Resource(s)
Expected Behavior
Pool is created and no error thrown
Actual Behavior
Pool is created, but 422 error thrown which leads to 422 exit code.
Steps to Reproduce
Terraform Configuration Files
Terraform version
1.2.X
1.3.X
The text was updated successfully, but these errors were encountered: