Skip to content
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

cloudsql instance suddenly gets recreated #2309

Closed
wmuizelaar opened this issue Oct 23, 2018 · 6 comments
Closed

cloudsql instance suddenly gets recreated #2309

wmuizelaar opened this issue Oct 23, 2018 · 6 comments
Labels

Comments

@wmuizelaar
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • If an issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v0.11.8
+ provider.google v1.19.1

Affected Resource(s)

  • google_sql_database_instance

Terraform Configuration Files

resource "google_sql_database_instance" "pcf-db" {
  name = "pcf-db"
  database_version = "POSTGRES_9_6"
  region = "europe-west4"
  project = "bolcom-pro-lion-72d"

  settings {
    tier = "db-custom-2-8192"
    activation_policy = "ALWAYS"
    availability_type = "REGIONAL"
    disk_size = "20"
    disk_type = "PD_HDD"
    user_labels = {
      bol-opex = "team77"
      bol-data-sensitivity = "low"
    }
    backup_configuration {
      enabled = "true"
      start_time = "01:00"
    }
    maintenance_window {
      day = "6"
      hour = "2"
      update_track = "stable"
    }
  }
}

resource "google_sql_database" "pcf-db-pcf" {
  name     = "pcf"
  instance = "${google_sql_database_instance.pcf-db.name}"
  project  = "bolcom-pro-lion-72d"
}

resource "google_sql_user" "pcf-db-cloudsqlproxy" {
  name     = "cloudsqlproxy"
  instance = "${google_sql_database_instance.pcf-db.name}"
  host     = ""
  password = "redacted"
  project  = "bolcom-pro-lion-72d"
}

provider "google" {
  credentials = "${file("/etc/gcp/cloudsql-manager")}"
  project     = "bolcom-pro-lion-72d"
  region      = "europe-west4"
}

Debug Output

google_sql_database_instance.pcf-db: Refreshing state... (ID: pcf-db)
google_sql_user.pcf-db-cloudsqlproxy: Refreshing state... (ID: cloudsqlproxy//pcf-db)
google_sql_database.pcf-db-pcf: Refreshing state... (ID: pcf-db:pcf)
google_sql_database_instance.pcf-db: Destroying... (ID: pcf-db)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 10s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 20s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 30s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 40s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 50s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m0s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m10s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m20s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m30s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m40s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 1m50s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m0s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m10s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m20s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m30s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m40s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 2m50s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m0s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m10s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m20s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m30s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m40s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 3m50s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 4m0s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 4m10s elapsed)
google_sql_database_instance.pcf-db: Still destroying... (ID: pcf-db, 4m20s elapsed)
google_sql_database_instance.pcf-db: Destruction complete after 4m25s
google_sql_database_instance.pcf-db: Creating...
  connection_name:                              "" => "<computed>"
  database_version:                             "" => "POSTGRES_9_6"
  first_ip_address:                             "" => "<computed>"
  ip_address.#:                                 "" => "<computed>"
  master_instance_name:                         "" => "<computed>"
  name:                                         "" => "pcf-db"
  project:                                      "" => "bolcom-pro-lion-72d"
  region:                                       "" => "europe-west4"
  replica_configuration.#:                      "" => "<computed>"
  self_link:                                    "" => "<computed>"
  server_ca_cert.#:                             "" => "<computed>"
  service_account_email_address:                "" => "<computed>"
  settings.#:                                   "" => "1"
  settings.0.activation_policy:                 "" => "ALWAYS"
  settings.0.availability_type:                 "" => "REGIONAL"
  settings.0.backup_configuration.#:            "" => "1"
  settings.0.backup_configuration.0.enabled:    "" => "true"
  settings.0.backup_configuration.0.start_time: "" => "01:00"
  settings.0.crash_safe_replication:            "" => "<computed>"
  settings.0.disk_autoresize:                   "" => "true"
  settings.0.disk_size:                         "" => "20"
  settings.0.disk_type:                         "" => "PD_HDD"
  settings.0.ip_configuration.#:                "" => "<computed>"
  settings.0.location_preference.#:             "" => "<computed>"
  settings.0.maintenance_window.#:              "" => "1"
  settings.0.maintenance_window.0.day:          "" => "6"
  settings.0.maintenance_window.0.hour:         "" => "2"
  settings.0.maintenance_window.0.update_track: "" => "stable"
  settings.0.pricing_plan:                      "" => "PER_USE"
  settings.0.replication_type:                  "" => "SYNCHRONOUS"
  settings.0.tier:                              "" => "db-custom-2-8192"
  settings.0.user_labels.%:                     "" => "2"
  settings.0.user_labels.bol-data-sensitivity:  "" => "low"
  settings.0.user_labels.bol-opex:              "" => "team77"
  settings.0.version:                           "" => "<computed>"

Error: Error applying plan:

1 error(s) occurred:

* google_sql_database_instance.pcf-db: 1 error(s) occurred:

* google_sql_database_instance.pcf-db: Error, the name pcf-db is unavailable because it was used recently

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

The apply should have left the instance in place.

Actual Behavior

The apply destroyed and recreated the db again.

Steps to Reproduce

The previous run of the instance was with provider version 1.19.0. We upgraded to 1.19.1, and then did a terraform apply. Unfortunately, I cannot reproduce the behavior, in isolated sandbox-projects.
I did compare statefiles before and after, and there is no relevant difference.

References

I looked at #2229 which was as far as I could see the only PR merged between 1.19.0 and 1.19.1 I could figure out that actually touched the CloudSQL resource. I'd rather have a system not recreate the database, but bail out with an error if there is an issue with the output gotten from the google API.

@ghost ghost added the bug label Oct 23, 2018
@pdecat
Copy link
Contributor

pdecat commented Oct 23, 2018

What was the plan like?

@wmuizelaar
Copy link
Author

Unfortunately, there was no seperate plan recorded, just only the apply.

@chrisst
Copy link
Contributor

chrisst commented Oct 25, 2018

I tried a handful up different upgrades and was also not able to reproduce. Without seeing the plan or the full debug output with TF=DEBUG it's hard for us to understand what happened.

@wmuizelaar
Copy link
Author

I completely understand. Implementing the plan in our workflow to actually better see what's going on - so -if- it happens another time, we got more visibility.

Not being able to reproduce makes this a hard problem.

@chrisst
Copy link
Contributor

chrisst commented Oct 26, 2018

Closing for now. Feel free to reopen if you see it again.

@chrisst chrisst closed this as completed Oct 26, 2018
@ghost
Copy link

ghost commented Mar 29, 2020

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants