Skip to content

fix: build cleanup and terminate on failure - #22

Merged
ethanholz merged 2 commits into
mainfrom
fix-failed-build-cleanup
Aug 4, 2026
Merged

fix: build cleanup and terminate on failure#22
ethanholz merged 2 commits into
mainfrom
fix-failed-build-cleanup

Conversation

@dwhswenson

Copy link
Copy Markdown
Member
  • Some failures were leaving behind AMIs (name prefaced by ami-builder-) that weren't getting cleaned up by the janitor. Added cleanup-related tags so the janitor would clean up failures.
  • Some failures were shutting down by leaving the instance in a "stopped" state, with the EBS volume still active, meaning we were getting charged for EBS. This switches shutdown mode to "terminate," which will delete the EBS volume on failure (just as on success).

Assisted-by: Codex.app:GPT-5.6-Sol

* Some failures were leaving behind AMIs (name prefaced by
  `ami-builder-`) that weren't getting cleaned up by the janitor. Added
  cleanup-related tags so the janitor would clean up failures.
* Some failures were shutting down by leaving the instance in a
  "stopped" state, with the EBS volume still active, meaning we were
  getting charged for EBS. This switches shutdown mode to "terminate,"
  which will delete the EBS volume on failure (just as on success).

Assisted-by: Codex.app:GPT-5.6-Sol

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves cleanup behavior for failed AMI builds by (1) ensuring failed-build artifacts are easier to identify/tag for automated cleanup and (2) changing the Packer instance shutdown behavior to terminate (to avoid leaving stopped instances/volumes behind on failure).

Changes:

  • Add failed-build AMI detection (ami-builder- name tag prefix) and emit a warning when auto-delete cleans these up.
  • Update Packer amazon-ebs config to shutdown_behavior = "terminate" and expand run_tags to include the merged cleanup tag set.
  • Extend CLI tests to cover failed-build detection and the new auto-delete warning behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cli/test_ami_cli.py Adds test coverage for failed-build name-prefix detection and auto-delete warning/deletion behavior.
cli/ami_cli.py Introduces failed-build AMI detection and warning output during auto-delete.
build-ami.pkr.hcl Switches shutdown behavior to terminate and merges standard tags into run_tags to improve cleanup/traceability on failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/ami_cli.py Outdated
Comment thread cli/ami_cli.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dwhswenson
dwhswenson requested a review from ethanholz August 3, 2026 22:15

@ethanholz ethanholz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good mergin.

@ethanholz
ethanholz merged commit 2721368 into main Aug 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants