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

panic: interface conversion: interface {} is string, not float64 #1209

Open
frederikkunze opened this issue Dec 20, 2024 · 5 comments
Open

Comments

@frederikkunze
Copy link

When i try to apply followong terraform the plugin does crash

terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
}
}
}

provider "proxmox" {
pm_api_url = "https://cleanedup:8006/api2/json"
pm_api_token_id = "cleanedup"
pm_api_token_secret = "cleanedup"
pm_tls_insecure = true
}

resource "proxmox_vm_qemu" "vm-instance" {
name = "vm-instance"
target_node = "pve01"
clone = "ubuntu-2404-template"
full_clone = true
cores = 2
memory = 2048

disk {
    size            = "32G"
    type            = "scsi"
    storage         = "local-lvm"
    discard         = "on"
}

network {
    model     = "virtio"
    bridge    = "vmbr1"
    firewall  = false
    link_down = false
}

}

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:

  • create

Terraform will perform the following actions:

proxmox_vm_qemu.vm-instance will be created

  • resource "proxmox_vm_qemu" "vm-instance" {
    • additional_wait = 5

    • automatic_reboot = true

    • balloon = 0

    • bios = "seabios"

    • boot = (known after apply)

    • bootdisk = (known after apply)

    • clone = "ubuntu-2404-template"

    • clone_wait = 10

    • cores = 2

    • cpu = "host"

    • default_ipv4_address = (known after apply)

    • define_connection_info = true

    • force_create = false

    • full_clone = true

    • guest_agent_ready_timeout = 100

    • hotplug = "network,disk,usb"

    • id = (known after apply)

    • kvm = true

    • memory = 2048

    • name = "vm-instance"

    • nameserver = (known after apply)

    • onboot = false

    • oncreate = true

    • preprovision = true

    • reboot_required = (known after apply)

    • scsihw = "lsi"

    • searchdomain = (known after apply)

    • sockets = 1

    • ssh_host = (known after apply)

    • ssh_port = (known after apply)

    • tablet = true

    • target_node = "pve01"

    • unused_disk = (known after apply)

    • vcpus = 0

    • vlan = -1

    • vmid = (known after apply)

    • disk {

      • backup = true
      • cache = "none"
      • discard = "on"
      • file = (known after apply)
      • format = (known after apply)
      • iops = 0
      • iops_max = 0
      • iops_max_length = 0
      • iops_rd = 0
      • iops_rd_max = 0
      • iops_rd_max_length = 0
      • iops_wr = 0
      • iops_wr_max = 0
      • iops_wr_max_length = 0
      • iothread = 0
      • mbps = 0
      • mbps_rd = 0
      • mbps_rd_max = 0
      • mbps_wr = 0
      • mbps_wr_max = 0
      • media = (known after apply)
      • replicate = 0
      • size = "32G"
      • slot = (known after apply)
      • ssd = 0
      • storage = "local-lvm"
      • storage_type = (known after apply)
      • type = "scsi"
      • volume = (known after apply)
        }
    • network {

      • bridge = "vmbr1"
      • firewall = false
      • link_down = false
      • macaddr = (known after apply)
      • model = "virtio"
      • queues = (known after apply)
      • rate = (known after apply)
      • tag = -1
        }
        }

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

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

proxmox_vm_qemu.vm-instance: Creating...

│ Error: Plugin did not respond

│ with proxmox_vm_qemu.vm-instance,
│ on main.tf line 16, in resource "proxmox_vm_qemu" "vm-instance":
│ 16: resource "proxmox_vm_qemu" "vm-instance" {

│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The
│ plugin logs may contain more details.

Stack trace from the terraform-provider-proxmox_v2.9.14.exe plugin:

panic: interface conversion: interface {} is string, not float64

goroutine 106 [running]:
github.com/Telmate/proxmox-api-go/proxmox.NewConfigQemuFromApi(0xc0003006c0, 0x0?)
github.com/Telmate/[email protected]/proxmox/config_qemu.go:584 +0x4605
github.com/Telmate/terraform-provider-proxmox/proxmox.prepareDiskSize(0x0?, 0xc0003125c0?, 0xb?, 0x0?)
github.com/Telmate/terraform-provider-proxmox/proxmox/resource_vm_qemu.go:1737 +0xeb
github.com/Telmate/terraform-provider-proxmox/proxmox.resourceVmQemuCreate(0xc000274900, {0xa58680?, 0xc0003351d0})
github.com/Telmate/terraform-provider-proxmox/proxmox/resource_vm_qemu.go:1059 +0x1cb2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xcda800?, {0xcda800?, 0xc000108b70?}, 0xd?, {0xa58680?, 0xc0003351d0?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003dc7e0, {0xcda800, 0xc000108b70}, 0xc000596ea0, 0xc000274a80, {0xa58680, 0xc0003351d0})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000464c60, {0xcda800?, 0xc000108a50?}, 0xc0004f4230)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00011a3c0, {0xcda800?, 0xc00018a390?}, 0xc000210070)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xb5f460?, 0xc00011a3c0}, {0xcda800, 0xc00018a390}, 0xc000210000, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00047e000, {0xcde3e0, 0xc0005841a0}, 0xc0003a2000, 0xc000480c00, 0x11a0880, 0x0)
google.golang.org/[email protected]/server.go:1336 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc00047e000, {0xcde3e0, 0xc0005841a0}, 0xc0003a2000, 0x0)
google.golang.org/[email protected]/server.go:1704 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-proxmox_v2.9.14.exe plugin crashed!

@wt2v
Copy link

wt2v commented Dec 28, 2024

I get the same error, although the VM is created and i can manually start it up fine.

When i enable debug logging, it looks like the type error is in the response from proxmox, where the "memory" is is formatted as a string unlike e.g. "cores".

This is the my first time trying out both proxmox and terraform, so I might be wrong.

2024-12-28T21:32:51.406+0100 [INFO]  provider.terraform-provider-proxmox_v2.9.14: 2024/12/28 21:32:51 >>>>>>>>>> REQUEST:
GET /api2/json/nodes/proxmox/qemu/106/config HTTP/1.1
Host: 100.118.234.34:8006
User-Agent: Go-http-client/1.1
Accept: application/json
Authorization: PVEAPIToken=terraform@pam!provision=<api_key>
Accept-Encoding: gzip
: timestamp="2024-12-28T21:32:51.406+0100"

2024-12-28T21:32:51.429+0100 [INFO]  provider.terraform-provider-proxmox_v2.9.14: 2024/12/28 21:32:51 <<<<<<<<<< RESULT:
HTTP/1.1 200 OK
Content-Length: 564
Cache-Control: max-age=0
Connection: Keep-Alive
Content-Type: application/json;charset=UTF-8
Date: Sat, 28 Dec 2024 20:32:54 GMT
Expires: Sat, 28 Dec 2024 20:32:54 GMT
Pragma: no-cache
Server: pve-api-daemon/3.0
{"data":{"smbios1":"uuid=9bfe0eea-c057-41bc-a578-cf0878b084aa","scsihw":"virtio-scsi-single","ostype":"l26","cpu":"x86-64-v2-AES","cores":2,"scsi0":"local-lvm:vm-106-disk-0,iothread=1,size=32G","sockets":1,"name":"vm-instance","numa":0,"net0":"virtio=BC:24:11:71:7B:97,bridge=vmbr1,firewall=1","boot":"order=scsi0;ide2;net0","vmgenid":"29bb7a0c-5a9f-4591-b5d4-a0d39c00df92","ide2":"local:iso/alpine-standard-3.21.0-x86_64.iso,media=cdrom,size=240M","digest":"365b655838eb76e1d38a1b4215fab1a9e4b9b391","meta":"creation-qemu=9.0.2,ctime=1735416692","memory":"2048"}}: timestamp="2024-12-28T21:32:51.429+0100"

@wt2v
Copy link

wt2v commented Dec 29, 2024

I had a try at it again, where i set up a proxy between terraform and proxmox, that changed the value of "memory" from string to integer for requests to the endpoint /nodes/proxmox/qemu/<vm_id>/config. And it worked!

This could easily be handled by the provider, but isn't this an error that should be fixed in Proxmox?

@Yfksw65
Copy link

Yfksw65 commented Jan 5, 2025

Same problem for me, any fix please ?

@ksparwald
Copy link

Hi there,

Unfortunately the 2.x provider version is broken.
Please try the 3.0.1-rc6 version.
Also check the documentation because the schema has changed!

@Yfksw65
Copy link

Yfksw65 commented Jan 5, 2025

Everything is fine in 3.0.1-rc6 thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants