Repository navigation
Record bind history outside StateDB - #7817
shreyas-goenka wants to merge 10 commits into
Conversation
a99be74 to
e02cd13
Compare
Regression test report ✅Commit: Selected 13 changed tests (limit=20, 0 not selected) 19 tests: regression=9 unreleased=0 coverage=10 failing=0
TestAccept/bundle/deployment/bind/feature_spec/DMS=true/OUTPUT_MODE=recorded: branch ✅ | main (3442593) ❌ | latest (v1.28.0) ❌main (3442593): latest (v1.28.0): TestAccept/bundle/dms/bind-immutable/DMS=true: branch ✅ | main (3442593) ❌ | latest (v1.28.0) ❌main (3442593): latest (v1.28.0): same output as main (3442593) TestAccept/bundle/dms/bind-unbind/DMS=true: branch ✅ | main (3442593) ❌ | latest (v1.28.0) ❌main (3442593): latest (v1.28.0): TestAccept/bundle/dms/bind-upload-failure/DMS=true: branch ✅ | main (3442593) ❌ | latest (v1.28.0) ❌main (3442593): latest (v1.28.0): TestAccept/bundle/dms_fault/complete_version/DMS=true: branch ✅ | main (3442593) ❌ | latest (v1.28.0) ❌main (3442593): latest (v1.28.0): 4 more failure details omitted, see the full report in the run. |
1841b1a to
fbccb43
Compare
✅ Integration test reportCommit: 545d6ad
Top 3 slowest tests (at least 2 minutes):
|
fbccb43 to
51ec50c
Compare
| @@ -0,0 +1,5 @@ | |||
|
|
|||
| >>> [CLI] bundle deployment bind spec1 main.fspec_[UNIQUE_NAME].boundspec --auto-approve | |||
| Warn: Failed to record deployment history for bind: failed to create deployment version: operations.resource_key must have a known resource type prefix (e.g. 'jobs.', 'pipelines.'): feature_specs.spec1 | |||
There was a problem hiding this comment.
I'm taking a look whether we need to add feature_spec as a resource to DMS.
51ec50c to
c2454aa
Compare
| $CLI bundle deployment bind kept "$job_id" --auto-approve &> LOG.setup | ||
| rm -f "$OUT_REQUESTS" | ||
|
|
||
| title "A remote state upload failure fails the bind version" |
There was a problem hiding this comment.
Because of API failing, the remote deployment state is not updated. In this case, deployment history does capture the bind operation but marks it as a failed version.
365bce7 to
40d560d
Compare
|
/review |
There was a problem hiding this comment.
Automated review at 40d560d. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) below.
This PR records committed bundle deployment bind operations as UPDATE versions in deployment history (DMS), running outside the StateDB. The implementation is correct: it creates a history version after bind commits, completes it after the remote state upload, handles failures gracefully with best-effort semantics, and has thorough fault-injection test coverage. The main concern is that createBindingVersion closely replicates DMS protocol logic already in dms.go, creating a maintenance risk.
| } | ||
|
|
||
| // createBindingVersion claims a history version for the staged binding operations. | ||
| func createBindingVersion(ctx context.Context, b *bundle.Bundle, serial int, staged []bundledeployments.StagedOperation) (*bindingHistory, error) { |
There was a problem hiding this comment.
[nice to have] createBindingVersion re-implements the create-deployment-if-absent block (lines 237–251, including the recoverCreatedDeployment fallback and DeploymentIDFromName extraction) and the git-info + CreateVersion construction (lines 255–270) that already live in createOrUpdateDeployment (dms.go:83–98) and startVersion (dms.go:220–241). A protocol change—say a new field on CreateVersion or a tweaked recovery rule—now needs updating in both places. Can you extract at least the "ensure deployment exists" block and the version-info builder into shared helpers that both paths call?
| } | ||
| history, err := createBindingVersion(ctx, b, metadata.Serial, []bundledeployments.StagedOperation{{ | ||
| ResourceKey: strings.TrimPrefix(resourceKey, dms.StatePrefix), | ||
| ActionType: bundledeployments.OperationActionTypeOperationActionTypeUpdate, |
There was a problem hiding this comment.
Bind leaves the resource unchanged, but history shows an update. Can we record OPERATION_ACTION_TYPE_BIND instead?
There was a problem hiding this comment.
Let's discuss this today. This is a open design question.
There was a problem hiding this comment.
We discussed offline - we'll proceed with an update operation type. The bind annotation will be captured in a separate new field added later.
| @@ -0,0 +1,4 @@ | |||
| # This test ensures that deployment history works with bind and immutable folders. This case is interesting | |||
| # because by default we record the snapshot path in deploy, but that is not available during bind. So it's important | |||
| # to ensure that we don't do that during deployment bind, and recording history continues to work. | |||
There was a problem hiding this comment.
This test still passes when bind records the snapshot path as the deployment's file path. Could it print the deployment's workspace info, like dms/immutable-folder does?
There was a problem hiding this comment.
updated the test assertion to check that file_path is not being recorded.
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.
| return nil, err | ||
| } | ||
| history.buffer.RecordOperation(ctx, resourceKey, false, entry.ID, state) | ||
| return history, history.buffer.Drain(ctx) |
There was a problem hiding this comment.
[AI Generated] nit: recordBindHistory returns a non-nil history with the Drain error, and Bind relies on that to stop the heartbeat and complete the version. Can its doc comment say so?
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Follow-up review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.
Earlier findings: 1 still open.
No new issues found.
Co-authored-by: Isaac <no-reply@databricks.com>
Print the deployment's workspace_info after bind, as dms/immutable-folder does, so the test fails if bind records the snapshot path as file_path. Co-authored-by: Isaac <no-reply@databricks.com>
34ce009 to
fce7ab5
Compare
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.
No issues found.
|
/review |
There was a problem hiding this comment.
Automated review at fce7ab5. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) below.
This PR records a committed bundle deployment bind as an UPDATE version in deployment history. Recording is best effort, and the version is completed after the remote state upload. The flow works, and the acceptance coverage for rejection, rebind and upload failure is thorough. The main concern is that createBindingVersion and completeBindingHistory copy the deploy-side version code in dms.go and deploy.go instead of reusing it, and the copies already behave differently. Two smaller issues: a failed operation PATCH marks a committed bind as a failed version, and the new immutable test prints a whole nested GET object.
| } | ||
|
|
||
| // createBindingVersion claims a history version for the staged binding operations. | ||
| func createBindingVersion(ctx context.Context, b *bundle.Bundle, serial int, staged []bundledeployments.StagedOperation) (*bindingHistory, error) { |
There was a problem hiding this comment.
[nice to have] createBindingVersion copies code that already exists in bundle/phases/dms.go. The CreateDeployment / recoverCreatedDeployment / DeploymentIDFromName block comes from createOrUpdateDeployment. The GitInfo / Version{...} / CreateVersion block and the "failed to create deployment version" wrap come from startVersion. completeBindingHistory (line 143) likewise copies StateDB.CompleteVersion from the deferred block in deploy.go.
The copies already differ:
- Bind numbers the version from the remote
LastVersionId, whilestartVersionusesStateDB.VersionID. - Bind never writes a new deployment ID into
StateDB.DeploymentIDorb.Config.Bundle.Deployment.DeploymentID. - A completion error in bind is always a warning, while deploy treats it as fatal in DMS mode.
A later fix to numbering, recovery or completion would have to land in both places. Could startVersion take the deployment ID, previous version and serial as arguments so bind calls it, with bind reusing the deploy-side completion path, instead of keeping a second copy? (AGENTS.md: search for an existing helper before adding one.)
| return nil, err | ||
| } | ||
| history.buffer.RecordOperation(ctx, resourceKey, false, entry.ID, state) | ||
| return history, history.buffer.Drain(ctx) |
There was a problem hiding this comment.
[nice to have] If Drain fails (for example the operation PATCH fault in dms_fault/update_operation), historyErr is set, so the deferred completeBindingHistory sends VERSION_COMPLETE_FAILURE. That happens even though the state was committed and pushed. Deploy treats the same best-effort recording failure as a warning: it completes with !logdiag.HasError(ctx) and records SUCCESS. Should bind base the completion reason only on the command outcome, as deploy does, and keep the Drain error as a warning?
|
|
||
| title "Bind uploads no files, so the deployment records no file_path" | ||
| # MSYS_NO_PATHCONV: Git Bash on Windows would rewrite the leading-'/' API path. | ||
| trace MSYS_NO_PATHCONV=1 $CLI api get "/api/2.0/bundle/deployments/${deployment_id}" | jq '{workspace_info}' |
There was a problem hiding this comment.
[nice to have] jq '{workspace_info}' prints the whole workspace_info object, but the test only asserts root_path and that file_path is absent. Any new field the testserver or backend adds to workspace_info would change this golden. testing.md asks to project GET responses to an allow-list. Something like jq '.workspace_info | {root_path, file_path} | with_entries(select(.value != null))' keeps the file_path check, and could live in a deployment_fields() helper in script.prepare.
A failed history upload is a warning and no longer fails the version: the binding was committed and pushed either way, so the version records success as a deploy's would in the same case. A failed state upload still fails it. Also project the immutable-folder test's workspace_info to the two fields it asserts, so new backend fields do not change the golden. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
#7895 replaced RecordsDeploymentHistory with DeploymentHistoryChoice, and an unset setting now means "ask the workspace", not "off". Bind is not a deploy, so it does not consult enrollment: an explicit setting wins, otherwise it follows the loaded state's marker, as other non-deploy commands do. Co-authored-by: Isaac <no-reply@databricks.com>
| defer func() { | ||
| // Completion reflects the bind's outcome, as deploy's does: a failed history upload is | ||
| // only a warning, since the state was committed either way. | ||
| completeBindingHistory(ctx, b, history, !logdiag.HasError(ctx)) |
There was a problem hiding this comment.
Deploy's StateDB.CompleteVersion fails the version when a history upload failed, so this comment, the test title and the description are wrong. Should bind follow the same rule?
Reverts the completion rule to match CompleteVersion: the bind still succeeds with a warning, but a version whose operation upload failed completes with failure, since the service holds no record of the binding. The upload-failure test now pins this case. Co-authored-by: Isaac <no-reply@databricks.com>
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Sonnet 5.5 + Claude Opus 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.
| if !explicit { | ||
| recordsHistory = b.StateDB.RecordsHistory() | ||
| } | ||
| if recordsHistory { |
There was a problem hiding this comment.
[AI Generated] Major: With deployment_history: false and a state that already has deployment_history_shadow, this only skips adding the marker, so line 227 still records history. Delete the marker when false, as process.go:385 does?
There was a problem hiding this comment.
🤖 Should fix +1, reproduced: in dms/bind-unbind, changing the rebind step to DATABRICKS_BUNDLE_DEPLOYMENT_HISTORY=false leaves the golden unchanged apart from the echoed command. Bind still sends CreateVersion, the operation PATCH with the job's full state, and CompleteVersion. That step would make a good regression test once an explicit false clears the marker, as cmd/bundle/utils/process.go does for deploy.
The bind bumps the state serial before its version is created, so that serial is the version's number; max with the service's next version keeps it from falling behind either counter. The former serial+1 skipped a number on every bind. Co-authored-by: Isaac <no-reply@databricks.com>
denik
left a comment
There was a problem hiding this comment.
🤖 Automated review of 4060ec91d by Opus, Fable and Astra; each finding verified against the code.
No blocking issues. One new should-fix is inline: history is recorded before the remote state push. I also added a reproduction to the open deployment_history: false thread.
Not posted inline (plausible; not checked against the real service):
bundle/phases/bind.go:241: on a freshmode: developmenttarget, locking is off, so nothing createsworkspace.state_pathbeforeCreateDeployment. If the service requires that parent folder (the testserver doesn't check), the first bind's history always fails with a warning. Pushing state before recording history would also fix this.
| return | ||
| } | ||
|
|
||
| history, historyErr = recordBindHistory(ctx, b, resourceKey, result.DMSMetadata) |
There was a problem hiding this comment.
🤖 Should fix History is recorded after the local state is committed (result.Finalize(), L130) but before PushResourcesState (L141). FetchDeployment, CreateDeployment, CreateVersion and the deferred CompleteVersion all go through the bundle client, which retries 429/503 for up to 15 minutes (RetryTimeoutSeconds in bundle/config/workspace.go). Only the operation upload has a 5s budget. When the history service is throttled, bind holds the deploy lock for minutes, with the binding in local state but not in remote state, all for best-effort data. An interrupt in that window leaves this checkout ahead of the workspace, and other checkouts don't see the binding. Before this PR that window was one rename wide.
Pushing the state first and recording history after it closes the window. A failed push then creates no version at all, rather than a failed version whose operation was already recorded as succeeded, and bindingHistory and the deferred completion go away.
| if !explicit { | ||
| recordsHistory = b.StateDB.RecordsHistory() | ||
| } | ||
| if recordsHistory { |
There was a problem hiding this comment.
🤖 Should fix +1, reproduced: in dms/bind-unbind, changing the rebind step to DATABRICKS_BUNDLE_DEPLOYMENT_HISTORY=false leaves the golden unchanged apart from the echoed command. Bind still sends CreateVersion, the operation PATCH with the job's full state, and CompleteVersion. That step would make a good regression test once an explicit false clears the marker, as cmd/bundle/utils/process.go does for deploy.
|
Heads-up: #7975 removed the To fix: use |
An explicit false only skipped adding the shadow marker, so a state that already carried one kept recording history. Delete the marker instead, as deploy does, so the bind records nothing. The bind-unbind test now covers an explicit false and an explicit true rebind. Co-authored-by: Isaac <no-reply@databricks.com>
The job is bound when the script ends, so bundle destroy already deletes it
and the explicit jobs delete 404s. errcode swallowed that status, but a
prepare-defined helper is not reliably in scope inside the EXIT trap in CI
("errcode: command not found", exit 127 appended to the golden). Call
destroy directly, as the other dms/ traps do.
Co-authored-by: Isaac <no-reply@databricks.com>
Changes
Record committed
bundle deployment bindoperations asUPDATEin deployment history. Recording is best effort and runs separately from StateDB, after approval and the existing temporary-file commit. A failed history upload warns and the bind still succeeds, but the version completes with failure, as a deploy's does: the service then holds no record of the binding. A failed remote state upload fails the bind and the version.This covers every bind path:
bundle deployment bind,bundle generate --bind, andapps import. A resource type the service does not know (such asfeature_specs) binds as before and prints a warning that its history was not recorded.Why
Bind changes resource state without recording history today. This preserves the existing preparation flow, two state writes, and serial increments. Bind omits uploaded-file metadata; existing deployment metadata is preserved. Bind is not a deploy, so it does not consult workspace enrollment (#7895): an explicit
deployment_historysetting wins, otherwise the loaded state's marker is kept.Tests
dms/bind-upload-failure: a failed state upload fails the command and the version, leaving the resource out of remote state; a failed history upload warns, fails only the version, and the resource is in remote state.dms/bind-immutable: the deployment records nofile_pathafter a bind.dms/bind-unbind: shadow history markers and resource IDs across bind, deploy, unbind, and rebind.This PR was written by Codex.