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

Container Instance with optional dns server causes crash #19989

Closed
1 task done
ste-camp opened this issue Jan 12, 2023 · 3 comments · Fixed by #20002
Closed
1 task done

Container Instance with optional dns server causes crash #19989

ste-camp opened this issue Jan 12, 2023 · 3 comments · Fixed by #20002

Comments

@ste-camp
Copy link

ste-camp commented Jan 12, 2023

Is there an existing issue for this?

  • I have searched the existing issues

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 Version

1.3.7

AzureRM Provider Version

3.37.0

Affected Resource(s)/Data Source(s)

azurerm_container_group

Terraform Configuration Files

resource "azurerm_virtual_network" "vnet" {
  name                = "vnt-001"
  location            = var.general.location
  resource_group_name = var.general.rg_name
  address_space       = var.address_ranges.vnet
}

resource "azurerm_subnet" "aci-subnet" {
  name                 = "sbn-002"
  resource_group_name  = var.general.rg_name
  virtual_network_name = azurerm_virtual_network.vnet.name
  address_prefixes     = var.address_ranges.sbn_aci
  delegation {
    name = "delegation"
    service_delegation {
      name = "Microsoft.ContainerInstance/containerGroups"
      actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
    }
  }
}

resource "azurerm_container_group" "agent" {
  name                = "aci-001"
  location            = var.general.location
  resource_group_name = var.general.rg_name
  ip_address_type     = "Private"
  os_type             = "Linux"
  subnet_ids          = [azurerm_subnet.aci-subnet.id]
  restart_policy      = "OnFailure"

  dynamic "dns_config" {
    for_each = (azurerm_virtual_network.vnet.dns_servers == [] || azurerm_virtual_network.vnet.dns_servers == null) ? [] : [1]
    content {
      nameservers    = azurerm_virtual_network.vnet.dns_servers
    }
  }

  container {
    name   = "devops-agent"
    image  = var.agent_image
    cpu    = "1"
    memory = "4"

    ports {
      port     = 22
      protocol = "TCP"
    }
  }

  exposed_port {
    port = 22
    protocol = "TCP"
  }
}

Debug Output/Panic Output

Stack trace from the terraform-provider-azurerm_v3.37.0_x5.exe plugin:
2023-01-12T15:09:08.9097908Z 
2023-01-12T15:09:08.9098357Z panic: interface conversion: interface {} is nil, not map[string]interface {}
2023-01-12T15:09:08.9098632Z 
2023-01-12T15:09:08.9098931Z goroutine 332 [running]:
2023-01-12T15:09:08.9099587Z github.com/hashicorp/terraform-provider-azurerm/internal/services/containers.expandContainerGroupDnsConfig({0x6547500?, 0xc001dd6920?})
2023-01-12T15:09:08.9101402Z 	github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/container_group_resource.go:1976 +0x658
2023-01-12T15:09:08.9102389Z github.com/hashicorp/terraform-provider-azurerm/internal/services/containers.resourceContainerGroupCreate(0xc002206500, {0x6726c00?, 0xc0006cd800})
2023-01-12T15:09:08.9103317Z 	github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/container_group_resource.go:708 +0xdb3
2023-01-12T15:09:08.9104212Z github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x7992380?, {0x7992380?, 0xc001d90750?}, 0xd?, {0x6726c00?, 0xc0006cd800?})
2023-01-12T15:09:08.9105314Z 	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:695 +0x178
2023-01-12T15:09:08.9106274Z github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000ad2700, {0x7992380, 0xc001d90750}, 0xc001d98dd0, 0xc002206380, {0x6726c00, 0xc0006cd800})
2023-01-12T15:09:08.9108038Z 	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:837 +0xa85
2023-01-12T15:09:08.9108963Z github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0005e5500, {0x7992380?, 0xc001d90630?}, 0xc0015fcc80)
2023-01-12T15:09:08.9109909Z 	github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:1021 +0xe8d
2023-01-12T15:09:08.9110847Z github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000170c80, {0x7992380?, 0xc001d90000?}, 0xc0012eaf50)
2023-01-12T15:09:08.9113987Z 	github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/tf5server/server.go:818 +0x574
2023-01-12T15:09:08.9115043Z github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x6dd9960?, 0xc000170c80}, {0x7992380, 0xc001d90000}, 0xc0012eaee0, 0x0)
2023-01-12T15:09:08.9115836Z 	github.com/hashicorp/terraform-plugin-go@v0.14.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
2023-01-12T15:09:08.9116443Z google.golang.org/grpc.(*Server).processUnaryRPC(0xc00001e000, {0x79a4520, 0xc000d221a0}, 0xc00197a6c0, 0xc0017f9a40, 0xbc5d1a0, 0x0)
2023-01-12T15:09:08.9116962Z 	google.golang.org/grpc@v1.50.1/server.go:1340 +0xd23
2023-01-12T15:09:08.9117594Z google.golang.org/grpc.(*Server).handleStream(0xc00001e000, {0x79a4520, 0xc000d221a0}, 0xc00197a6c0, 0x0)
2023-01-12T15:09:08.9118062Z 	google.golang.org/grpc@v1.50.1/server.go:1713 +0xa2f
2023-01-12T15:09:08.9118437Z google.golang.org/grpc.(*Server).serveStreams.func1.2()
2023-01-12T15:09:08.9118806Z 	google.golang.org/grpc@v1.50.1/server.go:965 +0x98
2023-01-12T15:09:08.9119194Z created by google.golang.org/grpc.(*Server).serveStreams.func1
2023-01-12T15:09:08.9119566Z 	google.golang.org/grpc@v1.50.1/server.go:963 +0x28a
2023-01-12T15:09:08.9119739Z 
2023-01-12T15:09:08.9120046Z Error: The terraform-provider-azurerm_v3.37.0_x5.exe plugin crashed!
2023-01-12T15:09:08.9120243Z 
2023-01-12T15:09:08.9121414Z This is always indicative of a bug within the plugin. It would be immensely
2023-01-12T15:09:08.9121839Z helpful if you could report the crash with the plugin's maintainers so that it
2023-01-12T15:09:08.9122246Z can be fixed. The output above should help diagnose the issue.
2023-01-12T15:09:08.9122430Z 
2023-01-12T15:09:08.9294587Z ##[error]Terraform command 'apply' failed with exit code '1'.:  The terraform-provider-azurerm_v3.37.0_x5.exe plugin crashed!
2023-01-12T15:09:08.9513720Z ##[error]�[31m╷�[0m�[0m

Expected Behaviour

I wanted to configure a container instance that supported both having and not having a dns_config block, depending on how the VNet component is configured (in the example it doesn't have custom DNS)

I expected the plugin to be able create the Container Instance with no dns_config section in this case

Actual Behaviour

It totally crashes the terraform executable and in my opinion the syntax for the dynamic block is not wrong, so I suspect it may be a bug

Steps to Reproduce

No response

Important Factoids

No response

References

No response

@sinbai
Copy link
Contributor

sinbai commented Jan 13, 2023

@ste-camp thanks for opening this issue. I have submitted PR to fix it. Could you track it for more updates?

@mbfrahry mbfrahry added this to the v3.40.0 milestone Jan 13, 2023
@github-actions
Copy link

This functionality has been released in v3.40.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 Feb 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants