packer-plugin-proxmox icon indicating copy to clipboard operation
packer-plugin-proxmox copied to clipboard

cpu_type broken since 1.2.2

Open cerowain opened this issue 1 year ago • 18 comments

Overview of the Issue

When provisioning the VM from packer cpu_type is not being passed to proxmox resulting in all hosts taking the default value regardless of cpu_type setting. This works in 1.2.1

Suspected Cause

proxmox-api-go defines QemuCPU as

type QemuCPU struct {
	Affinity     *[]uint          `json:"affinity,omitempty"`
	Cores        *QemuCpuCores    `json:"cores,omitempty"` // Required during creation
	Flags        *CpuFlags        `json:"flags,omitempty"`
	Limit        *CpuLimit        `json:"limit,omitempty"`
	Numa         *bool            `json:"numa,omitempty"`
	Sockets      *QemuCpuSockets  `json:"sockets,omitempty"`
	Type         *CpuType         `json:"type,omitempty"`
	Units        *CpuUnits        `json:"units,omitempty"`
	VirtualCores *CpuVirtualCores `json:"vcores,omitempty"`
}

In change https://github.com/hashicorp/packer-plugin-proxmox/commit/75dded5bd17410b4e5d4a5624c52621ac9acf370, in step_start_vm.go CpuType is not passed through in the config.

While I can spot the issue, my skills at committing are lacking. Don't blame me, I'm just a sysadmin. :)

Reproduction Steps

Set cpu_type = "x86-64-v3" within proxmox-iso source section. The resulting VM will have type kvm64

Plugin and Packer version

Packer v1.11.2 packer-plugin-proxmox_v1.2.2

Simplified Packer Buildfile

Very simple testing

packer {
  required_plugins {
    name = {
      version = "~> 1"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

variable "proxmox_username" {
  default = env("PROXMOX_USER")
}

variable "proxmox_token" {
  default = env("PROXMOX_TOKEN")
}

source "proxmox-iso" "oraclelinux-9_5" {
  proxmox_url               = "https://192.168.1.181:8006/api2/json"
  insecure_skip_tls_verify  = true
  username                  = "${var.proxmox_username}"
  token                     = "${var.proxmox_token}"

  node                  = "pm1"
  vm_name               = "oraclelinux-9.5"
  template_description  = "Oracle Linux 9.5 Image"

  cores   = "1"
  cpu_type = "x86-64-v3"

  memory  = "2048"

  os = "l26"
  qemu_agent = true
  
  boot_iso {
    type = "sata"
    iso_url = "https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/x86_64/OracleLinux-R9-U5-x86_64-dvd.iso"
    iso_storage_pool = "fractal"
    unmount = true
    iso_checksum = "sha256:c2fa76c502cf1d93dfbd084d494d963ab7ea0a6f5535a083b8547b34037e88e1"
    iso_download_pve = true
  }

  disks {
    disk_size         = "20G"
    storage_pool      = "fractal"
    type              = "sata"
    format            = "qcow2"
  }

  network_adapters {
    model = "virtio"
    bridge = "vmbr0"
    firewall = "false"
  }

  cloud_init = true
  cloud_init_storage_pool = "fractal"

  boot_command = [
    "<up>",
    "<tab><wait>",
    " text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg",
    "<wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><enter>"
  ]

  http_directory          = "http" 

  ssh_username            = "packer"
  ssh_private_key_file    = "../id_ed25519"

  ssh_timeout             = "30m"
  ssh_pty                 = true

  task_timeout            = "10m"
}

build {
  name = "oraclelinux-9.5"
  sources = ["source.proxmox-iso.oraclelinux-9_5"]

  provisioner "shell" {
    script          = "scripts/cleanup.sh"
  }
}

Operating system and Environment details

Running packer on M1 silicon, MacOS 15.1.1

Log Fragments and crash.log files

No relevant logs

cerowain avatar Dec 13 '24 03:12 cerowain

The same for me, cpu_type parameter does not work in 1.2.2 :(

maksimsamt avatar Dec 13 '24 08:12 maksimsamt

The is also occurring for me. Explicitly setting the type does nothing. This is critical for RHEL and RHEL-based builds, which will kernel panic when not set to host: https://forum.proxmox.com/threads/kernel-panic-installing-rocky-or-almalinux.114885/

ejbolt avatar Dec 21 '24 14:12 ejbolt

Can confirm this bug is still present. Any machine that is created by packer is using the default kvm64 cpu_type.

spreadneck avatar Dec 23 '24 20:12 spreadneck

Hello,

Thank you for your work on this project. I believe I have identified a potential source of the issue. After reviewing the code, I think the problem might come from the file builder/proxmox/common/step_start_vm.go, in version 1.2.1, there was a QemuCpu field that allowed setting the CPUType. However, it seems that this field was omitted in version 1.2.2.

https://github.com/hashicorp/packer-plugin-proxmox/compare/v1.2.1...v1.2.2#diff-c79872c7c5b2f4706f264eb794de52cb28c29107b0f9aeba147a5c6e3f1ea433L128

Was this omission intentional, or could it be an oversight?

Thank you for your feedback and for all the work you’ve done!

nicocau avatar Dec 24 '24 15:12 nicocau

Same here, can also confirm that the issue (still) exists. Downgrading to v1.2.1 does the trick for me.

Thanks for pointing out, @nicocau.

stdevel avatar Jan 02 '25 18:01 stdevel

Hey, @mpywell it appears that commit authored by you might have introduced a regression. Would you like to address it? Committer: @lbajolet-hashicorp, it appears we have a PR if you'd like to review it.

AndrewSav avatar Jan 08 '25 03:01 AndrewSav

This bug is preventing us from upgrading the plugin for Ludus.

kernel-sanders avatar Feb 12 '25 20:02 kernel-sanders

I also ran into the same issue and had to downgrade to 1.2.1 for it to work

evarring avatar Feb 19 '25 10:02 evarring

me too. had to downgrade to 1.2.1 for it to work

dbethke avatar Feb 19 '25 18:02 dbethke

Ditto, downgrade fixed it for now.

chris-mcewan-tlm avatar Mar 04 '25 16:03 chris-mcewan-tlm

problem still exists Packer v1.12.0

sbellis060 avatar Mar 20 '25 16:03 sbellis060

Here is when everything went broken:

Image

CPUType variable is never configured.

aalmenar avatar Mar 25 '25 13:03 aalmenar

@aalmenar, This was pointed out above

AndrewSav avatar Mar 25 '25 22:03 AndrewSav

The fix https://github.com/hashicorp/packer-plugin-proxmox/pull/308 was made quite a while ago, but it hasn't been fully approved yet.

maksimsamt avatar Mar 26 '25 07:03 maksimsamt

Hi team,

I’m running into the issue described here where cpu_type isn’t being passed to Proxmox in v1.2.2, forcing all my VMs to use the default value instead of what’s set in my Packer templates. Downgrading to 1.2.1 fixes it, but I can’t downgrade since 1.2.2 includes critical fixes I need. I noticed some users mentioned a fix was committed—could you please review and approve it for an official release? Right now, I’m stuck manually updating the cpu_type on every VM after provisioning, which is a pain. Thanks!

lsampaioweb avatar Apr 05 '25 14:04 lsampaioweb

Is there date when the updated version will be released fixing cpu_type issue ?

oldvladko avatar May 07 '25 09:05 oldvladko

This makes it impossible to build against proxmox since RHEL/Alma kernel panics...seems to take a long time to add a single line to the code.

I compiled it myself with this one line added just add the line from https://github.com/hashicorp/packer-plugin-proxmox/pull/308/commits/4caccd783728ff123b82850c8e1a2fff7316a1e5 in builder/proxmox/common/step_start_vm.go

telefax avatar May 10 '25 13:05 telefax

Now that IBM owns Hashicorp maybe we can hope for better RHEL support....?

sej7278 avatar May 12 '25 19:05 sej7278

I got tired of waiting, forked it, fixed the CPU issue, and created a release. You can check it out here: https://github.com/hashicorp/packer-plugin-proxmox/compare/main...badsectorlabs:packer-plugin-proxmox:main

And use it with

packer plugins remove github.com/hashicorp/proxmox v1.2.2
packer plugins install github.com/badsectorlabs/proxmox v1.2.3

kernel-sanders avatar May 16 '25 21:05 kernel-sanders

Is this plugin still maintained?

eskog avatar Jun 07 '25 07:06 eskog

The fix that many community members here have called out as the solution to this issue was released today https://github.com/hashicorp/packer-plugin-proxmox/releases/tag/v1.2.3, please let us know if you are still experiencing this issue in v1.2.3

JenGoldstrich avatar Jul 28 '25 21:07 JenGoldstrich

Thanks for the fix. I can approve that the v1.2.3 is now generating the correct CpuType

CodingTfC avatar Jul 29 '25 18:07 CodingTfC

Given that confirmation I'll close this issue, please feel free to re-open or open a new issue linking to this one if you still experience this bug

JenGoldstrich avatar Jul 29 '25 18:07 JenGoldstrich

But now I have to use boot = "c" boot = "order=scsi0;net0;ide0" is not working anymore

CodingTfC avatar Jul 29 '25 18:07 CodingTfC

The fix that many community members here have called out as the solution to this issue was released today https://github.com/hashicorp/packer-plugin-proxmox/releases/tag/v1.2.3, please let us know if you are still experiencing this issue in v1.2.3

Now the cpu flags doesn't work, prior to 1.2.3 I could use following cpu type: "host,flags=+md-clear;+pcid;+spec-ctrl;+ssbd;+aes" Now it doesn't work anymore.

TuncTaylan avatar Oct 17 '25 20:10 TuncTaylan