Keep what an adopted node reports holding, the firewall it found and what is reachable on it (hq ADR 0100)
This commit is contained in:
@@ -199,6 +199,27 @@ func (e Enrolment) Heard(ctx context.Context, report Report) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// What an adopted node holds, which firewall it found, and what is reachable on it (novox/hq
|
||||
// ADR 0100). Recorded whenever a report carries any of it — a node reports these on its own
|
||||
// schedule, when what it holds changes, not only after an apply — and never cleared by a
|
||||
// report that carries none, which is every bare word that the node is there. An adopted node
|
||||
// always names its firewall, so a report from one replaces all three, emptied held included.
|
||||
if len(report.Held) > 0 || report.Firewall != "" || len(report.Reachable) > 0 {
|
||||
held := make([]inventory.Held, 0, len(report.Held))
|
||||
for _, h := range report.Held {
|
||||
held = append(held, inventory.Held{ID: h.ID, Module: h.Module, Kind: h.Kind,
|
||||
Target: h.Target, Since: h.Since, Changed: h.Changed, Kept: h.Kept})
|
||||
}
|
||||
reachable := make([]inventory.Reach, 0, len(report.Reachable))
|
||||
for _, r := range report.Reachable {
|
||||
reachable = append(reachable, inventory.Reach{Protocol: r.Protocol, Address: r.Address,
|
||||
Port: r.Port, By: r.By, Published: r.Published, ContainerPort: r.ContainerPort})
|
||||
}
|
||||
if err := e.Inventory.RecordAdoption(ctx, node.ID, held, report.Firewall, reachable); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// A bare word that a node is there is not an account of what the machine did or holds: it
|
||||
// moves last_seen and touches nothing else. This arrives every minute (link.AliveEvery),
|
||||
// while a real report is rare, so recording it as one would overwrite the node's last real
|
||||
|
||||
Reference in New Issue
Block a user