Skip to content

fix(ci): sweep only the previews that still hold a slot - #1609

Open
FelixTJDietrich wants to merge 1 commit into
mainfrom
fix/reconcile-skips-retired-previews
Open

fix(ci): sweep only the previews that still hold a slot#1609
FelixTJDietrich wants to merge 1 commit into
mainfrom
fix/reconcile-skips-retired-previews

Conversation

@FelixTJDietrich

Copy link
Copy Markdown
Collaborator

Description

Merging #1538 with the preview label still attached exercised teardown for the first time, and it worked end to end. Checking the parts that only bite later found one that would have failed silently.

The nightly reconcile built its candidate list from every environment that had ever taken a preview deployment, with no filter on what became of it:

gh api --paginate ".../deployments?task=deploy%3Apreview" | ... | sort -nu

A preview torn down months ago stays a candidate for ever. Each night it is re-assessed, handed to Coolify as a close event for a stack that no longer exists, and re-retired. Measured against the live repository today: 1 candidate, pr-1538, already retired — the entire list was work that did not need doing.

The bound made it worse rather than containing it. Candidates were sorted ascending and truncated to the first hundred, so once more than a hundred pull requests had ever been previewed, the sweep would spend its whole budget on the oldest — the ones already dealt with — and never reach a preview that had actually leaked. The safety net would have stopped catching anything, without a single failed run to show for it.

Candidates now come from the same reckoning admission already uses — occupiedEnvironments, "the environments still holding a slot", which excludes tombstoned teardowns and failed deploys. That is the right set by construction: if admission believes a slot is held and the pull request is closed, that is exactly the leak reconcile exists to fix. The shell inventory moves into the controller, where it is testable.

How to test

  • New test asserts a retired preview is excluded from the sweep. Mutation-tested by removing the tombstone skip in occupiedEnvironments: the new test fails on the retired entry, and the existing admission test fails with it. Restored, 30 pass.
  • The whole teardown path was verified live on feat(webapp): unify the public product and documentation experience #1538's merge: cleanup ran 3s after merge and succeeded; containers, volumes and the per-preview network are gone from the host; Coolify's application_previews row is gone; the deployment reads queued → success → inactive with the tombstone description; the sticky comment now reads "Preview removed — its slot is free again".
  • bun run format and bun run check are green.

Checklist

  • My changeset summary reads as an operator/user-facing note — empty changeset: previews have not reached a release, so this corrects behaviour before anyone runs it
  • If the operator must act on this change, the changeset says how — no operator action

The nightly reconcile listed every environment that had ever taken a preview
deployment, with no filter on what became of it. A preview torn down months ago
stayed a candidate for ever, so each night it was re-assessed, handed to Coolify
as a close event for a stack that no longer exists, and re-retired.

The bound made that worse rather than containing it. Candidates were sorted
ascending and truncated to the first hundred, so as soon as more than a hundred
pull requests had ever been previewed, the sweep would spend its whole budget on
the oldest — the ones already dealt with — and never reach a preview that had
actually leaked. The safety net would have stopped catching anything, quietly.

Candidates now come from the same reckoning admission uses: the environments
still holding a slot. Nothing dealt with is swept, and the bound is reached only
if teardown is genuinely failing, which is when a bound is worth having.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VKWqbmrPJFv8aKZBp36uD
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 38 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cbbd62fd-73a1-47ea-bae2-a4e6578a598d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6942b and 0f5d679.

📒 Files selected for processing (4)
  • .changeset/reconcile-sweeps-live-previews.md
  • .github/workflows/reconcile-previews.yml
  • scripts/preview-controller.test.ts
  • scripts/preview-controller.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug Something isn't working ci GitHub Actions, workflows, build pipeline changes size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧩 Storybook Preview

Review this pull request's components and interaction states:

🔗 View Storybook Preview

Preview for commit 0f5d679. Updates automatically on new commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci GitHub Actions, workflows, build pipeline changes size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant