bpg / terraform-provider-proxmox

Terraform Provider for Proxmox
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
853 stars 138 forks source link

hostpci always gets updated to same value if set (if more than 4) #1541

Closed aamkye closed 1 month ago

aamkye commented 1 month ago

Describe the bug A clear and concise description of what the bug is. While having more than hostpci blocks in proxmox_virtual_environment_vm resource, anything above 4 blocks tries to update even if the same and already set (observed even on import).

To Reproduce Steps to reproduce the behavior:

  1. Import/create VM with more than 4 hostpci blocks in proxmox_virtual_environment_vm resource.
resource "proxmox_virtual_environment_vm" "test" {
  vm_id     = 100
  node_name = "test"
  name      = "test.test"

  hostpci {
    device  = "hostpci0"
    ...
  }

  hostpci {
    device  = "hostpci1"
    ...
  }

  hostpci {
    device  = "hostpci2"
    ...
  }

  hostpci {
    device  = "hostpci3"
    ...
  }

  hostpci {
    device  = "hostpci4"
    ...
  }

  hostpci {
    device  = "hostpci5"
    ...
  }

  hostpci {
    device  = "hostpci6"
    ...
  }

  hostpci {
    device  = "hostpci7"
    ...
  }

  hostpci {
    device  = "hostpci8"
    ...
  }
}

Expected behavior Everything applies as expected and the state is updated to corespondent state.

Screenshots CleanShot 2024-09-18 at 23 25 51

Additional context Add any other context about the problem here.

Toggle me! ![CleanShot 2024-09-18 at 23 38 18](https://github.com/user-attachments/assets/955f6a0e-2d96-4bfa-828d-d7a861028679) ```shell https://pastebin.com/09jXN4R0 ```
bpg commented 1 month ago

Hey @aamkye! 👋🏼

Thanks for the report. Should be relatively easy to fix.

bpg commented 1 month ago

Based on /usr/share/perl5/PVE/QemuServer/PCI.pm, the maximum number of hostpci devices is 16, so it will be better to fix this properly, rather than hardcoding 16 fields