acc: Destroy leaked bundles after cloud test runs - #6092
Open
denik wants to merge 10 commits into
Open
Conversation
Collaborator
Integration test reportCommit: e3bdcf2
8 interesting tests: 4 RECOVERED, 4 SKIP
Top 3 slowest tests (at least 2 minutes):
|
andrewnester
approved these changes
Jul 29, 2026
denik
enabled auto-merge
July 29, 2026 09:38
denik
disabled auto-merge
July 29, 2026 09:38
Contributor
Author
|
This is not good 4cdb54c because in integration tests we use RUN_ID as prefix, so we cleaner can affect other jobs within the same run, fixing. |
Cloud acceptance tests deploy bundles under the shared test workspace's ~/.bundle directory. Tests that crash before their cleanup trap fires leak their deployments, which accumulate and eventually hit the workspace child-node limit. Add a suite-level cleanup that runs after all tests finish and destroys every bundle deployed by this run. It keys off the "ci<runid>x" prefix that ciUniqueName already embeds into $UNIQUE_NAME (synthesizing a run id for non-CI cloud runs), so it sweeps only this run's deployments and is safe to run while other runs deploy concurrently. Local runs are unaffected: each gets its own in-memory fake workspace. Co-authored-by: Isaac
Move the cloud check to the caller and compute the sweepable run id once in testAccept instead of mutating GITHUB_RUN_ID in the environment: use the GitHub run id on CI, otherwise a random numeric id so a local cloud run is still sweepable. Off cloud the id is empty and ciUniqueName leaves names unchanged. Co-authored-by: Isaac
All matrix legs of a CI run share one GITHUB_RUN_ID, and legs of different OSes share a workspace, so a run-id-only prefix let one leg's end-of-run cleanup destroy another still-running leg's bundles. Append a random 3-char lowercase-alphanumeric suffix (per test process) to the ci<runid>x prefix so each leg sweeps only its own deployments. The run id stays a matchable substring, so the run-wide sweeper (sweep_test_resources.py) is unaffected. Verified on gcp-cli: cleanup destroyed 2/2 of this leg's leaked bundles, matching only names carrying its suffix. Co-authored-by: Isaac
Each destroy shells out to a separate `bundle destroy` (auth + state pull + deletes), so a sequential sweep of a full run's leaks takes minutes. Run them with a WaitGroup and a semaphore capped at min(GOMAXPROCS, 20), which stays well under the workspace API rate limit while cutting wall-clock. Best-effort semantics are unchanged: failures are collected and reported at the end. Co-authored-by: Isaac
denik
force-pushed
the
denik/bundle_cleaner
branch
from
July 29, 2026 13:22
4920656 to
9e1f8b9
Compare
Collapse randomBundleLegSuffix, bundleNamePrefix, and the run-id/suffix splitting inside ciUniqueName into one generator (newBundleNamePrefix) that returns the full "ci<runID>x<suffix>" string, leaving ciUniqueName as a plain length-preserving prepend. One package var instead of two. Co-authored-by: Isaac
From an adversarial review: - Fail the cleanup on a non-not-found workspace listing error instead of treating it as an empty directory, which would silently under-sweep and leak. - Also sweep /Shared/<user>/.bundle, where a few cloud tests set root_path (e.g. resources/jobs/shared-root-path), not just the home .bundle. - Cap the accepted run id at 12 digits so an over-long GITHUB_RUN_ID can't build a prefix that ciUniqueName silently drops. Co-authored-by: Isaac
From a second adversarial review: - A "/Shared/..." root_path is normalized to "/Workspace/Shared/..." by prependWorkspacePrefix, so sweep that path, not "/Shared/..." (which would 404 and miss the leak). - Widen the per-leg suffix to 4 random chars (36^4) and cap the run id at 11 digits so it still leaves the 8-char random minimum, making an accidental collision between sibling legs sharing a workspace negligible. Co-authored-by: Isaac
ciUniqueName previously returned the name unchanged when the prefix left fewer than 8 random characters, which silently disabled cleanup tagging. Since newBundleNamePrefix guarantees the prefix is short enough (empty prefix off cloud trivially fits), a too-long prefix is a programming error: panic with a descriptive message instead of papering over it. Co-authored-by: Isaac
From an Opus cross-check review: - The destroys are network-bound (auth + state pull + API deletes), not CPU-bound, so cap concurrency at a fixed 20 instead of min(GOMAXPROCS, 20), which throttled to 2-4 on typical CI runners and lost most of the speedup. - Build the local temp databricks.yml path with filepath.Join, not path.Join, since the dir comes from os.MkdirTemp. Co-authored-by: Isaac
The cleanup runs in a t.Cleanup on the root TestAccept, so a require failure there marks the root test failed with no failed subtest — which makes gotestsum --rerun-fails (used by the integration task) rerun the entire cloud suite. Cleanup is best-effort housekeeping and the product tests already passed, so log a loud WARNING on every failure path (client/user resolution, listing, destroy) instead of failing. Leaked deployments are reclaimed by the periodic prefix sweep. Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Cloud acceptance tests deploy bundles under the shared test workspace's ~/.bundle directory. Tests that crash before their cleanup trap fires leak their deployments, which accumulate and eventually exhaust the workspace child-node limit.
Changes
A suite-level cleanup runs after all tests finish and destroys every bundle this run deployed, keyed off the "cix" prefix that ciUniqueName embeds into $UNIQUE_NAME (synthesizing a run id for non-CI cloud runs). It sweeps only this run's deployments, so it is safe while other runs deploy concurrently. Local runs are unaffected — each gets its own in-memory fake workspace.
Tests
Verified on gcp-cli: a bundle deployed without a destroy step is found and destroyed by the cleanup.