The controller's last-heard word for a machine comes from the watchman's presence in nodes, node, status and the watchdogs (issue 1183, AC1, AC2)

This commit is contained in:
2026-10-19 02:13:56 +02:00
parent 89cfa9431d
commit 863db82737
6 changed files with 228 additions and 39 deletions
+4 -18
View File
@@ -50,7 +50,7 @@ func nodeCommand(ctx context.Context, args []string) error {
return addNode(ctx, inv, args[1:])
case "list":
nodes, err := inv.Nodes(ctx)
nodes, err := open.heardNodes(ctx)
if err != nil {
return err
}
@@ -755,22 +755,8 @@ func consumerReset(ctx context.Context, args []string) error {
return nil
}
// heardFrom says when a node was last heard from, in a form somebody can act on.
//
// "never" and "an hour ago" are different answers and are kept different. A node that has never
// spoken did not finish joining; a node last heard from an hour ago is running an hour-old
// picture of the mesh.
func heardFrom(n inventory.Node) string {
silent, ever := n.Silent()
switch {
case !ever:
return "never spoken"
case silent > SilentFor:
return "out of touch " + roughly(silent)
default:
return "here"
}
}
// heardFrom is heardFromAt for now.
func heardFrom(n inventory.Node) string { return heardFromAt(n, time.Now()) }
// roughly is a duration a person reads rather than parses.
func roughly(d time.Duration) string {
@@ -795,7 +781,7 @@ func roughly(d time.Duration) string {
// assignment carries `card1-DP-1`, and a person composing settings for that machine needs it.
func showNode(ctx context.Context, stored *stores, name string) error {
inv := stored.inventory
node, err := inv.NodeByName(ctx, name)
node, err := stored.heardNode(ctx, name)
if err != nil {
return err
}