Rename mesh-control -> mesh-controller, substrate -> foundation
One name per thing, per the HQ glossary: the module/container/image/binary/repo becomes mesh-controller, the seat the-controller, and the store+broker pair the foundation (embedded base bundles, default template and example lock renamed with their go:embed directives). No behaviour change — a pure vocabulary rename. Claude-Session: https://claude.ai/code/session_01D6qtiYU3P9jk3pnAXyAFyx
This commit is contained in:
@@ -9,37 +9,37 @@ import (
|
||||
|
||||
// Step 9 is where the control plane stops being a special case. These tests defend the two things
|
||||
// that could go wrong quietly: pinning it to the wrong image, and delivering it store connections
|
||||
// the mesh invented rather than the ones the substrate actually made.
|
||||
// the mesh invented rather than the ones the foundation actually made.
|
||||
|
||||
// theControlPlaneModule is the catalogue's manifest, trimmed to what this installer reads.
|
||||
//
|
||||
// A fixture rather than the file itself, unlike the substrate example the rewrite tests use: the
|
||||
// A fixture rather than the file itself, unlike the foundation example the rewrite tests use: the
|
||||
// catalogue is a different repository on a different branch, and a test that read it would pass or
|
||||
// fail according to what somebody else had checked out. What it must stay faithful to is the
|
||||
// SHAPE — the placeholder digest, the own-secret per context, the mount from the machine's path to
|
||||
// the container's, and the environment file that fills what is not a path.
|
||||
const theControlPlaneModule = `{
|
||||
"module": "mesh-control",
|
||||
"module": "mesh-controller",
|
||||
"version": "1",
|
||||
"slug": "control",
|
||||
"capabilities": ["container-runtime"],
|
||||
"claims": [{"name": "the-control-plane", "scope": "mesh"}],
|
||||
"claims": [{"name": "the-controller", "scope": "mesh"}],
|
||||
"own-secrets": {
|
||||
"inventory": "/var/lib/mesh/mesh-control/inventory",
|
||||
"identity": "/var/lib/mesh/mesh-control/identity",
|
||||
"licences": "/var/lib/mesh/mesh-control/licences",
|
||||
"broker": "/var/lib/mesh/mesh-control/broker",
|
||||
"broker-management": "/var/lib/mesh/mesh-control/broker-management"
|
||||
"inventory": "/var/lib/mesh/mesh-controller/inventory",
|
||||
"identity": "/var/lib/mesh/mesh-controller/identity",
|
||||
"licences": "/var/lib/mesh/mesh-controller/licences",
|
||||
"broker": "/var/lib/mesh/mesh-controller/broker",
|
||||
"broker-management": "/var/lib/mesh/mesh-controller/broker-management"
|
||||
},
|
||||
"resources": [
|
||||
{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-control", "mode": "0700"},
|
||||
{"id": "broker-env", "type": "file", "path": "/var/lib/mesh/mesh-control/broker.env",
|
||||
{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-controller", "mode": "0700"},
|
||||
{"id": "broker-env", "type": "file", "path": "/var/lib/mesh/mesh-controller/broker.env",
|
||||
"mode": "0600",
|
||||
"content": "MESH_BROKER_AMQP=${secret:broker}\nMESH_BROKER_MANAGEMENT=${secret:broker-management}\nMESH_BROKER_ADDRESS=${machine:at}:5671\n"},
|
||||
{"id": "server", "type": "container", "name": "mesh-control",
|
||||
"image": "mesh-control@` + placeholderDigest + `",
|
||||
{"id": "server", "type": "container", "name": "mesh-controller",
|
||||
"image": "mesh-controller@` + placeholderDigest + `",
|
||||
"network": "host", "args": ["serve"],
|
||||
"env-file": ["/var/lib/mesh/mesh-control/broker.env"],
|
||||
"env-file": ["/var/lib/mesh/mesh-controller/broker.env"],
|
||||
"env": {
|
||||
"MESH_STORE_INVENTORY_FILE": "/run/secrets/inventory",
|
||||
"MESH_STORE_IDENTITY_FILE": "/run/secrets/identity",
|
||||
@@ -48,18 +48,18 @@ const theControlPlaneModule = `{
|
||||
},
|
||||
"volumes": [
|
||||
"mesh-broker-tls:/broker-tls:ro",
|
||||
"/var/lib/mesh/mesh-control/inventory:/run/secrets/inventory:ro",
|
||||
"/var/lib/mesh/mesh-control/identity:/run/secrets/identity:ro",
|
||||
"/var/lib/mesh/mesh-control/licences:/run/secrets/licences:ro"
|
||||
"/var/lib/mesh/mesh-controller/inventory:/run/secrets/inventory:ro",
|
||||
"/var/lib/mesh/mesh-controller/identity:/run/secrets/identity:ro",
|
||||
"/var/lib/mesh/mesh-controller/licences:/run/secrets/licences:ro"
|
||||
]}
|
||||
]
|
||||
}`
|
||||
|
||||
const pushedReference = "127.0.0.1:5000/mesh-control@sha256:" +
|
||||
const pushedReference = "127.0.0.1:5000/mesh-controller@sha256:" +
|
||||
"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
|
||||
|
||||
// **The whole reference moves, not only the digest.** The manifest's placeholder names a
|
||||
// repository too, and replacing sixty-four zeros inside it would leave `mesh-control@sha256:…`
|
||||
// repository too, and replacing sixty-four zeros inside it would leave `mesh-controller@sha256:…`
|
||||
// with no registry in front — which a runtime would go to the internet for, and this mesh's
|
||||
// control plane exists in no public registry by design.
|
||||
func TestTheControlPlaneIsPinnedToWhatThisMeshsRegistryAssigned(t *testing.T) {
|
||||
@@ -73,7 +73,7 @@ func TestTheControlPlaneIsPinnedToWhatThisMeshsRegistryAssigned(t *testing.T) {
|
||||
if !strings.Contains(string(pinned), `"image": "`+pushedReference+`"`) {
|
||||
t.Errorf("the manifest does not name the pushed image:\n%s", pinned)
|
||||
}
|
||||
if strings.Contains(string(pinned), `"mesh-control@sha256:`) {
|
||||
if strings.Contains(string(pinned), `"mesh-controller@sha256:`) {
|
||||
t.Errorf("the digest was replaced and the manifest's own repository name was left in "+
|
||||
"front of it, so nothing says which registry serves it:\n%s", pinned)
|
||||
}
|
||||
@@ -95,10 +95,10 @@ func TestAManifestAlreadyPinnedByHandIsRefused(t *testing.T) {
|
||||
// otherwise be left half pinned, and fail inside an apply rather than here.
|
||||
func TestEveryPlaceTheManifestNamesTheImageIsPinned(t *testing.T) {
|
||||
twice := strings.Replace(theControlPlaneModule,
|
||||
`{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-control", "mode": "0700"},`,
|
||||
`{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-control", "mode": "0700"},
|
||||
{"id": "migrate", "type": "container", "name": "mesh-control-migrate", "run-once": true,
|
||||
"image": "mesh-control@`+placeholderDigest+`", "args": ["migrate"]},`, 1)
|
||||
`{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-controller", "mode": "0700"},`,
|
||||
`{"id": "mesh-state", "type": "directory", "path": "/var/lib/mesh/mesh-controller", "mode": "0700"},
|
||||
{"id": "migrate", "type": "container", "name": "mesh-controller-migrate", "run-once": true,
|
||||
"image": "mesh-controller@`+placeholderDigest+`", "args": ["migrate"]},`, 1)
|
||||
|
||||
pinned, places, err := pinImage([]byte(twice), pushedReference)
|
||||
if err != nil {
|
||||
@@ -112,8 +112,8 @@ func TestEveryPlaceTheManifestNamesTheImageIsPinned(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// **The connections are the substrate's, and they are read out of the bundle that made them.**
|
||||
// The mesh cannot invent them: they are the credentials the substrate created the databases with,
|
||||
// **The connections are the foundation's, and they are read out of the bundle that made them.**
|
||||
// The mesh cannot invent them: they are the credentials the foundation created the databases with,
|
||||
// and thirty-two random bytes in their place would leave the control plane unable to open a single
|
||||
// context. The pairing is read from the manifest so that whatever the catalogue calls these
|
||||
// secrets is what is delivered.
|
||||
@@ -141,38 +141,38 @@ func TestTheStoreConnectionsComeFromTheBundleThatMadeThem(t *testing.T) {
|
||||
t.Error("the address the mesh composes from the machine was treated as a secret")
|
||||
}
|
||||
|
||||
// The values are the substrate's own, taken from the produced bundle rather than composed.
|
||||
// The values are the foundation's own, taken from the produced bundle rather than composed.
|
||||
rewritten, err := Rewrite(theRealBundle(t), held)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime := &asked{answer: aMeshThatAgrees(nil)}
|
||||
control := controlPlane{container: "temp-mesh-control", run: runtime.run, timeout: time.Second}
|
||||
control := controlPlane{container: "temp-mesh-controller", run: runtime.run, timeout: time.Second}
|
||||
|
||||
delivered, err := deliverStores(context.Background(), Options{Node: "anchor"}, control,
|
||||
[]byte(theControlPlaneModule), rewritten.Declaration, func(string) {})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Three stores and both halves of the broker: everything the substrate made and nothing else.
|
||||
// Three stores and both halves of the broker: everything the foundation made and nothing else.
|
||||
if len(delivered) != 5 {
|
||||
t.Fatalf("%d values were delivered, and the substrate names five: %v",
|
||||
t.Fatalf("%d values were delivered, and the foundation names five: %v",
|
||||
len(delivered), delivered)
|
||||
}
|
||||
for _, secret := range delivered {
|
||||
if !runtime.ran("secret accept anchor mesh-control " + secret + " --from") {
|
||||
if !runtime.ran("secret accept anchor mesh-controller " + secret + " --from") {
|
||||
t.Errorf("%s was not accepted through `secret accept`: %v", secret, runtime.commands)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A secret the substrate did not make is left for the mesh to make, and said so. Every other
|
||||
// A secret the foundation did not make is left for the mesh to make, and said so. Every other
|
||||
// secret in a mesh is one the mesh made; `secret accept` is only for what predates the mesh.
|
||||
func TestASecretTheSubstrateNeverMadeIsLeftToTheMesh(t *testing.T) {
|
||||
func TestASecretTheFoundationNeverMadeIsLeftToTheMesh(t *testing.T) {
|
||||
extra := strings.Replace(theControlPlaneModule,
|
||||
`"broker": "/var/lib/mesh/mesh-control/broker",`,
|
||||
`"broker": "/var/lib/mesh/mesh-control/broker",
|
||||
"something-new": "/var/lib/mesh/mesh-control/something-new",`, 1)
|
||||
`"broker": "/var/lib/mesh/mesh-controller/broker",`,
|
||||
`"broker": "/var/lib/mesh/mesh-controller/broker",
|
||||
"something-new": "/var/lib/mesh/mesh-controller/something-new",`, 1)
|
||||
extra = strings.Replace(extra,
|
||||
`"content": "MESH_BROKER_AMQP=${secret:broker}\n`,
|
||||
`"content": "MESH_SOMETHING_NEW=${secret:something-new}\nMESH_BROKER_AMQP=${secret:broker}\n`, 1)
|
||||
@@ -182,7 +182,7 @@ func TestASecretTheSubstrateNeverMadeIsLeftToTheMesh(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime := &asked{answer: aMeshThatAgrees(nil)}
|
||||
control := controlPlane{container: "temp-mesh-control", run: runtime.run, timeout: time.Second}
|
||||
control := controlPlane{container: "temp-mesh-controller", run: runtime.run, timeout: time.Second}
|
||||
|
||||
var said []string
|
||||
delivered, err := deliverStores(context.Background(), Options{Node: "anchor"}, control,
|
||||
@@ -192,7 +192,7 @@ func TestASecretTheSubstrateNeverMadeIsLeftToTheMesh(t *testing.T) {
|
||||
}
|
||||
for _, secret := range delivered {
|
||||
if secret == "something-new" {
|
||||
t.Error("a value the substrate never made was accepted as though it had")
|
||||
t.Error("a value the foundation never made was accepted as though it had")
|
||||
}
|
||||
}
|
||||
if !strings.Contains(strings.Join(said, "\n"), "the mesh will make something-new") {
|
||||
@@ -205,8 +205,8 @@ func TestASecretTheSubstrateNeverMadeIsLeftToTheMesh(t *testing.T) {
|
||||
// be — which presents as a control plane that will not start, three steps from the cause.
|
||||
func TestAConnectionFileNothingWritesIsRefused(t *testing.T) {
|
||||
mismatched := strings.Replace(theControlPlaneModule,
|
||||
`"inventory": "/var/lib/mesh/mesh-control/inventory",`,
|
||||
`"inventory": "/var/lib/mesh/mesh-control/somewhere-else",`, 1)
|
||||
`"inventory": "/var/lib/mesh/mesh-controller/inventory",`,
|
||||
`"inventory": "/var/lib/mesh/mesh-controller/somewhere-else",`, 1)
|
||||
|
||||
_, err := secretsByVariableIn([]byte(mismatched))
|
||||
if err == nil {
|
||||
@@ -226,11 +226,11 @@ func TestAManifestWantingNoStoresIsRefusedWithTheShapeItShouldHave(t *testing.T)
|
||||
t.Fatal(err)
|
||||
}
|
||||
runtime := &asked{answer: aMeshThatAgrees(nil)}
|
||||
control := controlPlane{container: "temp-mesh-control", run: runtime.run, timeout: time.Second}
|
||||
control := controlPlane{container: "temp-mesh-controller", run: runtime.run, timeout: time.Second}
|
||||
|
||||
bare := `{"module":"mesh-control","version":"1","resources":[
|
||||
{"id":"container","type":"container","name":"mesh-control",
|
||||
"image":"mesh-control@` + placeholderDigest + `"}]}`
|
||||
bare := `{"module":"mesh-controller","version":"1","resources":[
|
||||
{"id":"container","type":"container","name":"mesh-controller",
|
||||
"image":"mesh-controller@` + placeholderDigest + `"}]}`
|
||||
|
||||
_, err = deliverStores(context.Background(), Options{Node: "anchor"}, control,
|
||||
[]byte(bare), rewritten.Declaration, func(string) {})
|
||||
@@ -244,13 +244,13 @@ func TestAManifestWantingNoStoresIsRefusedWithTheShapeItShouldHave(t *testing.T)
|
||||
|
||||
// The permanent control plane is asked a question, not merely looked at — the same question the
|
||||
// temporary one was asked at step 5, and for the same reason: `status` opens all three stores, so
|
||||
// a reply proves the sealed connections it was given are the ones the substrate made.
|
||||
// a reply proves the sealed connections it was given are the ones the foundation made.
|
||||
func TestThePermanentControlPlaneIsAskedTheSameQuestion(t *testing.T) {
|
||||
runtime := &asked{answer: aMeshThatAgrees(map[string]string{
|
||||
"module list": "",
|
||||
"exec mesh-control /mesh-control": "1 node, 0 waiting\n",
|
||||
"exec mesh-controller /mesh-controller": "1 node, 0 waiting\n",
|
||||
})}
|
||||
control := controlPlane{container: "temp-mesh-control", run: runtime.run, timeout: time.Second}
|
||||
control := controlPlane{container: "temp-mesh-controller", run: runtime.run, timeout: time.Second}
|
||||
rewritten, err := Rewrite(theRealBundle(t), held)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -265,11 +265,11 @@ func TestThePermanentControlPlaneIsAskedTheSameQuestion(t *testing.T) {
|
||||
if out.Answered != "1 node, 0 waiting" {
|
||||
t.Errorf("the permanent control plane's reply is reported as %q", out.Answered)
|
||||
}
|
||||
if !runtime.ran("docker exec mesh-control " + controlPlaneBinary + " status") {
|
||||
if !runtime.ran("docker exec mesh-controller " + controlPlaneBinary + " status") {
|
||||
t.Errorf("the permanent control plane was never asked anything: %v", runtime.commands)
|
||||
}
|
||||
// And the module was registered with the digest, not with the placeholder.
|
||||
if !runtime.ran("module add /mesh-control-module.json") {
|
||||
if !runtime.ran("module add /mesh-controller-module.json") {
|
||||
t.Errorf("the module was never registered: %v", runtime.commands)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user