hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.65k forks source link

Error: Plugin did not respond #17064

Closed NassaDevops closed 2 years ago

NassaDevops commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.1

AzureRM Provider Version

3.8.0

Affected Resource(s)/Data Source(s)

azurerm_linux_function_app_slot

Terraform Configuration Files

resource "azurerm_linux_function_app" "nassa-reports-function" {
  name                          = "nassa-reports-function-${var.country}"
  location                      = "West US"
  resource_group_name           = azurerm_resource_group.nassa-rg.name
  service_plan_id               = azurerm_service_plan.nassa-appservice-plan.id
  storage_account_name          = azurerm_storage_account.nassa-reports-function.name
  storage_account_access_key    = azurerm_storage_account.nassa-reports-function.primary_access_key
  enabled                       = true
  functions_extension_version   = "~3"

  app_settings = {
    "CONTAINER_NAME"                      = "reports"
    "FUNCTIONS_WORKER_RUNTIME"            = "java"
    "JAVA_OPTS"                           = "-Djava.awt.headless=true"
    "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
    "WEBSITE_ENABLE_SYNC_UPDATE_SITE"     = "true"
    "DOCKER_REGISTRY_SERVER_USERNAME"     = var.acrUserName-prod
    "DOCKER_REGISTRY_SERVER_PASSWORD"     = var.acrPassword-prod
    "AZURE_STORAGE_CONNECTION_STRING"     = var.nassaReportsFunctionConnectionStringProd
    "FUNCTIONS_EXTENSION_VERSION"         = "~3"
    "ASCS_CRPUBLICDEV"                    = var.info
    "ASCS_DEVSALESINSPECTIONWEBCR"        = var.info
  }

  lifecycle {
    ignore_changes = [
      # app_settings,
      # identity,
      # site_config,
    ]
  }

  site_config {
    always_on                        = true
    app_scale_limit                  = 200
    elastic_instance_minimum         = 1
    ftps_state                       = "AllAllowed"
    http2_enabled                    = false
    pre_warmed_instance_count        = 0
    runtime_scale_monitoring_enabled = false
    scm_use_main_ip_restriction      = false   
  }

  tags = {
    Project     = var.project
    CostCenter  = var.country
    Environment = var.environment
    Squad       = var.cross
    Createdby   = var.terraform
  }
}

resource "azurerm_linux_function_app_slot" "nassa-reports-function-dev" {
  name                         = "dev"
  function_app_id              = azurerm_linux_function_app.nassa-reports-function.id
  storage_account_name         = azurerm_storage_account.nassa-reports-function.name
  storage_account_access_key   = azurerm_storage_account.nassa-reports-function.primary_access_key
  enabled                      = true
  functions_extension_version  = "~3"
  app_settings = {
    "CONTAINER_NAME"                      = "reports"
    "FUNCTIONS_WORKER_RUNTIME"            = "java"
    "JAVA_OPTS"                           = "-Djava.awt.headless=true"
    "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
    "WEBSITE_ENABLE_SYNC_UPDATE_SITE"     = "true"
    "DOCKER_REGISTRY_SERVER_USERNAME"     = var.acrUserName-dev
    "DOCKER_REGISTRY_SERVER_PASSWORD"     = var.acrPassword-dev
    "AZURE_STORAGE_CONNECTION_STRING"     = var.nassaReportsFunctionConnectionStringDev
    "FUNCTIONS_EXTENSION_VERSION"         = "~3"
    "ASCS_CRPUBLICDEV"                    = var.info
    "ASCS_DEVSALESINSPECTIONWEBCR"        = var.info
  }

  lifecycle {
    ignore_changes = [
      # app_settings,
      # identity,
      # site_config,
    ]
  }

  site_config {
    always_on                        = true
    app_scale_limit                  = 200
    elastic_instance_minimum         = 1
    ftps_state                       = "AllAllowed"
    http2_enabled                    = false
    pre_warmed_instance_count        = 0
    runtime_scale_monitoring_enabled = false
    scm_use_main_ip_restriction      = false    
  }

  tags = {
    Project     = var.project
    CostCenter  = var.country
    Environment = var.environment
    Squad       = var.cross
    Createdby   = var.terraform
  }

}

Debug Output/Panic Output

panic: runtime error: index out of range [0] with length 0

goroutine 2940 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice.(*LinuxFunctionAppSlotModel).unpackLinuxFunctionAppSettings(0xc0000ba700, {{0xc001f98750}, 0xc002b8ecf0, 0xc0020fd710, 0xc0020fd720, 0x0, 0xc0020fd730}, {0xc001f94700, {0x71daf68, 0xc0004c24f8}, ...})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/linux_function_app_slot_resource.go:826 +0xefd
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice.LinuxFunctionAppSlotResource.Read.func1({0x71d9a68, 0xc000300cc0}, {0xc001f94700, {0x71daf68, 0xc0004c24f8}, 0xc001576d80, 0x0, {0x71dca88, 0xb170708}})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/linux_function_app_slot_resource.go:583 +0x151b
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.(*ResourceWrapper).Resource.func3({0x71d9a68, 0xc000300cc0}, 0x45d964add1?, {0x614ce20?, 0xc001f94700?})
        github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:65 +0x159
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.diagnosticsWrapper.func1({0x71d9a68, 0xc000300cc0}, 0xd5185b8?, {0x614ce20, 0xc001f94700})
        github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:185 +0xbe
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0004f42a0, {0x71d99f8, 0xc0034a7940}, 0x24?, {0x614ce20, 0xc001f94700})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:358 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0004f42a0, {0x71d99f8, 0xc0034a7940}, 0xc0026fc5b0, {0x614ce20, 0xc001f94700})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:635 +0x35b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00069cc60, {0x71d99f8, 0xc0034a7940}, 0xc0034a79c0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:576 +0x43f
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc000243900, {0x71d9aa0?, 0xc00307d590?}, 0xc0003006c0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:553 +0x33c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x66bd0e0?, 0xc000243900}, {0x71d9aa0, 0xc00307d590}, 0xc000300660, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000bae00, {0x71eac18, 0xc000420d80}, 0xc002a60b40, 0xc0014e07b0, 0xb12fa90, 0x0)
        google.golang.org/grpc@v1.39.0/server.go:1292 +0xc6f
google.golang.org/grpc.(*Server).handleStream(0xc0000bae00, {0x71eac18, 0xc000420d80}, 0xc002a60b40, 0x0)
        google.golang.org/grpc@v1.39.0/server.go:1617 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.39.0/server.go:940 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.39.0/server.go:938 +0x28a

Error: The terraform-provider-azurerm_v3.8.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Expected Behaviour

Expected plan as usual

Actual Behaviour

Error: The terraform-provider-azurerm_v3.8.0_x5 plugin crashed!

Steps to Reproduce

We switched from resource "azurerm_function_app" to resource "azurerm_linux_function_app" terraform plan

Important Factoids

no

References

No response

ToroNZ commented 2 years ago

Similar issue here too:

Terraform v1.2.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/azuread v1.6.0
+ provider registry.terraform.io/hashicorp/azurerm v3.8.0
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/random v3.2.0
+ provider registry.terraform.io/hashicorp/tls v3.4.0
╷
│ Error: Plugin did not respond
│ 
│   with azurerm_marketplace_agreement.linux_license_agreement[0],
│   on main.tf line 210, in resource "azurerm_marketplace_agreement" "linux_license_agreement":
│  210: resource "azurerm_marketplace_agreement" "linux_license_agreement" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.cassandravm.data.azurerm_resources.management,
│   on .terraform/modules/cassandravm/data.tf line 3, in data "azurerm_resources" "management":
│    3: data "azurerm_resources" "management" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain
│ more details.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.ea.data.azurerm_backup_policy_vm.backup[0],
│   on .terraform/modules/ea/backup.tf line 74, in data "azurerm_backup_policy_vm" "backup":
│   74: data "azurerm_backup_policy_vm" "backup" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain
│ more details.
╵
╷
│ Error: Plugin did not respond
│ 
│   with module.ea.azurerm_windows_virtual_machine.windows_vm[0],
│   on .terraform/modules/ea/main.tf line 67, in resource "azurerm_windows_virtual_machine" "windows_vm":
│   67: resource "azurerm_windows_virtual_machine" "windows_vm" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-azurerm_v3.8.0_x5 plugin:

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

goroutine 611 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices.dataSourceBackupPolicyVmRead(0x7ff0b3e98f50?, {0x554dfc0?, 0xc0002ea700?})
    github.com/hashicorp/terraform-provider-azurerm/internal/services/recoveryservices/backup_policy_vm_data_source.go:49 +0x55f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x5e7b3c1?, {0x65da938?, 0xc0016fd680?}, 0xc001634f00?, {0x554dfc0?, 0xc0002ea700?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:346 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc0001fa000, {0x65da938, 0xc0016fd680}, 0xc0019d3c80, {0x554dfc0, 0xc0002ea700})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/resource.go:569 +0xf7
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00000c090, {0x65da938, 0xc0016fd680}, 0xc001eec820)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.1/helper/schema/grpc_provider.go:1133 +0x339
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0xc0001d5900, {0x65da9e0?, 0xc001634750?}, 0xc0022e0f00)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:478 +0x31b
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x5abd740?, 0xc0001d5900}, {0x65da9e0, 0xc001634750}, 0xc001c708a0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:416 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000231180, {0x65ebad8, 0xc0001a0900}, 0xc001883200, 0xc001454750, 0xa52c970, 0x0)
    google.golang.org/grpc@v1.39.0/server.go:1292 +0xc6f
google.golang.org/grpc.(*Server).handleStream(0xc000231180, {0x65ebad8, 0xc0001a0900}, 0xc001883200, 0x0)
    google.golang.org/grpc@v1.39.0/server.go:1617 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
    google.golang.org/grpc@v1.39.0/server.go:940 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.39.0/server.go:938 +0x28a

Error: The terraform-provider-azurerm_v3.8.0_x5 plugin crashed!

Odd that it fails only on a single environment (out of 3). The referenced resources above have all been created before using AzureRM 2.x, brownfields.

I've worked around this environment (aka not getting any love anymore).

lungosta commented 2 years ago

Exact same problem here

github-actions[bot] commented 2 years ago

This functionality has been released in v3.11.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[bot] commented 2 years ago

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.