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

Azure SQL DB - Cant move database in or out of ElasticPool #590

Closed
ermeaney opened this issue Nov 29, 2017 · 5 comments
Closed

Azure SQL DB - Cant move database in or out of ElasticPool #590

ermeaney opened this issue Nov 29, 2017 · 5 comments
Labels
bug service/mssql Microsoft SQL Server

Comments

@ermeaney
Copy link

ermeaney commented Nov 29, 2017

Terraform Version

Terraform v0.11.0

  • provider.azurerm v0.3.2

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_sql_database

Terraform Configuration Files

Module

resource "azurerm_sql_database" "RzDatabase" {
  count = "${var.datacenter_count}"
  name = "${format("%sSqlDatabase%s",var.name, var.tier)}"
  create_mode = "${count.index == 0 ? "Default" : "OnlineSecondary"}"
  resource_group_name = "${var.resourcegroup[count.index]}"
  location = "${var.locations[var.datacenters[count.index]]}"
  server_name = "${var.server_name[count.index]}"
  requested_service_objective_name = "${var.service_objective}" #set to ElasticPool
  elastic_pool_name = "${var.elastic_pool_name}"
  tags = "${var.tags}"
}

Resource

module "ActivitiesDatabase" {
  source = "./SqlDatabases"
  datacenter_count = "${var.datacenter_count}"
  name = "Activities"
  service_objective = "${var.DBServiceLevel["Activities"]}"
  server_name = "${module.SqlServers.name}"
  tier = "${var.tier}"
  resourcegroup = "${module.ResourceGroups.name}"
  datacenters = "${local.datacenters}"
  locations = "${local.locations}"
  tags = "${local.tags}"
}

Expected Behavior

Terraform should be able to move a SQL database into or out of an ElasticPool

Actual Behavior

both ways fail.

Moving a DB out of a pool

requested_service_objective_name: "ElasticPool" => "S0"

Error: Error applying plan:

1 error(s) occurred:

  • module.ActivitiesDatabase.azurerm_sql_database.RzDatabase: 1 error(s) occurred
    :

  • azurerm_sql_database.RzDatabase: sql.DatabasesClient#CreateOrUpdate: Failure r
    esponding to request: StatusCode=400 -- Original Error: autorest/azure: Service
    returned an error. Status=400 Code="Unknown" Message="Unknown service error"

Moving a DB into a pool

azurerm_sql_database.RzDatabase: sql.DatabasesClient#CreateOrUpdate: Failure sending request: StatusCode=200
-- Original Error: Long running operation terminated with status 'Failed': Code="40860" Message="Elastic pool
'rz-pool-dev' and service level objective 'S0' combination is invalid."

Steps to Reproduce

  1. terraform apply

Important Factoids

I also tried using the parameter requested_service_objective_id on the database with the correct GUID and that also resulted in the same behavior.

Totally a guess, but it appears that that the two setting that need to change are happening independently.

I also tested with the Azure Powershell commands to verify that Azure REST API's themselves were not broken, and that worked.

@ermeaney
Copy link
Author

After a bit of digging, I am wondering if this is actually a bug in the Azure Rest SDK. I am saying that because the docs say that if elasticPoolName is set:

The name of the elastic pool the database is in. If elasticPoolName and requestedServiceObjectiveName are both updated, the value of requestedServiceObjectiveName is ignored. Not supported for DataWarehouse edition.
--

My go is really weak, but tracing through the source of this provider and the azure go library, it appears that the provider is doing the correct thing.

@steve-hawkins
Copy link
Contributor

I was considering raising another issue, but I believe my issue is related

I'm seeing the following error when simply trying to move from one Service Level Objective to another:-

requested_service_objective_name: "S0" => "S2"

Error: Error applying plan:

1 error(s) occurred:

* azurerm_sql_database.test: 1 error(s) occurred:

* azurerm_sql_database.test: Long running operation terminated with status 'Failed': Code="0" Message="The requested Service Objective Name does not match the requested Service Objective Id."

I agree with your guess and it looks like the error message above confirms that both Requested Service Objective ID and Name need to be changed at the same time

looking at azurerm/resource_arm_sql_database.go there is a comment about this:-

			"requested_service_objective_name": {
				Type:             schema.TypeString,
				Optional:         true,
				Computed:         true,
				DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
				// TODO: add validation once the Enum's complete
				// https://github.com/Azure/azure-rest-api-specs/issues/1609
			},

That issue 1609 appears to have been closed now

I'm new to GO too, so not sure how much help I will be

@achandmsft achandmsft added service/mssql Microsoft SQL Server bug labels Mar 8, 2018
@achandmsft achandmsft added this to the 1.4.0 milestone Mar 9, 2018
@tombuildsstuff tombuildsstuff modified the milestones: 1.4.0, Temp/To Be Sorted Apr 17, 2018
@katbyte katbyte removed the triage label May 18, 2018
@tombuildsstuff tombuildsstuff removed this from the Temp/To Be Sorted milestone Jul 24, 2018
@WodansSon
Copy link
Collaborator

Closing this issue as #1503 was merged on Jul 5, 2018.

@ermeaney
Copy link
Author

Hey, thanks for getting to this, and I wish I could test for you, but the world has moved on for me, and I am not using terraform or Azure anymore.

@ghost
Copy link

ghost commented Mar 30, 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 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/mssql Microsoft SQL Server
Projects
None yet
Development

No branches or pull requests

6 participants