diff --git a/cmd/mesh-controller/away.go b/cmd/mesh-controller/away.go index 85470ca8..fa04575a 100644 --- a/cmd/mesh-controller/away.go +++ b/cmd/mesh-controller/away.go @@ -16,14 +16,15 @@ import ( // A machine out of touch when a tier is sent is not sent to and not waited for (novox/hq ADR 0435 §1, issue 1161): the // delivery goes on with the machines heard, says the others were away, and the away ones get the builds by the send // they are given when heard again (ADR 0353, ADR 0360 §5). Away is the silent check's one verdict, machineFacts.silent -// over the watchman's presence (ADR 0433 §3), never a second rule; a machine that said it is asleep counts as away. +// over the watchman's presence (ADR 0433 §3), never a second rule; a sleeping machine is away once presence says so. -// awayOf is the machines out of touch at a moment: those the silent check calls silent, and those asleep. A machine +// awayOf is the machines out of touch at a moment: those the silent check calls silent (a sleeping machine +// is away once presence says so). A machine // never heard from has not joined and is not away. func awayOf(machines []machineFacts, now time.Time) map[string]bool { out := map[string]bool{} for _, m := range machines { - if m.silent(now) || m.asleep() { + if m.silent(now) { out[m.name] = true } } diff --git a/cmd/mesh-controller/away_test.go b/cmd/mesh-controller/away_test.go index 8ca3a84a..f31e9a48 100644 --- a/cmd/mesh-controller/away_test.go +++ b/cmd/mesh-controller/away_test.go @@ -7,13 +7,12 @@ import ( "time" "github.com/novox/mesh-controller/internal/inventory" - "github.com/novox/mesh-controller/internal/link" ) // A machine out of touch when a tier is sent is not sent to and not waited for (novox/hq ADR 0435 §1, issue 1161): the -// walk judges it with the silent check's one verdict, machineFacts.silent, and a machine asleep counts as away. +// walk judges it with the silent check's one verdict, machineFacts.silent, and a sleeping machine is away once presence says so. -// 1161/AC1: away is the silent check's verdict, and a machine asleep; AC4: a machine heard is not away. +// 1161/AC1: away is the silent check's verdict; AC4: a machine heard is not away. func TestAMachineIsAwayAsTheSilentCheckJudgesIt(t *testing.T) { now := time.Now().UTC() machines := []machineFacts{ @@ -21,11 +20,10 @@ func TestAMachineIsAwayAsTheSilentCheckJudgesIt(t *testing.T) { {name: "quiet", lastHeard: now.Add(-silentBound - time.Minute)}, {name: "stuck", lastHeard: now, presence: presenceSilent}, {name: "back", lastHeard: now.Add(-time.Hour), presence: presenceHeard}, - {name: "asleep", lastHeard: now.Add(-time.Minute), power: link.PowerState{State: "sleeping"}}, {name: "new"}, } got := awayOf(machines, now) - for node, want := range map[string]bool{"heard": false, "quiet": true, "stuck": true, "back": false, "asleep": true, + for node, want := range map[string]bool{"heard": false, "quiet": true, "stuck": true, "back": false, "new": false} { if got[node] != want { t.Errorf("1161/AC1: %s away is %v; want %v (away: %v)", node, got[node], want, got)