cos-customizer: Add flag `-enable-cleanup` to delete old VMs

When a cloudbuild workflow is forcefully cancelled,
COS-Customizer cannot remove the VM it created. This can
result in resource leak. This CL adds a flag `-enable-cleaup`
to automatically delete VMs with label `cos-customizer-cleanup`,
older than 1 day in the target project and zone. All the VMs
created by customizer will have that label.

BUG=b/131439193
TEST=unit tests and running the new cos-customizer to delete an old VM
with the target label.

Change-Id: Ie572d15687402294e5cc63858fe7acb66b17ec94
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/33311
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Tested-by: He Gao <hegao@google.com>
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
8 files changed
tree: 4fe57802142c87ecd737b9ed13ee492bf4015420
  1. release/
  2. src/
  3. testing/
  4. .gitignore
  5. BUILD.bazel
  6. cloudbuild.yaml
  7. CONTRIBUTING.md
  8. deps.bzl
  9. go.mod
  10. go.sum
  11. LICENSE
  12. README.md
  13. run_tests.sh
  14. WORKSPACE
README.md

Tools for Container-Optimized OS

This is a repository of various tools developed for Container-Optimized OS. Examples include cos-gpu-installer, cos-toolbox, etc.

See CONTRIBUTING.md for how to contribute.