hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
24 stars 54 forks source link

GCP import post processor: -force option does not work #71

Open hc-github-team-packer opened 2 years ago

hc-github-team-packer commented 2 years ago

This issue was originally opened by @cevich in https://github.com/hashicorp/packer/issues/9872 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Importing Fedora image through the (advanced/complex) nested KVM -> googlecompute-import post-processor works fine the first time. However, when executing packer build a second time, while specifying -force option, we get this error message.

Reproduction Steps

qemu builder -> shell provisioner -> compress then googlecompute-import post-processors

Packer version

1.4.5

Simplified Packer Buildfile

https://github.com/containers/automation_images/blob/master/base_images/gce.yml

Operating system and Environment details

Host is running CentOS 8 in GCE, but problem is also reproducible locally in a CentOS 8 container (provided GCE application default credentials).

Log Fragments and crash.log files

==> fedora (googlecompute-import): Uploading file /tmp/automation_images_tmp/fedora/disk.raw.tar.gz to GCS bucket packer-import/fedora-1598993532.tar.gz...
==> fedora (googlecompute-import): Creating GCE image fedora-b1598993532...
==> fedora (googlecompute-import): Error creating GCE image
2020/09/01 21:26:49 Deleting original artifact for build 'fedora'
Build 'fedora' errored: 1 error(s) occurred:

* Post-processor failed: googleapi: Error 409: The resource 'projects/libpod-218412/global/images/fedora-b1598993532' already exists, alreadyExists
2020/09/01 21:26:49 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/09/01 21:26:49 machine readable: fedora,error []string{"1 error(s) occurred:\n\n* Post-processor failed: googleapi: Error 409: The resource 'projects/libpod-218412/global/images/fedora-b1598993532' already exists, alreadyExists"}

* Post-processor failed: googleapi: Error 409: The resource 'projects/libpod-218412/global/images/fedora-b1598993532' already exists, alreadyExists
==> Builds finished but no artifacts were created.
* Post-processor failed: googleapi: Error 409: The resource 'projects/libpod-218412/global/images/fedora-b1598993532' already exists, alreadyExists

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

* Post-processor failed: googleapi: Error 409: The resource 'projects/libpod-218412/global/images/fedora-b1598993532' already exists, alreadyExists

2020/09/01 21:26:49 waiting for all plugin processes to complete...
==> Builds finished but no artifacts were created.