node-engine: at its first pass after an update, a process taken as running gets its unit written again with MESH_NODE (1984/AC16, AC17; H-A-711, H-A-713, H-A-714)

A module taken as running its want's composition at the start (the agent's TakenAtStart, now the named
takenAtStartIn the node agent hands it) has the unit of each process whose composed unit differs from its
applied record's written again, by one function (apply.ProcessWrote, which the apply builds its record with
too), and the record takes it, so a second pass finds nothing. Nothing is applied: no backup, no other
resource, the have unchanged. A held module, or one whose want names a new fingerprint, is never taken as
running and is not touched. A process whose record names another bundle, or none, is left as it is and said
(H-A-714); a failed units reload is said.

What restarts: services only. Run-once steps and scheduled processes' units are written, not run or started.
Brother's two processes (brother-device, brother-watch; neither run-once nor scheduled) are services: each
restarts once, if brother runs its want's composition.

Builds: design 47 G A-342, H-A-711, H-A-713, H-A-714
This commit is contained in:
2026-11-25 15:34:13 +01:00
parent c312e6a30e
commit 3c2e60dc1f
7 changed files with 253 additions and 9 deletions
+10 -2
View File
@@ -42,8 +42,9 @@ var daemonRoot = "/var/lib/mesh/daemons"
// directory of its own.
var unitDir = "/etc/systemd/system"
func applyProcess(ctx context.Context, r *declaration.Process, run Runner,
func applyProcess(ctx context.Context, declared *declaration.Process, node string, run Runner,
changed map[string]bool, previous store.Applied, held []byte, away *storeAway) (Outcome, error) {
r := withNode(declared, node)
out := begin(r)
out.Action = "unchanged"
@@ -67,7 +68,7 @@ func applyProcess(ctx context.Context, r *declaration.Process, run Runner,
// **Its identity is its bytes AND how it is run.** Two processes from one bundle differing
// only in their command are different, and a record tracking the digest alone would call the
// second one unchanged.
want := got + " " + unitFor(r)
want := ProcessWrote(declared, node)
at := filepath.Join(daemonRoot, r.Name)
// **Something it reads changed, so it must be restarted even though it is unchanged.** A
@@ -293,6 +294,13 @@ func withNode(r *declaration.Process, node string) *declaration.Process {
return &p
}
// ProcessWrote is what the engine's record holds as written for a process on node: its bundle's digest and the unit it
// writes for it, with the node's name in its env (design 47 G A-342). The apply builds its record with it, and the start's
// comparison reads it (H-A-713, one function).
func ProcessWrote(r *declaration.Process, node string) string {
return r.Digest + " " + unitFor(withNode(r, node))
}
// drainStopMargin is the seconds a draining process's stop timeout lies above its drain bound: the time it takes to stop
// its children after its drain (H-A-358).
const drainStopMargin = 15