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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user