feat: fail-fast preflight for schema upgrade path (multi-minor jumps) - #444
Draft
WentingWu666666 wants to merge 1 commit into
Draft
Conversation
Before running ALTER EXTENSION documentdb UPDATE, query pg_extension_update_paths to confirm PostgreSQL can resolve a chain of update scripts from the installed schema to the target. The documentdb extension ships minors frequently, so a user may bump more than one minor in a single change; that only succeeds when the extension packages the intermediate documentdb--A--B.sql scripts. When the chain is broken, ALTER EXTENSION UPDATE would otherwise fail every reconcile with a raw "no update path" error. The preflight detects the missing path up front, skips the ALTER, and emits a SchemaUpgradePathMissing Warning event (mirroring the existing ExtensionRollback precedent) so the schema and data are left untouched and the operator surfaces an actionable message instead of looping. Adds unit coverage for the no-path skip case and for extensionUpdatePathExists (source==target short-circuit, has-path, no-path, and SQL error propagation). Existing ALTER-path mocks are converted from order-based to content-based branching to account for the extra preflight query. Refs: documentdb#439 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d53b8fec-0585-4888-89da-d9a6847597a5 Signed-off-by: Wenting Wu <wentingwu@microsoft.com>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (controllers, test); effort from diff stats (245+17 LOC, 2 files); LLM: Adds a fail-fast preflight check in the reconcile loop to detect broken schema upgrade chains before executing ALTER EXTENSION, preventing repeated reconcile failures with no actionable signal — a meaningful functional improvement confined to the controller/extension upgrade logic. If a label is wrong, remove it manually and ping |
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.
Summary
Adds an operator-side fail-fast update-path preflight before running
ALTER EXTENSION documentdb UPDATE, so a schema upgrade that PostgreSQL cannot resolve is detected up front instead of failing every reconcile.Follow-up to #426 / part of #439 (the "skip more than one minor" / multi-version-chain gap).
Motivation
The
documentdbextension ships minors frequently (roughly every couple of weeks), so users may bump more than one minor in a single change.ALTER EXTENSION ... UPDATEcan chain intermediatedocumentdb--A--B.sqlscripts, but only when the extension actually packages that continuous chain. When the chain is broken,ALTER EXTENSION UPDATEfails at execution time with a rawno update patherror on every reconcile, with no actionable signal.What this does
ALTER EXTENSION, querypg_extension_update_paths('documentdb')for a non-NULL path from the installed schema to the target (same version graphALTER EXTENSION UPDATEwalks internally).SchemaUpgradePathMissingWarning event (mirroring the existingExtensionRollbackprecedent).source == target) short-circuits to "path exists" without querying.auto/ explicit version); two-phase mode returns early before it, so those paths are unaffected.Tests
extensionUpdatePathExistsunit tests:source==targetshort-circuit, has-path, no-path, and SQL error propagation.go test ./internal/controller/...green (163 specs).Design note / open question
The status API has no
Conditionsfield today, so this surfaces the failure via a Warning event only (consistent withExtensionRollback). Adding a status condition would need a CRD/deepcopy regen — flagging as a possible follow-up. See the design comment on #439; pending maintainer sign-off on the fail-fast contract and webhook-vs-controller placement.Follow-ups (not in this PR)
Refs: #439