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

terraform throws error while creating premium tier elasticpool : azurerm_sql_elasticpool #1605

Closed
ghost opened this issue Jul 18, 2018 · 17 comments · Fixed by #2071
Closed
Assignees
Labels
bug service/mssql Microsoft SQL Server upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Milestone

Comments

@ghost
Copy link

ghost commented Jul 18, 2018

This issue was originally opened by @reddyed as hashicorp/terraform#18488. It was migrated here as a result of the provider split. The original body of the issue is below.


Hello,

i am able to create the azurerm_sql_elasticpool with the basic tier edition. but when i add it as premium tier in the terraform scripts, it throws error.
my script is

resource "azurerm_sql_elasticpool" "elasticpool" {
name = "prod-epool"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${azurerm_resource_group.rg.location}"
server_name = "${azurerm_sql_server.sql_server.name}"
edition = "Premium"
dtu = 2000
db_dtu_min = 0
db_dtu_max = 1750
pool_size = 5000
}

The error i get when i execute the terraform script is

azurerm_sql_elasticpool.elasticpool: 1 error(s) occurred:

azurerm_sql_elasticpool.elasticpool: sql.ElasticPoolsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: json: cannot unmarshal array into Go struct field serviceError2.details of type map[string]interface {}

Any help is appriciated. Thanks

@srusru
Copy link

srusru commented Jul 18, 2018

This is the terraform version i am using
Terraform v0.11.7
provider.azurerm v1.9.0

@tombuildsstuff tombuildsstuff added bug service/mssql Microsoft SQL Server labels Jul 23, 2018
@Parvez-dkda
Copy link

Parvez-dkda commented Jul 24, 2018

I am experiencing the exact same issue with standard tier SQL DB Pool, basic works fine.
I'm using the following:
Terraform v0.11.7
provider.azurerm v1.10.0

pool_edition = "Standard"
pool_dtu = "50"
pool_db_dtu_min = "0"
pool_db_dtu_max = "10"
pool_size = "50000"

@Parvez-dkda
Copy link

I was able to get it to work, I manually configured the settings I wanted via the portal, and then looked at the Automation Script JSON file. My pool_size needed to be 51200 instead of 50000.

  pool_edition             = "Standard"
  pool_dtu                 = "50"
  pool_db_dtu_min          = "0"
  pool_db_dtu_max          = "10"
  pool_size                = **"51200"**

this worked,

@tombuildsstuff tombuildsstuff added this to the 1.12.0 milestone Jul 30, 2018
@maxirus
Copy link

maxirus commented Aug 2, 2018

Similar issues when using Basic tier with azurerm_sql_database

@tombuildsstuff tombuildsstuff modified the milestones: 1.12.0, 1.13.0 Aug 3, 2018
@tombuildsstuff tombuildsstuff modified the milestones: 1.13.0, 1.14.0 Aug 15, 2018
@ktobin-occm
Copy link

@tombuildsstuff is there any reason this keeps getting pushed back? Formatting in Base 2 was working last week, but as of Monday neither base 2 nor Base 10 formatting for pool_size is being accepted. Being able to manage Elastic Pools is a pretty critical component of Azure SQL administration. It would be great if we could get this resolved in a more timely fashion.

@cdhunt
Copy link

cdhunt commented Aug 24, 2018

This appears to be a global issue with the AzureRM SQL module failing to consume the error json.

Sample error response structure:

'{
  "error": {
    "code": "InvalidSourceDatabaseId",
    "message": "Invalid source database identifier."
  }
}'

@poojanKothari
Copy link

Getting same error while creating azurerm_sql_database with edition as Premium and Basic, only edition working is Standard.
Terraform v0.11.8
provider.azurerm v1.13.0

@tombuildsstuff tombuildsstuff modified the milestones: 1.14.0, 1.15.0 Sep 6, 2018
@eoly
Copy link

eoly commented Sep 13, 2018

Throwing my hat in the ring here too.

Experiencing this same issue creating an azurerm_sql_database using Basic edition. Standard works.

terraform v0.11.8
terraform-provider-azurerm_v1.14.0_x4

@tombuildsstuff tombuildsstuff modified the milestones: 1.15.0, 1.16.0, Soon Sep 13, 2018
@WodansSon
Copy link
Collaborator

Looking into this deeper there are a few issues here, none of them have to do with Terraform. There are a couple of API issues that I am chasing currently. The actual error that is coming back in the response body is:

{
    "code": "40874",
    "message": "The DTUs (1750) for the elastic pool does not belong to the specified values for service tier \u0027Premium\u0027.",
    "target": null,
    "details": [
        {
            "code": "40874",
            "message": "The DTUs (1750) for the elastic pool does not belong to the specified values for service tier \u0027Premium\u0027.",
            "target": null,
            "severity": "16"
        }
    ],
    "innererror": []
}

The root issue is that if you look at the response body the innererror is being passed as an array, but should really be an object. So what's happening is when the error is returned it attempts to unmarshal it into serviceError1 struct, which fails because the innererror is an array and not an object. Once that fails, the code then attempts to unmarshal it into serviceError2 struct which also fails because the target value is a null value and not a string.

@WodansSon
Copy link
Collaborator

WodansSon commented Sep 14, 2018

@reddyed BTW the error you are getting back from the posted repro tf file is:

{
    "code": "40868",
    "message": "The DTU max per database cannot exceed (1750) for service tier \u0027Premium\u0027.",
    "target": null,
    "details": [
        {
            "code": "40868",
            "message": "The DTU max per database cannot exceed (1750) for service tier \u0027Premium\u0027.",
            "target": null,
            "severity": "16"
        }
    ],
    "innererror": []
}

which makes sense since you have defined your dtu to 2000 and the db_dtu_max as 1750.

dtu = 2000
db_dtu_max = 1750

NOTE: The max DTU of a Premium service is 1000. If you update the below fields the provision will succeed.

dtu = 1000
db_dtu_max = 1000

@WodansSon
Copy link
Collaborator

WodansSon commented Sep 14, 2018

@maxirus @poojanKothari @eoly Thanks for reporting that you are seeing a similar issue in azurerm_sql_database. If you could open another issue for that resource that includes your configuration file used we can look in to it and see if it is the same issue or not. Thanks.

@eoly
Copy link

eoly commented Sep 14, 2018

@jeffreyCline Thanks, I created #1931 for the similar issue with azurerm_sql_database

@alant94
Copy link
Contributor

alant94 commented Oct 21, 2018

@jeffreyCline Hi, import errors in azurerm_sql_database are exactly like described here. May be happening because of the same issue.

@tombuildsstuff tombuildsstuff modified the milestones: Soon, Being Sorted Oct 25, 2018
@tombuildsstuff tombuildsstuff added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Oct 25, 2018
@tombuildsstuff
Copy link
Contributor

👋 hi all

Since this appears to be an issue in the Azure SDK for Go I'm going to close this issue in favour of an upstream issue. @jeffreyCline would you be able to reference the upstream issue in the Rest API Specs/Azure SDK for Go repository which is tracking this?

Thanks!

@WodansSon
Copy link
Collaborator

@tombuildsstuff This is a won't fix by the SDK and Service teams since it is an old API. They are going to deprecate the old API in favor of the new 2017-10-01-preview one.

@katbyte katbyte added this to the 1.19.0 milestone Nov 14, 2018
@midacts
Copy link
Contributor

midacts commented Nov 15, 2018

No fix in sight then, eh?

@ghost
Copy link
Author

ghost commented Mar 5, 2019

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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/mssql Microsoft SQL Server upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.