bpg / terraform-provider-proxmox

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

unable to parse volume filename `id/vm-id-disk-x.qcow2.qcow2` #203

Closed ItsMeBrianD closed 1 year ago

ItsMeBrianD commented 1 year ago

Describe the bug As a note; this is using an upstream wrapper; and I have also filed an issue there; however, I believethe issue likely stems here. I'm interacting with this using Pulumi, not terraform directly.

When attempting to create a VM Template with a Cloud Init drive, I am given the following error:

  proxmoxve:VM:VirtualMachine (Debian Cloud Template Template Virtual Machine):
    error: 1 error occurred:
        * creating urn:pulumi:infra::homelab-infrastructure::HomeLab:Proxmox:CloudImageTemplate$proxmoxve:VM/virtualMachine:VirtualMachine::Debian Cloud Template Template Virtual Machine: 1 error occurred:
        * Image resized.
    unable to parse volume filename '10000000/vm-10000000-disk-0.qcow2.qcow2'

I've put the relevant code here: https://gist.github.com/0c370t/1fbaecbbbb32d18d7a9207e07c8b1e5b

To Reproduce Steps to reproduce the behavior:

  1. Download a qcow2 disk ( i.e. Debian 10 Generic Cloud AMD64 )
  2. Load that into /your/storage/root/qcow2
  3. Create a VM with some drive scsi0
    {
    "interface": "scsi0",
    "datastoreId": "local",
    "fileId": "local:qcow2/debian-genericcloud.qcow2"
    }
  4. See error

Expected behavior I expected the VM to be created without errors.

Additional context It looks like the disk and the VM are getting created, it just isn't getting mounted / attached; see the screenshot: image

To fix this in the UI, it is simply a matter of hitting "Add"

ItsMeBrianD commented 1 year ago

Update: this might be a duplicate of #188

ItsMeBrianD commented 1 year ago

Another update: I'm not fluent in go, but I think the issue may be caused here: https://github.com/bpg/terraform-provider-proxmox/blob/main/proxmoxtf/resource_virtual_environment_vm.go#L2124

if $dsp_target includes the file extension already, this adds a redundant .qcow2 that seems to come up in the bug

Worked through this; using this seems to properly work for my use case: disk_id="${datastore_id_target}:$imported_disk${disk_options}"

Not sure what other cases might be impacted by the change

bpg commented 1 year ago

Hi @0c370t, thanks for the report!

187 is also seems to be related. My intention is to replace that custom shell scripting with a pvesm call, which should be more reliable.