terraform-provider-google: google_sql_database.users: operationInProgress error on `terraform apply`
Hi there,
I created this issue with a refrence to terraform issue #9018. I commented there, but I think it would be better to keep the conversation going over here because of the provider split.
I am facing a similar issue as in issue #9018 with the google_sql_user resource right now.
terraform -v Terraform v0.11.7 provider.google v1.13.0
I am using the following syntax to create nine users:
resource "google_sql_user" "users" {
count = 9
instance = "${var.instance}"
name = "${element(var.subenvs, count.index)}-${var.product_short}.${element(var.usernames, count.index)}"
}
Subenv and usernames are both a list of strings defined in a separate variables.tf file.
I also create two cloud sql instances:
resource "google_sql_database_instance" "mysql" {
name = "${var.name}"
region = "${var.region}"
database_version = "${var.database_version}"
master_instance_name = "${var.master_instance_name}"
settings {
tier = "${var.tier}"
disk_size = "${var.disk_size}"
disk_type = "${var.disk_type}"
disk_autoresize = "${var.disk_autoresize}"
database_flags = "${var.flags}"
backup_configuration {
binary_log_enabled = "${1 - var.failover_node}"
enabled = "${1 - var.failover_node}"
start_time = "${var.start_time}"
}
ip_configuration {
ipv4_enabled = true
authorized_networks = "${var.authorized_networks}"
}
maintenance_window {
day = "${var.maintenance_day}"
hour = "${var.maintenance_hour}"
}
}
replica_configuration = "${local.failover_value}"
}
and three databases:
resource "google_sql_database" "databases" {
count = 3
name = "${element(var.subenvs, count.index)}-${var.product}"
project = "${var.project}"
instance = "${var.instance}"
charset = "${var.charset}"
collation = "${var.collation}"
}
Usually terraform apply handles everything fine, until the databases and the users are created. They fail with the following error:
google_sql_database.databases.1: Error, failed to insert database <db_name> into instance <dbi_name>: googleapi: Error 403: Operation failed because another operation was already in progress., operationInProgress google_sql_database.users: Error, failed to insert database [name] into instance [name]: googleapi: Error 403: Operation failed because another operation was already in progress., operationInProgress
If I run terraform apply again everything works just fine and the users are created successfully.
A similar error happens with terraform destroy:
module.sql_users.google_sql_user.users[1] (destroy): 1 error(s) occurred: google_sql_user.users.1: Error, failure waiting for deletion of [user name] in [instance name]: module.sql_users.google_sql_user.users[0] (destroy): 1 error(s) occurred: google_sql_user.users.0: Error, failure waiting for deletion of [user name] in [instance name]:
If I run terraform destroy again everything works just fine and the users are deleted successfully.
Debug output
Is currently not available sorry! I will try to get it if really necessary.
Expected Behavior
The user accounts and databases are created.
Actual Behavior
The creation of the users and the databases fails.
Steps to Reproduce
terraform apply
Refrences
There is also issue #22 that faces timeouts upon creation of databases, but I think this issue is all about users so I don’t think this has anything to do with each other.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
@arvidviderberg That makes sense. The error you caught was from
sql internal operation
. I guess that is different from what other users reported.Thanks, removing the upstream-terraform label for now so this can get picked back up by our bug triaging process.