Repository navigation
Record deployment history for bundle resource bindings - #7400
shreyas-goenka wants to merge 28 commits into
Conversation
c8357c9 to
938294b
Compare
938294b to
2c7cf79
Compare
✅ Integration test reportCommit: 7b569b3
Top 18 slowest tests (at least 2 minutes):
|
|
Commit: Regression test reportSelected 6 changed tests (limit=20, 0 not selected) 11 tests: regression=3 unreleased=0 coverage=8 failing=0
TestAccept/bundle/dms/bind-history-failures/DMS=true: branch ✅ | main (5ed1897) ❌ | latest (v1.26.0) ❌main (5ed1897): latest (v1.26.0): same output as main (5ed1897) TestAccept/bundle/dms/bind-immutable/DMS=true: branch ✅ | main (5ed1897) ❌ | latest (v1.26.0) ❌main (5ed1897): latest (v1.26.0): same output as main (5ed1897) TestAccept/bundle/dms/bind-unbind/DMS=true: branch ✅ | main (5ed1897) ❌ | latest (v1.26.0) ❌main (5ed1897): latest (v1.26.0): |
| trace $CLI bundle deployment bind foo $NEW_PIPELINE_ID --auto-approve &> out.bind-success.txt | ||
| trace print_requests.py '^//import-file/' '^//workspace/' | ||
|
|
||
| trace $CLI bundle summary -o json | jq .resources > out.summary.json |
There was a problem hiding this comment.
added because now the summary contains deployment and version ID
| print_requests.py '^//import-file/' '^//workspace/delete' | ||
|
|
||
| trace $CLI bundle summary -o json > out.summary.json | ||
| trace $CLI bundle summary -o json | nostamp.py > out.summary.json |
There was a problem hiding this comment.
updated nostamp.py to scrub the deployment ID from the summary output as well.
andrewnester
left a comment
There was a problem hiding this comment.
Deploy decides recording from config alone and deletes the shadow marker when experimental.deployment_history is false (process.go:376-384); destroy follows the marker alone; bind records when either the marker or the config says so. On a state that carries the marker, deployment_history: false plus bundle deploy records nothing and drops the marker, while bundle deployment bind on the same state still publishes a version. Is bind meant to follow the marker when the config turns recording off, or should it follow the config like deploy?
Nits:
- bundle/phases/bind.go:292: the
UpdateOperationerror is returned unwrapped, so the warning reads "Failed to record bind history: Fault injected by test." with nothing saying which call failed;OperationBuffer.runwraps the same error as "recording operation for %s: %w". - libs/dms/metadata.go:156-159: the new first sentence and the retained "Lookup and return the deployment object from ..." say the same thing, and the TODO still proposes a
dms.ReadDeploymentnow that this isdms.LookupDeployment. - .nextchanges/bundles/record-bind-history.md: "when binding ... when deployment history is enabled" stacks two "when" clauses; e.g. "Record a deployment history version for
bundle deployment bindwhen deployment history is enabled."
| configured = configRoot.Experimental.DeploymentHistory | ||
| } | ||
| var dmsMetadata *DMSBindMetadata | ||
| if b.StateDB.RecordsHistory() || bundleenv.RecordsDeploymentHistory(ctx, configured) { |
There was a problem hiding this comment.
This decides to record the bind in DMS, but nothing writes the deployment_history_shadow marker into the state that gets committed: UpgradeToWrite sees no marker and picks WritingFile, whose WAL header clears features (dstate/state.go:964), so after a first bind with history on, resources.json has features: null while DMS already lists jobs.foo under a new deployment. Every non-deploy command follows the marker (process.go:386, destroy.go:159), so bind followed by destroy records no destroy version and never deletes the deployment, and the node under the state path goes away with the state dir, leaving a DMS deployment that still lists the bound resource. Can bind set the marker when it records, the way process.go:376 does before deploy upgrades to shadow mode, and can bind-unbind grow a bind-then-destroy case to pin that down?
| } | ||
|
|
||
| // createBindingVersion claims a history version for the staged binding operations. | ||
| func createBindingVersion(ctx context.Context, b *bundle.Bundle, serial int, staged []bundledeployments.StagedOperation) (string, error) { |
There was a problem hiding this comment.
This is startVersion (dms.go:173) with previous/deploymentID taken from a lookup instead of the StateDB; likewise completeBindingHistory repeats DeploymentState.CompleteVersion, recordBindingOperation rebuilds what OperationUpdate.operation() and OperationBuffer.write already do (and hardcodes the 5s that historyDrainTimeoutPerOperation names), and createBindingDeployment repeats the create branch of createOrUpdateDeployment. The version-number comment in startVersion about why claiming the number up front is safe now lives in only one of the two copies. Can the request building move into shared helpers (a version-create taking deploymentID/previous/serial, a dms.CompleteVersion(ctx, w, name, success), an exported operation()), so bind and deploy cannot drift?
| defer cancel() | ||
| var state json.RawMessage | ||
| var resourceID string | ||
| if entry != nil { |
There was a problem hiding this comment.
recordBindHistory always passes &metadata.ResourceState, so the entry == nil branch and the "or its removal" in the doc comment have no caller in this PR. Can this land with the unbind recording in #7401 that needs it, so the function here says only what it does?
| if isinstance(data, dict): | ||
| for k in _PLAN_HEADER_KEYS: | ||
| data.pop(k, None) # 4. plan header, present only at the root | ||
| # 5. Strip the summary's DMS IDs, keeping deployment settings such as locks. |
There was a problem hiding this comment.
Running the DMS=true variants of the three scripts this PR pipes through nostamp (bind/pipelines/update, bind/pipelines/recreate, bind/dashboard/recreation) with the scripts at their base revision passes locally at this HEAD: after a first bind there is no marker, so summary and the state dump never carry bundle.deployment IDs. What difference is shape 5 and these three pipes guarding against, a cloud run or a later PR in the stack? If the latter, can they move there?
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got, err := parseLastVersionID(tt.deployment) | ||
| got, err := dms.ParseLastVersionID(tt.deployment) |
There was a problem hiding this comment.
This now tests dms.ParseLastVersionID from a different package. Can the table move to libs/dms/metadata_test.go next to the function, since the one in this file no longer exists?
| ResourceId string | ||
| } | ||
|
|
||
| // createBindingDeployment registers a first binding without changing metadata from an existing deploy. |
There was a problem hiding this comment.
"without changing metadata from an existing deploy" describes a case this function never sees: it only runs when current == nil (line 229), so there is no existing deploy to preserve. Something like "creates the deployment record when a bind is the first recorded operation; unlike deploy's createOrUpdateDeployment it reports no file_path because bind uploads no files, and the next deploy fills it in through StaleFields" would tell the reader what is actually different.
445c82f to
7b569b3
Compare
Changes
Record successful
bundle deployment bindcommands asUPDATEoperations in deployment history. Complete the history version after remote state upload; history failures warn while state upload continues.Use the existing
dms.OperationBuffer, which StateDB also uses, for state validation, uploads, bounded best-effort draining, and heartbeats. The engine returns optional DMS metadata with the committed resource and serial. No extra state writes are added, and existing deployment metadata is preserved because bind does not upload a snapshot.Direct StateDB recording was evaluated: bind's current
SaveStatecalls prepare temporary state before approval. Sharing that path would require moving the approved commit into StateDB, or adding a second state write that advances the serial. Reusing its DMS buffer removes the duplicate operation-update code while preserving the binding flow.Shared deployment lookup lives in
libs/dms. First in a stack; #7401 adds unbind recording.Tests
This PR was written by Codex.