Say which platform each cluster and VM is on #81
No files matched your search
@@ -345,6 +345,18 @@ everything at once.
|
||||
- **Workloads:** one table for every kind, filtered by cluster, namespace,
|
||||
kind, node and state and searched by name, problems first, paged. The
|
||||
same table filtered to `vm` is the **VMs** page.
|
||||
- **Platforms (#80):** every cluster, array and VM host says what it runs
|
||||
on, the way people name it: OpenShift, OKD, Kubernetes, VMware vSphere,
|
||||
Nutanix, Proxmox VE, Hyper-V, KVM, Pure FlashArray, Pure FlashBlade,
|
||||
IBM i, IBM Power, Vault or OpenBao. A cluster's comes from the
|
||||
distribution its watcher reports (OpenShift's from its cluster version),
|
||||
a host's VMs' from their hypervisor. It's a label on the Clusters cards,
|
||||
in the Workloads "Where" column and cluster picker, on a host's VM line
|
||||
and in the network map's cluster boxes. Workloads filters by it
|
||||
(`/workloads?platform=VMware vSphere`), with a count on each choice. The
|
||||
API gives `platform` on each cluster, workload row and VM link, and the
|
||||
workload list adds `platforms` (counts, before the platform, state and
|
||||
kind filters) and `platform_of` (each source's).
|
||||
- **A controller, VM or node:** its record, its pods (for a controller or
|
||||
a node), its warning events, its history, its incidents. For operators
|
||||
and admins, the last log lines of a failing container, when the cluster
|
||||
|
||||
@@ -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: c.Summary, Count: c.Nodes})
|
||||
Sub: c.Platform + " · " + c.Summary, Count: c.Nodes})
|
||||
}
|
||||
|
||||
case "site", "group":
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"strings"
|
||||
|
||||
"github.com/cairnobs/cairnobs/internal/report"
|
||||
)
|
||||
|
||||
// Platforms (#80): what a cluster, array or VM host is, said the way people
|
||||
// name it, so the pages can show OpenShift apart from plain Kubernetes and
|
||||
// VMware apart from Nutanix or Proxmox. A cluster's comes from the
|
||||
// distribution its watcher reports; a host's VMs' from their hypervisor.
|
||||
|
||||
// platformOf names the platform from a cluster's distribution, or for a
|
||||
// host's own VMs (distribution ""), from their hypervisor fact.
|
||||
func platformOf(distribution, hypervisor string) string {
|
||||
switch d := distribution; {
|
||||
case d == "OpenShift", d == "OKD":
|
||||
return d
|
||||
case d == "vCenter":
|
||||
return "VMware vSphere"
|
||||
case d == "Prism Central":
|
||||
return "Nutanix"
|
||||
case strings.HasPrefix(d, "Proxmox"):
|
||||
return "Proxmox VE"
|
||||
case d == "Purity//FB":
|
||||
return "Pure FlashBlade"
|
||||
case strings.HasPrefix(d, "Purity"):
|
||||
return "Pure FlashArray"
|
||||
case d == ibmiDistribution:
|
||||
return "IBM i"
|
||||
case d == hmcDistribution:
|
||||
return "IBM Power"
|
||||
case d == "OpenBao":
|
||||
return d
|
||||
case strings.HasPrefix(d, "Vault"):
|
||||
return "Vault"
|
||||
case d != "":
|
||||
return "Kubernetes"
|
||||
}
|
||||
switch hypervisor {
|
||||
case "Hyper-V":
|
||||
return "Hyper-V"
|
||||
case "libvirt":
|
||||
return "KVM"
|
||||
case "vSphere":
|
||||
return "VMware vSphere"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// platform is the source's: a cluster's from its distribution (a cluster
|
||||
// agent that hasn't said is Kubernetes), a host's from its VMs.
|
||||
func (s wsnap) platform() string {
|
||||
if s.host {
|
||||
for _, r := range s.recs {
|
||||
if h, _ := r.Facts["hypervisor"].(string); h != "" {
|
||||
return platformOf("", h)
|
||||
}
|
||||
}
|
||||
return "KVM" // a host lists VMs through libvirt unless it says otherwise
|
||||
}
|
||||
if p := platformOf(s.distribution(), ""); p != "" {
|
||||
return p
|
||||
}
|
||||
return "Kubernetes"
|
||||
}
|
||||
|
||||
// clusterPlatform is a stored cluster source's platform, from its own
|
||||
// record (vmLinks reads the store directly, under its lock).
|
||||
func clusterPlatform(recs map[string]*wrec) string {
|
||||
d := distributionOf(func(yield func(report.Workload) bool) {
|
||||
for _, r := range recs {
|
||||
if !yield(r.Workload) {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
return cmp.Or(platformOf(d, ""), "Kubernetes")
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"strings"
|
||||
|
||||
"github.com/cairnobs/cairnobs/internal/report"
|
||||
@@ -21,8 +22,9 @@ type VMLink struct {
|
||||
State string `json:"state"`
|
||||
Word string `json:"word"`
|
||||
Href string `json:"href"`
|
||||
OnHost bool `json:"on_host,omitempty"` // Source is a host running libvirt, not a cluster
|
||||
Title string `json:"title,omitempty"` // the cluster's own name, when it isn't Source's (Proxmox)
|
||||
OnHost bool `json:"on_host,omitempty"` // Source is a host running libvirt, not a cluster
|
||||
Title string `json:"title,omitempty"` // the cluster's own name, when it isn't Source's (Proxmox)
|
||||
Platform string `json:"platform,omitempty"` // what Source runs on: VMware vSphere, OpenShift, KVM (#80)
|
||||
key string // its condition's key: vm/<source>/<ns>/<name>
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ func (srv *Server) vmLinks() (byHost map[string]VMLink, byVM map[string]HostLink
|
||||
ws := &srv.wl
|
||||
ws.mu.RLock()
|
||||
for src, s := range ws.src {
|
||||
title := ""
|
||||
title, plat := "", clusterPlatform(s.recs)
|
||||
if r, ok := s.recs[report.ClusterSelf]; ok && r.Name != "" && r.Name != src {
|
||||
title = r.Name
|
||||
}
|
||||
@@ -75,7 +77,7 @@ func (srv *Server) vmLinks() (byHost map[string]VMLink, byVM map[string]HostLink
|
||||
if _, ok := vmOf[u]; ok {
|
||||
dupVM[u] = true
|
||||
}
|
||||
vmOf[u] = VMLink{Source: src, Title: title, Namespace: r.Namespace, Name: r.Name, Node: r.Node, State: r.State, Word: r.Word,
|
||||
vmOf[u] = VMLink{Source: src, Title: title, Platform: plat, Namespace: r.Namespace, Name: r.Name, Node: r.Node, State: r.State, Word: r.Word,
|
||||
Href: workloadHref(src, r.Namespace, r.Name), key: "vm/" + src + "/" + r.Namespace + "/" + r.Name}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +92,8 @@ func (srv *Server) vmLinks() (byHost map[string]VMLink, byVM map[string]HostLink
|
||||
if _, ok := vmOf[u]; ok {
|
||||
dupVM[u] = true
|
||||
}
|
||||
vmOf[u] = VMLink{Source: h.name, Name: r.Name, State: r.State, Word: r.Word,
|
||||
hv, _ := r.Facts["hypervisor"].(string)
|
||||
vmOf[u] = VMLink{Source: h.name, Platform: cmp.Or(platformOf("", hv), "KVM"), Name: r.Name, State: r.State, Word: r.Word,
|
||||
Href: workloadHref(h.name, "", r.Name), OnHost: true, key: "vm/" + h.name + "//" + r.Name}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestVMLinkedToItsHost(t *testing.T) {
|
||||
|
||||
// Running: linked both ways; silence is the guest's or the network's.
|
||||
hosts, conds := a.view(now)
|
||||
if hosts[0].VM == nil || hosts[0].VM.Name != "db" || hosts[0].VM.Source != "prod" || hosts[0].VM.Href != "/workloads?source=prod&ns=vms&q=db" {
|
||||
if hosts[0].VM == nil || hosts[0].VM.Name != "db" || hosts[0].VM.Source != "prod" || hosts[0].VM.Href != "/workloads?source=prod&ns=vms&q=db" || hosts[0].VM.Platform != "Kubernetes" {
|
||||
t.Fatalf("host's VM: %+v", hosts[0].VM)
|
||||
}
|
||||
silent := find(conds, "silent/node1")
|
||||
@@ -45,6 +45,9 @@ func TestVMLinkedToItsHost(t *testing.T) {
|
||||
if rec.Code != http.StatusOK || len(list.Workloads) != 1 || list.Workloads[0].Host == nil || list.Workloads[0].Host.Name != "node1" {
|
||||
t.Fatalf("VM's host: %d %s", rec.Code, rec.Body)
|
||||
}
|
||||
if list.Workloads[0].Platform != "Kubernetes" {
|
||||
t.Errorf("VM's platform: %q", list.Workloads[0].Platform)
|
||||
}
|
||||
|
||||
// The VM is down: one incident for it, the host held under it.
|
||||
sendBatch(t, a, tok, report.Workloads{Records: []report.Workload{vm(report.StateDown, "Can't be scheduled")}})
|
||||
@@ -130,6 +133,31 @@ func TestHostVMs(t *testing.T) {
|
||||
if rec.Code != http.StatusOK || len(list.Workloads) != 2 || len(list.Hypervisors) != 1 || list.Hypervisors[0] != "kvm1" {
|
||||
t.Fatalf("list: %d %s", rec.Code, rec.Body)
|
||||
}
|
||||
for _, w := range list.Workloads {
|
||||
if w.Platform != "KVM" {
|
||||
t.Errorf("%s: platform %q, want KVM", w.Name, w.Platform)
|
||||
}
|
||||
}
|
||||
// ?platform= keeps one platform's, and the counts say how many each has.
|
||||
var by struct {
|
||||
Workloads []WorkloadRow
|
||||
Platforms map[string]int
|
||||
PlatformOf map[string]string `json:"platform_of"`
|
||||
}
|
||||
_ = json.Unmarshal(get(a.Handler(), "/api/v1/workloads?platform=KVM", devCookie(t, a.Handler())).Body.Bytes(), &by)
|
||||
if len(by.Workloads) != 2 || by.Platforms["KVM"] != 2 || by.PlatformOf["kvm1"] != "KVM" {
|
||||
t.Errorf("platform=KVM: %d rows, %v, %v", len(by.Workloads), by.Platforms, by.PlatformOf)
|
||||
}
|
||||
_ = json.Unmarshal(get(a.Handler(), "/api/v1/workloads?platform=Hyper-V", devCookie(t, a.Handler())).Body.Bytes(), &by)
|
||||
if len(by.Workloads) != 0 || by.Platforms["KVM"] != 2 {
|
||||
t.Errorf("platform=Hyper-V: %d rows, %v", len(by.Workloads), by.Platforms)
|
||||
}
|
||||
hosts, _ := a.view(now)
|
||||
for _, h := range hosts {
|
||||
if h.Name == "web" && (h.VM == nil || h.VM.Platform != "KVM") {
|
||||
t.Errorf("web's VM: %+v", h.VM)
|
||||
}
|
||||
}
|
||||
for _, w := range list.Workloads {
|
||||
if w.Name == "web" && (w.Host == nil || w.Host.Name != "web" || w.Usage == nil || w.Usage.CPU != 0.5) {
|
||||
t.Errorf("web: host %+v usage %+v", w.Host, w.Usage)
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
"log"
|
||||
"maps"
|
||||
"net/http"
|
||||
@@ -576,8 +577,14 @@ func (s wsnap) kindLabel() string {
|
||||
return "IBM i partition"
|
||||
case n == "Array":
|
||||
return "Pure array"
|
||||
case n == "vCenter":
|
||||
return "VMware vCenter"
|
||||
case n == "Prism Central":
|
||||
return "Nutanix Prism Central"
|
||||
case n == "HMC":
|
||||
return "IBM Power HMC"
|
||||
case n != "Cluster":
|
||||
return n // vCenter, Prism Central, HMC, Vault, OpenBao
|
||||
return n // Vault, OpenBao
|
||||
case strings.HasPrefix(d, "Proxmox"):
|
||||
return "Proxmox cluster"
|
||||
case d == "OpenShift", d == "OKD":
|
||||
@@ -652,14 +659,34 @@ func (s wsnap) nodeNoun() string {
|
||||
return "Node"
|
||||
}
|
||||
|
||||
// distribution is what the source's watcher says it is: on its own
|
||||
// record, or for OpenShift and OKD on the cluster version's, which is
|
||||
// where the cluster watcher reads it.
|
||||
func (s wsnap) distribution() string {
|
||||
for _, r := range s.recs {
|
||||
if r.Kind == report.KindCluster && r.ID == report.ClusterSelf {
|
||||
d, _ := r.Facts["distribution"].(string)
|
||||
return distributionOf(func(yield func(report.Workload) bool) {
|
||||
for _, r := range s.recs {
|
||||
if !yield(r) {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func distributionOf(recs iter.Seq[report.Workload]) string {
|
||||
ocp := ""
|
||||
for r := range recs {
|
||||
if r.Kind != report.KindCluster {
|
||||
continue
|
||||
}
|
||||
d, _ := r.Facts["distribution"].(string)
|
||||
switch {
|
||||
case r.ID == report.ClusterSelf && d != "":
|
||||
return d
|
||||
case strings.HasPrefix(r.Name, "clusterversion/") && d != "":
|
||||
ocp = d
|
||||
}
|
||||
}
|
||||
return ""
|
||||
return ocp
|
||||
}
|
||||
|
||||
// alertable applies a workload's alert setting: off drops it, and only
|
||||
@@ -1166,6 +1193,9 @@ type ClusterView struct {
|
||||
// workloads", "CPU 54% · system ASP 85% · 4 of 5 subsystems active".
|
||||
Group string `json:"group"`
|
||||
Summary string `json:"summary"`
|
||||
// Platform is what it runs on, said the way people name it:
|
||||
// OpenShift, Kubernetes, VMware vSphere, Nutanix, Proxmox VE (#80).
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
||||
// expectSubsystems marks an IBM i partition's subsystems that
|
||||
@@ -1356,7 +1386,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(), Group: s.group()}
|
||||
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(), Platform: s.platform()}
|
||||
v.Status, v.Word, _ = srv.sourceStatus(s, now)
|
||||
if !s.heard.IsZero() {
|
||||
h := s.heard
|
||||
@@ -1511,6 +1541,8 @@ func rank(sev string) int {
|
||||
// WorkloadRow is one workload in the Workloads list.
|
||||
type WorkloadRow struct {
|
||||
Source string `json:"source"`
|
||||
// Platform is what Source runs on: OpenShift, VMware vSphere, KVM (#80).
|
||||
Platform string `json:"platform"`
|
||||
report.Workload
|
||||
Severity string `json:"severity"`
|
||||
// Host is the host agent inside a VM, linked by its SMBIOS UUID.
|
||||
@@ -1526,13 +1558,17 @@ type WorkloadRow struct {
|
||||
|
||||
// handleWorkloadList is every workload, most in need first: ?source=,
|
||||
// ?kind=, ?ns=, ?node=, ?owner=, ?show= (problems, good, waiting, off),
|
||||
// ?q= (name, namespace, owner or node), ?offset=, ?limit= (100, at most
|
||||
// 1000). counts leave show and kind out and kinds leaves kind out, so each
|
||||
// choice can say how many it holds; namespaces are the chosen cluster's.
|
||||
// ?q= (name, namespace, owner or node), ?platform= (#80), ?offset=,
|
||||
// ?limit= (100, at most 1000). counts leave show and kind out, kinds
|
||||
// leaves kind out and platforms leaves platform, show and kind out, so
|
||||
// each choice can say how many it holds; namespaces are the chosen
|
||||
// cluster's. platform_of names each source's platform, for the picker.
|
||||
func (srv *Server) handleWorkloadList(w http.ResponseWriter, r *http.Request) {
|
||||
now := time.Now()
|
||||
qv := r.URL.Query()
|
||||
source, kind, ns, node, owner, show := qv.Get("source"), qv.Get("kind"), qv.Get("ns"), qv.Get("node"), qv.Get("owner"), qv.Get("show")
|
||||
platform := qv.Get("platform")
|
||||
platforms, platformOfSource := map[string]int{}, map[string]string{}
|
||||
q := strings.ToLower(strings.TrimSpace(qv.Get("q")))
|
||||
offset, limit := page(r, 100, 1000)
|
||||
counts := map[string]int{"all": 0, "problems": 0, "good": 0, "waiting": 0, "off": 0}
|
||||
@@ -1543,6 +1579,8 @@ func (srv *Server) handleWorkloadList(w http.ResponseWriter, r *http.Request) {
|
||||
snaps := srv.workloadSnapshot()
|
||||
byPVC, byVolume := volumeLinks(snaps)
|
||||
for _, s := range snaps {
|
||||
plat := s.platform()
|
||||
platformOfSource[s.name] = plat
|
||||
if source != "" && s.name != source {
|
||||
continue
|
||||
}
|
||||
@@ -1560,6 +1598,10 @@ func (srv *Server) handleWorkloadList(w http.ResponseWriter, r *http.Request) {
|
||||
if q != "" && !strings.Contains(strings.ToLower(rec.Name+" "+rec.Namespace+" "+rec.Owner+" "+rec.Node), q) {
|
||||
continue
|
||||
}
|
||||
platforms[plat]++
|
||||
if platform != "" && plat != platform {
|
||||
continue
|
||||
}
|
||||
sev := stateSeverity(rec.State)
|
||||
counts["all"]++
|
||||
switch sev {
|
||||
@@ -1575,7 +1617,7 @@ func (srv *Server) handleWorkloadList(w http.ResponseWriter, r *http.Request) {
|
||||
if kind != "" && rec.Kind != kind {
|
||||
continue
|
||||
}
|
||||
row := WorkloadRow{Source: s.name, Workload: rec, Severity: sev, Usage: s.usageOf(rec.ID, now)}
|
||||
row := WorkloadRow{Source: s.name, Platform: plat, Workload: rec, Severity: sev, Usage: s.usageOf(rec.ID, now)}
|
||||
if h, ok := byVM["vm/"+s.name+"/"+rec.Namespace+"/"+rec.Name]; ok && rec.Kind == report.KindVM {
|
||||
row.Host = &h
|
||||
}
|
||||
@@ -1600,7 +1642,8 @@ func (srv *Server) handleWorkloadList(w http.ResponseWriter, r *http.Request) {
|
||||
// Facts and labels stay for whoever opens a row: the list is the rest.
|
||||
win := window(rows, offset, limit)
|
||||
writeJSON(w, http.StatusOK, map[string]any{"workloads": win, "total": len(rows), "offset": offset, "limit": limit,
|
||||
"counts": counts, "kinds": kinds, "namespaces": namespaces, "clusters": names(srv.clusterSnaps()), "hypervisors": names(srv.hostVMSnaps())})
|
||||
"counts": counts, "kinds": kinds, "namespaces": namespaces, "clusters": names(srv.clusterSnaps()), "hypervisors": names(srv.hostVMSnaps()),
|
||||
"platforms": platforms, "platform_of": platformOfSource})
|
||||
}
|
||||
|
||||
// lowerFirst lowers a word's first letter, for the middle of a sentence,
|
||||
|
||||
@@ -698,19 +698,56 @@ 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"},
|
||||
for d, want := range map[string][3]string{
|
||||
"": {"Kubernetes cluster", "Kubernetes", "Kubernetes"},
|
||||
"OpenShift": {"OpenShift cluster", "Kubernetes", "OpenShift"},
|
||||
"OKD": {"OKD cluster", "Kubernetes", "OKD"},
|
||||
"Proxmox VE": {"Proxmox cluster", "Virtualization", "Proxmox VE"},
|
||||
"vCenter": {"VMware vCenter", "Virtualization", "VMware vSphere"},
|
||||
"Prism Central": {"Nutanix Prism Central", "Virtualization", "Nutanix"},
|
||||
"HMC": {"IBM Power HMC", "IBM i", "IBM Power"},
|
||||
"IBM i": {"IBM i partition", "IBM i", "IBM i"},
|
||||
"Purity//FA": {"Pure array", "Storage", "Pure FlashArray"},
|
||||
"Purity//FB": {"Pure array", "Storage", "Pure FlashBlade"},
|
||||
"Vault": {"Vault", "Secrets", "Vault"},
|
||||
"OpenBao": {"OpenBao", "Secrets", "OpenBao"},
|
||||
} {
|
||||
if got := [2]string{snap(d).kindLabel(), snap(d).group()}; got != want {
|
||||
if got := [3]string{snap(d).kindLabel(), snap(d).group(), snap(d).platform()}; got != want {
|
||||
t.Errorf("%q: %v, want %v", d, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A host's own VMs are on the platform their hypervisor names (#80).
|
||||
func TestHostPlatform(t *testing.T) {
|
||||
vm := func(h string) wsnap {
|
||||
return wsnap{host: true, recs: []report.Workload{{Kind: report.KindVM, Name: "a", Facts: map[string]any{"hypervisor": h}}}}
|
||||
}
|
||||
for h, want := range map[string]string{"Hyper-V": "Hyper-V", "libvirt": "KVM", "": "KVM"} {
|
||||
if got := vm(h).platform(); got != want {
|
||||
t.Errorf("hypervisor %q: %q, want %q", h, got, want)
|
||||
}
|
||||
}
|
||||
if got := (wsnap{host: true}).platform(); got != "KVM" {
|
||||
t.Errorf("a host with no VMs: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// OpenShift says so on its cluster version, not on the cluster's own
|
||||
// record: that's where the cluster watcher reads it (#80).
|
||||
func TestOpenShiftPlatform(t *testing.T) {
|
||||
s := wsnap{recs: []report.Workload{
|
||||
{Kind: report.KindCluster, ID: report.ClusterSelf, Name: "prod"},
|
||||
{Kind: report.KindCluster, ID: "cv", Name: "clusterversion/version", Facts: map[string]any{"distribution": "OpenShift", "version": "4.20.3"}},
|
||||
}}
|
||||
if got := [3]string{s.platform(), s.kindLabel(), s.group()}; got != [3]string{"OpenShift", "OpenShift cluster", "Kubernetes"} {
|
||||
t.Errorf("OpenShift: %v", got)
|
||||
}
|
||||
recs := map[string]*wrec{}
|
||||
for _, r := range s.recs {
|
||||
recs[r.ID] = &wrec{Workload: r}
|
||||
}
|
||||
if got := clusterPlatform(recs); got != "OpenShift" {
|
||||
t.Errorf("clusterPlatform: %q", got)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
// What a cluster, array or VM runs on (#80): a small label with a dot
|
||||
// whose color tells the families apart at a glance: Kubernetes and
|
||||
// OpenShift, VMware, Nutanix, Proxmox, Hyper-V, KVM, Pure, IBM.
|
||||
let { p = '' }: { p?: string } = $props();
|
||||
const family = (p: string) =>
|
||||
p === 'OpenShift' || p === 'OKD' ? 'openshift'
|
||||
: p === 'Kubernetes' ? 'k8s'
|
||||
: p.startsWith('VMware') ? 'vmware'
|
||||
: p === 'Nutanix' ? 'nutanix'
|
||||
: p.startsWith('Proxmox') ? 'proxmox'
|
||||
: p === 'Hyper-V' ? 'hyperv'
|
||||
: p === 'KVM' ? 'kvm'
|
||||
: p.startsWith('Pure') ? 'pure'
|
||||
: p.startsWith('IBM') ? 'ibm'
|
||||
: 'other';
|
||||
</script>
|
||||
|
||||
{#if p}<span class="plat {family(p)}" title="Runs on {p}">{p}</span>{/if}
|
||||
|
||||
<style>
|
||||
.plat { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 1px 6px; border: 1px solid var(--border); border-radius: 999px;
|
||||
font-size: 11px; font-weight: 600; line-height: 16px; color: var(--foreground); white-space: nowrap; vertical-align: middle; background: var(--card); }
|
||||
.plat::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--muted-fg)); flex: none; }
|
||||
.k8s { --dot: #4f7fe0; }
|
||||
.openshift { --dot: #e0453a; }
|
||||
.vmware { --dot: #3fa45b; }
|
||||
.nutanix { --dot: #8a5cd6; }
|
||||
.proxmox { --dot: #e2861b; }
|
||||
.hyperv { --dot: #1f9bd6; }
|
||||
.kvm { --dot: #c9a227; }
|
||||
.pure { --dot: #f26b2a; }
|
||||
.ibm { --dot: #3b6fd1; }
|
||||
</style>
|
||||
+5
-2
@@ -36,7 +36,7 @@ export interface Host {
|
||||
export interface HostEvents { at: string; since: string; list: EventGroup[]; error?: string }
|
||||
export interface EventGroup { log: string; source: string; id: number; level: 'critical' | 'error'; count: number; first: string; last: string; message?: string }
|
||||
/** A cluster's VM, as linked to a host (internal/server/vmlink.go). */
|
||||
export interface VMLink { source: string; namespace?: string; name: string; node?: string; state: string; word: string; href: string; on_host?: boolean; title?: string }
|
||||
export interface VMLink { source: string; namespace?: string; name: string; node?: string; state: string; word: string; href: string; on_host?: boolean; title?: string; platform?: string }
|
||||
/** The libvirt VMs a host runs. */
|
||||
export interface HostVMCount { total: number; running: number; error?: string; href: string }
|
||||
export interface UnitView { name: string; load: string; active: string; sub: string; restarts: number; since?: string; host: string; severity: Severity; word: string }
|
||||
@@ -88,6 +88,8 @@ export interface Cluster {
|
||||
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;
|
||||
/** What it runs on, the way people name it: OpenShift, Kubernetes, VMware vSphere, Nutanix (#80). */
|
||||
platform?: string;
|
||||
/** An IBM i partition's own numbers, in place of nodes. */
|
||||
partition?: PartitionNums;
|
||||
}
|
||||
@@ -101,7 +103,8 @@ export interface ClusterPart { name: string; title: string; state: string; word:
|
||||
export interface ClusterNode { name: string; state: string; severity: Severity; word: string; since?: string; facts?: Record<string, unknown> }
|
||||
/** A row of the workloads list: GET /api/v1/workloads. */
|
||||
export interface Workload {
|
||||
source: string; kind: string; id: string; name: string; namespace?: string; owner?: string; node?: string;
|
||||
/** platform is what source runs on: OpenShift, VMware vSphere, KVM (#80). */
|
||||
source: string; platform?: string; kind: string; id: string; name: string; namespace?: string; owner?: string; node?: string;
|
||||
state: string; severity: Severity; word: string; since?: string; alert?: string;
|
||||
labels?: Record<string, string>; facts?: Record<string, unknown>;
|
||||
/** For a VM: the host agent inside it, linked by its SMBIOS UUID. */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { replaceState } from '$app/navigation';
|
||||
import Icon from '$lib/Icon.svelte';
|
||||
import Panel from '$lib/Panel.svelte';
|
||||
import Platform from '$lib/Platform.svelte';
|
||||
import Status from '$lib/Status.svelte';
|
||||
import ArrayIO from '$lib/ArrayIO.svelte';
|
||||
import VaultLeases from '$lib/VaultLeases.svelte';
|
||||
@@ -64,7 +65,7 @@
|
||||
if (show === 'problems' && !needsLook(c)) return false;
|
||||
if (!q) return true;
|
||||
const f = q.toLowerCase();
|
||||
return [c.name, c.title, c.read_by, c.version, c.noun].some((x) => x?.toLowerCase().includes(f));
|
||||
return [c.name, c.title, c.read_by, c.version, c.noun, c.platform].some((x) => x?.toLowerCase().includes(f));
|
||||
};
|
||||
const sections = $derived(
|
||||
groups
|
||||
@@ -98,7 +99,7 @@
|
||||
</nav>
|
||||
<div class="filters">
|
||||
<Icon name="filter" />
|
||||
<input class="input" placeholder="Name, version or what it is" aria-label="Find a cluster" bind:value={typed} style="width:240px" />
|
||||
<input class="input" placeholder="Name, version or platform" aria-label="Find a cluster" bind:value={typed} style="width:240px" />
|
||||
<button class="chip" class:on={group === ''} onclick={() => (group = '')}>All kinds</button>
|
||||
{#each sections as x (x.g)}<button class="chip" class:on={group === x.g} onclick={() => (group = group === x.g ? '' : x.g)}>{x.g}</button>{/each}
|
||||
<button class="chip" class:on={show === 'problems'} onclick={() => (show = show === 'problems' ? '' : 'problems')}>Need a look <b>{badCount}</b></button>
|
||||
@@ -114,6 +115,7 @@
|
||||
<div class="mt">
|
||||
<Panel title={c.title ? `${c.title} · read by ${c.read_by || c.name}` : c.name} aside={c.version ? `version ${c.version}` : ''}>
|
||||
<div class="top">
|
||||
<Platform p={c.platform} />
|
||||
<Status s={c.status} word={c.word} />
|
||||
<span class="sub">{c.heard ? `Heard ${ago(c.heard)}` : 'Never heard from'}{#if c.listed} · listed in full {ago(c.listed)}{/if}</span>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import Icon from '$lib/Icon.svelte';
|
||||
import Platform from '$lib/Platform.svelte';
|
||||
import Panel from '$lib/Panel.svelte';
|
||||
import Spark from '$lib/Spark.svelte';
|
||||
import Status from '$lib/Status.svelte';
|
||||
@@ -49,7 +50,7 @@
|
||||
<h1>{name}</h1>
|
||||
<p>{#if host?.os}{host.os} · {windows ? 'build' : 'kernel'} {host.kernel} · {host.cpus} CPUs · {bytes(host.mem_total)} memory{:else if host}Waiting for this host's first report.{/if}</p>
|
||||
{#if host?.vm}
|
||||
<p class="vm">VM <a href={host.vm.href}>{host.vm.namespace ? host.vm.namespace + '/' : ''}{host.vm.name}</a> {#if host.vm.on_host}on <a href="/hosts/{host.vm.source}">{host.vm.source}</a>{:else}in {host.vm.title ?? host.vm.source}{/if}{#if host.vm.node}, on {host.vm.node}{/if} · <span class:bad={!['ok', 'updating', 'degraded'].includes(host.vm.state)}>{host.vm.word}</span></p>
|
||||
<p class="vm">VM <a href={host.vm.href}>{host.vm.namespace ? host.vm.namespace + '/' : ''}{host.vm.name}</a> {#if host.vm.on_host}on <a href="/hosts/{host.vm.source}">{host.vm.source}</a>{:else}in {host.vm.title ?? host.vm.source}{/if}{#if host.vm.platform}{' '}<Platform p={host.vm.platform} />{/if}{#if host.vm.node}, on {host.vm.node}{/if} · <span class:bad={!['ok', 'updating', 'degraded'].includes(host.vm.state)}>{host.vm.word}</span></p>
|
||||
{/if}
|
||||
{#if host?.vms}
|
||||
<p class="vm">{#if host.vms.error}<span class="bad">Can't read its VMs</span>: {host.vms.error}{:else}Runs <a href={host.vms.href}>{host.vms.total} {host.vms.total === 1 ? 'VM' : 'VMs'}</a>, {host.vms.running} running{/if}</p>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import Spark from '$lib/Spark.svelte';
|
||||
import { live } from '$lib/live.svelte';
|
||||
import { ago, bytes, sourceLabel } from '$lib/format';
|
||||
import Platform from '$lib/Platform.svelte';
|
||||
|
||||
// Every node, pod, controller, job, volume and VM the cluster agents
|
||||
// send, filtered and paged by obs-beacond: at fleet size that's tens of
|
||||
@@ -21,6 +22,7 @@
|
||||
let node = $state(u.get('node') ?? '');
|
||||
let owner = $state(u.get('owner') ?? '');
|
||||
let show = $state(u.get('show') ?? '');
|
||||
let platform = $state(u.get('platform') ?? '');
|
||||
let typed = $state(u.get('q') ?? '');
|
||||
let q = $state(u.get('q') ?? '');
|
||||
let offset = $state(0);
|
||||
@@ -32,6 +34,8 @@
|
||||
let namespaces = $state<string[]>([]);
|
||||
let clusters = $state<string[]>([]);
|
||||
let hypervisors = $state<string[]>([]); // hosts reporting libvirt VMs
|
||||
let platforms = $state<Record<string, number>>({}); // workloads on each platform, other filters applied
|
||||
let platformOf = $state<Record<string, string>>({}); // each cluster's and host's
|
||||
let open = $state<string | null>(null);
|
||||
// The open row's last day, hour by hour, when it has usage.
|
||||
let hours = $state<{ key: string; list: WorkloadHour[] } | null>(null);
|
||||
@@ -56,7 +60,7 @@
|
||||
|
||||
const params = () => {
|
||||
const p = new URLSearchParams();
|
||||
for (const [k, v] of [['source', source], ['kind', kind], ['ns', ns], ['node', node], ['owner', owner], ['show', show], ['q', q]]) if (v) p.set(k, v);
|
||||
for (const [k, v] of [['source', source], ['platform', platform], ['kind', kind], ['ns', ns], ['node', node], ['owner', owner], ['show', show], ['q', q]]) if (v) p.set(k, v);
|
||||
return p;
|
||||
};
|
||||
async function load(p: URLSearchParams, offset: number) {
|
||||
@@ -64,7 +68,7 @@
|
||||
const qp = new URLSearchParams(p);
|
||||
qp.set('offset', String(offset));
|
||||
qp.set('limit', String(limit));
|
||||
const r = await get<{ workloads: Workload[]; total: number; counts: Record<string, number>; kinds: Record<string, number>; namespaces: string[]; clusters: string[]; hypervisors?: string[] }>('/api/v1/workloads?' + qp);
|
||||
const r = await get<{ workloads: Workload[]; total: number; counts: Record<string, number>; kinds: Record<string, number>; namespaces: string[]; clusters: string[]; hypervisors?: string[]; platforms?: Record<string, number>; platform_of?: Record<string, string> }>('/api/v1/workloads?' + qp);
|
||||
rows = r.workloads;
|
||||
total = r.total;
|
||||
counts = r.counts;
|
||||
@@ -72,6 +76,8 @@
|
||||
namespaces = r.namespaces;
|
||||
clusters = r.clusters;
|
||||
hypervisors = r.hypervisors ?? [];
|
||||
platforms = r.platforms ?? {};
|
||||
platformOf = r.platform_of ?? {};
|
||||
error = '';
|
||||
loaded = true;
|
||||
} catch (e) {
|
||||
@@ -93,7 +99,10 @@
|
||||
const kindNames: Record<string, string> = { node: 'Nodes', pod: 'Pods', controller: 'Controllers', job: 'Jobs', pvc: 'Volumes', vm: 'VMs', service: 'Services', ingress: 'Ingresses', cert: 'Certificates' };
|
||||
const kindWord: Record<string, string> = { node: 'Node', pod: 'Pod', controller: 'Controller', job: 'Job', pvc: 'Volume', vm: 'VM', service: 'Service', ingress: 'Ingress', cert: 'Certificate' };
|
||||
const set = (fn: () => void) => { fn(); offset = 0; open = null; };
|
||||
const clear = () => set(() => { source = ''; kind = ''; ns = ''; node = ''; owner = ''; show = ''; typed = ''; q = ''; });
|
||||
const clear = () => set(() => { source = ''; platform = ''; kind = ''; ns = ''; node = ''; owner = ''; show = ''; typed = ''; q = ''; });
|
||||
// Most workloads first, so the platform chips read biggest to smallest.
|
||||
const platformList = $derived(Object.entries(platforms).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])));
|
||||
const pick = (name: string, label: string) => (platformOf[name] ? `${label} · ${platformOf[name]}` : label);
|
||||
const fact = (v: unknown) => (typeof v === 'object' ? JSON.stringify(v) : String(v));
|
||||
</script>
|
||||
|
||||
@@ -114,10 +123,10 @@
|
||||
<select class="input" aria-label="Cluster or host" value={source} onchange={(e) => set(() => { source = e.currentTarget.value; ns = ''; })}>
|
||||
<option value="">Every cluster and host</option>
|
||||
{#if hypervisors.length}
|
||||
<optgroup label="Clusters">{#each clusters as c}<option value={c}>{sourceLabel(c)}</option>{/each}</optgroup>
|
||||
<optgroup label="Hosts running VMs">{#each hypervisors as h}<option value={h}>{h}</option>{/each}</optgroup>
|
||||
<optgroup label="Clusters">{#each clusters as c}<option value={c}>{pick(c, sourceLabel(c))}</option>{/each}</optgroup>
|
||||
<optgroup label="Hosts running VMs">{#each hypervisors as h}<option value={h}>{pick(h, h)}</option>{/each}</optgroup>
|
||||
{:else}
|
||||
{#each clusters as c}<option value={c}>{sourceLabel(c)}</option>{/each}
|
||||
{#each clusters as c}<option value={c}>{pick(c, sourceLabel(c))}</option>{/each}
|
||||
{/if}
|
||||
</select>
|
||||
{/if}
|
||||
@@ -131,6 +140,15 @@
|
||||
<button class="chip" class:on={show === k} onclick={() => set(() => (show = k))}>{label} <b>{showCount(k)}</b></button>
|
||||
{/each}
|
||||
</div>
|
||||
{#if platformList.length > 1 || platform}
|
||||
<div class="filters kinds" role="group" aria-label="Platform">
|
||||
<button class="chip" class:on={platform === ''} onclick={() => set(() => (platform = ''))}>Every platform</button>
|
||||
{#each platformList as [p, n] (p)}
|
||||
<button class="chip" class:on={platform === p} onclick={() => set(() => { platform = p; source = ''; ns = ''; })}><Platform {p} /> <b>{n}</b></button>
|
||||
{/each}
|
||||
{#if platform && !platforms[platform]}<button class="chip on" onclick={() => set(() => (platform = ''))}>On {platform} ×</button>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="filters kinds">
|
||||
<button class="chip" class:on={kind === ''} onclick={() => set(() => (kind = ''))}>Every kind</button>
|
||||
{#each Object.keys(kindNames) as k}
|
||||
@@ -139,7 +157,7 @@
|
||||
{#if node}<button class="chip on" onclick={() => set(() => (node = ''))}>On {node} ×</button>{/if}
|
||||
{#if owner}<button class="chip on" onclick={() => set(() => (owner = ''))}>Of {owner} ×</button>{/if}
|
||||
{#if source && clusters.length + hypervisors.length <= 1}<button class="chip on" onclick={() => set(() => { source = ''; ns = ''; })}>In {sourceLabel(source)} ×</button>{/if}
|
||||
{#if source || kind || ns || node || owner || show || q}<button class="btn sm" onclick={clear}>Clear</button>{/if}
|
||||
{#if source || platform || kind || ns || node || owner || show || q}<button class="btn sm" onclick={clear}>Clear</button>{/if}
|
||||
</div>
|
||||
|
||||
<div class="tbl-wrap">
|
||||
@@ -153,7 +171,7 @@
|
||||
<td class="sub">{kindWord[w.kind] ?? w.kind}</td>
|
||||
<td class="sub mono use">{#if w.usage}{cores(w.usage.cpu)} CPU{#if w.usage.cpu_pct}{' '}<b class:hot={w.usage.cpu_pct >= 90}>{Math.round(w.usage.cpu_pct)}%</b>{/if} · {bytes(w.usage.mem)}{#if w.usage.mem_pct}{' '}<b class:hot={w.usage.mem_pct >= 90}>{Math.round(w.usage.mem_pct)}%</b>{/if}{:else}—{/if}</td>
|
||||
<td class="mono sub">{#if w.node}<button class="link" onclick={(e) => { e.stopPropagation(); set(() => { node = w.node ?? ''; source = w.source; }); }}>{w.node}</button>{:else}—{/if}</td>
|
||||
<td class="sub">{#if hypervisors.includes(w.source)}<a href="/hosts/{w.source}">{w.source}</a>{:else}{sourceLabel(w.source)}{/if}</td>
|
||||
<td class="sub where">{#if hypervisors.includes(w.source)}<a href="/hosts/{w.source}">{w.source}</a>{:else}{sourceLabel(w.source)}{/if} <Platform p={w.platform} /></td>
|
||||
<td class="sub">{w.since ? ago(w.since) : '—'}</td>
|
||||
</tr>
|
||||
{#if open === w.source + '/' + w.id}
|
||||
@@ -193,6 +211,8 @@
|
||||
|
||||
<style>
|
||||
.kinds { margin-top: -6px; }
|
||||
.where :global(.plat) { margin-left: 2px; }
|
||||
.chip :global(.plat) { border: 0; padding: 0; background: none; font-size: inherit; font-weight: inherit; }
|
||||
.row { cursor: pointer; }
|
||||
.row.sel td { background: var(--accent); }
|
||||
.nm { font-weight: 600; }
|
||||
|
||||
Reference in new issue
Block a user