feat(canopy): tear down ephemeral (verify) replicas after verification#87
Merged
Conversation
This was referenced Jul 2, 2026
A `verify` replica's job is to prove a snapshot restores, not to serve queries. It was booting postgres and then idling forever. Add `spec.ephemeral` (default false; set true by the verify intent): once a restore reaches Active (postgres came up healthy, and for canopy replicas the RestoreVerification was reported in the switchover block), the reconciler records `status.verifiedSnapshotId` and deletes the restore, reclaiming the Deployment + PVC. The replica CR and namespace stay so canopy's worklist stays satisfied. Re-restore is gated on the verified marker: with no active restore after teardown, the reconciler compares the desired snapshot against `verifiedSnapshotId` instead of a (now absent) active restore, so it only restores again when canopy offers a newer snapshot (canopy path) or the schedule fires (legacy path). Without the marker the active-restore-deleted / desired-changed triggers would loop. The analytics intents keep ephemeral=false (long-lived query replicas). Gated entirely behind spec.ephemeral, so non-ephemeral replicas are unchanged. Adds an integration test (tests/ephemeral.rs, new CI matrix entry) that does not need stub-canopy: it drives a legacy ephemeral replica through restore -> Active -> teardown and asserts no re-restore loop. Does NOT include the requested health_details on RestoreVerification: bestool-canopy 0.4.3 has no such field yet. Deferred until the crate ships it.
30ab42c to
518d535
Compare
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.
🤖 A
verifyreplica's job is to prove a snapshot restores, not to servequeries — but it was booting postgres and then idling forever. This adds
spec.ephemeral(defaultfalse; settrueby theverifyintent):once a restore reaches
Active(postgres came up healthy, and forcanopy replicas the
RestoreVerificationwas reported), the reconcilerrecords
status.verifiedSnapshotIdand deletes the restore — reclaimingthe Deployment + PVC. The replica CR and namespace stay so canopy's
worklist stays satisfied.
Re-restore gating
With no active restore after teardown, the naive triggers
(
active_restore_deleted, canopy desired-snapshot-changed) would fireimmediately and loop. The verified marker breaks that: the reconciler
compares the desired snapshot against
verifiedSnapshotIdwhen there'sno active restore, so it only restores again when canopy offers a
newer snapshot (canopy path) or the schedule fires (legacy path).
The analytics intents stay
ephemeral: false(long-lived queryreplicas). The whole teardown path is gated behind
spec.ephemeral, soexisting replicas are unchanged.
Tests
tests/ephemeral.rs(+ CI matrix entry) drives a legacy ephemeralreplica — no stub-canopy needed — through restore →
Active→ teardownand asserts the restore is gone,
verifiedSnapshotIdis set,currentRestoreis cleared, and it does not re-restore.