Status says when each machine last reported, beside when it was sent
"Not waiting" says the declaration is current, not that the machine finished applying it: the sent digest is recorded at send. So a test that pushed, saw waiting clear, and asked the machine what it was running found containers that did not exist yet — the certificate fix made compositions stable, and the settling that used to fail first had been hiding the gap behind it. The mesh already held the missing half: every machine's last report, with its time. It just was not in the JSON. `reported` now sets each machine's last word beside when the current declaration went to it, and "has it caught up" becomes a comparison of two timestamps the mesh recorded itself — a report newer than the send means the machine acted on what was sent; older means it is still working, which waiting alone cannot distinguish.
This commit is contained in:
@@ -35,6 +35,11 @@ type meshStatus struct {
|
||||
// Behind one level down: that says the catalogue is old, this says a machine is — and only
|
||||
// this one has somebody's change waiting inside it.
|
||||
Waiting []machineWaiting `json:"waiting"`
|
||||
// Reported is every machine's last word beside when it was last sent a declaration. A
|
||||
// machine whose report is newer than its send has acted on the current declaration; one
|
||||
// whose is older is still working — and Waiting cannot tell those apart, because the sent
|
||||
// digest is recorded at send, not at apply.
|
||||
Reported []machineReported `json:"reported"`
|
||||
// Machines is how many the mesh knows about, so a reader can tell "none wrong" from
|
||||
// "none at all".
|
||||
Machines int `json:"machines"`
|
||||
@@ -54,6 +59,13 @@ type machineDoing struct {
|
||||
At time.Time `json:"at"`
|
||||
}
|
||||
|
||||
type machineReported struct {
|
||||
Node string `json:"node"`
|
||||
Outcome string `json:"outcome"`
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
Sent *time.Time `json:"sent,omitempty"`
|
||||
}
|
||||
|
||||
type machineWaiting struct {
|
||||
Node string `json:"node"`
|
||||
// Never is true when nothing has ever been sent to it. Not out of date: nobody has ever asked
|
||||
@@ -79,10 +91,15 @@ type moduleBehind struct {
|
||||
// statusAsJSON answers the same three questions as the text form, from the same calls.
|
||||
func statusAsJSON(wrong []inventory.Doing, nodes []inventory.Node, quiet []inventory.Node,
|
||||
behind map[string][]string, sources map[string]inventory.Source,
|
||||
waiting []inventory.Machine) ([]byte, error) {
|
||||
waiting []inventory.Machine, reported []inventory.Reported) ([]byte, error) {
|
||||
|
||||
out := meshStatus{Machines: len(nodes), Wrong: []machineDoing{},
|
||||
Quiet: []machineQuiet{}, Behind: []moduleBehind{}, Waiting: []machineWaiting{}}
|
||||
Quiet: []machineQuiet{}, Behind: []moduleBehind{}, Waiting: []machineWaiting{},
|
||||
Reported: []machineReported{}}
|
||||
for _, r := range reported {
|
||||
out.Reported = append(out.Reported, machineReported{
|
||||
Node: r.Node, Outcome: r.Outcome, At: r.At, Sent: r.Sent})
|
||||
}
|
||||
|
||||
for _, m := range waiting {
|
||||
out.Waiting = append(out.Waiting, machineWaiting{
|
||||
|
||||
Reference in New Issue
Block a user