hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.11k stars 3.33k forks source link

[proxmox] error calculating first free VMID on a blank proxmox server #9392

Open bemanuel opened 4 years ago

bemanuel commented 4 years ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

When I build an template the system uses an nextid to the vm and disk that always in use. I checked the API and PVE returns correct ID

Reproduction Steps

PACKER_LOG=1 packer build -var 'usr=' -var 'pwd=' -var 'proxmox_api=https://SERVER_IP:8006/api2/json' -var 'node=' glabrun.json

Packer version

Packer v1.6.0

Simplified Packer Buildfile

glabrun.son

Operating system and Environment details

-- Running on: Ubuntu 20.04 - 64 bits

-- Applied on Proxmox VE proxmox-ve: 6.2-1 (running kernel: 5.3.18-3-pve) pve-manager: 6.2-4 (running version: 6.2-4/9824574a) pve-kernel-5.4: 6.2-1 pve-kernel-helper: 6.2-1 pve-kernel-5.3: 6.1-6 pve-kernel-5.4.34-1-pve: 5.4.34-2 pve-kernel-5.3.18-3-pve: 5.3.18-3 pve-kernel-5.3.18-2-pve: 5.3.18-2 pve-kernel-4.15.18-13-pve: 4.15.18-37 pve-kernel-4.4.117-1-pve: 4.4.117-109 pve-kernel-4.4.35-1-pve: 4.4.35-77 ceph-fuse: 14.2.9-pve1 corosync: 3.0.3-pve1 criu: 3.11-3 glusterfs-client: 5.5-3 ifupdown: 0.8.35+pve1 ksm-control-daemon: 1.3-1 libjs-extjs: 6.0.1-10 libknet1: 1.15-pve1 libproxmox-acme-perl: 1.0.3 libpve-access-control: 6.1-1 libpve-apiclient-perl: 3.0-3 libpve-common-perl: 6.1-2 libpve-guest-common-perl: 3.0-10 libpve-http-server-perl: 3.0-5 libpve-storage-perl: 6.1-7 libqb0: 1.0.5-1 libspice-server1: 0.14.2-4~pve6+1 lvm2: 2.03.02-pve4 lxc-pve: 4.0.2-1 lxcfs: 4.0.3-pve2 novnc-pve: 1.1.0-1 openvswitch-switch: 2.12.0-1 proxmox-mini-journalreader: 1.1-1 proxmox-widget-toolkit: 2.2-1 pve-cluster: 6.1-8 pve-container: 3.1-5 pve-docs: 6.2-4 pve-edk2-firmware: 2.20200229-1 pve-firewall: 4.1-2 pve-firmware: 3.1-1 pve-ha-manager: 3.0-9 pve-i18n: 2.1-2 pve-qemu-kvm: 5.0.0-2 pve-xtermjs: 4.3.0-1 qemu-server: 6.2-2 smartmontools: 7.1-pve2 spiceterm: 3.1-1 vncterm: 1.6-1 zfsutils-linux: 0.8.3-pve1

Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster

Log Fragments and crash.log files

LOG Detailed

carlpett commented 4 years ago

Hi @bemanuel, I'm not sure I understand this bit correctly, "the system uses an nextid to the vm and disk that always in use", so let me know if I'm missing something here. But from what I can tell from the logs, the problem is that while the VM id 146 does not exist, but there is a disk that at one point belonged to a VM with that id? When you say that the API returns the correct id, do you mean that you get back an id which does not have an orphaned disk? What API are you using when testing this?

bemanuel commented 4 years ago

Exists a VM and Disk with the ID 146. Even this Packer try to use the ID 146. The PVE API (pvesh) returns the correct ID.

romantomjak commented 4 years ago

I had a similiar thing occur to me, but this was because I had an orphaned disk belonging to a VM that no longer exists.

Packer tried to get the "next available ID" and since the previous VM no longer exists, it would just get the same ID again, but because the disk already exists it would fail to create VM.

@bemanuel do you still have this issue? If you can reproduce it, can you please post the output of the following commands:

And in case you still have the problematic 146 VM lying around: