From 7523b1c635280e0624d70c283d94c224740f2186 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sun, 15 Nov 2026 23:23:57 -0700 Subject: [PATCH 1/2] Clusters page by kind; each cluster summed up in its own terms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Clusters page was one long scroll mixing Kubernetes, FlashArrays, IBM i partitions, an HMC, vCenter, Nutanix, Proxmox and Vault (#41). Now it has sections: Kubernetes, Virtualization, Storage, IBM i and Secrets, the ones that need a look first in each, a jump list with each kind's count and problems, and filters (kind, need a look, name) kept in the address: /clusters?group=Storage&show=problems&q=prod. An HMC's VMs are its partitions. obs-beacond gives every cluster its group and a summary in its kind's terms. The dashboard's Clusters panel and the network map's cluster boxes use it, so an IBM i partition reads "CPU 41% · system ASP 85% · 4 of 5 subsystems active", not "0/0 nodes ready, 0 workloads" (#46), and an array says its volumes and space used. The service map's box for a cluster's services says what the cluster is ("vCenter", "HMC", "Proxmox cluster", "OpenShift cluster"), not "Kubernetes cluster" for all of them (#37). Closes #41, closes #46, closes #37. --- internal/server/mapviews.go | 10 +++- internal/server/workloads.go | 90 +++++++++++++++++++++++++++- internal/server/workloads_test.go | 46 ++++++++++++++ web/src/lib/api.ts | 2 + web/src/routes/+page.svelte | 7 +-- web/src/routes/clusters/+page.svelte | 75 ++++++++++++++++++++++- 6 files changed, 219 insertions(+), 11 deletions(-) diff --git a/internal/server/mapviews.go b/internal/server/mapviews.go index 402a817..a52c155 100644 --- a/internal/server/mapviews.go +++ b/internal/server/mapviews.go @@ -289,7 +289,7 @@ func (srv *Server) networkView(focus string, now time.Time) (*MapView, bool) { _, conds := srv.view(now) for _, c := range srv.clusterViews(now, conds) { v.Boxes = append(v.Boxes, MapBox{ID: "cluster:" + c.Name, Kind: "cluster", Name: c.Name, Status: c.Status, - Sub: fmt.Sprintf("%d/%d nodes ready", c.NodesReady, c.Nodes), Count: c.Nodes}) + Sub: c.Summary, Count: c.Nodes}) } case "site", "group": @@ -688,14 +688,18 @@ func (srv *Server) servicesView(focus string, steps int, now time.Time) (*MapVie where[s.ID] = gid layer[gid] = min(layer[gid], s.Layer) } + kinds := map[string]string{} // a source's name → what it is, for its box (#37) + for _, s := range srv.workloadSnapshot() { + kinds[s.name] = s.kindLabel() + } for _, gid := range order { b := fold(gid, "group", names[gid], members[gid], status) for i, m := range b.Problems { b.Problems[i] = svc[m].Name } b.Layer = layer[gid] - if strings.HasPrefix(gid, "group:cluster:") { - b.Sub = "Kubernetes cluster" + if c, ok := strings.CutPrefix(gid, "group:cluster:"); ok { + b.Sub = cmp.Or(kinds[c], "Kubernetes cluster") } v.Boxes = append(v.Boxes, b) } diff --git a/internal/server/workloads.go b/internal/server/workloads.go index 14bd5b3..0a4ed50 100644 --- a/internal/server/workloads.go +++ b/internal/server/workloads.go @@ -552,6 +552,87 @@ func (s wsnap) noun() string { return "Cluster" } +// group is the Clusters page's section for the source (#41). +func (s wsnap) group() string { + switch d := s.distribution(); { + case strings.HasPrefix(d, "Vault"), d == "OpenBao": + return "Secrets" + case strings.HasPrefix(d, "Purity"): + return "Storage" + case d == ibmiDistribution, d == hmcDistribution: + return "IBM i" + case d == "vCenter", d == "Prism Central", strings.HasPrefix(d, "Proxmox"): + return "Virtualization" + } + return "Kubernetes" +} + +// kindLabel is what the source is, said on its own: "Kubernetes +// cluster", "Proxmox cluster", "vCenter", "HMC", "IBM i partition". +func (s wsnap) kindLabel() string { + d := s.distribution() + switch n := s.noun(); { + case n == "Partition": + return "IBM i partition" + case n == "Array": + return "Pure array" + case n != "Cluster": + return n // vCenter, Prism Central, HMC, Vault, OpenBao + case strings.HasPrefix(d, "Proxmox"): + return "Proxmox cluster" + case d == "OpenShift", d == "OKD": + return d + " cluster" + } + return "Kubernetes cluster" +} + +// summary is a cluster's state in a line, in the terms of its kind (#46). +func (v *ClusterView) summary() string { + count := func(n int) string { return humanCount(n) } + if p := v.Partition; p != nil { + var out []string + cpu := p.CPUPct + if v.Usage != nil && v.Usage.CPUOf > 0 { + cpu = &v.Usage.CPUPct // the last minute's, as the page shows + } + if cpu != nil { + out = append(out, fmt.Sprintf("CPU %.0f%%", *cpu)) + } + out = append(out, fmt.Sprintf("system ASP %.0f%%", p.SystemASPPct)) + if p.Subsystems > 0 { + out = append(out, fmt.Sprintf("%d of %d subsystems active", p.SubsystemsActive, p.Subsystems)) + } + return strings.Join(out, " · ") + } + nodes := strings.ToLower(cmp.Or(v.NodeNoun, "Node")) + "s" + out := []string{fmt.Sprintf("%d/%d %s ready", v.NodesReady, v.Nodes, nodes)} + switch v.Noun { + case "Array": + out = append(out, count(v.Workloads)+" volumes") + if v.Usage != nil && v.Usage.IO != nil && v.Usage.IO.UsedOf > 0 { + out = append(out, fmt.Sprintf("%.0f%% used", 100*float64(v.Usage.IO.Used)/float64(v.Usage.IO.UsedOf))) + } + case "HMC": + out = append(out, count(v.Workloads)+" partitions") + case "Vault", "OpenBao": + out = append(out, count(v.Workloads)+" certificates") + case "vCenter", "Prism Central": + out = append(out, count(v.Workloads)+" VMs") + default: + out = append(out, count(v.Workloads)+" workloads") + } + return strings.Join(out, " · ") +} + +// humanCount is n with thousands separated: 3,300. +func humanCount(n int) string { + s := strconv.Itoa(n) + for i := len(s) - 3; i > 0 && s[i-1] != '-'; i -= 3 { + s = s[:i] + "," + s[i:] + } + return s +} + // nodeNoun is what its nodes are: a FlashArray's are controllers, a // FlashBlade's blades; a vCenter's and Prism Central's, hosts; an HMC's, // Power servers. @@ -1079,6 +1160,12 @@ type ClusterView struct { NodeNoun string `json:"node_noun"` // Partition is an IBM i partition's own numbers (docs/ibmi.md). Partition *PartitionView `json:"partition,omitempty"` + // Group is the Clusters page's section: Kubernetes, Virtualization, + // Storage, IBM i or Secrets. Summary is one line fitted to the kind, + // for the dashboard and the maps: "31/32 nodes ready · 3,300 + // workloads", "CPU 54% · system ASP 85% · 4 of 5 subsystems active". + Group string `json:"group"` + Summary string `json:"summary"` } // expectSubsystems marks an IBM i partition's subsystems that @@ -1269,7 +1356,7 @@ func (srv *Server) clusterViews(now time.Time, conds []Condition) []ClusterView if s.host { continue // a host's VMs: on its page and Workloads, not Clusters } - v := ClusterView{Name: s.name, Agent: s.agent, Problems: probs[s.name], Kinds: map[string]map[string]int{}, Noun: s.noun(), NodeNoun: s.nodeNoun()} + v := ClusterView{Name: s.name, Agent: s.agent, Problems: probs[s.name], Kinds: map[string]map[string]int{}, Noun: s.noun(), NodeNoun: s.nodeNoun(), Group: s.group()} v.Status, v.Word, _ = srv.sourceStatus(s, now) if !s.heard.IsZero() { h := s.heard @@ -1352,6 +1439,7 @@ func (srv *Server) clusterViews(now time.Time, conds []Condition) []ClusterView if v.Status == "good" && v.Problems > 0 { v.Status, v.Word = "warning", plural(v.Problems, "problem", "problems") } + v.Summary = v.summary() out = append(out, v) } return out diff --git a/internal/server/workloads_test.go b/internal/server/workloads_test.go index 397e80f..4e57057 100644 --- a/internal/server/workloads_test.go +++ b/internal/server/workloads_test.go @@ -668,3 +668,49 @@ func TestLowerFirst(t *testing.T) { } } } + +// A cluster's summary says what matters for its kind (#46). +func TestClusterSummary(t *testing.T) { + cpu := 41.0 + cases := []struct { + v ClusterView + want string + }{ + {ClusterView{Noun: "Cluster", NodeNoun: "Node", Nodes: 32, NodesReady: 31, Workloads: 3300}, "31/32 nodes ready · 3,300 workloads"}, + {ClusterView{Noun: "Partition", Partition: &PartitionView{CPUPct: &cpu, SystemASPPct: 84.6, Subsystems: 5, SubsystemsActive: 4}}, "CPU 41% · system ASP 85% · 4 of 5 subsystems active"}, + {ClusterView{Noun: "Array", NodeNoun: "Controller", Nodes: 2, NodesReady: 2, Workloads: 600, + Usage: &UsageNow{IO: &report.IO{Used: 71, UsedOf: 100}}}, "2/2 controllers ready · 600 volumes · 71% used"}, + {ClusterView{Noun: "HMC", NodeNoun: "Server", Nodes: 2, NodesReady: 2, Workloads: 6}, "2/2 servers ready · 6 partitions"}, + } + for _, c := range cases { + if got := c.v.summary(); got != c.want { + t.Errorf("%s: %q, want %q", c.v.Noun, got, c.want) + } + } + if humanCount(1234567) != "1,234,567" || humanCount(999) != "999" { + t.Errorf("humanCount: %s %s", humanCount(1234567), humanCount(999)) + } +} + +// The service map says what a cluster is, not "Kubernetes cluster" for an +// HMC or a vCenter (#37); the Clusters page puts each in its section (#41). +func TestClusterKind(t *testing.T) { + snap := func(d string) wsnap { + return wsnap{recs: []report.Workload{{Kind: report.KindCluster, ID: report.ClusterSelf, Facts: map[string]any{"distribution": d}}}} + } + for d, want := range map[string][2]string{ + "": {"Kubernetes cluster", "Kubernetes"}, + "OpenShift": {"OpenShift cluster", "Kubernetes"}, + "Proxmox VE": {"Proxmox cluster", "Virtualization"}, + "vCenter": {"vCenter", "Virtualization"}, + "Prism Central": {"Prism Central", "Virtualization"}, + "HMC": {"HMC", "IBM i"}, + "IBM i": {"IBM i partition", "IBM i"}, + "Purity//FA": {"Pure array", "Storage"}, + "OpenBao": {"OpenBao", "Secrets"}, + } { + if got := [2]string{snap(d).kindLabel(), snap(d).group()}; got != want { + t.Errorf("%q: %v, want %v", d, got, want) + } + } +} diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index c377c49..459947f 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -68,6 +68,8 @@ export interface Cluster { usage?: Usage; history?: string; /** What it is (Cluster, Array, vCenter, Prism Central) and what its nodes are (Node, Controller, Host). */ noun: string; node_noun: string; + /** The Clusters page's section (Kubernetes, Virtualization, Storage, IBM i, Secrets), and its state in a line, in its kind's terms. */ + group: string; summary: string; /** An IBM i partition's own numbers, in place of nodes. */ partition?: PartitionNums; } diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index 097ae9f..bb261f9 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -111,8 +111,7 @@ {k.name} {k.version ?? ''} - {k.nodes_ready}/{k.nodes} {(k.node_noun || 'Node').toLowerCase()}s ready - {k.workloads} workloads + {k.summary} {/each} @@ -189,8 +188,8 @@ .csum span { color: var(--muted-fg); font-size: 12px; } .csum .bad b { color: var(--critical); } .clist { display: grid; gap: 6px; } - .crow { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(140px, 1.4fr) minmax(60px, .8fr) 1fr 1fr; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); } + .crow { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(140px, 1.4fr) minmax(60px, .8fr) 2fr; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--foreground); } .crow:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); } - @media (max-width: 700px) { .crow { grid-template-columns: 1fr 1fr; } } + @media (max-width: 700px) { .crow { grid-template-columns: 1fr 1fr; } .crow .sum { grid-column: 1 / -1; } } @media (max-width: 860px) { .clock { text-align: left; } .csum { grid-template-columns: 1fr 1fr; } } diff --git a/web/src/routes/clusters/+page.svelte b/web/src/routes/clusters/+page.svelte index b83ff2e..05f6346 100644 --- a/web/src/routes/clusters/+page.svelte +++ b/web/src/routes/clusters/+page.svelte @@ -1,4 +1,6 @@ Cairn OBS · Clusters
-

Clusters

Each cluster a cluster agent watches: its nodes, and what runs on them by state. A node that's down is one problem, with what's on it listed under it.

+

Clusters

Everything Cairn OBS reads as a cluster, by kind: Kubernetes, hypervisor managers, arrays, IBM i and Vault. The ones that need a look come first in each. A node that's down is one problem, with what's on it listed under it.

{#if error}

{error}

{/if} {#if loaded && clusters.length === 0}

No clusters yet. A cluster agent adds its cluster once it has joined.

{/if} -{#each clusters as c (c.name)} +{#if clusters.length} + +
+ + + + {#each sections as x (x.g)}{/each} + + {#if group || show || q}{/if} +
+{/if} + +{#each sections as x (x.g)} + {#if !group || group === x.g} +

{x.g} {(x.shown.length === x.all.length ? `${x.all.length}` : `${x.shown.length} of ${x.all.length}`) + (x.bad ? ` · ${x.bad} ${x.bad === 1 ? 'needs' : 'need'} a look` : '')}

+ {#if !x.shown.length}

None match.

{/if} + {#each x.shown as c (c.name)}
@@ -93,7 +153,7 @@ {#each kinds as [k, label]} {#if n(c, k)} - {k === 'node' && c.node_noun ? c.node_noun + 's' : label} + {k === 'node' && c.node_noun ? c.node_noun + 's' : k === 'vm' && c.noun === 'HMC' ? 'Partitions' : label} {n(c, k)} {#each sevs as [s]} {#if n(c, k, s)}{n(c, k, s)}{:else}0{/if} @@ -114,10 +174,19 @@ {/if}
+ {/each} + {/if} {/each}

Refreshes every 10 seconds.