Git Product home page Git Product logo

Comments (13)

magne avatar magne commented on September 17, 2024

The provider should respect normal resource Operation Timeouts.

from terraform-provider-mssql.

greggbjensen avatar greggbjensen commented on September 17, 2024

@magne can you give some more details on how this should work? I am running into the same issue with timeouts at 30 seconds. We tried adding the Operation Timeout to both azurerm_mssql_server and azurerm_sql_database and it does not seem to change it. We are using a SQL login.

from terraform-provider-mssql.

wtassi avatar wtassi commented on September 17, 2024

It would be great if the provider configuration allowed for a configurable timeout for connecting to the DB. Currently using Azure SQL serverless which goes to sleep after 1 hour...it usually takes it 45-60 seconds to wake up and I get:

Error: unable to read user [xxx].[xxx]: db connection failed after 30s timeout with mssql_user.xxx, on xxx.database.tf line 54, in resource "mssql_user" "xxx": 54: resource "mssql_user" "xxx" {

This is because the resource tries to connect to the instance to do the validation, and when we created the azure_mssql_server we didn't insert our output ip in the Firewall.

If you add your outgoing ip on the sql server firewall, it will run successfully.

from terraform-provider-mssql.

dhoss1979 avatar dhoss1979 commented on September 17, 2024

I am able to connect to the database locally and I am still getting this message:

Error: unable to read user [Communication].[Communication]: db connection failed after 30s timeout
│
│   with module.cluster.module._api_communication.mssql_user._api_db,
│   on ..\modules\cluster\modules\_api_with_db\main.tf line 67, in resource "mssql_user" "_api_db":
│   67: resource "mssql_user" "_api_db"

from terraform-provider-mssql.

waltervos avatar waltervos commented on September 17, 2024

For anyone unsure of how to use the "normal resource Operation Timeouts" that magne mentions, here's a snippet:

resource "mssql_user" "users" {
  server {
    host = azurerm_mssql_server.main.fully_qualified_domain_name
    azure_login {
      client_id     = null
      client_secret = null
      tenant_id     = null
    }
  }
  database = azurerm_mssql_database.my_database.name
  username = "..."
  roles    = ["db_owner"]
  timeouts {
    default = "5m"
  }
}

Note the timeouts block (which supports only the property default).

from terraform-provider-mssql.

pisethdanh avatar pisethdanh commented on September 17, 2024

For anyone unsure of how to use the "normal resource Operation Timeouts" that magne mentions, here's a snippet:

resource "mssql_user" "users" {
  server {
    host = azurerm_mssql_server.main.fully_qualified_domain_name
    azure_login {
      client_id     = null
      client_secret = null
      tenant_id     = null
    }
  }
  database = azurerm_mssql_database.my_database.name
  username = "..."
  roles    = ["db_owner"]
  timeouts {
    default = "5m"
  }
}

Note the timeouts block (which supports only the property default).

I have the following:

resource "mssql_login" "example" {

  # omit for brevity ...

  timeouts {
    default = "5m"
  }
}

and I'm still getting:

Error: unable to read login [login_name]: db connection failed after 30s timeout

@magne, is this the correct way to use the Resource Timeouts mentioned above? There doesn't seem to be any documentation for this timeouts property.

Note: I'm using the latest version (v0.2.5)

from terraform-provider-mssql.

waltervos avatar waltervos commented on September 17, 2024

@pisethdanh I think you'll find you'll keep getting that error message for 5 minutes. That's all that a resource operation timeout does.

from terraform-provider-mssql.

pisethdanh avatar pisethdanh commented on September 17, 2024

@waltervos , thank you for your response. The error message says it's timing out after 30 seconds, which doesn't respect the 5 minutes override that I specified. Unless I'm misconstruing how this works?

from terraform-provider-mssql.

waltervos avatar waltervos commented on September 17, 2024

@pisethdanh As far as I know this timeout value just refers to how long terraform will keep trying: https://www.terraform.io/language/resources/syntax#operation-timeouts

from terraform-provider-mssql.

magne avatar magne commented on September 17, 2024

@pisethdanh, could you try change the timeouts block to

timeouts {
    read = "5m"
}

If this works, I've misunderstood the terraform internals, assuming that the struct would automatically return the default if no specific timeout was set.

from terraform-provider-mssql.

pisethdanh avatar pisethdanh commented on September 17, 2024

@magne , thank you for your response. When setting create, read, update, or delete, I get this error:

image

It appears those attributes are not supported.

Speculation here, but Azure SQL MI may be throttling the read requests resulting in transient errors. Are there any plans to implement retry logic in this provider?

Apologies for resurrecting a closed issue. Is it more appropriate to create a new issue?

from terraform-provider-mssql.

nazirakz avatar nazirakz commented on September 17, 2024

It would be great if the provider configuration allowed for a configurable timeout for connecting to the DB. Currently using Azure SQL serverless which goes to sleep after 1 hour...it usually takes it 45-60 seconds to wake up and I get:

Error: unable to read user [xxx].[xxx]: db connection failed after 30s timeout with mssql_user.xxx, on xxx.database.tf line 54, in resource "mssql_user" "xxx": 54: resource "mssql_user" "xxx" {

Hello! I also faced this error. How did you resolve it?

from terraform-provider-mssql.

luis-ochoa avatar luis-ochoa commented on September 17, 2024

@nazirakz , no real resolution...I just re-run terraform and by the second time the DB is already awake

from terraform-provider-mssql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.