-
Notifications
You must be signed in to change notification settings - Fork 233
bundle: record and read deployment state via DMS #6094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
167 commits
Select commit
Hold shift + click to select a range
f0673ef
bundle: record and read deployment state via DMS
shreyas-goenka a9ce3a2
acceptance/dms: list-resources shows empty tombstone for no-resources
shreyas-goenka 4abbea0
acceptance/dms: assert declined deploy leaves recorded resources unch…
shreyas-goenka 2a56b8b
acceptance/dms: list-resources coverage for depends-on and emptied-re…
shreyas-goenka af3ffde
acceptance/dms: inline bundle summary into no-drift + declined-deploy…
shreyas-goenka 0978bb8
libs/dms: document the three SDK gaps the raw client works around; dr…
shreyas-goenka 6163285
acceptance/dms: fold serialized-plan header assertion into stale-plan…
shreyas-goenka 632b8ea
acceptance/bin: centralize recorded-state reconstruction in dms_resou…
shreyas-goenka 1b0b45f
acceptance/dms: record-failure uses a real bogus node type + a scoped…
shreyas-goenka 09f61c3
libs/dms: gofmt the rawClient doc comment
shreyas-goenka d42b08e
bundle: make the recorded-state marker the source of truth for DMS; O…
shreyas-goenka 8dc139d
bundle: move the DMS client and operation buffer into StateDB; drop t…
shreyas-goenka 8ec86f8
bundle/dms: StorageBackend enum as source of truth; hide operation bu…
shreyas-goenka 3683aed
bundle/dms: rename first-version stamp, inline env predicate, state-g…
shreyas-goenka c0bc24d
acceptance/dms: record plan JSON, list-resources, and raw recorded state
shreyas-goenka eaa31f4
acceptance/dms: record plan JSON, list-resources, and raw recorded st…
shreyas-goenka db6a166
bundle/dms: guard StorageBackend() gate on direct engine; bump future…
shreyas-goenka 0afcb13
bundle/dms: StateDB owns plan lineage; unbind-specific message; fail …
shreyas-goenka 0f92c14
acceptance/dms: drop dedicated readplan test; cover deploy --plan via…
shreyas-goenka 5f10805
bundle/dms: trim redundant comment on the cmdctx workspace-client bridge
shreyas-goenka abd7357
acceptance/dms: record plan/list-resources/state for the failure tests
shreyas-goenka b4d23d2
bundle/dms: review fixes - naming, single lineage fields, user-facing…
shreyas-goenka 97ba52a
hand edits
shreyas-goenka dad2993
bundle/dms: fix hand-edit regressions in unlockedOpen and declined-de…
shreyas-goenka bb5abcd
acceptance/dms: serialize deployment_id and version_id in plan output
shreyas-goenka aadf972
acceptance/dms: assert tombstone state via print_state.py --no-dms
shreyas-goenka 5e7a846
acceptance/dms: assert tombstone state via print_state.py --no-dms; p…
shreyas-goenka ab79f3b
acceptance/dms: put record_deployment_history feature in existing-sta…
shreyas-goenka bbade26
acceptance/dms: drop two racy mid-flow titles in deployment-metadata-…
shreyas-goenka 55b1256
acceptance/dms: drop redundant resources.json guard in print_state.py
shreyas-goenka 41b1adf
acceptance/dms: assert failed delete records its error via list-opera…
shreyas-goenka 4563cbc
bundle/direct/dstate: restore original migrateState feature-version c…
shreyas-goenka 5435321
acceptance/dms: failed-recreate fails naturally via nonexistent catal…
shreyas-goenka ae90e56
bundle/direct/dstate: restore TestEmptyFeatureStateAcceptedWithoutFli…
shreyas-goenka 6a21a0e
bundle/direct/dstate: use lock/defer-unlock in RecordingError
shreyas-goenka 9806599
acceptance/dms: cover bind/unbind refusal while recording deployment …
shreyas-goenka 8d65ab2
libs/dms: fold latestState update into record under one lock
shreyas-goenka c0a2e50
acceptance/dms: print plan header via jq + readable plan instead of f…
shreyas-goenka d76883e
libs/dms: shorten record/RecordFailure comments, rename flag to keepE…
shreyas-goenka f839765
acceptance/dms: bind test uses a real job so it records the DMS refusal
shreyas-goenka f8894d5
acceptance/dms: rename emptied-resource to empty-grants, record the k…
shreyas-goenka 4b01fa8
acceptance/dms: assert failed permissions update records its error vi…
shreyas-goenka 7bf906a
acceptance/dms: remove operation-upload-fails test
shreyas-goenka bdcc887
acceptance/dms: remove redundant record and failed-update tests
shreyas-goenka cc4d4cc
libs/testserver: gofmt fake_workspace.go after seeding the main catalog
shreyas-goenka 983777e
Class A: Revert catalog-existence validation regression
shreyas-goenka ab2ccc6
Regenerate failed-recreate test golden after fault injection rewrite
shreyas-goenka 7b84ffe
Add storage_backend to nostamp.py plan header keys
shreyas-goenka 101fa48
Class B: Pipe bundle plan JSON through nostamp.py in 32 tests
shreyas-goenka ef650bc
Fix failed-recreate: ensure out.requests.txt cleanup and suppress ver…
shreyas-goenka a85053c
Regenerate acceptance test goldens after nostamp.py fixes
shreyas-goenka 2488374
libs/testserver: gofmt struct alignment after reverting seeded main c…
shreyas-goenka eba427d
acceptance: strip leaked CLI_VERSION commit suffix from regenerated g…
shreyas-goenka 818e972
acceptance: harden CLI_VERSION repl against +sha suffix; skip empty-g…
shreyas-goenka 669fe1f
acceptance/dms: fix failed-recreate recreate trigger; skip readplan+D…
shreyas-goenka a42fcc3
Enable DMS testing for additional bundle tests with saved plans
shreyas-goenka d32d92e
Enable DMS testing for resources/models/readplan-permissions
shreyas-goenka ff8c67d
Enable DMS testing for dashboards/change-serialized-dashboard
shreyas-goenka 0319c54
Enable DMS testing for more dashboard tests
shreyas-goenka 20de1a7
Enable DMS testing for additional bundle tests
shreyas-goenka 5d98f2b
Enable DMS testing for bundle/select tests
shreyas-goenka 5863fda
Simplify plan saves: remove redundant tee+nostamp pattern
shreyas-goenka 0f14dd4
Fix whitespace: remove trailing blank lines from test.toml files
shreyas-goenka 620fcb9
Update golden outputs for DMS-enabled tests
shreyas-goenka 15c7df2
Enable DMS for serialized dashboard test
shreyas-goenka 9442cab
Enable DMS for dashboard tests: simple and detect-change
shreyas-goenka 3dbda98
Enable DMS for more dashboard tests
shreyas-goenka 0c743d9
Add nostamp wrapper function to script.prepare
shreyas-goenka d1e2801
Add explicit DMS field validation for serialized plans
shreyas-goenka 294bcc8
Fix select tests to run with all DMS/READPLAN combinations
shreyas-goenka 4834820
Update select tests to use engine-specific plan files
shreyas-goenka 07dce69
Relax DMS plan validation to allow first-deploy plans
shreyas-goenka 00c17ce
Update plan_file_survives_not_selected golden output
shreyas-goenka 041013c
Set NextVersionId for first deployments in plan generation
shreyas-goenka 94f0646
Add DMS test: plan without DMS rejected when target has DMS
shreyas-goenka a0730e2
Update golden file for plan-without-dms test
shreyas-goenka b5960ca
Simplify plan-without-dms test to use print_requests.py
shreyas-goenka 4024655
Remove unnecessary plan corruption from test
shreyas-goenka 6123585
acceptance/bundle/deploy/readplan: Enable DMS testing for grants-remo…
shreyas-goenka e767ed8
acceptance/bin: consolidate DMS helpers into print_state.py
shreyas-goenka bde2b0e
acceptance/bundle/deploy/readplan: Fix tests to work with DMS by usin…
shreyas-goenka b0ae7f2
acceptance/bundle/deploy/readplan: Regenerate outputs for fixed tests
shreyas-goenka 633e357
acceptance/readplan: normalize recorded requests with nostamp under DMS
shreyas-goenka e55afd5
acceptance/readplan: nostamp recorded requests in cli-version-mismatch
shreyas-goenka aab6337
acceptance/bin: inline the deployment-history env check
shreyas-goenka d365f85
Merge remote-tracking branch 'origin/main' into isaac/pr6052-fixes
shreyas-goenka 92c61c5
Revert first-deploy version stamping and the extra plan validation
shreyas-goenka 37e5d6b
acceptance: match PLAN_VERSION repl to plan version 3; drop unused sy…
shreyas-goenka 83c4fb8
acceptance/bin: document why get_id_recorded lists instead of GET
shreyas-goenka 0e452f4
acceptance: stop nostamping plans that feed deploy --plan
shreyas-goenka 63b2c7c
Use state features as the DMS signal in the plan, drop storage_backend
shreyas-goenka 0a2d4bf
Say "bundle target" in the bind/unbind recording errors
shreyas-goenka 2a9e879
acceptance/immutable: drop no-op nostamp
shreyas-goenka a7d1301
acceptance/wal: trim the DMS skip comment
shreyas-goenka b3eebb9
acceptance/select: add missing trailing newline (whitespace lint)
shreyas-goenka 2bc157e
acceptance: regenerate goldens stale after the nostamp/plan-file changes
shreyas-goenka ed209b3
acceptance: stop nostamping plans captured with &> into a golden
shreyas-goenka a76b434
acceptance/bundle/resources/postgres_projects: Add compute_last_activ…
shreyas-goenka 26f4329
acceptance/bundle/resources/grants/schemas/remove_all: Skip DMS=true …
shreyas-goenka 62d461b
acceptance/bundle/resources/postgres_*: Add out.requests.txt to Ignor…
shreyas-goenka 9cbedde
acceptance/bundle/resources/postgres_*: Remove --keep flag from print…
shreyas-goenka f6a0cfd
Revert "acceptance/bundle/resources/postgres_*: Remove --keep flag fr…
shreyas-goenka 2d1eaa0
Revert "acceptance/bundle/resources/postgres_*: Add out.requests.txt …
shreyas-goenka 94e4135
Revert "acceptance/bundle/resources/postgres_projects: Add compute_la…
shreyas-goenka d74c107
acceptance/grants: regenerate remove_all golden after adding test.toml
shreyas-goenka 6138e60
Derive the deployment version from serial; no version for a no-op plan
shreyas-goenka f488c86
Rename record_deployment_history to deployment_history
shreyas-goenka f7ac997
bundle/phases: trim the version-creation comment
shreyas-goenka 538852e
Validate serial against the deployment's last version; cover the stal…
shreyas-goenka 26792ff
Reject a stale plan on serial vs the deployment's last version
shreyas-goenka 243b3c4
Say "version" not "serial" in the stale-plan error
shreyas-goenka 873109b
acceptance/apps: run readplan-lifecycle under DMS
shreyas-goenka 7d1a57a
bundle/direct/dstate: set DeploymentID in Open
shreyas-goenka c345ea2
bundle/direct: co-locate the plan-vs-state validations
shreyas-goenka 90b5c3b
bundle/deployplan: drop deployment_id from the plan, keep plan versio…
shreyas-goenka 7750a32
acceptance: revert readplan plan fixtures to plan version 2
shreyas-goenka cf4f400
bundle/direct/dstate: take the serial from the deployment's last_vers…
shreyas-goenka 16ef4b2
cmd/bundle/utils: validate lineage and serial for a plan that has nei…
shreyas-goenka bc0a598
bundle/direct/dstate: keep the created version on the state, not behi…
shreyas-goenka 7033b09
bundle/phases: compute the update mask only where it is used
shreyas-goenka 3aee9af
cmd/bundle/utils: note the state-path deployment lookup could be one API
shreyas-goenka 2c91f6b
better comment
shreyas-goenka 3767ff3
nit
shreyas-goenka c3b8e27
bundle/direct/dstate: write no WAL for a recorded deployment
shreyas-goenka e9dbe85
Merge remote-tracking branch 'origin/main' into isaac/pr6052-fixes
shreyas-goenka c3bd4ed
bundle/direct/dstate: tidy up the recorded write path
shreyas-goenka 17ed80e
bundle/phases: read the deployment from the state, drop deploymentAnd…
shreyas-goenka a96c805
bundle/direct/dstate: make VersionID the recorded version, int all th…
shreyas-goenka 77bd756
cmd/bundle/utils: check lineage before the version, set the deploymen…
shreyas-goenka f2c5ec6
cmd/bundle/utils: assign the fetched deployment to its own variables
shreyas-goenka 94bf4ed
acceptance: restore serial-mismatch script
shreyas-goenka 4776d57
acceptance/readplan: keep tmp plans out of the file count, run lineag…
shreyas-goenka 73ca1d2
acceptance: run escaped_refs under recording, drop a needless nostamp…
shreyas-goenka d1aa9bd
acceptance: run two more jobs tests under recording, document the gra…
shreyas-goenka c73985d
Report the recorded version where the state serial used to be read
shreyas-goenka c7135c1
acceptance: run jobs/big_id under recording
shreyas-goenka ab50d9d
acceptance/telemetry: name the serial in the recording exclusion reason
shreyas-goenka a7e430a
acceptance/state_present: do not run it with recording
shreyas-goenka 320cd34
acceptance: normalize the state serial in lineage-mismatch-after-rede…
shreyas-goenka 9f03439
acceptance: say why the serial repl is needed
shreyas-goenka e1339e2
acceptance: resolve the deployment once, keep the lineage-mismatch fi…
shreyas-goenka 324bd9d
Scrub the deployment stamp inside print_state.py, run two more tests …
shreyas-goenka fb1eb3c
acceptance/change_assets_dir: run it with recording
shreyas-goenka c05cc55
Merge remote-tracking branch 'origin/main' into isaac/pr6052-fixes
shreyas-goenka 3aabe82
bundle/direct/dstate: keep recorded state in memory so metadata.json …
shreyas-goenka 2e8baf1
acceptance: commit a DMS plan fixture, run two more tests with recording
shreyas-goenka 8bcdc81
acceptance/destroy_without_mgmtperms: run it with recording
shreyas-goenka 96ffaa2
acceptance/change_table_name: run it with recording
shreyas-goenka 8f047e8
acceptance/lineage-mismatch: drop the redundant Ignore
shreyas-goenka 8af91e8
bundle/direct/dstate: add GetSerial, always copy features into the plan
shreyas-goenka 7a4424a
bundle/direct/dstate: GetSerial, refuse a leftover WAL, tidy DeleteState
shreyas-goenka fe3f963
acceptance/dms/existing-state: clear the stale WAL before destroy
shreyas-goenka 0aa6c53
libs/dms: compare workspace info with structdiff.IsEqual, note the se…
shreyas-goenka 3aac3ab
libs/dms: shorten the sameWorkspaceInfo doc comment
shreyas-goenka 2467a05
Carry the deployment version as an int, add getOperationBuffer
shreyas-goenka 7c6a157
bundle/direct/dstate: drop StorageBackend, read the features instead
shreyas-goenka 5d35498
update comment
shreyas-goenka 83f339e
better commentn
shreyas-goenka 33be751
remove wrapper struct for deployment ID and last version ID
shreyas-goenka a4540bf
Regenerate the schema for the flattened deployment fields, complete t…
shreyas-goenka 0dbffa2
bundle/direct/dstate: restore the empty-shell assertion in applyDMSState
shreyas-goenka 93ac803
cmd/bundle/utils: note the half-created deployment recovery in the TODO
shreyas-goenka 0883adc
libs/dms: record two deferred items in the code, correct the resource…
shreyas-goenka 12e10e7
cmd/bundle/utils: split the two deployment-lookup TODOs
shreyas-goenka 9233825
bundle/direct/dstate: cache whether the deployment records history
shreyas-goenka 792146f
bundle/direct: move the plan-vs-state checks back into ValidatePlanAg…
shreyas-goenka ecf5608
acceptance/dms/successful-recreate: fix a title that claimed the wron…
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/usr/bin/env python3 | ||
| """Read JSON on stdin, write it back with the DMS deployment stamp removed. | ||
|
|
||
| Deployment history recording (DATABRICKS_BUNDLE_DEPLOYMENT_HISTORY=true; see | ||
| bundle/test.toml) adds a deployment stamp to plans, states, and resource payloads. Pipe any of | ||
| those through this so an acceptance golden compares equal whether or not recording is on. Output | ||
| is a 2-space indent, keys in input order, <>& left unescaped, and integers at full precision. | ||
| Tests under bundle/dms assert the stamp itself and must not use it. | ||
|
|
||
| Removed in three shapes plus the plan header: | ||
| 1. deployment_id/version_id nested in a deployment block, recognized by the | ||
| neighbouring "kind" and "metadata_file_path", which are kept; version_id | ||
| == "" is kept (a Terraform state dump carries that for an unstamped job). | ||
| 2. changes entries keyed "deployment.deployment_id" / "deployment.version_id". | ||
| 3. a changes object emptied by (2), or already empty. | ||
| 4. the recorded plan header field features. | ||
| """ | ||
|
|
||
| import argparse | ||
| import json | ||
| import sys | ||
|
|
||
| _STAMP_KEYS = ("deployment_id", "version_id") | ||
| _CHANGE_KEYS = ("deployment.deployment_id", "deployment.version_id") | ||
| _PLAN_HEADER_KEYS = ("features",) | ||
|
|
||
|
|
||
| def scrub(node): | ||
| if isinstance(node, dict): | ||
| # 1. A deployment block is the only object carrying both of these. | ||
| if "kind" in node and "metadata_file_path" in node: | ||
| for k in _STAMP_KEYS: | ||
| if node.get(k, "") != "": | ||
| node.pop(k, None) | ||
| out = {} | ||
| for k, v in node.items(): | ||
| if k == "changes" and isinstance(v, dict): | ||
| v = {ck: scrub(cv) for ck, cv in v.items() if ck not in _CHANGE_KEYS} | ||
| if not v: | ||
| continue # 3. drop a changes object left (or already) empty | ||
| out[k] = v | ||
| else: | ||
| out[k] = scrub(v) | ||
| return out | ||
| if isinstance(node, list): | ||
| return [scrub(x) for x in node] | ||
| return node | ||
|
|
||
|
|
||
| def render(data, indent): | ||
| data = scrub(data) | ||
| if isinstance(data, dict): | ||
| for k in _PLAN_HEADER_KEYS: | ||
| data.pop(k, None) # 4. plan header, present only at the root | ||
| return json.dumps(data, indent=indent, ensure_ascii=False, separators=(",", ": ")) | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser() | ||
| # A state dump is printed with a single-space indent; plans use two. | ||
| parser.add_argument("--indent", type=int, default=2) | ||
| args = parser.parse_args() | ||
|
|
||
| # Input is one JSON value (a plan or state dump) or a whitespace-separated stream of them (each | ||
| # request emitted by a print_requests filter) - jq accepted both here, so this must too. | ||
| text = sys.stdin.read() | ||
| decoder = json.JSONDecoder() | ||
| idx, n = 0, len(text) | ||
| while idx < n: | ||
| while idx < n and text[idx].isspace(): | ||
| idx += 1 | ||
| if idx >= n: | ||
| break | ||
| data, idx = decoder.raw_decode(text, idx) | ||
| sys.stdout.write(render(data, args.indent) + "\n") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read_id.py today only takes the job name without the resource type prefix (
job1vsjobs.job1). For now thus this is implemented via the list API and then only matching the suffix of the key.Eventually we can simplify and make this more efficient by only relying on GET /resource as a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you move this comment into the code? It's useful there.
I agree that this should be GET and that this can be a follow up. It's probably a sign that we might need to change database schema, since DABs currently enforce uniqueness of names and user-visible commands allow specifying just name without type prefix (bundle run my_job).