diff --git a/cmd/mesh-control/board.go b/cmd/mesh-control/board.go index fc11d2a..49702ac 100644 --- a/cmd/mesh-control/board.go +++ b/cmd/mesh-control/board.go @@ -7,6 +7,8 @@ import ( "fmt" "html/template" "net/http" + "sort" + "strings" "time" ) @@ -94,8 +96,7 @@ func board() http.Handler { http.Error(w, err.Error(), http.StatusServiceUnavailable) return } - body, err := statusAsJSON(asked.wrong, asked.nodes, asked.quiet, asked.behind, asked.sources, - asked.waiting, asked.reported) + body, err := statusAsJSON(asked) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -129,7 +130,21 @@ type view struct { Quiet []quietMachine Behind []staleModule Waiting []waitingMachine - At string + // Unresolved is every machine that cannot be worked out at all. Shown above everything else, + // because a machine here is in none of the other lists: nothing was computed for it, so it is + // not broken, not quiet and not behind — and a page without this said "all well" about a mesh + // where nothing could be sent anywhere. + Unresolved []blockedMachine + // Network is why the private network could not be computed, when it could not. + Network string + At string +} + +type blockedMachine struct { + Node string + // Said is the mesh's own words, a line at a time. Every unmet requirement, not the first: + // a machine is usually blocked by more than one and fixing one of them changes nothing. + Said []string } type waitingMachine struct { @@ -165,7 +180,20 @@ type staleModule struct { } func viewOf(asked answers) view { - out := view{Machines: len(asked.nodes), At: time.Now().Format("15:04:05")} + out := view{Machines: len(asked.nodes), At: time.Now().Format("15:04:05"), + Network: asked.network} + var blocked []string + for name := range asked.refused { + blocked = append(blocked, name) + } + sort.Strings(blocked) + for _, name := range blocked { + one := blockedMachine{Node: name} + for _, line := range strings.Split(strings.TrimRight(asked.refused[name], "\n"), "\n") { + one.Said = append(one.Said, strings.TrimSpace(line)) + } + out.Unresolved = append(out.Unresolved, one) + } for _, d := range asked.wrong { one := brokenMachine{Node: d.Node, Outcome: d.Outcome, When: d.At.Local().Format("2006-01-02 15:04")} @@ -223,6 +251,22 @@ find out.

{{else}}

{{.Machines}} machine{{if ne .Machines 1}}s{{end}}

+{{if .Unresolved}} +

Can everything be worked out?

+ +

Nothing can be sent to a machine here, and it appears in none of the lists below: +nothing was computed for it, so there is nothing it can be behind.

+{{end}} +{{if .Network}} +

The private network could not be computed: {{.Network}}

+{{end}} +

Is anything broken?

{{if .Broken}}