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:
@@ -276,6 +276,49 @@ func awaitBackup(ctx context.Context, events <-chan []byte, node, module string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// takenAtStartIn is what the agent does with a module taken as running at this start, with no apply: each record-held
|
||||||
|
// directory entry of it given its owner and mode where they drifted on disk (H-A-374, H-A-392), and the unit of each of
|
||||||
|
// its processes written again where it lacks its node's name (H-A-713), one line each.
|
||||||
|
func takenAtStartIn(opts options, say func(string)) func(module string, runs compositions.Composed) {
|
||||||
|
return func(module string, runs compositions.Composed) {
|
||||||
|
for _, line := range convergeDirectories(opts.state, runs) {
|
||||||
|
say(line)
|
||||||
|
}
|
||||||
|
for _, line := range convergeUnits(context.Background(), opts, runs) {
|
||||||
|
say(line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// convergeUnits writes again the unit of each process of a module taken as running at this start whose unit as composed
|
||||||
|
// differs from its applied record's, and restarts a service of them (apply.ConvergeProcessUnits, H-A-713): the module's
|
||||||
|
// have is unchanged and nothing else of it is written, backed up or run. One line per process, and one when the
|
||||||
|
// composition or the state does not read.
|
||||||
|
func convergeUnits(ctx context.Context, opts options, runs compositions.Composed) []string {
|
||||||
|
d, err := declarationOf(runs)
|
||||||
|
if err != nil {
|
||||||
|
return []string{fmt.Sprintf("the units of %s are not judged at this start: its composition does not read: %v", runs.Module, err)}
|
||||||
|
}
|
||||||
|
applying.Lock()
|
||||||
|
defer applying.Unlock()
|
||||||
|
unlock, err := store.Lock(opts.state, nil)
|
||||||
|
if err != nil {
|
||||||
|
return []string{fmt.Sprintf("the units of %s are not judged at this start: %v", runs.Module, err)}
|
||||||
|
}
|
||||||
|
defer unlock()
|
||||||
|
known, err := store.Load(opts.state)
|
||||||
|
if err != nil {
|
||||||
|
return []string{fmt.Sprintf("the units of %s are not judged at this start: %v", runs.Module, err)}
|
||||||
|
}
|
||||||
|
now, lines := apply.ConvergeProcessUnits(ctx, d, known, opts.run())
|
||||||
|
if len(lines) > 0 {
|
||||||
|
if err := store.Save(opts.state, now); err != nil {
|
||||||
|
lines = append(lines, fmt.Sprintf("the record of the units of %s could not be saved: %v", runs.Module, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
// convergeDirectories gives each directory entry of runs that this node's record holds, drifted on disk, its declared
|
// convergeDirectories gives each directory entry of runs that this node's record holds, drifted on disk, its declared
|
||||||
// owner and mode (apply.ConvergeDirectories, H-A-374, H-A-392): one line per directory, and one when the record or the
|
// owner and mode (apply.ConvergeDirectories, H-A-374, H-A-392): one line per directory, and one when the record or the
|
||||||
// composition does not read.
|
// composition does not read.
|
||||||
@@ -586,11 +629,7 @@ func nodeAgent(ctx context.Context, opts options, signer ed25519.PublicKey, trus
|
|||||||
// again (ace, 2026-10-25 21:17).
|
// again (ace, 2026-10-25 21:17).
|
||||||
// A module taken as running at this start has each record-held directory entry of it given its owner and mode
|
// A module taken as running at this start has each record-held directory entry of it given its owner and mode
|
||||||
// where they drifted on disk, one line each (H-A-374, H-A-392).
|
// where they drifted on disk, one line each (H-A-374, H-A-392).
|
||||||
TakenAtStart: func(module string, runs compositions.Composed) {
|
TakenAtStart: takenAtStartIn(opts, say),
|
||||||
for _, line := range convergeDirectories(opts.state, runs) {
|
|
||||||
say(line)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DirectoryDrift: func(runs compositions.Composed) []nodeengine.CompositionAnswerDriftItem {
|
DirectoryDrift: func(runs compositions.Composed) []nodeengine.CompositionAnswerDriftItem {
|
||||||
d, err := declarationOf(runs)
|
d, err := declarationOf(runs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/declaration"
|
||||||
|
"github.com/novox/mesh-host/internal/apply"
|
||||||
engcomp "github.com/novox/mesh-host/internal/compositions"
|
engcomp "github.com/novox/mesh-host/internal/compositions"
|
||||||
|
"github.com/novox/mesh-host/internal/system"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/novox/mesh-host/internal/liveness"
|
"github.com/novox/mesh-host/internal/liveness"
|
||||||
@@ -33,6 +44,110 @@ func testACompositionIsRecordedOnlyWhenEveryResourceIs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1984/AC16 (H-A-713): a module taken as running at the start, whose processes a real apply recorded with units written
|
||||||
|
// without MESH_NODE, has those units written again with it: the service restarted, the run-once step written and not run,
|
||||||
|
// no other command (no backup is the agent's, never reached here), and nothing at the second pass. The record the
|
||||||
|
// comparison reads comes from a real apply (apply.Apply with no node, as the engine before the fix).
|
||||||
|
func testProcessUnitsWithoutTheNodesNameAreWrittenAgainAtTheStart(t *testing.T) {
|
||||||
|
var raw bytes.Buffer
|
||||||
|
zipped := gzip.NewWriter(&raw)
|
||||||
|
w := tar.NewWriter(zipped)
|
||||||
|
_ = w.WriteHeader(&tar.Header{Name: "main.js", Mode: 0o644, Size: 1, Typeflag: tar.TypeReg})
|
||||||
|
_, _ = w.Write([]byte("1"))
|
||||||
|
_ = w.Close()
|
||||||
|
_ = zipped.Close()
|
||||||
|
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { _, _ = rw.Write(raw.Bytes()) }))
|
||||||
|
t.Cleanup(server.Close)
|
||||||
|
one := func(id, name, extra string) json.RawMessage {
|
||||||
|
return json.RawMessage(`{"id":"` + id + `","type":"process","name":"` + name + `","source":"` + server.URL + `/a.tgz","digest":"` +
|
||||||
|
declaration.DigestOf(raw.Bytes()) + `","run":["node","main.js"],"env":{"A":"1"}` + extra + `}`)
|
||||||
|
}
|
||||||
|
service, step := one("m.service", "m-service", ""), one("m.step", "m-step", `,"run-once":true`)
|
||||||
|
units := t.TempDir()
|
||||||
|
t.Cleanup(apply.ForTests(units, t.TempDir()))
|
||||||
|
var commands []string
|
||||||
|
run := func(_ context.Context, name string, args ...string) (string, error) {
|
||||||
|
commands = append(commands, name+" "+strings.Join(args, " "))
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
sys, err := system.For("arch")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
d, err := declaration.Parse([]byte(`{"declaration":1,"resources":[` + string(service) + `,` + string(step) + `]}`))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
_, applied, err := apply.Apply(context.Background(), sys, d, store.State{}, store.OriginDeclared, run, nil, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
state := filepath.Join(t.TempDir(), "state.json")
|
||||||
|
if err := store.Save(state, applied); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if b, _ := os.ReadFile(filepath.Join(units, "m-service.service")); strings.Contains(string(b), "MESH_NODE") {
|
||||||
|
t.Fatalf("the first apply, with no node, wrote the name:\n%s", b)
|
||||||
|
}
|
||||||
|
commands = nil
|
||||||
|
opts := options{state: state, out: &strings.Builder{}, runner: run}
|
||||||
|
c := engcomp.Composed{Node: "ace", Module: "m", Resources: []json.RawMessage{service, step}}
|
||||||
|
var said []string
|
||||||
|
takenAt := takenAtStartIn(opts, func(l string) { said = append(said, l) })
|
||||||
|
takenAt(c.Module, c)
|
||||||
|
if len(said) != 2 {
|
||||||
|
t.Fatalf("the first pass said %v; want one line per process", said)
|
||||||
|
}
|
||||||
|
for _, name := range []string{"m-service", "m-step"} {
|
||||||
|
if b, _ := os.ReadFile(filepath.Join(units, name+".service")); !strings.Contains(string(b), `Environment="MESH_NODE=ace"`) {
|
||||||
|
t.Errorf("%s was not written again with the node's name:\n%s", name, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if got := strings.Join(commands, "\n"); !strings.Contains(got, "systemctl restart m-service.service") ||
|
||||||
|
strings.Contains(got, "m-step") || strings.Contains(got, "pacman") {
|
||||||
|
t.Errorf("the first pass ran:\n%s; want the service restarted, the step not run, nothing else", got)
|
||||||
|
}
|
||||||
|
commands = nil
|
||||||
|
said = nil
|
||||||
|
takenAt(c.Module, c)
|
||||||
|
if len(said) != 0 || len(commands) != 0 {
|
||||||
|
t.Errorf("the second pass said %v and ran %v; want nothing", said, commands)
|
||||||
|
}
|
||||||
|
// 1984/AC16 (H-A-714): a process whose record names another bundle is left as it is, with a line naming both; and a
|
||||||
|
// units reload that fails is said, not skipped.
|
||||||
|
other := one("m.other", "m-other", `,"env":{"B":"2"}`)
|
||||||
|
var st store.State
|
||||||
|
st.Record(store.Applied{ID: "m.other", Type: "process", Target: "m-other", Wrote: "sha256:" + strings.Repeat("1", 64) + " unit"})
|
||||||
|
st.Record(store.Applied{ID: "m.service", Type: "process", Target: "m-service", Wrote: apply.ProcessWrote(mustProcess(t, service), "")})
|
||||||
|
if err := store.Save(state, st); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
say2 := []string{}
|
||||||
|
commands = nil
|
||||||
|
opts.runner = func(_ context.Context, name string, args ...string) (string, error) {
|
||||||
|
commands = append(commands, name+" "+strings.Join(args, " "))
|
||||||
|
return "", errors.New("no bus to the manager")
|
||||||
|
}
|
||||||
|
takenAtStartIn(opts, func(l string) { say2 = append(say2, l) })("m", engcomp.Composed{Node: "ace", Module: "m", Resources: []json.RawMessage{other, service}})
|
||||||
|
joined := strings.Join(say2, "\n")
|
||||||
|
if !strings.Contains(joined, "m-other") || !strings.Contains(joined, "sha256:"+strings.Repeat("1", 64)) || !strings.Contains(joined, declaration.DigestOf(raw.Bytes())) ||
|
||||||
|
!strings.Contains(joined, "units could not be reloaded") || !strings.Contains(joined, "m-service") {
|
||||||
|
t.Errorf("the lines were:\n%s", joined)
|
||||||
|
}
|
||||||
|
if b, _ := os.ReadFile(filepath.Join(units, "m-other.service")); strings.Contains(string(b), "MESH_NODE") {
|
||||||
|
t.Error("a process whose record names another bundle was written")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func mustProcess(t *testing.T, raw json.RawMessage) *declaration.Process {
|
||||||
|
t.Helper()
|
||||||
|
r, err := declaration.ParseResource(raw)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return r.(*declaration.Process)
|
||||||
|
}
|
||||||
|
|
||||||
// The modules applied again are those with a missing resource, each once; one down but there is not among them.
|
// The modules applied again are those with a missing resource, each once; one down but there is not among them.
|
||||||
func testTheModulesAppliedAgainAreThoseWithAMissingResource(t *testing.T) {
|
func testTheModulesAppliedAgainAreThoseWithAMissingResource(t *testing.T) {
|
||||||
t.Run("1957: the machine shows a resource not active", testTheMachineShowsAResourceNotActive)
|
t.Run("1957: the machine shows a resource not active", testTheMachineShowsAResourceNotActive)
|
||||||
@@ -97,6 +212,7 @@ func testAFilledFileDoesNotMakeItsCompositionUnrecorded(t *testing.T) {
|
|||||||
// TestRecorded runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
|
// TestRecorded runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
|
||||||
func TestRecorded(t *testing.T) {
|
func TestRecorded(t *testing.T) {
|
||||||
t.Run("ACompositionIsRecordedOnlyWhenEveryResourceIs", testACompositionIsRecordedOnlyWhenEveryResourceIs)
|
t.Run("ACompositionIsRecordedOnlyWhenEveryResourceIs", testACompositionIsRecordedOnlyWhenEveryResourceIs)
|
||||||
|
t.Run("ProcessUnitsWithoutTheNodesNameAreWrittenAgainAtTheStart", testProcessUnitsWithoutTheNodesNameAreWrittenAgainAtTheStart)
|
||||||
t.Run("TheModulesAppliedAgainAreThoseWithAMissingResource", testTheModulesAppliedAgainAreThoseWithAMissingResource)
|
t.Run("TheModulesAppliedAgainAreThoseWithAMissingResource", testTheModulesAppliedAgainAreThoseWithAMissingResource)
|
||||||
t.Run("OnlyANewlyMissingResourceAppliesItsModuleAgain", testOnlyANewlyMissingResourceAppliesItsModuleAgain)
|
t.Run("OnlyANewlyMissingResourceAppliesItsModuleAgain", testOnlyANewlyMissingResourceAppliesItsModuleAgain)
|
||||||
t.Run("AFilledFileDoesNotMakeItsCompositionUnrecorded", testAFilledFileDoesNotMakeItsCompositionUnrecorded)
|
t.Run("AFilledFileDoesNotMakeItsCompositionUnrecorded", testAFilledFileDoesNotMakeItsCompositionUnrecorded)
|
||||||
|
|||||||
@@ -195,7 +195,8 @@ type Env struct {
|
|||||||
Settled func(module string)
|
Settled func(module string)
|
||||||
// TakenAtStart is told, outside the agent's lock, each module taken as running at this start from its have or the
|
// TakenAtStart is told, outside the agent's lock, each module taken as running at this start from its have or the
|
||||||
// kept declaration, with no apply, and the composition it runs: the node-engine converges the owner and mode of each
|
// kept declaration, with no apply, and the composition it runs: the node-engine converges the owner and mode of each
|
||||||
// record-held directory entry of it (H-A-374, H-A-392). Nil tells nothing.
|
// record-held directory entry of it (H-A-374, H-A-392) and writes again the unit of each process of it whose unit
|
||||||
|
// lacks its node's name, restarting a service (H-A-713). Nil tells nothing.
|
||||||
TakenAtStart func(module string, runs compositions.Composed)
|
TakenAtStart func(module string, runs compositions.Composed)
|
||||||
// DirectoryDrift reads, for the verb composition's diff, each directory entry of runs the mesh made whose owner or
|
// DirectoryDrift reads, for the verb composition's diff, each directory entry of runs the mesh made whose owner or
|
||||||
// mode on disk differ (apply.DirectoryDrifts, H-A-392). Nil reads none.
|
// mode on disk differ (apply.DirectoryDrifts, H-A-392). Nil reads none.
|
||||||
|
|||||||
@@ -1083,6 +1083,13 @@ func testADataModuleIsBackedUpFirstAndHeldWhenItFails(t *testing.T) {
|
|||||||
if got := r.appliedList(); len(got) != 0 {
|
if got := r.appliedList(); len(got) != 0 {
|
||||||
t.Fatalf("applied behind a hold with no answer: %v", got)
|
t.Fatalf("applied behind a hold with no answer: %v", got)
|
||||||
}
|
}
|
||||||
|
// 1984/AC17 (H-A-713): a held module is not taken as running at the start, so nothing of it is written again.
|
||||||
|
r.mu.Lock()
|
||||||
|
taken := len(r.takenAtStart)
|
||||||
|
r.mu.Unlock()
|
||||||
|
if taken != 0 {
|
||||||
|
t.Fatalf("a held module was told as taken at the start: %v", r.takenAtStart)
|
||||||
|
}
|
||||||
r.wants.put(wk, selfWant(row.later))
|
r.wants.put(wk, selfWant(row.later))
|
||||||
eventually(t, "the read tool does not say the answer", func() bool {
|
eventually(t, "the read tool does not say the answer", func() bool {
|
||||||
v, err := r.ag.Composition(context.Background(), "nats", "", false)
|
v, err := r.ag.Composition(context.Background(), "nats", "", false)
|
||||||
|
|||||||
@@ -1629,7 +1629,7 @@ func applyOne(ctx context.Context, sys system.System, r declaration.Resource, ru
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return begin(r), err
|
return begin(r), err
|
||||||
}
|
}
|
||||||
return applyProcess(ctx, withNode(res, in.node), run, changed, previous, held, in.away)
|
return applyProcess(ctx, res, in.node, run, changed, previous, held, in.away)
|
||||||
case *declaration.Action:
|
case *declaration.Action:
|
||||||
return applyAction(ctx, res, run)
|
return applyAction(ctx, res, run)
|
||||||
case *declaration.Network:
|
case *declaration.Network:
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package apply
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/declaration"
|
||||||
|
"github.com/novox/mesh-host/internal/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConvergeProcessUnits writes again the unit of each process of d whose unit as composed (ProcessWrote, with d's node)
|
||||||
|
// differs from the one its applied record says it wrote, for a module taken as running its want's composition at the
|
||||||
|
// engine's start (design 47 G A-342, H-A-713): the process then has the node's name in its env. A service is restarted; a
|
||||||
|
// run-once step's and a scheduled process's unit are written and neither run nor started, and take the name at their next
|
||||||
|
// run. Nothing else is written or run (no backup, no other resource), and the record takes the new unit, so a second pass
|
||||||
|
// finds nothing. A process with no record, or whose record holds another bundle than the composition's, is not touched: the
|
||||||
|
// apply of its new form gives it the name. It answers the changed record state and one line per process.
|
||||||
|
func ConvergeProcessUnits(ctx context.Context, d *declaration.Declaration, known store.State, run Runner) (store.State, []string) {
|
||||||
|
var lines []string
|
||||||
|
if d == nil {
|
||||||
|
return known, nil
|
||||||
|
}
|
||||||
|
for _, res := range d.Resources {
|
||||||
|
r, ok := res.(*declaration.Process)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
rec, held := known.Find(r.Identity())
|
||||||
|
if !held || rec.Type != string(declaration.TypeProcess) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
have, same := strings.CutPrefix(rec.Wrote, r.Digest+" ")
|
||||||
|
want := ProcessWrote(r, d.For)
|
||||||
|
if !same {
|
||||||
|
// Another bundle than the composition's (or none) is what the record holds: the apply of the new form gives the
|
||||||
|
// name (H-A-714). Said, so that the process left as it is can be read from the journal.
|
||||||
|
named, _, _ := strings.Cut(rec.Wrote, " ")
|
||||||
|
if named == "" {
|
||||||
|
named = "none"
|
||||||
|
}
|
||||||
|
lines = append(lines, fmt.Sprintf("%s (%s) is left as it is at this start: its record names the bundle %s and the composition names %s",
|
||||||
|
r.Name, r.ID, named, r.Digest))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if have == strings.TrimPrefix(want, r.Digest+" ") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
unit := filepath.Join(unitDir, r.Name+".service")
|
||||||
|
if err := os.WriteFile(unit, []byte(unitFor(withNode(r, d.For))), 0o644); err != nil {
|
||||||
|
lines = append(lines, fmt.Sprintf("%s (%s) cannot be given its node's name at this start: %v", r.Name, r.ID, err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err := run(ctx, "systemctl", "daemon-reload"); err != nil {
|
||||||
|
lines = append(lines, fmt.Sprintf("%s (%s) was written with its node's name and the units could not be reloaded: %v", r.Name, r.ID, err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
verb := "written again with its node's name at this start"
|
||||||
|
if !r.RunOnce && r.Schedule == "" {
|
||||||
|
if _, err := run(ctx, "systemctl", "restart", r.Name+".service"); err != nil {
|
||||||
|
lines = append(lines, fmt.Sprintf("%s (%s) was written with its node's name and would not restart: %v", r.Name, r.ID, err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
verb = "written again with its node's name and restarted at this start"
|
||||||
|
}
|
||||||
|
rec.Wrote = want
|
||||||
|
known.Record(rec)
|
||||||
|
lines = append(lines, fmt.Sprintf("%s (%s) %s", r.Name, r.ID, verb))
|
||||||
|
}
|
||||||
|
return known, lines
|
||||||
|
}
|
||||||
@@ -42,8 +42,9 @@ var daemonRoot = "/var/lib/mesh/daemons"
|
|||||||
// directory of its own.
|
// directory of its own.
|
||||||
var unitDir = "/etc/systemd/system"
|
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) {
|
changed map[string]bool, previous store.Applied, held []byte, away *storeAway) (Outcome, error) {
|
||||||
|
r := withNode(declared, node)
|
||||||
out := begin(r)
|
out := begin(r)
|
||||||
out.Action = "unchanged"
|
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
|
// **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
|
// only in their command are different, and a record tracking the digest alone would call the
|
||||||
// second one unchanged.
|
// second one unchanged.
|
||||||
want := got + " " + unitFor(r)
|
want := ProcessWrote(declared, node)
|
||||||
at := filepath.Join(daemonRoot, r.Name)
|
at := filepath.Join(daemonRoot, r.Name)
|
||||||
|
|
||||||
// **Something it reads changed, so it must be restarted even though it is unchanged.** A
|
// **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
|
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
|
// 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).
|
// its children after its drain (H-A-358).
|
||||||
const drainStopMargin = 15
|
const drainStopMargin = 15
|
||||||
|
|||||||
Reference in New Issue
Block a user