bpg / terraform-provider-proxmox

Terraform / OpenTofu Provider for Proxmox VE
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
892 stars 140 forks source link

The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call #1491

Closed gustavodrodriguez closed 2 months ago

gustavodrodriguez commented 3 months ago

Describe the bug

This error appears when adding a cloud init device to an instance that did not have the resource provisioned.

Description: When running a terraform recipe to add a VM that did not have the cloudinit device, the error appears.

To Reproduce Steps to reproduce the behavior:

  1. With Terraform you create a vm without a cloud init device with a comparison variable so that it does not assign the resource.
  2. The variable is changed so that now the cloudinit resource is added
  3. When applying the changes, the error appears --> Error: Plugin did not respond (*) The user_account part is commented out because that change forces the vm to be regenerated

Please also provide a minimal Terraform configuration that reproduces the issue.


        dynamic "initialization" {
                for_each = var.enable_cloudinit ? [1] : []
                content {
                        datastore_id    = var.disk_storage
                        interface       = var.ci_interface
                        ip_config {
                                ipv4 {
                                        address = var.ci_ipv4_address
                                        gateway = var.ci_ipv4_address == "dhcp" ? null : var.ci_gateway
                                }
                        }
                        #user_account {
                        #       username        = var.ci_user
                        #       keys            = [trimspace(var.ci_sshkey)]
                        #}
                        dns {
                                domain          = var.ci_dns_domain
                                servers         = [var.ci_dns_servers]
                        }
                }
        }

Expected behavior That the resource can be added without problem, as Terraform is proposing when validating the plan

  # module.server.proxmox_virtual_environment_vm.instance[0] will be updated in-place
  ~ resource "proxmox_virtual_environment_vm" "instance" {
        id                      = "8001"
        name                    = "testing-1"
        tags                    = [
            "debian12",
            "testing",
        ]
        # (27 unchanged attributes hidden)

      + initialization {
          + datastore_id = "XXXX"
          + interface    = "sata0"

          + dns {
              + domain  = "XXXXXXXXXXXXXXXXX"
              + servers = [
                  + "10.XXXXXXX",
                ]
            }

          + ip_config {
              + ipv4 {
                  + address = "dhcp"
                }
            }
        }

        # (10 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Additional context

Error Message:

module.server.proxmox_virtual_environment_vm.instance[0]: Modifying... [id=8001]
╷
│ 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.62.0 plugin:

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

goroutine 31 [running]:
github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/vm.vmUpdate({0x11db320, 0xc0007c6a80}, 0xc000252300, {0xf11f40, 0xc0004101b0})
    /home/runner/work/terraform-provider-proxmox/terraform-provider-proxmox/proxmoxtf/resource/vm/vm.go:4959 +0x56e5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002a20e0, {0x11db278, 0xc0002a96b0}, 0xc000252300, {0xf11f40, 0xc0004101b0})
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:840 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002a20e0, {0x11db278, 0xc0002a96b0}, 0xc0003df860, 0xc000252180, {0xf11f40, 0xc0004101b0})
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:947 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000011c68, {0x11db278?, 0xc0002a91a0?}, 0xc000449c20)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x11e7678?, 0xc000011c68?}}, {0x11db278, 0xc0002a91a0}, 0x0?)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:38 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0xc000292e00, {0x11db278?, 0xc0002a8000?}, 0xc000449bd0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000286960, {0x11db278?, 0xc000212cc0?}, 0xc000214b60)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xf9fb40, 0xc000286960}, {0x11db278, 0xc000212cc0}, 0xc00041a480, 0x0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000ff200, {0x11db278, 0xc000212c30}, {0x11e2700, 0xc0001f2300}, 0xc0004acfc0, 0xc0003413b0, 0x1895978, 0x0)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc0000ff200, {0x11e2700, 0xc0001f2300}, 0xc0004acfc0)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-proxmox_v0.62.0 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-08-15T15:23:06.121-0300 [INFO]  backend/local: apply calling Apply
2024-08-15T15:23:06.121-0300 [DEBUG] Building and walking apply graph for NormalMode plan
2024-08-15T15:23:06.124-0300 [DEBUG] adding implicit provider configuration provider["registry.terraform.io/bpg/proxmox"], implied first by module.server.proxmox_virtual_environment_vm.instance (expand)
2024-08-15T15:23:06.124-0300 [DEBUG] ProviderTransformer: "module.server.proxmox_virtual_environment_vm.instance (expand)" (*terraform.nodeExpandApplyableResource) needs module.server.provider["registry.terraform.io/bpg/proxmox"]
2024-08-15T15:23:06.124-0300 [DEBUG] ProviderTransformer: "module.server.proxmox_virtual_environment_vm.instance[0]" (*terraform.NodeApplyableResourceInstance) needs module.server.provider["registry.terraform.io/bpg/proxmox"]
2024-08-15T15:23:06.125-0300 [DEBUG] pruning unused provider["registry.terraform.io/bpg/proxmox"]
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.networks (expand)" references: []
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_kernel (expand)" references: []
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_dns_servers (expand)" references: []
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.mem_balloon (expand)" references: []
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_up_delay (expand)" references: []
2024-08-15T15:23:06.127-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_stop_on_destroy (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_id (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_down_delay (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_type (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_keyboard (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_sshkey (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_tablet (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_limit (expand)" references: []
2024-08-15T15:23:06.128-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_user (expand)" references: []
2024-08-15T15:23:06.129-0300 [DEBUG] ReferenceTransformer: "module.server.proxmox_virtual_environment_vm.instance[0]" references: [module.server.var.vm_qty (expand) module.server.var.vm_description (expand) module.server.var.vm_migrate (expand) module.server.var.vm_scsihw (expand) module.server.var.vm_name (expand) module.server.var.vm_target_node (expand) module.server.var.vm_protection (expand) module.server.var.vm_id (expand) module.server.var.vm_stop_on_destroy (expand) module.server.var.vm_started (expand) module.server.var.vm_keyboard (expand) module.server.var.vm_tags (expand) module.server.var.vm_acpi (expand) module.server.var.vm_bios (expand) module.server.var.vm_tablet (expand) module.server.var.vm_reboot (expand) module.server.var.vm_onboot (expand) module.server.var.networks (expand) module.server.var.volumes (expand) module.server.var.enable_cloudinit (expand) module.server.var.vm_kernel (expand) module.server.var.vm_down_delay (expand) module.server.var.vm_up_delay (expand) module.server.var.agent_type (expand) module.server.var.agent_enable (expand) module.server.var.agent_timeout (expand) module.server.var.agent_trim (expand) module.server.var.vm_template_id (expand) module.server.var.disk_storage (expand) module.server.var.vm_full_clone (expand) module.server.var.vm_target_node (expand) module.server.var.cpu_numa (expand) module.server.var.cpu_limit (expand) module.server.var.cpu_units (expand) module.server.var.cpu_hotplugged (expand) module.server.var.cpu_sockets (expand) module.server.var.cpu_arq (expand) module.server.var.cpu_cores (expand) module.server.var.cpu_type (expand) module.server.var.mem_balloon (expand) module.server.var.mem_shared (expand) module.server.var.mem_qty (expand) module.server.var.disk_storage (expand) module.server.var.disk_storage (expand) module.server.var.ci_interface (expand) module.server.var.ci_ipv4_address (expand) module.server.var.ci_ipv4_address (expand) module.server.var.ci_gateway (expand) module.server.var.ci_dns_domain (expand) module.server.var.ci_dns_servers (expand)]
2024-08-15T15:23:06.129-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_cores (expand)" references: []
2024-08-15T15:23:06.129-0300 [DEBUG] ReferenceTransformer: "module.server.output.vm_ips (expand)" references: [module.server.proxmox_virtual_environment_vm.instance[0] module.server.proxmox_virtual_environment_vm.instance (expand)]
2024-08-15T15:23:06.129-0300 [DEBUG] ReferenceTransformer: "module.server.var.volumes (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_gateway (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_tags (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_qty (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_bios (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.mem_shared (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_description (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_protection (expand)" references: []
2024-08-15T15:23:06.130-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_units (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_arq (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_ipv4_address (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_template_id (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_migrate (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_numa (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_dns_domain (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_started (expand)" references: []
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "output.IPs_Lists (expand)" references: [module.server.output.vm_ips (expand)]
2024-08-15T15:23:06.131-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_full_clone (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.ci_interface (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.provider[\"registry.terraform.io/bpg/proxmox\"]" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.agent_trim (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_target_node (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.agent_enable (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_sockets (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.cpu_hotplugged (expand)" references: []
2024-08-15T15:23:06.132-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_scsihw (expand)" references: []
2024-08-15T15:23:06.133-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_name (expand)" references: []
2024-08-15T15:23:06.133-0300 [DEBUG] ReferenceTransformer: "module.server.var.mem_qty (expand)" references: []
2024-08-15T15:23:06.133-0300 [DEBUG] ReferenceTransformer: "module.server.var.agent_type (expand)" references: []
2024-08-15T15:23:06.133-0300 [DEBUG] ReferenceTransformer: "module.server.proxmox_virtual_environment_vm.instance (expand)" references: [module.server.var.vm_qty (expand) module.server.var.vm_target_node (expand) module.server.var.vm_keyboard (expand) module.server.var.vm_scsihw (expand) module.server.var.vm_tablet (expand) module.server.var.vm_migrate (expand) module.server.var.vm_reboot (expand) module.server.var.vm_tags (expand) module.server.var.vm_acpi (expand) module.server.var.vm_bios (expand) module.server.var.vm_description (expand) module.server.var.vm_id (expand) module.server.var.vm_onboot (expand) module.server.var.vm_started (expand) module.server.var.vm_name (expand) module.server.var.vm_protection (expand) module.server.var.vm_stop_on_destroy (expand) module.server.var.networks (expand) module.server.var.volumes (expand) module.server.var.enable_cloudinit (expand) module.server.var.vm_kernel (expand) module.server.var.vm_down_delay (expand) module.server.var.vm_up_delay (expand) module.server.var.agent_enable (expand) module.server.var.agent_timeout (expand) module.server.var.agent_trim (expand) module.server.var.agent_type (expand) module.server.var.vm_full_clone (expand) module.server.var.vm_target_node (expand) module.server.var.vm_template_id (expand) module.server.var.disk_storage (expand) module.server.var.cpu_limit (expand) module.server.var.cpu_type (expand) module.server.var.cpu_numa (expand) module.server.var.cpu_cores (expand) module.server.var.cpu_units (expand) module.server.var.cpu_hotplugged (expand) module.server.var.cpu_sockets (expand) module.server.var.cpu_arq (expand) module.server.var.mem_balloon (expand) module.server.var.mem_shared (expand) module.server.var.mem_qty (expand) module.server.var.disk_storage (expand) module.server.var.disk_storage (expand) module.server.var.ci_interface (expand) module.server.var.ci_ipv4_address (expand) module.server.var.ci_ipv4_address (expand) module.server.var.ci_gateway (expand) module.server.var.ci_dns_servers (expand) module.server.var.ci_dns_domain (expand)]
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_reboot (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.agent_timeout (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.disk_storage (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_onboot (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.enable_cloudinit (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server.var.vm_acpi (expand)" references: []
2024-08-15T15:23:06.134-0300 [DEBUG] ReferenceTransformer: "module.server (close)" references: []
2024-08-15T15:23:06.139-0300 [DEBUG] pruneUnusedNodes: module.server.var.ci_sshkey (expand) is no longer needed, removing
2024-08-15T15:23:06.139-0300 [DEBUG] pruneUnusedNodes: module.server.var.ci_user (expand) is no longer needed, removing
2024-08-15T15:23:06.140-0300 [DEBUG] Starting graph walk: walkApply
2024-08-15T15:23:06.141-0300 [DEBUG] created provider logger: level=debug
2024-08-15T15:23:06.141-0300 [INFO]  provider: configuring client automatic mTLS
2024-08-15T15:23:06.146-0300 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/bpg/proxmox/0.62.0/linux_amd64/terraform-provider-proxmox_v0.62.0 args=[".terraform/providers/registry.terraform.io/bpg/proxmox/0.62.0/linux_amd64/terraform-provider-proxmox_v0.62.0"]
2024-08-15T15:23:06.146-0300 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/bpg/proxmox/0.62.0/linux_amd64/terraform-provider-proxmox_v0.62.0 pid=38890
2024-08-15T15:23:06.146-0300 [DEBUG] provider: waiting for RPC address: plugin=.terraform/providers/registry.terraform.io/bpg/proxmox/0.62.0/linux_amd64/terraform-provider-proxmox_v0.62.0
2024-08-15T15:23:06.152-0300 [INFO]  provider.terraform-provider-proxmox_v0.62.0: configuring server automatic mTLS: timestamp=2024-08-15T15:23:06.152-0300
2024-08-15T15:23:06.163-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: plugin address: address=/tmp/plugin3306607768 network=unix timestamp=2024-08-15T15:23:06.163-0300
2024-08-15T15:23:06.164-0300 [DEBUG] provider: using plugin: version=6
2024-08-15T15:23:06.174-0300 [INFO]  provider.terraform-provider-proxmox_v0.62.0: Configuring the Proxmox provider...: tf_req_id=411fd408-3bb5-e380-ba7c-4d24b2219a17 tf_rpc=ConfigureProvider @module=proxmox tf_mux_provider="*proto6server.Server" tf_provider_addr=registry.terraform.io/bpg/proxmox @caller=/home/runner/work/terraform-provider-proxmox/terraform-provider-proxmox/fwprovider/provider.go:236 timestamp=2024-08-15T15:23:06.173-0300
2024-08-15T15:23:06.187-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: [DEBUG] A computed value with the empty string as the new value and a non-empty old value was found. Interpreting the empty string as "unset" to align with legacy behavior.
2024-08-15T15:23:06.188-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: [DEBUG] A computed value with the empty string as the new value and a non-empty old value was found. Interpreting the empty string as "unset" to align with legacy behavior.
module.server.proxmox_virtual_environment_vm.instance[0]: Modifying... [id=8001]
2024-08-15T15:23:06.194-0300 [WARN]  Provider "registry.terraform.io/bpg/proxmox" produced an invalid plan for module.server.proxmox_virtual_environment_vm.instance[0], but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .template: planned value cty.False for a non-computed attribute
      - .timeout_create: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_shutdown_vm: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_stop_vm: planned value cty.NumberIntVal(300) for a non-computed attribute
      - .timeout_migrate: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_reboot: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_clone: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_move_disk: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .timeout_start_vm: planned value cty.NumberIntVal(1800) for a non-computed attribute
      - .disk[0].file_id: planned value cty.StringVal("") for a non-computed attribute
      - .disk[0].serial: planned value cty.StringVal("") for a non-computed attribute
      - .network_device[0].trunks: planned value cty.StringVal("") for a non-computed attribute
      - .network_device[1].trunks: planned value cty.StringVal("") for a non-computed attribute
      - .cpu[0].flags: planned value cty.ListValEmpty(cty.String) for a non-computed attribute
      - .cpu[0].affinity: planned value cty.StringVal("") for a non-computed attribute
      - .startup[0].order: planned value cty.NumberIntVal(-1) for a non-computed attribute
      - .memory[0].hugepages: planned value cty.StringVal("") for a non-computed attribute
      - .clone[0].retries: planned value cty.NumberIntVal(1) for a non-computed attribute
2024-08-15T15:23:06.194-0300 [INFO]  Starting apply for module.server.proxmox_virtual_environment_vm.instance[0]
2024-08-15T15:23:06.196-0300 [DEBUG] module.server.proxmox_virtual_environment_vm.instance[0]: applying the planned Update change
0
2024-08-15T15:23:06.219-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: panic: runtime error: index out of range [0] with length 0
2024-08-15T15:23:06.219-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0
2024-08-15T15:23:06.220-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: goroutine 31 [running]:
2024-08-15T15:23:06.220-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/vm.vmUpdate({0x11db320, 0xc0005e15e0}, 0xc00041a200, {0xf11f40, 0xc0004101b0})
2024-08-15T15:23:06.220-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/work/terraform-provider-proxmox/terraform-provider-proxmox/proxmoxtf/resource/vm/vm.go:4959 +0x56e5
2024-08-15T15:23:06.220-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002a00e0, {0x11db278, 0xc0002ad6e0}, 0xc00041a200, {0xf11f40, 0xc0004101b0})
2024-08-15T15:23:06.220-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:840 +0x119
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002a00e0, {0x11db278, 0xc0002ad6e0}, 0xc0003755f0, 0xc00041b600, {0xf11f40, 0xc0004101b0})
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:947 +0x83a
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000011c98, {0x11db278?, 0xc0002ad260?}, 0xc00044bc20)
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x11e7678?, 0xc000011c98?}}, {0x11db278, 0xc0002ad260}, 0x0?)
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:38 +0x54
2024-08-15T15:23:06.221-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0xc000294e00, {0x11db278?, 0xc0002ac360?}, 0xc00044bbd0)
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000288a00, {0x11db278?, 0xc000216cf0?}, 0xc0002136c0)
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:865 +0x3d0
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xf9fb40, 0xc000288a00}, {0x11db278, 0xc000216cf0}, 0xc00041a300, 0x0)
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:518 +0x1a6
2024-08-15T15:23:06.222-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000101200, {0x11db278, 0xc000216c60}, {0x11e2700, 0xc0001f6300}, 0xc00049f320, 0xc0003413b0, 0x1895978, 0x0)
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: google.golang.org/grpc.(*Server).handleStream(0xc000101200, {0x11e2700, 0xc0001f6300}, 0xc00049f320)
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: google.golang.org/grpc.(*Server).serveStreams.func2.1()
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0: created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
2024-08-15T15:23:06.223-0300 [DEBUG] provider.terraform-provider-proxmox_v0.62.0:   /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x125
2024-08-15T15:23:06.224-0300 [ERROR] plugin6.(*GRPCProvider).ApplyResourceChange: error="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-08-15T15:23:06.226-0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-08-15T15:23:06.226-0300 [ERROR] provider: error encountered while scanning stdout: error="read |0: file already closed"
2024-08-15T15:23:06.226-0300 [ERROR] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/bpg/proxmox/0.62.0/linux_amd64/terraform-provider-proxmox_v0.62.0 id=38890 error="exit status 2"
2024-08-15T15:23:06.228-0300 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-08-15T15:23:06.228-0300 [ERROR] vertex "module.server.proxmox_virtual_environment_vm.instance[0]" 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.62.0 plugin:

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

goroutine 31 [running]:
github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/vm.vmUpdate({0x11db320, 0xc0005e15e0}, 0xc00041a200, {0xf11f40, 0xc0004101b0})
    /home/runner/work/terraform-provider-proxmox/terraform-provider-proxmox/proxmoxtf/resource/vm/vm.go:4959 +0x56e5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc0002a00e0, {0x11db278, 0xc0002ad6e0}, 0xc00041a200, {0xf11f40, 0xc0004101b0})
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:840 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0002a00e0, {0x11db278, 0xc0002ad6e0}, 0xc0003755f0, 0xc00041b600, {0xf11f40, 0xc0004101b0})
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:947 +0x83a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000011c98, {0x11db278?, 0xc0002ad260?}, 0xc00044bc20)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x11e7678?, 0xc000011c98?}}, {0x11db278, 0xc0002ad260}, 0x0?)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:38 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0xc000294e00, {0x11db278?, 0xc0002ac360?}, 0xc00044bbd0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc000288a00, {0x11db278?, 0xc000216cf0?}, 0xc0002136c0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0xf9fb40, 0xc000288a00}, {0x11db278, 0xc000216cf0}, 0xc00041a300, 0x0)
    /home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000101200, {0x11db278, 0xc000216c60}, {0x11e2700, 0xc0001f6300}, 0xc00049f320, 0xc0003413b0, 0x1895978, 0x0)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc000101200, {0x11e2700, 0xc0001f6300}, 0xc00049f320)
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
    /home/runner/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x125

Error: The terraform-provider-proxmox_v0.62.0 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-08-15T15:23:06.231-0300 [DEBUG] provider: plugin exited

Thanks for the help

bpg commented 3 months ago

Hi @gustavodrodriguez

The cloud-init (i.e. initialization block) cannot be added to already provisioned VM, as its whole purpose is to initialize the VM at the first boot up.

Seems to be a duplicate of #1400

bpg commented 2 months ago

Closing as a duplicate