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

Incorrect VGA block addition after VM import #1502

Open
arsensimonyanpicsart opened this issue Aug 21, 2024 · 2 comments
Open

Incorrect VGA block addition after VM import #1502

arsensimonyanpicsart opened this issue Aug 21, 2024 · 2 comments

Comments

@arsensimonyanpicsart
Copy link

Describe the bug
After importing a VM running terraform plan prompts terraform to add a VGA block, even though the imported VM already has a VGA configured.

To Reproduce
Steps to reproduce the behavior:

  1. Import an existing VM using the Proxmox Terraform provider with a configuration that already includes a VGA.
  2. Run terraform plan.
  3. Notice that the plan indicates the need to add a VGA block, despite it being already configured in the VM.

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

# >>> module "vm" {
  source = "./.."
  vm_name     = "cloud-test1"
  description = "Managed by Terraform"
  tags        = ["infradb", "ubuntu"]
  pool_id     = "infra-DB"
  node_name   = "va-dev-proxmox01"
  protection      = false
  migrate         = true
  stop_on_destroy = true
  on_boot         = true
  reboot          = false
  started         = true
  scsi_hardware         = "virtio-scsi-single"
  acpi                  = true
  bios                  = "seabios"
  machine               = "pc"
  boot_order            = ["scsi0"]
  timeout_clone         = 1800
  timeout_create        = 1800
  timeout_migrate       = 1800
  timeout_reboot        = 1800
  timeout_shutdown_vm   = 1800
  timeout_start_vm      = 1800
  timeout_stop_vm       = 300
  clone_vm_id           = "9000"
  clone_full            = true
  clone_retries         = 3
  clone_node_name       = "va-dev-proxmox02"
  cpu_cores             = 1
  cpu_sockets           = 1
  cpu_type              = "host"
  cpu_units             = 100
  cpu_limit             = 0
  cpu_hotplugged        = 0
  cpu_numa              = false
  memory_dedicated      = 4096
  memory_floating       = 0
  memory_shared         = 0
  memory_keep_hugepages = false
  disks = [
    {
      datastore_id = "Pure-NFS"
      interface    = "scsi0"
      file_format  = "raw"
      size         = "10"
      iothread     = true
      aio          = "io_uring"
      backup       = true
      cache        = "none"
      discard      = "ignore"
      replicate    = true
      ssd          = false
    },
    {
      datastore_id = "Pure-NFS"
      interface    = "scsi1"
      file_format  = "raw"
      size         = "10"
      iothread     = true
      aio          = "io_uring"
      backup       = true
      cache        = "none"
      discard      = "ignore"
      replicate    = true
      ssd          = false
    }
  ]
  network_bridge       = "vmbr0"
  network_vlan_id      = 1045
  network_disconnected = false
  network_enabled      = true
  network_firewall     = true
  network_model        = "virtio"
  network_mtu          = 0
  network_queues       = 0
  network_rate_limit   = 0
  vga_type             = "std"
  vga_memory           = 16
  tablet_device        = true
  keyboard_layout      = "en-us"
  os_type              = "l26"
} <<< #

Expected behavior
The imported VM’s VGA configuration should be recognized as existing, and Terraform should not prompt for adding or replacing the VGA block during the plan phase.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox: Clustered
  • Proxmox version: 8.2.4
  • Provider version (ideally it should be the latest version): 0.63.0
  • Terraform/OpenTofu version: 1.5.7
  • OS (where you run Terraform/OpenTofu from): MacOs Sonoma
  • Debug logs (TF_LOG=DEBUG terraform apply):N/A
@arsensimonyanpicsart arsensimonyanpicsart added the 🐛 bug Something isn't working label Aug 21, 2024
@kbcz1989
Copy link

can confirm. VGA block does not get imported into state at all.

terraform show -json | jq '.values.root_module.resources[] | select(.address == "proxmox_virtual_environment_vm.this").values.vga'
[]

@bpg
Copy link
Owner

bpg commented Sep 10, 2024

@arsensimonyanpicsart @kbcz1989

I can't reproduce it with a simple VM, so probably it is something about a particular VM configuration, or the import flow.

Could you provide more details about the source VM, and how exactly you were importing it?

What I did:

  • deployed this simple VM:
      resource "proxmox_virtual_environment_vm" "test_vm" {
      node_name = "pve"
      vm_id     = 999
      name      = "test-gpu"
    
      cpu {
        cores = 2
        sockets = 1
      }
    
      vga {
        type = "qxl"
        memory = 16
      }
    }
    OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
      + create
    
    OpenTofu will perform the following actions:
    
      # proxmox_virtual_environment_vm.test_vm will be created
      + resource "proxmox_virtual_environment_vm" "test_vm" {
          + acpi                    = true
          + bios                    = "seabios"
          + id                      = (known after apply)
          + ipv4_addresses          = (known after apply)
          + ipv6_addresses          = (known after apply)
          + keyboard_layout         = "en-us"
          + mac_addresses           = (known after apply)
          + migrate                 = false
          + name                    = "test-gpu"
          + network_interface_names = (known after apply)
          + node_name               = "pve"
          + on_boot                 = true
          + protection              = false
          + reboot                  = false
          + scsi_hardware           = "virtio-scsi-pci"
          + started                 = true
          + stop_on_destroy         = false
          + tablet_device           = true
          + template                = false
          + timeout_clone           = 1800
          + timeout_create          = 1800
          + timeout_migrate         = 1800
          + timeout_move_disk       = 1800
          + timeout_reboot          = 1800
          + timeout_shutdown_vm     = 1800
          + timeout_start_vm        = 1800
          + timeout_stop_vm         = 300
          + vm_id                   = 999
    
          + cpu {
              + cores      = 2
              + hotplugged = 0
              + limit      = 0
              + numa       = false
              + sockets    = 1
              + type       = "qemu64"
              + units      = 1024
            }
    
          + vga {
              + memory = 16
              + type   = "qxl"
            }
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    proxmox_virtual_environment_vm.test_vm: Creating...
    proxmox_virtual_environment_vm.test_vm: Creation complete after 2s [id=999]
    
    Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
    
  • added new resource to the template
    resource "proxmox_virtual_environment_vm" "imported_vm" {
      node_name = "pve"
    }
  • ran import
    ❯ tofu import proxmox_virtual_environment_vm.imported_vm pve/999
    proxmox_virtual_environment_vm.imported_vm: Importing from ID "pve/999"...
    proxmox_virtual_environment_vm.imported_vm: Import prepared!
      Prepared proxmox_virtual_environment_vm for import
    proxmox_virtual_environment_vm.imported_vm: Refreshing state... [id=999]
    
    Import successful!
    
    The resources that were imported are shown above. These resources are now in
    your OpenTofu state and will henceforth be managed by OpenTofu.
    
  • show state
    ❯ tofu show
    # proxmox_virtual_environment_vm.imported_vm:                   
    resource "proxmox_virtual_environment_vm" "imported_vm" {
        acpi                    = true
        bios                    = "seabios"
        id                      = "999"
        ipv4_addresses          = []
        ipv6_addresses          = []
        keyboard_layout         = "en-us"
        mac_addresses           = []
        name                    = "test-gpu"
        network_interface_names = []
        node_name               = "pve"
        protection              = false
        scsi_hardware           = "virtio-scsi-pci"
        started                 = true
        tablet_device           = true
        tags                    = []
        template                = false
        vm_id                   = 999
    
        cpu {
            cores      = 2
            flags      = []
            hotplugged = 0
            limit      = 0
            numa       = false
            sockets    = 1
            type       = "qemu64"
            units      = 1024
        }
    
        vga {
            enabled = false
            memory  = 16
            type    = "qxl"
        }
    }
    
    # proxmox_virtual_environment_vm.test_vm:
    resource "proxmox_virtual_environment_vm" "test_vm" {
        acpi                    = true
        bios                    = "seabios"
        id                      = "999"
        ipv4_addresses          = []
        ipv6_addresses          = []
        keyboard_layout         = "en-us"
        mac_addresses           = []
        migrate                 = false
        name                    = "test-gpu"
        network_interface_names = []
        node_name               = "pve"
        on_boot                 = true
        protection              = false
        reboot                  = false
        scsi_hardware           = "virtio-scsi-pci"
        started                 = true
        stop_on_destroy         = false
        tablet_device           = true
        template                = false
        timeout_clone           = 1800
        timeout_create          = 1800
        timeout_migrate         = 1800
        timeout_move_disk       = 1800
        timeout_reboot          = 1800
        timeout_shutdown_vm     = 1800
        timeout_start_vm        = 1800
        timeout_stop_vm         = 300
        vm_id                   = 999
    
        cpu {
            cores      = 2
            hotplugged = 0
            limit      = 0
            numa       = false
            sockets    = 1
            type       = "qemu64"
            units      = 1024
        }
    
        vga {
            enabled = false
            memory  = 16
            type    = "qxl"
        }
    }
    
    The timeouts and some other arguments are missing, but vga is there.

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

No branches or pull requests

3 participants