bundle: record and read deployment state via DMS with server-generated IDs#6052
Draft
shreyas-goenka wants to merge 2 commits into
Draft
bundle: record and read deployment state via DMS with server-generated IDs#6052shreyas-goenka wants to merge 2 commits into
shreyas-goenka wants to merge 2 commits into
Conversation
…d IDs Wire the direct engine into the Deployment Metadata Service (DMS) so that a `record_deployment_history`-enabled bundle records each deploy/destroy as a version and can read its resource state back from DMS. The deployment ID is now assigned by the server: the first deploy calls CreateDeployment with an empty ID, reads the assigned ID back from the response, and persists it in the direct-engine state header (Header.DeploymentID). Later deploys pass the stored ID back, so a bundle maps one-to-one to a DMS deployment even after the local cache is deleted (the ID rides along in the workspace-synced state file). - libs/dms: Recorder creates the deployment (server-assigned ID) + version, heartbeats the lease, completes it, and deletes the deployment on destroy. - bundle/direct: operationRecorder reports each applied resource operation; the wire resource_key drops the CLI-internal "resources." prefix. - bundle/direct/dstate: Open takes a DMS client and overlays DMS resource state when DMS holds a successful version; deployment ID persisted in the header. - bundle/phases: create the version after plan approval, complete it under the lock, record operations during apply. - libs/testserver: stateful fake DMS (deployments/versions/operations/resources) with server-generated IDs; acceptance test covers deploy, cache-loss redeploy, and destroy. Co-authored-by: Isaac
Collaborator
Integration test reportCommit: da1ed9d
9 interesting tests: 4 SKIP, 3 RECOVERED, 2 flaky
Top 13 slowest tests (at least 2 minutes):
|
shreyas-goenka
force-pushed
the
dms-state-recording
branch
from
July 24, 2026 14:33
2d759e4 to
5590258
Compare
The read overlay decided whether DMS owns a deployment's state by listing versions and scanning for a successful one. The deployment now exposes last_successful_version_id directly, so a single GetDeployment answers the same question — no version listing. The field is still stage:DEVELOPMENT in the proto and therefore stripped from the generated SDK, so this reads the deployment via a raw GET into a local struct as a temporary stub. Once the field is promoted to PRIVATE_PREVIEW and regenerated, the raw call collapses to client.GetDeployment(...). LastSuccessfulVersionId and the threaded config argument goes away (see the TODO in deploymentHasSuccessfulVersion). The testserver's GetDeployment now serves last_successful_version_id (tracked on version completion), and the now-unused ListVersions fake is removed. Co-authored-by: Isaac
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.
What
Wires the direct deployment engine into the Deployment Metadata Service (DMS) so that a bundle with
experimental.record_deployment_historyenabled:deploy/destroyas a DMS version (with heartbeat + completion).The key design point: server-generated deployment IDs
The DMS API assigns the deployment ID server-side. Earlier prototypes used the local state lineage (a client-minted UUID) as the deployment ID; that no longer holds. The flow is now:
CreateDeploymentwith an empty ID → the server mints one and returns it indeployment.Name→ we parse it out and persist it in the direct-engine state header (Header.DeploymentID).GetDeploymentto compute the next version number.Because the ID lives in the state file (which is synced to the workspace), it survives deleting the local
.databrickscache — the redeploy recovers the same deployment and just increments the version. No newCreateDeployment.Reading DMS authority:
last_successful_version_idThe read overlay only trusts DMS state when DMS holds a successfully completed version for the deployment. The deployment exposes
last_successful_version_id(advanced only on success, unlikelast_version_id), so a singleGetDeploymentanswers that — no version listing.That field is still
stage: DEVELOPMENTin the proto, so it's stripped from the generated SDK. Until it's promoted toPRIVATE_PREVIEWand regenerated, the CLI reads it via a temporary raw GET into a local struct:The proto flip to
PRIVATE_PREVIEWis a separate universe change; once it lands and the SDK regenerates, the raw call collapses toclient.GetDeployment(...).LastSuccessfulVersionIdand the threadedcfgargument goes away.Wiring
libs/dms—Recorder: create deployment (server-assigned ID) + version, heartbeat the lease, complete it, delete the deployment on destroy.bundle/direct/oprecorder.go—operationRecorder: reports each applied operation. The wireresource_keydrops the CLI-internalresources.prefix (resources.jobs.foo→jobs.foo); the read path re-adds it.bundle/direct/dstate—Openoverlays DMS resource state when DMS holds a successful version (last_successful_version_idset);DeploymentIDpersisted in the state header.bundle/phases— create the version after plan approval, complete it under the lock (deferred beforelock.Release), record operations during apply.libs/testserver— a stateful fake DMS (deployments / versions / operations / resources) with server-generated IDs;GetDeploymentserveslast_successful_version_idon version completion.Testing
acceptance/bundle/dms/recordcovers the full arc: deploy → server assigns ID → redeploy afterrm -rf .databricks(ID recovered, version increments, no new CreateDeployment) → destroy (delete op + deployment deletion).Gated entirely behind
experimental.record_deployment_history+ the direct engine; terraform and non-opted bundles are untouched.This pull request and its description were written by Isaac.