CI: ensure teardown runs regardless of test outcome#391
Conversation
Previously, teardown-infrastructure only triggered when both run-bats and run-int passed (via Concourse 'passed' constraints which only match successful builds). If either test failed, the director VM and its static IP remained allocated, causing subsequent runs to fail with 'External IP address is already in-use'. Fix by merging deploy-ubuntu, run-bats, run-int, and teardown-infrastructure into a single job: - Tests run in parallel via in_parallel (fail_fast defaults to false, so both complete even if one fails) - Job-level 'ensure' guarantees teardown always runs - Teardown wrapped in 'try' so infra destroy proceeds even if director state is missing (e.g. setup-director failed before creating the VM) - sole-tenancy infrastructure cleanup preserved via nested ensure
WalkthroughThis pull request consolidates the Concourse pipeline job structure for the bosh-google-cpi-release by combining four separate sequential jobs ( 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR restructures the Concourse pipeline to guarantee infrastructure teardown even when BATS or integration tests fail, preventing leaked GCP resources (e.g., static external IPs) that break subsequent runs.
Changes:
- Merged
deploy-ubuntu,run-bats,run-int, andteardown-infrastructureinto a singledeploy-ubuntu-and-run-testsjob. - Runs BATS + integration tests in parallel within the combined job.
- Adds an
ensure-style cleanup sequence intended to always delete orphaned VMs, tear down the director, and destroy Terraform-managed infrastructure.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aramprice
left a comment
There was a problem hiding this comment.
Excited to see cleanup be more resilliant.
Problem
When
run-batsorrun-intfails, theteardown-infrastructurejob never triggers because Concourse'spassedconstraint only matches successful builds (it queries thesuccessful_build_outputstable internally). This leaves the BOSH director VM and its static external IP allocated, causing the next pipeline run to fail with:This requires manual cleanup every time a test fails.
Solution
Merge
deploy-ubuntu,run-bats,run-int, andteardown-infrastructureinto a singledeploy-ubuntu-and-run-testsjob with a job-levelensureblock that guarantees cleanup.Key design decisions:
run-batsandrun-intexecute in parallel viain_parallel(fail_fastdefaults tofalse, so both run to completion even if one fails)ensurealways runs: deletes orphaned VMs, tears down the director, and destroys terraform infrastructuretryso that infrastructure destroy proceeds even if the director state is missing (e.g.,setup-directorfailed before creating the VM)ensureonrun-int(unchanged behavior)Pipeline structure (before → after)
Before:
teardown-infrastructureonly ran if both test jobs succeeded.After:
Trade-offs
run-bats/run-intjobs are no longer visible as individual boxes in the pipeline UI, but individual task pass/fail is still visible within the jobImplemented with ClaudeAI.