Skip to content

Answer what is left to clean up across the fleet - #483

Merged
em3s merged 1 commit into
mainfrom
feat/control-cleanup-projection
Aug 7, 2026
Merged

em3s merged 1 commit into
mainfrom
feat/control-cleanup-projection

Conversation

@em3s

@em3s em3s commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #482 — merge that first. Both commits show here because CI only runs on PRs based on main; the second commit is this PR's change, and the diff collapses to it once #482 lands.

Summary

A cleanup client needs to know, per datastore table, what each side holds and what still binds to it. Every client derives that itself today — and two of the facts involved are ones no single cluster can supply.

GET /control/htables answers it once for the whole fleet.

Sides are symmetric. A table's state is one entry per side, so a table that survives only on the standby is an absent active side rather than a second kind of row. Clients model that as a separate list because they see one cluster at a time; the control plane does not have to.

The chain is read, not reconstructed. References come from the endpoint added in #478, and each one carries the side it was found on — a label still active on the standby is exactly the thing that blocks a teardown halfway through.

Sharing is noticed without anyone declaring it. Two tenants configured against the same cluster resolve to the same cluster key (host:port), so a table held by another tenant shows up as sharedWith — and it names the tenant, because "blocked" without "by whom" leaves the operator where they started.

A failed side is reported as failed. An empty table list from a cluster that never answered would read as nothing left to clean up, which is the one wrong answer this endpoint must never give.

Changes

  • Add CleanupProjection (pure) and CleanupService under server/control/cleanup
  • Add GET /control/htables with optional tenant and env filters
  • Add Topology.cluster(tenant, side) — the cluster key that makes sharing visible
  • Env.of accepts the spelling config uses: env: prod in yaml and ?env=prod in a url should not disagree, and an unknown value names the ones that exist
  • Extract CallerHeaders so both control endpoints forward the caller's identity the same way

How to Test

./gradlew :server:test --tests "*CleanupProjectionTest*" --tests "*ControlCleanupE2ETest*" --tests "*TopologyTest*"

CleanupProjectionTest drives the projection from fixtures — standby-only tables, a table held from another tenant, references carrying their side, and a failed side not reading as a clean fleet. ControlCleanupE2ETest points every configured cluster at a closed port, so the all-sides-failed path is exercised over http.

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 5)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 6, 2026
@em3s
em3s force-pushed the feat/control-cleanup-projection branch from a0e8c20 to fef44b9 Compare August 6, 2026 14:34
@em3s
em3s changed the base branch from feat/control-cluster-fanout to main August 6, 2026 14:41
@em3s em3s closed this Aug 6, 2026
@em3s em3s reopened this Aug 6, 2026
@em3s
em3s force-pushed the feat/control-cleanup-projection branch from fef44b9 to 8df7531 Compare August 7, 2026 01:23
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 7, 2026
A cleanup client has to know, per table, what each side holds and what
still binds to it. Every client derives that itself today, and two of the
facts are ones no single cluster can supply.

Sides are symmetric here: a table's state is one entry per side, so a
table that survives only on the standby is an absent active side rather
than a second kind of row. Clients model that as a separate list because
they see one cluster at a time; the control plane does not have to.

The chain comes from the references endpoint added in #478 rather than
being reconstructed, and each reference carries the side it was found on -
a label still active on the standby is exactly the thing that blocks a
teardown halfway through.

Two tenants configured against the same cluster resolve to the same
cluster key, which is how a table held by another tenant is noticed
without anyone declaring it. That answer names the tenant, because
"blocked" without "by whom" leaves the operator where they started.

A side that failed is reported as failed. An empty table list from a
cluster that never answered would read as nothing left to clean up, which
is the one wrong answer this endpoint must never give.

Part of #370

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@em3s
em3s force-pushed the feat/control-cleanup-projection branch from 8df7531 to ceee811 Compare August 7, 2026 01:26
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Aug 7, 2026
@em3s

em3s commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Optimistic

@em3s
em3s merged commit 4b3dc03 into main Aug 7, 2026
2 checks passed
@em3s
em3s deleted the feat/control-cleanup-projection branch August 7, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant