Add direct state v3 - opt in only for record_deployment_history preview#5403
Add direct state v3 - opt in only for record_deployment_history preview#5403shreyas-goenka wants to merge 1 commit into
Conversation
|
Commit: cf6ef38 |
ad20bc3 to
ccbd8f1
Compare
ccbd8f1 to
cefabe0
Compare
cefabe0 to
e70bc2c
Compare
e70bc2c to
e1babf2
Compare
e1babf2 to
d15b537
Compare
d15b537 to
fab41cc
Compare
fab41cc to
ea32c1d
Compare
ea32c1d to
cf5f00d
Compare
cf5f00d to
69c7de4
Compare
69c7de4 to
522d49e
Compare
522d49e to
47fbd29
Compare
|
|
||
| // Enforce the recorded DMS protocol version only when this bundle has | ||
| // opted into DMS; a bundle that has not opted in does not act on it. | ||
| if b.Config.Experimental != nil && b.Config.Experimental.RecordDeploymentHistory { |
There was a problem hiding this comment.
if the config is not set - the deployment just falls back to direct deplioyment.
Approval status: pending
|
| func TestStateSchemaVersions(t *testing.T) { | ||
| assert.Equal(t, 2, currentStateVersion) | ||
| assert.Equal(t, 3, dmsStateVersion) | ||
| assert.Equal(t, 1, currentDmsVersion) |
There was a problem hiding this comment.
What does this test? We know constants in golang work.
There was a problem hiding this comment.
This is a tripwire test that will trigger anytime someone does a version bump. This forces the author and reviewer to read the instructions above and not miss them.
|
|
||
| title "without the flag, the same state is accepted (the check is gated on opt-in)" | ||
| trace update_file.py databricks.yml "record_deployment_history: true" "record_deployment_history: false" | ||
| trace errcode $CLI bundle plan 2>&1 | contains.py "!is newer than supported version" |
There was a problem hiding this comment.
What happens if experimental flag is removed? Do we stop calling DMS but keep using normal direct engine? Do we keep version 3 or 2 in that case?
There was a problem hiding this comment.
Do we stop calling DMS but keep using normal direct engine?
Yes, we fall back to normal direct engine. It works fine because we'll continue to maintain direct state with WAL and resources.json as we preview.
There was a problem hiding this comment.
Do we keep version 3 or 2 in that case?
We keep version 3. The configuration remains the source of truth for whether to use direct or DMS (provide easy fallback for customers).
47fbd29 to
94d066e
Compare
Normal deploys keep writing state_version 2. When the bundle opts into experimental.record_deployment_history, the deploy upgrades the local state to dmsStateVersion (3) and stamps a new CurrentDmsVersion header field, so future DMS breaking changes or minimum-CLI requirements can be gated on what the state was written with. migrateState now reads up to dmsStateVersion but still auto-migrates only up to the baseline currentStateVersion, so a v3 state is neither auto-applied nor downgraded. The upgrade is applied explicitly in deployCore, never as an automatic migration. Co-authored-by: Isaac
94d066e to
cf6ef38
Compare
Why
experimental.record_deployment_historyis the opt-in preview of the deployment metadata service (DMS). Previewing DMS changes the on-disk state format — but most bundles haven't opted in, and we must not force that format change on them. Two things have to hold:What
state_version: 2— unchanged.state_version: 3and stampsdms_version: 1.UpgradeToDMSruns before the WAL is started so the bumped version is captured in the WAL header (it panics if called after).dms_version) is enforced byOpen'sWithDMSoption, passed byprocess.goonly when the bundle has opted into DMS — a bundle that hasn't opted in does not act on the recorded version, so it isn't blocked by it.record_deployment_historyis rejected under the terraform engine (it drives DMS, which only the direct engine supports) instead of being silently ignored.dmsStateVersion/currentDmsVersionare deliberately separate fromcurrentStateVersion; the constant comments record this and the bump-to-4 procedure (step-by-step inTestStateSchemaVersions).Tests
dstate): state-version gating,WithDMSrejection (newer rejected / gated off when not opted in),UpgradeToDMSround-trip + panic-after-WAL, the bump-procedure tripwire, and a migrations-completeness invariant.record-deployment-history/):state-upgrade— baseline (v2) → opt-in upgrade (v3) → older CLI rejects v3 → newerdms_versionrejected → without the flag the same state is accepted.terraform-unsupported— the flag is rejected under the terraform engine.This pull request and its description were written by Isaac.