Introduction
This article explains the reason why a version is showing v0 with Incomplete status in HCP Packer buckets.
Problem
When running packer build with the flag --only or --except, the build finished successfully with these outputs,
Build 'amazon-ebs.basic-example-east' finished after 4 minutes 46 seconds.
==> Wait completed after 4 minutes 46 seconds
==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs.basic-example-east: AMIs were created:
us-east-2: ami-027089xxxxxxxxxx
--> amazon-ebs.basic-example-east: Published metadata to HCP Packer registry packer/learn-packer-ubuntu/versions/01XXXXXXXXXXXXXXXXXXXXXXXX
Version "01XXXXXXXXXXXXXXXXXXXXXXXX" is incomplete, the following builds are missing artifact metadata:
* "amazon-ebs.basic-example-west": BUILD_UNSET
You may resume work on this version in further Packer builds by defining the following variable in your environment:
HCP_PACKER_BUILD_FINGERPRINT="01XXXXXXXXXXXXXXXXXXXXXXXX"
and a new version v0 with Incomplete status is created in the bucket,
Cause
The reason why the created version shows v0 with Incomplete state is that the flag --only or --except was added to the packer build command,
packer build --only amazon-ebs.basic-example-east ubuntu-focal.pkr.hcl
while the build block in the code would look like this,
build {
sources = [
"source.amazon-ebs.basic-example-east",
"source.amazon-ebs.basic-example-west"
]
...
}
also note that the build outputs contain this line,
* "amazon-ebs.basic-example-west": BUILD_UNSET
and not all the Packer images defined in the build block were created.
Sequential version numbers (v1, v2, and so on) are only allocated when the created version is complete and the status is Active. v0 is the zero-value for the versions that are in Incomplete state. The BUILD_UNSET is a sentinel zero value so that an uninitialized value can be detected by HCP Packer. This is where the zero version is referring to.
Solution
The Packer image that were skipped previously will need to be created in order for the version v0 to escape from the Incomplete state. Run the commands below to build the skipped Packer image,
- Copy the exported fingerprint from the previous run and export it as an environment variable,
export HCP_PACKER_BUILD_FINGERPRINT="01XXXXXXXXXXXXXXXXXXXXXXXX"
- Run
packer buildwith the flag--onlyor--exceptto build the previously skipped image,packer build --only amazon-ebs.basic-example-west ubuntu-focal.pkr.hcl