hashicorp / packer-plugin-googlecompute

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

Support max-run-duration and instance-termination-action #173

Open ralbertazzi opened 1 year ago

ralbertazzi commented 1 year ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

We have automated Packer jobs running in our CI systems. Sometimes Packer encounters temporary non-reproducible errors that lead to VMs that are not shutdown properly. This has several downsides both in terms of costs and robustness of future jobs (as running VMs contribute to the project's quota).

We learnt to live with this flakiness and embraced the fact that things can sometimes fail. We now have a periodic cleanup job that deletes packer VMs that have been running for too long, as it means that the related job probably failed in an ungraceful way.

Google Cloud supports setting the maximum runtime of an instance via the max-run-duration and instance-termination-action parameters. If this Packer plugin supported setting these values through HCL language, we would be able to get rid of the custom cleanup job.

Use Case(s)

A failsafe mechanism to delete Packer VMs even if Packer fails to delete a VM.

Potential configuration

max_run_duration
instance_termination_action

Potential References

https://cloud.google.com/compute/docs/instances/limit-vm-runtime