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

[3.0.1-rc2] Error refresh state USB passthrough device #1032

Closed
den-patrakeev opened this issue Jun 4, 2024 · 19 comments · Fixed by #1143
Closed

[3.0.1-rc2] Error refresh state USB passthrough device #1032

den-patrakeev opened this issue Jun 4, 2024 · 19 comments · Fixed by #1143

Comments

@den-patrakeev
Copy link

den-patrakeev commented Jun 4, 2024

Hi, migrates from 3.0.1-rc1 to 3.0.1-rc2 and fix error with USB passthrough device.

Proxmox VE cluster with version nodes: 8.0.4 and 8.2.2
Terraform - 1.8.4

USB manually config in VM by root and fix in .tfstate by terraform refresh.
Ignore changes in state VM from provider by this:

  lifecycle {
    ignore_changes = [
      usb
    ]
  }

In new version 3.0.1-rc2 error by terraform refresh or terraform plan:

│ Error: Invalid address to set: []string{"usb", "0", "id"}
│ 
│   with proxmox_vm_qemu._101_xxx,
│   on 101_xxx.tf line 3, in resource "proxmox_vm_qemu" "_101_xxx":
│    3: resource "proxmox_vm_qemu" "_101_xxx" {
@den-patrakeev den-patrakeev changed the title [3.0.1-rc2] Error refresh USB passthrough device [3.0.1-rc2] Error refresh state USB passthrough device Jun 4, 2024
@maksimsamt
Copy link
Contributor

Try this ignore_changes:

...
    ignore_changes = [
      usb[0]
    ]
...

or

...
    ignore_changes = [
      usb[0].host
      usb[0].usb3
    ]
...

@den-patrakeev
Copy link
Author

Try this ignore_changes:

...
    ignore_changes = [
      usb[0]
    ]
...

or

...
    ignore_changes = [
      usb[0].host
      usb[0].usb3
    ]
...

Hi! Thank you!
Unfortunately this didn't help.

@maksimsamt
Copy link
Contributor

Hi! Thank you! Unfortunately this didn't help.

Can you share your config snippet with usb block/blocks?

@Aksogen
Copy link

Aksogen commented Jun 5, 2024

The same error with hostpci section
Invalid address to set: []string{"hostpci", "0", "id"}

block:

    dynamic hostpci {
        for_each = var.vm_pci_devices
        content {
            host   = hostpci.value.id
            rombar = hostpci.value.rombar
            pcie   = hostpci.value.pcie
        }
    }
    vm_pci_devices = [
        { id = "0000:00:02", rombar = 1, pcie = 0 }
    ]

@maksimsamt
Copy link
Contributor

The same error with hostpci section Invalid address to set: []string{"hostpci", "0", "id"}

block:

    dynamic hostpci {
        for_each = var.vm_pci_devices
        content {
            host   = hostpci.value.id
            rombar = hostpci.value.rombar
            pcie   = hostpci.value.pcie
        }
    }
    vm_pci_devices = [
        { id = "0000:00:02", rombar = 1, pcie = 0 }
    ]
  1. I'm not sure if you're using Terraform dynamic blocks correctly.
...
dynamic hostpci {
...

As per Terraform documentation it should be like this:

...
dynamic "hostpci" {
...
  1. Are you sure the latest version of the provider supports hostpci?

I couldn't find anything similar in Temate provider documentation

@Aksogen
Copy link

Aksogen commented Jun 5, 2024

  1. you can use both variants: example of working dynamic block (network)
    dynamic network {
        for_each = var.vm_network_interfaces
        content {
            bridge   = network.value.bridge
            model    = network.value.model
            firewall = network.value.firewall
            tag      = network.value.vlan        
        }
    }
  1. So..it worked before, and it didn't say in the change notes that it no longer works :|
    hostpci block was added in v2.9.14 (How to enable PCI passthrough #299)

(anyway it present in

)

@maksimsamt
Copy link
Contributor

  1. you can use both variants: example of working dynamic block (network)
    dynamic network {
        for_each = var.vm_network_interfaces
        content {
            bridge   = network.value.bridge
            model    = network.value.model
            firewall = network.value.firewall
            tag      = network.value.vlan        
        }
    }
  1. So..it worked before, and it didn't say in the change notes that it no longer works :|
    hostpci block was added in v2.9.14 (How to enable PCI passthrough #299)

(anyway it present in

)

  1. OK, but there is no official documentation that this can be done un such way...

  2. Latest major version is v3, not v2
    Present - doesn't mean that it really works :) and at the same time there is no documentation for this...
    Here it is necessary to get comments from the developers.

@den-patrakeev
Copy link
Author

den-patrakeev commented Jun 5, 2024

Hi! Thank you! Unfortunately this didn't help.

Can you share your config snippet with usb block/blocks?

Block with USB commented out and don`t use.

Cause:
User for provider on ProxMox VE cluster has no rights for configure USB passthrought. USB configuration is available only to the user root. This is a limitation ProxMox VE.

Therefore, we set it up manually and ignore USB in config provider.

Uncommenting the block gives the same error.

@maksimsamt
Copy link
Contributor

Block with USB commented out and don`t use.
Therefore, we set it up manually and ignore USB in config provider.
Uncommenting the block gives the same error.

Seems something you are doing wrong...
Unfortunately, without all the details I can’t say what exactly is wrong.

User for provider on ProxMox VE cluster has no rights for configure USB passthrought. USB configuration is available only to the user root. This is a limitation ProxMox VE.

As for this, check and try out this Proxmox Forum thread:

Only root@pam is now allowed to clone and restore guests with passed through PCI/USB devices that are not using the new mapping feature. To allow regular users to clone and restore with PCI/USB devices, create a mapping and give the user 'Mapping.Use' on that.

You can try as well use other Mapping privileges for that:

Mapping.Audit: view resource mappings
Mapping.Modify: manage resource mappings
Mapping.Use: use resource mappings

@den-patrakeev
Copy link
Author

@maksimsamt Thanks for the information about the directive Mapping.Use!
I'll try it and post the results.

@baltazorbest
Copy link

baltazorbest commented Jun 10, 2024

Hello. After updating from version 3.0.1-rc1 to version 3.0.1-rc3, I encountered the same error for VMs to which I added PCI-e device mapping. How can I add an ignore rule for devices that I added myself?

I tried this one:

  lifecycle {
    ignore_changes = [
      hostpci,
    ]
  }

But the error is stilling.

@dsander
Copy link

dsander commented Jun 26, 2024

I am getting the same error when using usb like it's documented:

  usb {
    host = "051d:0002"
    usb3 = false
  }

Did some bisecting of the plugin and is the commit that introduced the change: 819869a. I don't know the code, maybe before the change the data from the proxmox API was just ignored and never put into the state because it didn't/doesn't match the expected format?

@psychodracon
Copy link

Hello, any news on that? I've created machine using root account for authentication everything worked as expected including usb creation but after that i can no longer run terraform refresh or terraform plan because of the same error. I've already tried adding different combinations to ignore_changes block but none of them is working

@otwieracz
Copy link

Same here:

Error: Invalid address to set: []string{"usb", "0", "id"}

Does not matter if I add the USB passthrough through the webui or the TF itself.

@den-patrakeev
Copy link
Author

@maksimsamt

Block with USB commented out and don`t use.
Therefore, we set it up manually and ignore USB in config provider.
Uncommenting the block gives the same error.

Seems something you are doing wrong... Unfortunately, without all the details I can’t say what exactly is wrong.

User for provider on ProxMox VE cluster has no rights for configure USB passthrought. USB configuration is available only to the user root. This is a limitation ProxMox VE.

As for this, check and try out this Proxmox Forum thread:

Only root@pam is now allowed to clone and restore guests with passed through PCI/USB devices that are not using the new mapping feature. To allow regular users to clone and restore with PCI/USB devices, create a mapping and give the user 'Mapping.Use' on that.

You can try as well use other Mapping privileges for that:

Mapping.Audit: view resource mappings
Mapping.Modify: manage resource mappings
Mapping.Use: use resource mappings

Hi!
Sorry for the long wait.

Adding user for terraform provirder access:

Mapping.Audit: view resource mappings
Mapping.Modify: manage resource mappings
Mapping.Use: use resource mappings

didn't help.

Regardless of whether the block is commented out or not.
And also whether usb is added to ignore or not.
Tried to manually clear the USB information in the .tfstate file.

The error persists and Terraform cannot refresh.

@rwburgman
Copy link

@lucian-tx fixed a similar issue for the hostpci config. I applied the same path to usb devices in #1077, which fixes this issue for me.

@tuxthepenguin84
Copy link

@lucian-tx fixed a similar issue for the hostpci config. I applied the same path to usb devices in #1077, which fixes this issue for me.

Thanks, this fixed it for me.

@zoechi
Copy link

zoechi commented Sep 5, 2024

I just tried it and I don't get this error anymore:
Error: Invalid address to set: []string{"usb", "0", "id"}

The only change I'm aware of is updating the proxmox terraform provider to version 3.0.1-rc4

@Tinyblargon
Copy link
Collaborator

Currently working on a fix. It will also ad support for mapped USB devices, so it will be feature complete with the PVE 8.2 GUI.

@Tinyblargon Tinyblargon self-assigned this Oct 28, 2024
This was referenced Oct 28, 2024
Tinyblargon added a commit that referenced this issue Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.