bundle/statemgmt: add StateReader abstraction for file and DMS state#5355
Draft
shreyas-goenka wants to merge 1 commit into
Draft
bundle/statemgmt: add StateReader abstraction for file and DMS state#5355shreyas-goenka wants to merge 1 commit into
shreyas-goenka wants to merge 1 commit into
Conversation
3 tasks
shreyas-goenka
added a commit
that referenced
this pull request
May 28, 2026
The deadcode lint check flagged this as unreachable on PR #5355's CI. ManagedState returned (string, bool) but no caller existed — every consumer uses IsManagedState (the bool wrapper). Drop it; reintroduce only if a caller needs the raw value. Co-authored-by: Isaac
3 tasks
Collaborator
|
Commit: 71a41d9 |
Introduce a StateReader interface with two implementations that populate the direct engine's resource-state DB: - file-based, reading the local resources.json (delegates to DeploymentState.Open, preserving WAL recovery + migration) - DMS-based, reading from the deployment metadata service via the SDK Bundle.ListResourcesAll This is a self-contained, drop-in abstraction with unit tests; it is not yet wired into the deploy path. Integration (selecting the reader by managed-state and sourcing the deployment ID) follows once the DMS lock and op-reporting PRs land. Co-authored-by: Isaac
0e706b8 to
71a41d9
Compare
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.
Summary
Adds a self-contained
StateReaderabstraction for reading the direct engine'sresource state, with two implementations:
NewFileStateReader(path)— reads localresources.json(delegates toDeploymentState.Open, so WAL recovery + migration are preserved).NewDMSStateReader(client, deploymentID, path)— reads from the deploymentmetadata service via
Bundle.ListResourcesAll, mapping each DMS resource intoa state entry (prefixing keys with
resources., copyingresource_id+serialized
state).This is deliberately not wired into the deploy path. It is a drop-in seam to
replace the current
StateDB.Opencall inprocess.goonce the DMS lock andop-reporting PRs land; selecting the reader by managed-state and sourcing the
deployment ID are integration-time concerns that depend on those PRs.
Rework notes (vs the previous version of this PR)
The earlier version inlined
LoadStateFromDMSand scattered managed-statebranches across
state_pull.go/state_push.go/process.go, stacked on thenow-superseded old DMS-lock branch. This version instead:
the house style of
lock.DeploymentManageranddirect.opRecorder.DeploymentState.Openso WAL recovery andstate migration are not lost.
mainand carries no integration changes, so it can landindependently and be integrated later.
Test plan
go test ./bundle/statemgmt/...(newTestDMSStateReader*/TestFileStateReader*)go build ./...go tool golangci-lint run ./bundle/statemgmt/— 0 issues