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

cpu_type broken since 1.2.2 #307

Open
cerowain opened this issue Dec 13, 2024 · 6 comments
Open

cpu_type broken since 1.2.2 #307

cerowain opened this issue Dec 13, 2024 · 6 comments
Labels

Comments

@cerowain
Copy link

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 75dded5, 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 cerowain added the bug label Dec 13, 2024
@maksimsamt
Copy link

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

@ejbolt
Copy link

ejbolt commented Dec 21, 2024

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/

@Spreadneck
Copy link

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

@nicocau
Copy link

nicocau commented Dec 24, 2024

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.

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!

@stdevel
Copy link

stdevel commented Jan 2, 2025

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.

@AndrewSav
Copy link

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.

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

No branches or pull requests

7 participants