H2, H8 (H-A-735): the owner pass at the engine's start stops and starts the module's units; composition-diff keeps the entry's name, the words go to the journal

Builds: design 47 H2 H-A-641, H-A-701, H-A-710 (4), H-A-735
This commit is contained in:
2026-11-25 17:23:16 +01:00
parent 39964d32d8
commit 180d57fe16
7 changed files with 169 additions and 18 deletions
+11 -1
View File
@@ -2128,6 +2128,16 @@ func testTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes(
if _, err := b.ag.CompositionDiff(context.Background(), "db", 0, ""); err == nil {
t.Error("composition-diff with neither a revision nor a digest was answered")
}
var leftSaid []string
wasLine := journalLine
journalLine = func(l string) { leftSaid = append(leftSaid, l) }
defer func() { journalLine = wasLine }()
fingerprintLeftSaid.Clear()
defer func() {
if len(leftSaid) != 1 || !strings.Contains(leftSaid[0], "web.box") || !strings.Contains(leftSaid[0], "left from before H2, taken out at the container's next recreate") {
t.Errorf("the container's difference was said as %q, want one journal line", leftSaid)
}
}()
if got := DiffResources([]json.RawMessage{json.RawMessage(`{"id":"web.key","type":"file","sealed":"a","content":"x"}`),
json.RawMessage(`{"id":"web.run","type":"process","env":{"MODE":"a","GONE":"1"}}`),
json.RawMessage(`{"id":"web.box","type":"container","env":{"MESH_FINGERPRINT":"src2:a"}}`),
@@ -2138,7 +2148,7 @@ func testTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes(
json.RawMessage(`{"id":"web.d","type":"process","env":{"MESH_FINGERPRINT":"src2:b"}}`)}); len(got) != 4 ||
!slices.Equal(got[2].Entries, []nodeengine.CompositionDiffEntry{{Name: "content", Masked: true}, {Name: "sealed", Masked: true}}) ||
// H-A-710 (4): a container's difference of MESH_FINGERPRINT is left from before H2; a daemon's is an ordinary entry.
!slices.Equal(got[0].Entries, []nodeengine.CompositionDiffEntry{{Name: "env.MESH_FINGERPRINT (left from before H2, taken out at the container's next recreate)", Running: "src2:a"}}) ||
!slices.Equal(got[0].Entries, []nodeengine.CompositionDiffEntry{{Name: "env.MESH_FINGERPRINT", Running: "src2:a"}}) ||
!slices.Equal(got[1].Entries, []nodeengine.CompositionDiffEntry{{Name: "env.MESH_FINGERPRINT", Running: "src2:a", Other: "src2:b"}}) ||
!slices.Equal(got[3].Entries, []nodeengine.CompositionDiffEntry{{Name: "env.GONE", Running: "1"}, {Name: "env.MODE", Running: "a", Other: "b"}}) {
t.Errorf("the entries that differ, a secret masked, read %+v", got)
+11 -1
View File
@@ -6,7 +6,9 @@ import (
"errors"
"fmt"
"maps"
"os"
"slices"
"sync"
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
@@ -409,6 +411,11 @@ func (a *Agent) CompositionDiff(ctx context.Context, module string, revision int
// fingerprintLeft says what a container's difference of its env MESH_FINGERPRINT is (design 47 H2, H-A-710 (4)).
const fingerprintLeft = "left from before H2, taken out at the container's next recreate"
// fingerprintLeftSaid is each container whose difference was said, once per node-engine process; journalLine says a line
// in the node-engine's journal (its standard error), a variable so a test reads it.
var fingerprintLeftSaid sync.Map
var journalLine = func(line string) { fmt.Fprintf(os.Stderr, "mesh-host: %s\n", line) }
// DiffResources is, per resource by its id, the entries that differ from running to other (design 47 H2 §813 (3)): each
// top-level field by its name, the environment's entries each by `env.<name>`, and a value the declaration keeps secret
// (a file's sealed, vault-sealed or secrets, and the content of a file that has any of them) masked. Resources in id
@@ -442,7 +449,10 @@ func DiffResources(running, other []json.RawMessage) []nodeengine.CompositionDif
e := nodeengine.CompositionDiffEntry{Name: name}
if name == "env."+engcomp.FingerprintVar && (w.values["type"] == string(declaration.TypeContainer) || n.values["type"] == string(declaration.TypeContainer)) {
// A container is handed none since H2 (H-A-710 (4)): what a composition from before holds is no change to make.
e.Name = name + " (" + fingerprintLeft + ")"
// The entry keeps its name; the words are the verb's description and one journal line per container and process.
if _, said := fingerprintLeftSaid.LoadOrStore(id, true); !said {
journalLine(fmt.Sprintf("%s: %s: %s", id, name, fingerprintLeft))
}
}
if w.secret[name] || n.secret[name] {
e.Masked = true