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

azurerm_mssql_database - error when secondary database uses max_size_gb #11401

Merged
merged 7 commits into from
Apr 21, 2021

Conversation

aristosvo
Copy link
Collaborator

@aristosvo aristosvo commented Apr 20, 2021

@katbyte I introduced a bug in #11286 :(

Because max_size_gb is Computed, GetOk("max_size_gb") is not empty in a second run. I added HasChange("max_size_gb") as an extra check before I throw an error to fix it.

Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @aristosvo! Can we confirm this fix through a test? We want to make sure that this change is broken in the current version of the provider and that it'll be fixed in the next version of the provider.

@aristosvo
Copy link
Collaborator Author

aristosvo commented Apr 20, 2021

Sure! I had a hard time reproducing the issue in the first place, but I'll try!!

Update: Done!

  • Succeeds for new version
    ❯ make acctests SERVICE='mssql' TESTARGS='-run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup'
    ==> Checking that code complies with gofmt requirements...
    ==> Checking that Custom Timeouts are used...
    ==> Checking that acceptance test packages are used...
    TF_ACC=1 go test -v ./azurerm/internal/services/mssql -run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
    2021/04/21 10:38:00 [DEBUG] not using binary driver name, it's no longer needed
    2021/04/21 10:38:01 [DEBUG] not using binary driver name, it's no longer needed
    === RUN   TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === PAUSE TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === CONT  TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    --- PASS: TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup (1072.79s)
    PASS
    ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mssql 1076.526
    
  • Fails on fixed version
    ❯ make acctests SERVICE='mssql' TESTARGS='-run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup'
    ==> Checking that code complies with gofmt requirements...
    ==> Checking that Custom Timeouts are used...
    ==> Checking that acceptance test packages are used...
    TF_ACC=1 go test -v ./azurerm/internal/services/mssql -run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
    2021/04/21 11:56:19 [DEBUG] not using binary driver name, it's no longer needed
    2021/04/21 11:56:20 [DEBUG] not using binary driver name, it's no longer needed
    === RUN   TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === PAUSE TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === CONT  TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
        testing.go:620: Step 2/3 error: Error running apply: 
            Error: it is not possible to change maximum size nor advised to configure maximum size on SQL Database "acctest-db-210421115621680898" (Resource Group "acctestRG-mssql2-210421115621680898", Server "acctest-sqlserver2-210421115621680898") in secondary create mode
            
              on ../../../../../../../../var/folders/wt/rn76884977bfp0dcqr7g1l7w0000gn/T/tftest328216436/work550553155/config175315476/terraform_plugin_test.tf line 50, in resource "azurerm_mssql_database" "secondary":
              50: resource "azurerm_mssql_database" "secondary" {
            
            
    --- FAIL: TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup (519.75s)
    FAIL
    FAIL    github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mssql  523.482s
    FAIL
    make: *** [acctests] Error 1
    
  • Fails for old version
    ❯ make acctests SERVICE='mssql' TESTARGS='-run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup'
    ==> Checking that code complies with gofmt requirements...
    ==> Checking that Custom Timeouts are used...
    ==> Checking that acceptance test packages are used...
    TF_ACC=1 go test -v ./azurerm/internal/services/mssql -run=TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
    2021/04/21 12:10:11 [DEBUG] not using binary driver name, it's no longer needed
    2021/04/21 12:10:13 [DEBUG] not using binary driver name, it's no longer needed
    === RUN   TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === PAUSE TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
    === CONT  TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup
        testing.go:620: Step 2/3 error: Error running apply: 
            Error: waiting for creation of MsSql Database "acctest-db-210421121014390662" (MsSql Server Name "acctest-sqlserver2-210421121014390662" / Resource Group "acctestRG-mssql2-210421121014390662"): Code="InvalidOperationForDatabaseInReplicationRelationship" Message="The operation cannot be performed since the database 'acctest-db-210421121014390662' is in a replication relationship."
            
              on ../../../../../../../../var/folders/wt/rn76884977bfp0dcqr7g1l7w0000gn/T/tftest876467736/work700466839/config702982328/terraform_plugin_test.tf line 50, in resource "azurerm_mssql_database" "secondary":
              50: resource "azurerm_mssql_database" "secondary" {
            
            
    --- FAIL: TestAccMsSqlDatabase_scaleReplicaSetWithFailovergroup (548.34s)
    FAIL
    FAIL    github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/mssql   552.241s
    FAIL
    make: *** [acctests] Error 1
            
    

@ghost ghost added size/M and removed size/XS labels Apr 21, 2021
@aristosvo aristosvo force-pushed the feature/mssql-db-replica-scaling branch from 32eae84 to a329cd4 Compare April 21, 2021 08:44
@aristosvo aristosvo requested a review from mbfrahry April 21, 2021 10:19
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for getting this written out into a test!

@mbfrahry mbfrahry changed the title Bugfix for mssql_database Update documentation and print warning for secondary db with max_size_gb azurerm_mssql_database - error when secondary database uses max_size_gb Apr 21, 2021
@mbfrahry mbfrahry merged commit 2457b3d into hashicorp:master Apr 21, 2021
mbfrahry added a commit that referenced this pull request Apr 21, 2021
@mbfrahry mbfrahry added the service/mssql Microsoft SQL Server label Apr 21, 2021
@mbfrahry mbfrahry added this to the v2.57.0 milestone Apr 21, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.57.0"
}
# ... other configuration ...

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants