Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Creating a database resource does not wait for resource readiness #397

Open
nhedger opened this issue Nov 26, 2024 · 3 comments
Open
Labels

Comments

@nhedger
Copy link

nhedger commented Nov 26, 2024

Current Behavior

I'm unsure if this is a a bug or intended, but I find it annoying that when creating a database resource using exoscale_database, Terraform does not wait for the database to be ready and returns immediately indicating that the resource has been created.

Expected Behavior

I would expect Terraform to return only when the database is available and ready to receive queries.

Steps To Reproduce

Create a database

resource "exoscale_database" "telemetry" {
  name = "telemetry"
  plan = "hobbyist-2"
  zone = "ch-gva-2"
  type = "pg"

  pg {
    version        = "16"
    ip_filter      = ["0.0.0.0/0", "::/0"]
  }
}

Provider Version

0.62.1

Terraform Version

OpenTofu v1.8.5

Relevant log output

module.database.exoscale_database.telemetry: Creating...
module.database.exoscale_database.telemetry: Creation complete after 2s [id=telemetry]
@nhedger nhedger added the bug label Nov 26, 2024
@simisoft-exo
Copy link
Contributor

Hi!

This is the intended behavior as the create and update operations are async.

If you want to make sure the database it's ready you need to use a datasource_uri output and that will wait and return a connection string or credentials when it's ready.

You can see how to do this in the examples:
https://github.com/exoscale/terraform-provider-exoscale/blob/master/examples/database/main.tf#L38

@nhedger
Copy link
Author

nhedger commented Nov 26, 2024

Thanks for clarifying and for providing an alternative.

Is there a specific reason why the exoscale_database resource is created asynchronously? Even so, I would expect the provider to block and poll for the status of the resource and return only when the resource is ready.

Thanks!

@kobajagi
Copy link
Contributor

kobajagi commented Dec 5, 2024

We discussed this topic internally. Resource exoscale_database follows our existing practice of completing creation of resource as soon as it is allocated by the orchestrator. Another example is compute instance which will be in state 'starting' when resource creation completes.

We are looking to change this behavior as part of our migration to terraform framework.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants