fix(helm): verify mongo restore completeness and allow skipping collections - #3613
Open
yodem wants to merge 1 commit into
Open
fix(helm): verify mongo restore completeness and allow skipping collections#3613yodem wants to merge 1 commit into
yodem wants to merge 1 commit into
Conversation
…ctions Nothing in the restore pipeline ever checked that mongorestore produced a complete database, so a truncated restore was indistinguishable from a good one. A cauldron came up with 8 of 73 collections and still reported healthy. Two changes to the restore hook. restore.verify (default true) compares the collections extracted from the dump against what mongo actually holds afterwards, and fails the job listing what is missing. It is self-calibrating -- the expected set is derived from the .bson files on disk, so excluded collections are not expected and no collection list is hardcoded. restore.excludeCollections drops collections at tar-extraction time rather than at restore time, so their bytes are never written to local disk. The untar stage is disk-bound and is the slowest part of a restore, so this saves time twice. `sheets` is ~14GB of the ~27GB dump and most cauldrons never exercise user sheets. Note this catches an incomplete restore that *finishes*. A restore killed mid-flight by a Helm hook timeout never reaches the check; that path is handled separately by install.timeout and install.remediation on the HelmRelease (Sefaria/cauldrons#152). Also switches tar from xzvf to xzf -- the file list was 148 lines of noise in the pod log. Not changed here: the `[[ ! -z "MONGO_REPLICASET_NAME" ]]` test just above is missing its `$` and so is always true, appending an empty replicaSet param. Restores work today, so fixing it would change connection semantics for every environment; left for its own change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFb3rAtzXJ4Ue7w4G3c4VW
📊 Code Quality Score: 7/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
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.
Follow-up to Sefaria/cauldrons#152. That PR stopped a timed-out restore from reporting success; this one stops an incomplete restore from going unnoticed at all, and gives cauldrons a way to skip the expensive half of the dump.
Independent of #152 and safe to merge in either order.
1.
restore.verify(defaulttrue)Nothing in the pipeline ever checked that
mongorestoreproduced a complete database, which is why a cauldron with 8 of 73 collections looked identical to a healthy one. After the restore, the job now compares the collections extracted from the dump against what mongo actually holds:Self-calibrating — the expected set is derived from the
.bsonfiles on disk, so excluded collections are not expected and no collection list is hardcoded anywhere.Scope limit worth knowing: this catches an incomplete restore that finishes. A restore killed mid-flight by the Helm hook timeout never reaches the check — that path is what
install.timeout/install.remediationin cauldrons#152 handles. The two are complementary, which is why both exist.2.
restore.excludeCollections(default[])Exclusion happens at tar-extraction time, not restore time, so skipped bytes are never written to local disk. That matters because the untar is the disk-bound stage and the slowest part of a restore — measured at 13 m 38 s of a 30 m budget, running at 37 MB/s against a node disk at 98% utilization. So excluding a collection saves time twice.
sheetsis ~14.2 GB of the ~27 GB dump. For cauldrons that never exercise user sheets, this roughly halves the restore.Verification
Template renders and the generated bash passes
bash -nin all three configurations (default / with exclusions / verify off). The exclude and detection logic was functionally tested against a fake dump built with the real./dump/<db>/<coll>.bsonlayout:.bsonpresenthelm lintclean; full-charthelm templateexits 0.Not changed here
The
[[ ! -z "MONGO_REPLICASET_NAME" ]]test just above the edited region is missing its$, so it is always true and appends an empty&replicaSet=to the URI. Restores work today, so correcting it would change connection-string behaviour for every environment — left for its own change rather than smuggled into this one.🤖 Generated with Claude Code
https://claude.ai/code/session_01HFb3rAtzXJ4Ue7w4G3c4VW