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

deleting azurerm_cosmosdb_sql_container when azurerm_management_lock is defined on azurerm_cosmosdb_account crashes plugin #13202

Closed
sMuro opened this issue Sep 1, 2021 · 2 comments · Fixed by #13339

Comments

@sMuro
Copy link

sMuro commented Sep 1, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v1.0.5
on linux_amd64

  • provider registry.terraform.io/hashicorp/azurerm v2.73.0

Affected Resource(s)

  • azurerm_cosmosdb_account
  • azurerm_management_lock
  • azurerm_cosmosdb_sql_container

Terraform Configuration Files

resource "azurerm_resource_group" "rg" {
  name     = "lockingresourcegroup"
  location = "northeu"
}

resource "azurerm_cosmosdb_account" "cosmosdb" {
  name                              = "cosmosdb"
  location                          = azurerm_resource_group.rg.location
  resource_group_name               = azurerm_resource_group.rg.name
  offer_type                        = "Standard"
  kind                              = "GlobalDocumentDB"
}

resource "azurerm_management_lock" "cosmosdb_lock" {
  name       = "cosmosdbdeletionlock"
  scope      = azurerm_cosmosdb_account.cosmosdb.id
  lock_level = "CanNotDelete"
  notes      = "cosmosdb lock"
}


resource "azurerm_cosmosdb_sql_database" "sql_database" {
  name                = "database"
  resource_group_name = azurerm_cosmosdb_account.cosmosdb.resource_group_name
  account_name        = azurerm_cosmosdb_account.cosmosdb.name
}

#destroy this resource after apply
resource "azurerm_cosmosdb_sql_container" "container" {
  name                = "container"
  resource_group_name = azurerm_cosmosdb_account.cosmosdb.resource_group_name
  account_name        = azurerm_cosmosdb_account.cosmosdb.name
  database_name       = azurerm_cosmosdb_sql_database.sql_database.name
  partition_key_path  = "/myPath"
}

Debug Output

Panic Output

Stack trace from the terraform-provider-azurerm_v2.73.0_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x4afae88]

goroutine 70 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/cosmos.resourceCosmosDbSQLContainerDelete(0xc0012d2880, 0x588e0c0, 0xc001255180, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/internal/services/cosmos/cosmosdb_sql_container_resource.go:419 +0x468
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).delete(0xc000496c40, 0x6844cc8, 0xc0016be1c0, 0xc0012d2880, 0x588e0c0, 0xc001255180, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:369 +0x1ee
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000496c40, 0x6844cc8, 0xc0016be1c0, 0xc0011e43f0, 0xc001f4e800, 0x588e0c0, 0xc001255180, 0x0, 0x0, 0x0, ...)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:428 +0x8f7
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000d440, 0x6844cc8, 0xc0016be1c0, 0xc000fd0b40, 0xc0016be1c0, 0x5d7a940, 0xc001256400)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/grpc_provider.go:955 +0x8ef
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc001af5360, 0x6844d70, 0xc0016be1c0, 0xc0011e40e0, 0xc001af5360, 0xc0012564e0, 0xc001b83ba0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/server/server.go:332 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x5d7a940, 0xc001af5360, 0x6844d70, 0xc0012564e0, 0xc001402060, 0x0, 0x6844d70, 0xc0012564e0, 0xc00140c700, 0x379)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002908c0, 0x6892598, 0xc000642480, 0xc001406000, 0xc001028ae0, 0x9e56140, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1292 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0002908c0, 0x6892598, 0xc000642480, 0xc001406000, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1617 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000bb4860, 0xc0002908c0, 0x6892598, 0xc000642480, 0xc001406000)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:940 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:938 +0x1fd

Error: The terraform-provider-azurerm_v2.73.0_x5 plugin crashed!

Expected Behaviour

throw error "could not delete the resource" or fail otherwise gracefully

Actual Behaviour

  • panic crash
  • with error: The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@github-actions
Copy link

This functionality has been released in v2.77.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

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 have found a problem that seems similar to this, 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 Oct 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants