HCP Packer Registry support for Openstack builder

After attempting to use an HCP Registry block in an Openstack build, I got this message:

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

It seems that HCP registry is not compatible with the Openstack builder. Is there any reason for this? Can we enable this functionality easily?

1 Like

Hi @darrick,

I’m surprised this happens tbh, out of curiosity could you share the configuration that you’re running packer on?

I’m looking at the code for both HCP and Openstack, it looks like both should work, however there are indeed some cases where the Openstack builder returns no artifact, I suspect your template might be one such case.
Are you using the skip_create_image option in your template?

Hi,

I am not using skip_create_image

without the HCP block, the image gets created and added to openstack with no issues

I used the block from: https://developer.hashicorp.com/packer/tutorials/hcp-get-started/hcp-push-image-metadata

hcp_packer_registry {
    bucket_name = "learn-packer-ubuntu"
    description = <<EOT
Some nice description about the image being published to HCP Packer Registry.
    EOT
    bucket_labels = {
      "owner"          = "platform-team"
      "os"             = "Ubuntu",
      "ubuntu-version" = "Focal 20.04",
    }

    build_labels = {
      "build-time"   = timestamp()
      "build-source" = basename(path.cwd)
    }
  }

Hi @darrick,

With the hcp_packer_registry config you provided, that should indeed work with HCP enabled.

The message you receive is likely due to the build not producing an artifact, so I’d look into that to understand why and how that happens, and if it’s unexpected, maybe there’s a bug in the plugin or Packer.

Could you share your complete template so we can take a look at this?

Thanks

Hi,

Build log:

.   
.
.
 server.openstack.focal_base: Generating grub configuration file ...
    server.openstack.focal_base: Found linux image: /boot/vmlinuz-5.4.0-131-generic
    server.openstack.focal_base: Found initrd image: /boot/initrd.img-5.4.0-131-generic
    server.openstack.focal_base: done
    server.openstack.focal_base: linux-image-5.4.0-131-generic set on hold.
    server.openstack.focal_base: linux-headers-5.4.0-131-generic set on hold.
    server.openstack.focal_base: linux-modules-extra-5.4.0-131-generic set on hold.
==> server.openstack.focal_base: Stopping server: 1666dba1-70c0-4407-bafd-54813b020ad2 ...
    server.openstack.focal_base: Waiting for server to stop: 1666dba1-70c0-4407-bafd-54813b020ad2 ...
==> server.openstack.focal_base: Creating the image: My Custom Image (Server)
    server.openstack.focal_base: Image: 49b1ebf2-d8ec-474b-8193-bfb706d10ada
==> server.openstack.focal_base: Waiting for image My Custom Image (Server) (image id: 49b1ebf2-d8ec-474b-8193-bfb706d10ada) to become ready...
==> server.openstack.focal_base: Terminating the source server: 1666dba1-70c0-4407-bafd-54813b020ad2 ...
==> server.openstack.focal_base: Deleting temporary keypair: packer_638118c4-6535-2af9-22bb-b9ab79162f89 ...
==> server.openstack.focal_base: Running post-processor:  (type manifest)
==> server.openstack.focal_base: Running post-processor:
Build 'server.openstack.focal_base' errored after 2 minutes 30 seconds: 1 error(s) occurred:

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

==> Wait completed after 2 minutes 30 seconds

==> Some builds didn't complete successfully and had errors:
--> server.openstack.focal_base: 1 error(s) occurred:

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

==> Builds finished but no artifacts were created.

It says no artifacts created, but the maniphest file shows an artifact, and the image is successfully uploaded in openstack. If I run without the HCP block, the artifact is reported as being created successfully

Here is my template:

source "openstack" "focal_base" {
  flavor                 = "Test Flavor"
  networks               = ["network_uuid"]
  security_groups        = ["sg_uuid"]
  source_image           = "image_uuid"
  ssh_ip_version         = "4"
  ssh_username           = "ubuntu"
  ssh_read_write_timeout = "5m" # Allow reboots
}

build {
  name = "server"

  hcp_packer_registry {
    bucket_name = "learn-packer-ubuntu"
    description = <<EOT
Some nice description about the image being published to HCP Packer Registry.
    EOT
    bucket_labels = {
      "owner"          = "platform-team"
      "os"             = "Ubuntu",
      "ubuntu-version" = "Focal 20.04",
    }
    build_labels = {
      "build-time"   = timestamp()
      "build-source" = basename(path.cwd)
    }
  }

  source "source.openstack.focal_base" {
    image_name = "My Custom Image (Server)"
    }
  provisioner "file" {
    source = "upload/focal/configs"
    destination = "/tmp/"
  }
  provisioner "shell" {
    scripts = ["server.sh"]
  }
  post-processor "manifest" {
    output     = "${build.name}_manifest.json"
  }
}