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

Build 'proxmoc-clone' errored: error starting vm: VM xxx already running #167

Open
gponciano opened this issue Feb 24, 2023 · 4 comments
Open

Comments

@gponciano
Copy link

I am using 2 JSON(builder and variables) files to create a template on Proxmox. The template creation starts and after 'Starting the VM', it throws me an error stating that the VM xxx is already running and then destroys the VM template.

Find the files below:
----THIS IS THE BUILDER FILE----
{
"builders": [{
"type": "proxmox-clone",
"proxmox_url": "https://{{user proxmox_hostname}}/api2/json",
"username": "{{user proxmox_username}}",
"password": "{{user proxmox_password}}",
"node": "{{user proxmox_node}}",
"insecure_skip_tls_verify": true,
"task_timeout": "10m",

    "clone_vm": "{{ user `clone_vm`}}",
    "full_clone": true,

    "template_name": "{{ user `clone_vm` }}{{ user `version_tag`}}",
    "template_description": "image made from packer",

    "os": "l26",
    "cores": 1,
    "sockets": 1,
    "memory": 2048,
    "network_adapters": [{
        "bridge": "vmbr0"
    }],

    "ssh_timeout": "90m",
    "ssh_password": "{{ user `ssh_password` }}",
    "ssh_username": "{{ user `ssh_username` }}"
}],

"provisioners": [{
    "pause_before": "20s",
    "type": "shell",
    "inline": [
        "echo {{ user `version_tag` }} > provision.txt",
        "sudo apt update",
        "sudo apt -y upgrade",
        "sudo apt -y install apache2",
        "sudo apt -y install qemu-guest-agent cloud-init"
    ]
}]

}

Anyone has come across this before? I saw a trend that suggests adding efidisk. However, this has been deprecated. I tried adding efi_config but no luck either.

Cheers.

@gponciano gponciano added the bug label Feb 24, 2023
@github-actions github-actions bot removed the bug label Feb 24, 2023
@lbajolet-hashicorp
Copy link
Contributor

Hi @gponciano,

From your description, it looks like the problem you're describing is fixed by #93, is that right? If possible, could you test your configuration on the current main, eventually with the --force option to Packer. We don't provide nightlies for the plugins, so you will have to manually build it for test purposes, let me know if you need assistance for this, happy to help!

If so, it will be addressed in the upcoming release of the plugin, we should release it either this week or the following.

In the meantime, since your issue is specific to proxmox, I'll transfer it over to this plugin.

Thanks!

@lbajolet-hashicorp lbajolet-hashicorp transferred this issue from hashicorp/packer Feb 27, 2023
@tinhtruong
Copy link

I am having the same issue as @gponciano .
I am using the latest plugin version (1.1.3) as following:

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.1.3"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

Here is the packer build output:

proxmox-clone.servarr: output will be in this color.

==> proxmox-clone.servarr: Creating VM
==> proxmox-clone.servarr: Starting VM
==> proxmox-clone.servarr: Error starting VM: VM 1010 already running
==> proxmox-clone.servarr: Stopping VM
==> proxmox-clone.servarr: Deleting VM
Build 'proxmox-clone.servarr' errored after 38 seconds 593 milliseconds: Error starting VM: VM 1010 already running

@tinhtruong
Copy link

tinhtruong commented Jun 10, 2023

I checked out the code in the main branch. Here is what I found:
The code at https://github.com/Telmate/proxmox-api-go/blob/master/proxmox/client.go#L471 tried to start the VM 3 times after cloning it.
Here is the screenshot of the Task Log on the proxmox server:
Screenshot 2023-06-10 at 10 21 17 pm
Proxmox server returned a response as WARNING 1 for the first call to start the VM. After that, the proxmox server returned errors saying that the VM was already started.
I decided to hack the proxmox-api-go code a bit to ignore the error from the start VM call to get further. But the VM got into a weird state as following:
Screenshot 2023-06-10 at 10 24 18 pm
If I manually create a new VM from the same VM template that proxmox-clone plugin is using, then the VM start normally.
I am using Proxmox 7.4-13

@tinhtruong
Copy link

I took a look at the WARNING response from Proxmox and found out that my packer source settings was not correct.
I fixed that and now the VM was cloned properly.

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

No branches or pull requests

3 participants