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

Provider panic when empty ip_config is present in initialization section, when provisioning container #936

Closed
Anfer410 opened this issue Jan 20, 2024 · 1 comment · Fixed by #977
Labels
🐛 bug Something isn't working

Comments

@Anfer410
Copy link

Describe the bug
Not sure if that is desired behavior but I run in to an error when trying to persist ip address to the secondary network device, when primary one needs to stay without configuration.

To Reproduce
Steps to reproduce the behavior:

  1. Create a container resource with multiple network devices and create initialization config with at least one empty ip_config.

  2. Run terraform plan

  3. See error

module.lxc_debian_gateway.proxmox_virtual_environment_container.lxc_container: Modifying... [id=4000]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-proxmox_v0.43.3 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 81 [running]:
github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource.containerUpdate({0x106d7f0, 0xc000534930}, 0xc000417100, {0xe38340?, 0xc000015710?})
       github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/container.go:2529 +0x3586
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002f49a0, {0x106d748, 0xc000627110}, 0xd?, {0xe38340, 0xc000015710})
       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:812 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002f49a0, {0x106d748, 0xc000627110}, 0xc0000c2000, 0xc000416e00, {0xe38340, 0xc000015710})
       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0001173f8, {0x106d748?, 0xc000626f60?}, 0xc0006283c0)
       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xdbc
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x1074e20?, 0xc0001173f8?}}, {0x106d748, 0xc000626f60}, 0x0?)
       github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x106d780?, {0x106d748?, 0xc000626c60?}, 0xc000628370)
       github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc00026b900, {0x106d748?, 0xc000626240?}, 0xc0000d8000)
       github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xeb7a40?, 0xc00026b900}, {0x106d748, 0xc000626240}, 0xc000416280, 0x0)
       github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00025e1e0, {0x106d748, 0xc0006261b0}, {0x10733d0, 0xc0000fe000}, 0xc00062c000, 0xc0003bec30, 0x167ed98, 0x0)
       google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc00025e1e0, {0x10733d0, 0xc0000fe000}, 0xc00062c000)
       google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
       google.golang.org/grpc@v1.60.0/server.go:1016 +0x59
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 11
       google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

Error: The terraform-provider-proxmox_v0.43.3 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.




  1. Please also provide a minimal Terraform configuration that reproduces the issue.
resource "proxmox_virtual_environment_container" "lxc_container" {
  description = "Managed by Terraform"

  node_name = var.node_id

  unprivileged = var.unprivileged
  
  initialization {
    hostname = var.hostname
    
    user_account {
      password = "123456"
    }
        
    
    ip_config {
      
    }
    ip_config {
      ipv4 {
        address = "192.0.0.10/24"
      }
    }
    
  }


  network_interface {
    name    = "veth0"
  }
  network_interface {
    name    = "veth1"
  }

  operating_system {
    template_file_id = var.lxc_template["template_file_id"]
    type             = var.lxc_template["type"]
  }

  disk {
    datastore_id = var.rootfs.datastore_id
    size         = var.rootfs.size
  }

}

Expected behavior
Network device should be initialized with empty static ip

  • Clustered Proxmox:
  • Provider version (ideally it should be the latest version): PVE 8.1.3, terraform-provider-proxmox_v0.43.3
  • Terraform version: Terraform v1.7.0
  • OS (where you run Terraform from): linux_amd64 (debian)
  • Debug logs (TF_LOG=DEBUG terraform apply):
 module.lxc_debian_gateway.proxmox_virtual_environment_container.lxc_container: Modifying... [id=4000]
2024-01-19T20:06:33.260-0500 [INFO]  Starting apply for module.lxc_debian_gateway.proxmox_virtual_environment_container.lxc_container
2024-01-19T20:06:33.260-0500 [DEBUG] module.lxc_debian_gateway.proxmox_virtual_environment_container.lxc_container: applying the planned Update change
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: panic: interface conversion: interface {} is nil, not map[string]interface {}
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: goroutine 52 [running]:
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource.containerUpdate({0x106d7f0, 0xc00030cee0}, 0xc0000fde00, {0xe38340?, 0xc0000aa4b0?})
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/container.go:2529 +0x3586
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002e29a0, {0x106d748, 0xc0005becf0}, 0xd?, {0xe38340, 0xc0000aa4b0})
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:812 +0x11b
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002e29a0, {0x106d748, 0xc0005becf0}, 0xc000142dd0, 0xc0000fdc80, {0xe38340, 0xc0000aa4b0})
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x83a
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000011410, {0x106d748?, 0xc0005beb40?}, 0xc000453860)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xdbc
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x1074e20?, 0xc000011410?}}, {0x106d748, 0xc0005beb40}, 0x0?)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x54
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x106d780?, {0x106d748?, 0xc000182c00?}, 0xc00041e5f0)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000261900, {0x106d748?, 0xc0001820f0?}, 0xc0000da380)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xeb7a40?, 0xc000261900}, {0x106d748, 0xc0001820f0}, 0xc0000fc800, 0x0)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002541e0, {0x106d748, 0xc000182000}, {0x10733d0, 0xc0004101a0}, 0xc0005417a0, 0xc0003acc30, 0x167ed98, 0x0)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: google.golang.org/grpc.(*Server).handleStream(0xc0002541e0, {0x10733d0, 0xc0004101a0}, 0xc0005417a0)
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: google.golang.org/grpc.(*Server).serveStreams.func2.1()
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       google.golang.org/grpc@v1.60.0/server.go:1016 +0x59
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3: created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 20
2024-01-19T20:06:33.267-0500 [DEBUG] provider.terraform-provider-proxmox_v0.43.3:       google.golang.org/grpc@v1.60.0/server.go:1027 +0x115
2024-01-19T20:06:33.268-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/bpg/proxmox/0.43.3/linux_amd64/terraform-provider-proxmox_v0.43.3 pid=63221 error="exit status 2"
2024-01-19T20:06:33.268-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-19T20:06:33.268-0500 [ERROR] plugin6.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-19T20:06:33.280-0500 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-01-19T20:06:33.280-0500 [ERROR] vertex "module.lxc_debian_gateway.proxmox_virtual_environment_container.lxc_container" error: Plugin did not respond
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-proxmox_v0.43.3 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 52 [running]:
github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource.containerUpdate({0x106d7f0, 0xc00030cee0}, 0xc0000fde00, {0xe38340?, 0xc0000aa4b0?})
        github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/container.go:2529 +0x3586
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002e29a0, {0x106d748, 0xc0005becf0}, 0xd?, {0xe38340, 0xc0000aa4b0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:812 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002e29a0, {0x106d748, 0xc0005becf0}, 0xc000142dd0, 0xc0000fdc80, {0xe38340, 0xc0000aa4b0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/resource.go:919 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000011410, {0x106d748?, 0xc0005beb40?}, 0xc000453860)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.31.0/helper/schema/grpc_provider.go:1074 +0xdbc
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x1074e20?, 0xc000011410?}}, {0x106d748, 0xc0005beb40}, 0x0?)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf5to6server/tf5to6server.go:37 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x106d780?, {0x106d748?, 0xc000182c00?}, 0xc00041e5f0)
        github.com/hashicorp/terraform-plugin-mux@v0.13.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000261900, {0x106d748?, 0xc0001820f0?}, 0xc0000da380)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xeb7a40?, 0xc000261900}, {0x106d748, 0xc0001820f0}, 0xc0000fc800, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002541e0, {0x106d748, 0xc000182000}, {0x10733d0, 0xc0004101a0}, 0xc0005417a0, 0xc0003acc30, 0x167ed98, 0x0)
        google.golang.org/grpc@v1.60.0/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc0002541e0, {0x10733d0, 0xc0004101a0}, 0xc0005417a0)
        google.golang.org/grpc@v1.60.0/server.go:1783 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.0/server.go:1016 +0x59
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 20
        google.golang.org/grpc@v1.60.0/server.go:1027 +0x115

Error: The terraform-provider-proxmox_v0.43.3 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.

2024-01-19T20:06:33.284-0500 [DEBUG] provider: plugin exited
2024-01-19T20:06:33.284-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-19T20:06:33.284-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-19T20:06:33.284-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/http/3.4.1/linux_amd64/terraform-provider-http_v3.4.1_x5 pid=63196
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin exited
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/local/2.4.1/linux_amd64/terraform-provider-local_v2.4.1_x5 pid=63205
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin exited
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/massdriver-cloud/jq/0.2.0/linux_amd64/terraform-provider-jq_v0.2.0 pid=63233
2024-01-19T20:06:33.285-0500 [DEBUG] provider: plugin exited
@bpg
Copy link
Owner

bpg commented Jan 20, 2024

Thanks!
It is very similar to #918. I guess there are plenty of similar use cases where checks for empty blocks are missing.

A fair warning though, the empty sections will stay in the terraform state, but won't be reflected in any way in the VM state in PVE, so the TF plan will always complain that there is a change, and will try to apply that empty section every time (which will be no-op after the fix).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants