A re-run does not replace the registered forge with whatever checkout it was given
Registering a module is an overwrite. Recording the forge's port ran `module add` every time, so a genesis re-run pointed at an older catalogue would replace the manifest of a forge that is built and assigned — with a push a few lines later. Registering is only here so a settings row has a module row to hang on, and that row is already there on a mesh that knows the forge. So: ask first, and skip. Two comments narrowed to what is true. What follows the node's setting is what the mesh derives from a module's ports — its container mapping, its filter rule, its opening and what it serves. The forge's own address in its runtime's environment (hq 088) and its route contribution's port do not, and are already wrong for any port the mesh assigned. And a settings layer is the module's, not one resource's: a second mergeable file on the builder would be given `serves` too. novox/hq 04-ISSUES/085
This commit is contained in:
@@ -24,7 +24,7 @@ const theBuildersBinding = `{
|
||||
"path": "/var/lib/mesh/builder/package-registry.json",
|
||||
"mode": "0600",
|
||||
"merge": "json",
|
||||
"protected": ["provision", "from", "as"],
|
||||
"protected": ["provision", "from", "at", "as"],
|
||||
"content": "{\"provision\": \"package-registry\", \"from\": \"gitea\", \"at\": \"127.0.0.1\", \"as\": \"mesh-builder\", \"serves\": {\"scheme\": \"http\", \"port\": 3000, \"npm-path\": \"/api/packages/novox/npm/\"}}\n"
|
||||
}
|
||||
]
|
||||
@@ -111,6 +111,40 @@ func TestThePackagesPortIsTheForgeModulesSettingOnThisNode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// knowingControl is a control plane that already has the forge in its catalogue, as a mesh that
|
||||
// has been running has.
|
||||
type knowingControl struct{ controlRecorder }
|
||||
|
||||
func (k *knowingControl) run(ctx context.Context, name string, args ...string) (string, error) {
|
||||
out, err := k.controlRecorder.run(ctx, name, args...)
|
||||
if name == "docker" && args[0] == "exec" && len(args) > 4 &&
|
||||
args[3] == "module" && args[4] == "list" {
|
||||
return ForgeModule + " 1 assigned to anchor\n", nil
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
|
||||
func TestARerunDoesNotReplaceAForgeTheMeshAlreadyHas(t *testing.T) {
|
||||
t.Setenv("TMPDIR", t.TempDir())
|
||||
k := &knowingControl{controlRecorder{settings: map[string]string{}}}
|
||||
control := controlPlane{container: "mesh-controller", run: k.run, timeout: time.Second}
|
||||
// An older checkout than the mesh is running, which is what makes an overwrite here damage.
|
||||
o := Options{Node: "anchor", Catalogue: aCatalogueWith(t, ForgeModule, `{"module": "gitea"}`),
|
||||
Ports: FoundationPorts{Packages: 3100}, Wait: time.Second}
|
||||
if err := recordTheForgesPort(context.Background(), o, control, quietly); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Registering is an overwrite, and the manifest of a forge that is built and assigned is not
|
||||
// this installer's to replace with whatever checkout it was pointed at.
|
||||
if k.index("module add") >= 0 {
|
||||
t.Errorf("a re-run replaced the registered forge's manifest: %v", k.told)
|
||||
}
|
||||
// The port is still recorded: a settings row needs the module row, and it is already there.
|
||||
if got := k.settings["gitea-settings.json"]; got != `{"ports":{"3000":3100}}` {
|
||||
t.Errorf("the forge's port was not recorded on a mesh that knows it: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAGenesisOnTheCataloguesPackagesPortRegistersNoForge(t *testing.T) {
|
||||
c, control := recording(t)
|
||||
o := Options{Node: "anchor", Catalogue: aCatalogueWith(t, ForgeModule, theForgesManifest),
|
||||
|
||||
Reference in New Issue
Block a user