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

capture_name_prefix and capture_container_name do not appear as expected in the resulting Packer manifest JSON file #339

Closed
ianpittwood opened this issue Sep 19, 2023 · 1 comment · Fixed by #344
Labels

Comments

@ianpittwood
Copy link

Overview of the Issue

In our workflow, we build and save off several Packer images over multiple stages. To make sure we're building on top of the previous stage, we always recall the artifact_id of the previous build from the manifest.json file. After the upgrade from v1.4.5 to v2.0.0, the artifact_id entries in manifest.json no longer match up with the artifacts that are actually saved to blob storage. We would expect both the artifact_id and the URL of the blob to look like this as noted in the docs:

https://<storage_account>.blob.core.windows.net/system/Microsoft.Compute/Images/<capture_container_name>/<capture_name_prefix>.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd

But instead, the artifact_id in manifest.json is always set to the defaults for the capture arguments and instead looks like this:

https://<storage_account>.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd

The UUID in the file name is still stored correctly so this can be worked around for now by reconstructing the image path with the correct arguments.

Reproduction Steps

  1. Configure the Packer build to save to a blob storage account.
  2. Use a custom capture_name_prefix other than the default of "packer".
  3. Run the Packer build.
  4. Check and compare the manifest.json to the name of the image saved in blob storage. The manifest.json will have the default "packer" prefix for the image while the image in blob storage will be appropriately named using the capture_name_prefix.

Plugin and Packer version

  • Packer v1.8.7
  • Azure Plugin v2.0.0 (last working in v1.4.5)

Simplified Packer Buildfile

source "azure-arm" "azure" {
  azure_tags             = local.tags
  capture_container_name = "customimagename"
  capture_name_prefix    = "productdirectory"
  client_id              = var.azure_client_id
  client_secret          = var.azure_client_secret
  image_url              = "${local.azure_image_url_root}/base/${var.base_image}"
  location               = var.azure_region
  os_disk_size_gb        = var.os_disk_size
  os_type                = "Linux"
  resource_group_name    = var.azure_resource_group
  ssh_pty                = "true"
  storage_account        = var.azure_storage_account
  subscription_id        = var.azure_subscription_id
  tenant_id              = var.azure_tenant_id
  vm_size                = var.azure_vm_sku
}

Operating system and Environment details

Images are built on Ubuntu 22.04. Packer is ran from a Jenkins instance.

Log Fragments and crash.log files

Expected (v1.4.5):

[2023-09-19T19:32:30.381Z] ==> Builds finished. The artifacts of successful builds are:

[2023-09-19T19:32:30.381Z] --> byol.azure-arm.azure: Azure.ResourceManagement.VMImage:

[2023-09-19T19:32:30.381Z] 

[2023-09-19T19:32:30.381Z] OSType: Linux

[2023-09-19T19:32:30.381Z] StorageAccountLocation: eastus

[2023-09-19T19:32:30.381Z] OSDiskUri: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/productdirectory/customimagename-osDisk.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd

[2023-09-19T19:32:30.381Z] OSDiskUriReadOnlySas: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/productdirectory/customimagename-osDisk.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd?<token>

[2023-09-19T19:32:30.381Z] TemplateUri: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/productdirectory/customimagename-vmTemplate.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json

[2023-09-19T19:32:30.381Z] TemplateUriReadOnlySas: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/productdirectory/customimagename-vmTemplate.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json?<token>

Actual (v2.0.0):

[2023-09-19T19:07:45.239Z] ==> Builds finished. The artifacts of successful builds are:

[2023-09-19T19:07:45.239Z] --> byol.azure-arm.azure: Azure.ResourceManagement.VMImage:

[2023-09-19T19:07:45.239Z] 

[2023-09-19T19:07:45.239Z] OSType: Linux

[2023-09-19T19:07:45.239Z] StorageAccountLocation: <storage-account-name>

[2023-09-19T19:07:45.239Z] OSDiskUri: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd

[2023-09-19T19:07:45.239Z] TemplateUri: https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-vmTemplate.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json

@JenGoldstrich
Copy link
Contributor

@ianpittwood thanks for reporting this issue, appreciate the detail you included!

I have merged a fix in #344 to the main branch and will release it soon

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

Successfully merging a pull request may close this issue.

2 participants