Everything in server.yaml that is not one machine's own is now a versioned document in the store (cluster_settings), the same on every control plane. The first start against a store imports the file's cluster keys, with the baseline guard policy when there is none; after that those keys in a file are ignored, with a warning. Each control plane polls the document's version and its own server.yaml's hash. A change is validated and applied: guard live (Gate.Replace), anything else by a graceful restart that systemd brings back, standbys first and the leader 30s later. A version that does not load on a machine is not applied; at start the newest one that loads is used, so a bad edit cannot keep every control plane down. llmgw ctl config show/get/set/unset/edit/history/rollback, the admin API under /api/v1/settings, and the console's Settings screen, which layers the store's document over the machine's file, write it. Commands beside the control plane that read cluster keys (init, node add, server add, backup, upgrade) read the layered configuration; init --bundle writes offline to the store once it holds the settings. A standby that becomes the leader re-reads models, engine choices and facility holds from the store. Retires appendGuardIfMissing: the import does it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package store
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestSettingsAreVersionedAndTwoEditsCannotBothWin(t *testing.T) {
|
|
s := capacityStore(t)
|
|
ctx := t.Context()
|
|
if v, err := s.ClusterSettings(ctx); err != nil || v.Version != 0 {
|
|
t.Fatalf("empty store: %+v %v", v, err)
|
|
}
|
|
v1, err := s.PutClusterSettings(ctx, 0, "router: {}\n", "import", "from server.yaml")
|
|
if err != nil || v1 != 1 {
|
|
t.Fatalf("first: %d %v", v1, err)
|
|
}
|
|
if _, err := s.PutClusterSettings(ctx, 0, "x: 1\n", "late", ""); !errors.Is(err, ErrSettingsChanged) {
|
|
t.Fatalf("a change from an old version: %v", err)
|
|
}
|
|
if _, err := s.PutClusterSettings(ctx, 1, "guard: {}\n", "ilker", "guard"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cur, _ := s.ClusterSettings(ctx)
|
|
if cur.Version != 2 || cur.Body != "guard: {}\n" || cur.By != "ilker" {
|
|
t.Errorf("newest: %+v", cur)
|
|
}
|
|
if n, _ := s.ClusterSettingsVersion(ctx); n != 2 {
|
|
t.Errorf("version %d", n)
|
|
}
|
|
old, _ := s.ClusterSettingsAt(ctx, 1)
|
|
if old.Body != "router: {}\n" || old.Note != "from server.yaml" {
|
|
t.Errorf("version 1: %+v", old)
|
|
}
|
|
h, _ := s.ClusterSettingsHistory(ctx, 10)
|
|
if len(h) != 2 || h[0].Version != 2 {
|
|
t.Errorf("history: %+v", h)
|
|
}
|
|
}
|