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

Add HCP Packer support for the QEMU builders #111

Open
afretwell opened this issue Nov 26, 2022 · 4 comments
Open

Add HCP Packer support for the QEMU builders #111

afretwell opened this issue Nov 26, 2022 · 4 comments

Comments

@afretwell
Copy link

afretwell commented Nov 26, 2022

Overview of the Issue

When I add the hcp_packer_registry block to my builds block I see that my build instantly fails when reaching the hcp_packer_registry block. When I do not add the hcp_packer_registry block I am able to successfully create my Ubuntu image with no issues, I just cant push it to HCP Registry. I have logged into HCP cloud and was able to see that my build is being queued to hcp registry, but always results in failed status because of the issue Im being faced with. All of my parameters from my hcp_packer_registry block are making being sent to hcp successfully but my image is not for some reason. Ive even tried removing all parameters with the exception of bucket_name but still results in this block failing 100% of the time on multiple systems. Assistance would be greatly appreciated.

Reproduction Steps

  1. Add the HCP_CLIENT_ID and HCP_CLIENT_SECRET env vars
  2. Add the hcp_packer_registry block to your build block in your hcl2 file
  3. Run PACKER_LOG=1 packer build ubuntu.pkr.hcl

Packer errors out after post-processors end and returns the error:

==> qemu.ubuntu: Running post-processor:

* Post-processor failed: [TRACE] failed to update Packer registry with image artifacts for "qemu.ubuntu": setting a build to DONE with no published images is not currently supported.
Build 'qemu.ubuntu' errored after 7 minutes 44 seconds: 1 error(s) occurred:

==> Wait completed after 7 minutes 44 seconds
2022/11/26 16:38:51 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2022/11/26 16:38:51 machine readable: qemu.ubuntu,error []string{"1 error(s) occurred:\n\n* Post-processor failed: [TRACE] failed to update Packer registry with image artifacts for \"qemu.ubuntu\": setting a build to DONE with no published images is not currently supported."}

* Post-processor failed: [TRACE] failed to update Packer registry with image artifacts for "qemu.ubuntu": setting a build to DONE with no published images is not currently supported.
==> Builds finished but no artifacts were created.
* Post-processor failed: [TRACE] failed to update Packer registry with image artifacts for "qemu.ubuntu": setting a build to DONE with no published images is not currently supported.

==> Wait completed after 7 minutes 44 seconds

2022/11/26 16:38:51 [INFO] (telemetry) Finalizing.
==> Some builds didn't complete successfully and had errors:
--> qemu.ubuntu: 1 error(s) occurred:

* Post-processor failed: [TRACE] failed to update Packer registry with image artifacts for "qemu.ubuntu": setting a build to DONE with no published images is not currently supported.

==> Builds finished but no artifacts were created.
2022/11/26 16:38:51 waiting for all plugin processes to complete...
2022/11/26 16:38:51 /usr/local/bin/github.com/hashicorp/qemu/packer-plugin-qemu_v1.0.6_x5.0_darwin_amd64: plugin process exited

Packer version

Packer v1.8.4

Simplified Packer Template

packer {
  required_plugins {
    qemu = {
      version = ">= 1.0.6"
      source  = "github.com/hashicorp/qemu"
    }
  }
}

source "qemu" "ubuntu" {
  accelerator               = "tcg"
  boot_command              = [
    "c<wait3s>",
    "set gfxpayload=keep<enter>",
    "linux /casper/vmlinuz autoinstall \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" ",
    "hostname={{.Name}} boot=casper fsck.mode=skip auto=true noprompt noeject<enter>",
    "initrd /casper/initrd<enter>",
    "boot<enter>"
  ]
  boot_wait                 = "10s"
  communicator              = "ssh"
  cpus                      = var.cpus
  disk_size                 = var.disk_size
  format                    = "qcow2"
  headless                  = true
  http_directory            = "./cidata"
  iso_checksum              = var.iso_checksum
  iso_url                   = var.iso_url
  memory                    = var.memory
  output_directory          = "./build"
  skip_compaction           = true
  shutdown_command          = "echo 'ubuntu' | sudo -S -E shutdown -P +1"
  ssh_clear_authorized_keys = false
  ssh_password              = "ubuntu"
  ssh_port                  = 22
  ssh_timeout               = "4h"
  ssh_username              = "ubuntu"
  vm_name                   = var.vm_name
}

build {
  hcp_packer_registry {
    bucket_name = "ubuntu"
    description = "ubuntu base image"
    bucket_labels = {
      "os"             = "ubuntu",
      "ubuntu-version" = "22.04",
      "image"          = "ubuntu"
    }

    build_labels = {
      "build-time"   = timestamp()
      "build-source" = "${var.iso_url}"
    }
  }

  sources = ["source.qemu.ubuntu"]
}

Operating system and Environment details

  • x64 - Windows 10 & 11 - whpx accelerator
  • x64 - Mac OS Monteray 12.0.1 - hvf accelerator

Log Fragments and crash.log files

PACKER_LOG=1 Error Logs

@afretwell afretwell added the bug label Nov 26, 2022
@github-actions github-actions bot removed the bug label Nov 26, 2022
@nywilken
Copy link
Contributor

Hi there @afretwell thanks for reaching out. Your template is setup correctly. The issue you are running into here is that the QEMU builder is not generating HCP Packer images, as they require some additional metadata.

That said, only a handful of Packer builders work with HCP Packer. I'm going to use this issue as a feature request to add HCP Packer image publishing support to the QEMU builder.

@nywilken nywilken changed the title hcp_packer_registry block causes failure, unable to send images to HCP Registry Add HCP Packer support for the QEMU builders Nov 30, 2022
@nywilken nywilken transferred this issue from hashicorp/packer Nov 30, 2022
@github-actions
Copy link

This issue has been synced to JIRA for planning.

JIRA ID: HPR-843

@afretwell
Copy link
Author

Hi there @afretwell thanks for reaching out. Your template is setup correctly. The issue you are running into here is that the QEMU builder is not generating HCP Packer images, as they require some additional metadata.

That said, only a handful of Packer builders work with HCP Packer. I'm going to use this issue as a feature request to add HCP Packer image publishing support to the QEMU builder.

Amazing to hear, thank you, I'm sure it's not the top of priorities, but is there an average turnaround time for enhancements like this one?

@afretwell afretwell reopened this Nov 30, 2022
@afretwell
Copy link
Author

Any update on this feature for qemu builder?

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

2 participants