fix(statestore): build the recovery control-plane server on the shared step vocabulary
After the rebase onto main, controlplane.NewServer takes the step vocabulary it resolves definitions against (controlplane.ResourceStore, *workflow.Manager) and returns (Server, error). Both offline call sites still passed the store alone, so internal/app/archied stopped compiling -- and with it cmd/archie-state-store, cmd/archied and cmd/archie-gateway. validate and rollback now build their server through openStateStoreControlPlane, the root helper the served path already uses, so the offline checks resolve the same shared provider set (internal/infrastructure/workflowsteps) as the process whose verdict they predict, and the constructor's error is returned as a refusal rather than dropped. No second vocabulary call site: the fwmp pin on openStateStoreControlPlane covers these paths unchanged. The test's seeding helper builds its server from the same shared set (workflowsteps.NewManager) because it cannot call the unexported root helper; an empty manager there would seed values the served path never validates against. That is not merely a claim: with an empty manager the three validate tests fail with `workflow "bootstrap" step 1: unknown type "bootstrap.prepare"`, so they already pin that the offline path resolves a live, shared vocabulary.
This commit is contained in:
1 parent
b5b58c370a
commit
21c6aca513
2 files changed
+32
-4
No files matched your search
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/app/archied"
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/workflowsteps"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
)
|
||||
|
||||
@@ -685,13 +686,29 @@ func writeConfigWithLogFile(t *testing.T, dir string) (string, string) {
|
||||
// from the same config file the operator hands validate: the command's verdict
|
||||
// is about the pair, and a store whose settings never matched the config is a
|
||||
// state boot does not recognise either.
|
||||
//
|
||||
// The seeding builds its control-plane server from the shared provider set
|
||||
// (internal/infrastructure/workflowsteps), which is what every composition root
|
||||
// registers -- including openStateStoreControlPlane, the root helper the
|
||||
// recovery path uses. This test cannot call that unexported helper, so it
|
||||
// registers the same set itself rather than an empty manager: the definitions
|
||||
// are decoded with the vocabulary the served path validates against, which is
|
||||
// what makes the seeded values the ones validate is asked about.
|
||||
func seedStoreResources(t *testing.T, st *store.Store, configPath string) {
|
||||
t.Helper()
|
||||
doc, err := configuration.New(nil).Resolve(configPath, "")
|
||||
if err != nil {
|
||||
t.Fatalf("resolve %s: %v", configPath, err)
|
||||
}
|
||||
if _, err := controlplane.NewServer(st).ImportConfig(t.Context(), doc.Config); err != nil {
|
||||
steps, err := workflowsteps.NewManager()
|
||||
if err != nil {
|
||||
t.Fatalf("register workflow step vocabulary: %v", err)
|
||||
}
|
||||
server, err := controlplane.NewServer(st, steps)
|
||||
if err != nil {
|
||||
t.Fatalf("build control plane server: %v", err)
|
||||
}
|
||||
if _, err := server.ImportConfig(t.Context(), doc.Config); err != nil {
|
||||
t.Fatalf("seed store resources: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
// cannot stop the process that runs it, so the snapshot that makes a failed
|
||||
// update reversible is taken against a serving store through SQLite's own
|
||||
// consistent copy.
|
||||
//
|
||||
// The control-plane server both validate and rollback read through is built by
|
||||
// openStateStoreControlPlane -- the same root helper the served path uses -- so
|
||||
// the offline checks resolve the same workflow step vocabulary as the process
|
||||
// whose verdict they predict, and a constructor error is a refusal here rather
|
||||
// than a server that would validate against a different vocabulary.
|
||||
package archied
|
||||
|
||||
import (
|
||||
@@ -19,7 +25,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/app/controlplane"
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
@@ -131,7 +136,10 @@ func validateStore(ctx context.Context, options StateStoreRecoveryOptions) (stri
|
||||
}
|
||||
defer func() { _ = st.Close() }()
|
||||
|
||||
server := controlplane.NewServer(st)
|
||||
server, err := openStateStoreControlPlane(st)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Is there a resources table at all? A store written before the control plane
|
||||
// existed has none, and the State Store creates it and seeds every kind from
|
||||
// this same config on its next start -- so there is nothing stored to check
|
||||
@@ -210,7 +218,10 @@ func rollbackResource(ctx context.Context, options StateStoreRecoveryOptions) (s
|
||||
}
|
||||
defer func() { _ = st.Close() }()
|
||||
|
||||
server := controlplane.NewServer(st)
|
||||
server, err := openStateStoreControlPlane(st)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !server.Owns(options.Kind) {
|
||||
return "", fmt.Errorf("unknown resource kind %q", options.Kind)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user