feat(ui): operator triage board + richer pods table columns (#24)

Triage board (`:triage`/`:issues [namespace|all]`): a live, worst-first board of
only the pods needing an operator's attention — CrashLoopBackOff/OOMKilled/
ImagePullBackOff/Error (critical), Pending/NotReady/restart-hot ≥3 (warning).
Healthy pods are omitted; the title summarizes `N critical · M warning`; capped
at 500 rows worst-first. Rebuilt from store state each frame; navigate j/k+g/G,
esc closes. This is the daily-driver "is anything wrong, and where" view.

Pods table gained the columns operators expect:
RST · CPU · %CPU/R · %CPU/L · MEM · %MEM/R · %MEM/L · IP · NODE. RST (container
restarts) colors yellow at ≥3, red at ≥10. Metric headers are the explicit
%CPU/R-style form.

Model: add `restarts`, `ready`, and `pod_ip` to the lean `Extracted` (the
crashloop/readiness/IP signals the status string and prior columns lacked).
Also fixed `classify_status_severity` to flag `*BackOff`/`ImagePullBackOff` as
critical (was silently Ok) — corrects table coloring too.

Tests: restart/readiness/IP extraction; triage selection + worst-first ordering
+ counts; pods table renders RST/IP/NODE and the percentage columns.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
ErfanandClaude Opus 4.8 authored and GitHub committed 2026-06-26 00:06:06 +02:00
1 parent 589a5d859e
commit dadb18d10c
11 files changed
+474 -37

No files matched your search

+10
View File
@@ -249,6 +249,16 @@ Root problem: full object JSON kept for every entity.
or `sh.helm.release.v1.*` name); filtered at the projection layer. Tests: model detection,
projector hide/show, render+toggle integration.
Remaining: revisit when new views/commands land (e.g. interactive dynamic-list overlay).
- [x] **5.6 Triage board** — operator daily-driver "what needs attention" view (`:triage`/`:issues
[ns|all]`): a live, worst-first board of only the pods needing an eye — CrashLoopBackOff/OOMKilled/
ImagePullBackOff/Error (critical), Pending/NotReady/restart-hot ≥3 (warning). Reuses existing
severity + adds `restarts`/`ready` to `Extracted` (crashloop + readiness signals the status string
hides). Title summarizes `N critical · M warning`; healthy pods omitted; capped at 500 rows
worst-first. Also fixed `classify_status_severity` to flag `ImagePullBackOff`/`*BackOff` (was Ok)
— improves table coloring too. The pods table also gained `RST` (restarts, colored ≥3/≥10),
`IP`, and `NODE` columns (pod IP added to `Extracted`); metric headers are now the explicit
`%CPU/R`/`%CPU/L`/`%MEM/R`/`%MEM/L`. Next: per-tenant (namespace) health rollup; workload rollout
health (ready≠desired).
- [ ] **5.3 Config defaults for large fleets** — review fps_limit / delta_channel_capacity /
warm_contexts / TTL defaults; document tuning.
- [ ] **5.4 Docs refresh** — architecture/performance/operator guides updated to new model.
+29 -9
View File
@@ -99,20 +99,24 @@ each kind shows columns tailored to it (like `kubectl get`), e.g.:
Kinds without distinctive columns show just the four universal ones. Pods are special — see Metrics.
Filtering and `:dump`/copy operate over all visible columns.
The **Pods table** adds, beyond the universal four:
`RST` (container restarts) · `CPU %CPU/R %CPU/L` · `MEM %MEM/R %MEM/L` · `IP` · `NODE`. `RST` turns
yellow at ≥3 restarts, red at ≥10 (crashloop signal); the metric columns are described below.
## Metrics
If the cluster has a metrics-server (`metrics.k8s.io`), krust shows live usage and right-sizing.
The **Pods table** splits this into six right-aligned, fixed-width columns — `CPU CR CL` then
`MEM MR ML`:
The **Pods table** splits this into six right-aligned columns — `CPU %CPU/R %CPU/L` then
`MEM %MEM/R %MEM/L`:
- **CPU** / **MEM** — actual usage (e.g. `1.50c`, `256Mi`).
- **CR** / **MR** — usage as a percentage of the CPU/memory **request** (the right-sizing signal:
low = over-provisioned, ≥100 = under-requested). Turns yellow at ≥100%.
- **CL** / **ML** — usage as a percentage of the CPU/memory **limit** (the risk signal). Turns red
at ≥90% (throttle/OOM risk).
- **%CPU/R** / **%MEM/R** — usage as a percentage of the CPU/memory **request** (the right-sizing
signal: low = over-provisioned, ≥100 = under-requested). Turns yellow at ≥100%.
- **%CPU/L** / **%MEM/L** — usage as a percentage of the CPU/memory **limit** (the risk signal).
Turns red at ≥90% (throttle/OOM risk).
So a pod showing CPU `1.50c`, CR `150%`, CL `75%` is using 1.5 cores, 150% of its CPU request, and
75% of its CPU limit. Missing pieces (no request/limit, or no metrics) render as `-`. The **Cluster
Pulse** panel shows a `[USE]` row: cluster cpu/mem used vs allocatable + util%.
So a pod showing CPU `1.50c`, %CPU/R `150%`, %CPU/L `75%` is using 1.5 cores, 150% of its CPU
request, and 75% of its CPU limit. Missing pieces (no request/limit, or no metrics) render as `-`.
The **Cluster Pulse** panel shows a `[USE]` row: cluster cpu/mem used vs allocatable + util%.
Without a metrics-server these degrade gracefully (columns show `-`, the table title notes
`metrics-server n/a`, and the pulse falls back to request/limit-based numbers).
@@ -154,6 +158,7 @@ Common command mode entries:
- `:ns` namespaces
- `:po`, `:deploy`, `:svc`, `:ing`, `:cm`, `:sec`, etc.
- `:api [filter]` list all API resources/CRDs discovered on the context
- `:triage [namespace|all]` (alias `:issues`) board of pods needing attention, worst first
- `:xray [namespace|all]` open the namespace ownership graph (workloads → pods → containers)
- `:<resource>` browse any discovered resource/CRD (e.g. `:endpoints`, `:widgets`); `:<resource> <name>` describes one
- `:fmt yaml|json`
@@ -161,6 +166,21 @@ Common command mode entries:
- `:sort <name|namespace|status|age> [asc|desc]` set the table sort column/direction
- `:helm [show|hide]` toggle (or set) visibility of Helm release secrets in the Secrets list
## Triage (what needs attention)
`:triage [namespace|all]` (alias `:issues`; defaults to the current namespace, `all` = whole cluster)
opens a live board of only the pods that need an operator's eye, worst severity first:
- **Critical** (`[XX]`): CrashLoopBackOff, OOMKilled, ImagePullBackOff, Error, Evicted, Failed, …
- **Warning** (`[!!]`): Pending/Unschedulable, NotReady (Running but failing its readiness probe —
e.g. a slow JVM start), and restart hotspots (≥3 container restarts)
Columns: severity · namespace · pod · reason · restarts · ready · age. Healthy pods
(Running + Ready + few restarts) are omitted entirely, so the board is empty when nothing is wrong.
The title summarizes counts (`N critical · M warning`). It rebuilds from live cluster state each
frame; navigate with `j`/`k` (+ `g`/`G`), `esc` closes. Large incidents are capped at 500 rows
(worst-first) with the count shown.
## XRay (relationship graph)
`:xray [namespace]` opens a live ownership graph of a namespace — a single forest rooted at the
+63
View File
@@ -16,6 +16,13 @@ pub(crate) fn extracted_for(kind: ResourceKind, raw: &Value) -> Extracted {
.map(str::to_string),
_ => None,
},
pod_ip: match kind {
ResourceKind::Pods => raw
.pointer("/status/podIP")
.and_then(Value::as_str)
.map(str::to_string),
_ => None,
},
containers: match kind {
ResourceKind::Pods => container_names(raw),
_ => Vec::new(),
@@ -29,9 +36,45 @@ pub(crate) fn extracted_for(kind: ResourceKind, raw: &Value) -> Extracted {
ResourceKind::Nodes => Some(node_capacity(raw)),
_ => None,
},
restarts: match kind {
ResourceKind::Pods => pod_restarts(raw),
_ => 0,
},
// Non-pod kinds don't have pod readiness; treat them as ready so they're never flagged.
ready: match kind {
ResourceKind::Pods => pod_ready(raw),
_ => true,
},
}
}
/// Sum of container restart counts across a pod's containers.
fn pod_restarts(raw: &Value) -> u32 {
raw.pointer("/status/containerStatuses")
.and_then(Value::as_array)
.map(|statuses| {
statuses
.iter()
.filter_map(|s| s.get("restartCount").and_then(Value::as_u64))
.map(|c| c as u32)
.sum()
})
.unwrap_or(0)
}
/// Whether the pod's `Ready` condition is True.
fn pod_ready(raw: &Value) -> bool {
raw.pointer("/status/conditions")
.and_then(Value::as_array)
.map(|conds| {
conds.iter().any(|c| {
c.get("type").and_then(Value::as_str) == Some("Ready")
&& c.get("status").and_then(Value::as_str) == Some("True")
})
})
.unwrap_or(false)
}
fn container_names(raw: &Value) -> Vec<String> {
raw.pointer("/spec/containers")
.and_then(Value::as_array)
@@ -286,6 +329,26 @@ mod tests {
assert_eq!(r.mem_request_b, (64 + 32) * 1024 * 1024);
}
#[test]
fn extracts_pod_restarts_and_readiness() {
let raw = json!({
"status": {
"conditions": [ { "type": "Ready", "status": "False" } ],
"containerStatuses": [
{ "name": "app", "restartCount": 5 },
{ "name": "side", "restartCount": 2 }
]
}
});
let e = extracted_for(ResourceKind::Pods, &raw);
assert_eq!(e.restarts, 7);
assert!(!e.ready);
// Non-pods are treated as ready with no restarts (never triaged on those signals).
let svc = extracted_for(ResourceKind::Services, &json!({}));
assert!(svc.ready && svc.restarts == 0);
}
#[test]
fn parses_real_metrics_usage_units() {
// formats seen on a real cluster: nanocores + Ki memory
+7
View File
@@ -278,6 +278,8 @@ pub struct ResourceEntity {
pub struct Extracted {
/// Pod's scheduled node (pods only).
pub node_name: Option<String>,
/// Pod IP (pods only) — shown in the pods table.
pub pod_ip: Option<String>,
/// Pod container names (pods only) — used by the container picker and log fan-in.
pub containers: Vec<String>,
/// ownerReferences (kind,name) — used to map Deployment -> ReplicaSet -> Pod for logs.
@@ -286,6 +288,11 @@ pub struct Extracted {
pub pod_resources: Option<PodResources>,
/// Node capacity/condition summary (nodes only) — used by the cluster pulse.
pub node_capacity: Option<NodeCapacity>,
/// Total container restarts (pods only) — crashloop signal for the triage board.
pub restarts: u32,
/// Whether the pod's Ready condition holds (pods only; true for kinds where it doesn't apply).
/// A Running-but-not-Ready pod (failing readiness probe / slow JVM start) is a triage signal.
pub ready: bool,
}
impl ResourceEntity {
+118 -13
View File
@@ -82,6 +82,7 @@ mod detail_pane;
mod logs;
mod overlay;
mod render_loop;
mod triage;
mod xray;
#[derive(Debug, Clone)]
@@ -188,6 +189,13 @@ enum Overlay {
selected: usize,
collapsed: HashSet<String>,
},
/// Live triage board (`:triage`): pods needing attention (crashloop/OOM/pending/not-ready/
/// restart-hot), worst first. Rows rebuilt from the store each frame. `namespace` None =
/// whole cluster.
Triage {
namespace: Option<String>,
selected: usize,
},
Contexts {
title: String,
contexts: Vec<String>,
@@ -817,7 +825,7 @@ impl App {
| Overlay::LogSources { filter, .. } => {
return filter.clone();
}
Overlay::Text { .. } | Overlay::Xray { .. } => {}
Overlay::Text { .. } | Overlay::Xray { .. } | Overlay::Triage { .. } => {}
}
}
let tab = self.current_tab();
@@ -845,7 +853,7 @@ impl App {
} => {
*overlay_filter = filter;
}
Overlay::Text { .. } | Overlay::Xray { .. } => {}
Overlay::Text { .. } | Overlay::Xray { .. } | Overlay::Triage { .. } => {}
}
return;
}
@@ -875,7 +883,7 @@ impl App {
Overlay::Contexts { .. }
| Overlay::Containers { .. }
| Overlay::LogSources { .. } => "Filter",
Overlay::Text { .. } | Overlay::Xray { .. } => "Search",
Overlay::Text { .. } | Overlay::Xray { .. } | Overlay::Triage { .. } => "Search",
};
}
if self.current_tab().pane == Pane::Table {
@@ -1378,6 +1386,27 @@ impl App {
.join("\n"),
)
}
Overlay::Triage { namespace, .. } => {
let (items, _) = self.triage_items(namespace.as_deref());
Some(
items
.iter()
.map(|i| {
format!(
"{} {}/{} {} restarts:{} ready:{} {}",
severity_tag(i.severity),
i.namespace,
i.name,
i.reason,
i.restarts,
if i.ready { "yes" } else { "no" },
i.age
)
})
.collect::<Vec<_>>()
.join("\n"),
)
}
Overlay::Contexts {
contexts,
selected,
@@ -1829,6 +1858,16 @@ impl App {
}
}
}
// The triage board scans pods for problems, so it needs pods watched in its scope.
if let Some(Overlay::Triage { namespace, .. }) = &self.overlay {
let target = WatchTarget {
kind: ResourceKind::Pods,
namespace: namespace.clone(),
};
if !targets.contains(&target) {
targets.push(target);
}
}
if let Err(err) = self
.resource_provider
.replace_watch_plan(&tab.context, &targets)
@@ -2560,14 +2599,15 @@ mod tests {
use tokio::sync::mpsc;
use super::{
App, ColorSupport, ResourceAlias, base64_decode, base64_encode, classify_status_severity,
color_support_label, command_names, decoded_secret_text, detect_color_support_from_env,
highlighted_json_text, highlighted_text, highlighted_yaml_text, is_auth_refresh_log_error,
is_retryable_log_error, is_visible_log_line, json_spans_for_line,
next_log_reconnect_backoff_ms, parse_log_source, parse_resource_alias,
resolved_active_match_line, resource_alias_names, search_match_lines_in_logs, severity_tag,
slice_chars, step_match_line, sync_table_viewport, table_viewport_rows,
truncate_for_clipboard, ui_theme_for, yaml_spans_for_line,
App, ColorSupport, ResourceAlias, Severity, base64_decode, base64_encode,
classify_status_severity, color_support_label, command_names, decoded_secret_text,
detect_color_support_from_env, highlighted_json_text, highlighted_text,
highlighted_yaml_text, is_auth_refresh_log_error, is_retryable_log_error,
is_visible_log_line, json_spans_for_line, next_log_reconnect_backoff_ms, parse_log_source,
parse_resource_alias, resolved_active_match_line, resource_alias_names,
search_match_lines_in_logs, severity_tag, slice_chars, step_match_line,
sync_table_viewport, table_viewport_rows, truncate_for_clipboard, ui_theme_for,
yaml_spans_for_line,
};
use crate::{
cluster::{
@@ -3196,10 +3236,13 @@ mod tests {
mem_request_b: 128 * 1024 * 1024,
mem_limit_b: 512 * 1024 * 1024,
});
entity.extracted.restarts = 7;
entity.extracted.pod_ip = Some("10.0.1.23".to_string());
entity.extracted.node_name = Some("ip-10-0-1-9.ec2.internal".to_string());
app.store.apply(StateDelta::Upsert(entity));
app.seed_pod_metrics_for_test("default", "pod-a", 1500, 256 * 1024 * 1024);
let snap = render_snapshot(&mut app, 160, 20);
let snap = render_snapshot(&mut app, 200, 20);
// actual usage
assert!(snap.contains("1.50c"), "cpu used: {snap}");
assert!(snap.contains("256Mi"), "mem used: {snap}");
@@ -3212,6 +3255,11 @@ mod tests {
snap.contains("200%") && snap.contains("50%"),
"mem %R/%L: {snap}"
); // 256/128, 256/512
// restarts, IP, and node columns
assert!(snap.contains("RST"), "restarts header: {snap}");
assert!(snap.contains('7'), "restart count: {snap}");
assert!(snap.contains("10.0.1.23"), "pod ip: {snap}");
assert!(snap.contains("ip-10-0-1-9.ec2.internal"), "node: {snap}");
}
#[test]
@@ -3383,6 +3431,63 @@ mod tests {
assert_eq!(rows[0].marker, '▸', "collapsed marker");
}
#[test]
fn triage_surfaces_unhealthy_pods_worst_first() {
let mut app = test_app();
let mut healthy = mk_entity(
"ctx-dev",
ResourceKind::Pods,
Some("default"),
"ok",
"Running",
);
healthy.extracted.ready = true;
app.store.apply(StateDelta::Upsert(healthy));
let mut crash = mk_entity(
"ctx-dev",
ResourceKind::Pods,
Some("default"),
"crash",
"CrashLoopBackOff",
);
crash.extracted.ready = false;
crash.extracted.restarts = 9;
app.store.apply(StateDelta::Upsert(crash));
let mut pending = mk_entity(
"ctx-dev",
ResourceKind::Pods,
Some("default"),
"pending",
"Pending",
);
pending.extracted.ready = false;
app.store.apply(StateDelta::Upsert(pending));
let mut notready = mk_entity(
"ctx-dev",
ResourceKind::Pods,
Some("default"),
"slow",
"Running",
);
notready.extracted.ready = false; // Running but failing readiness
app.store.apply(StateDelta::Upsert(notready));
let (items, total) = app.triage_items(Some("default"));
let names: Vec<&str> = items.iter().map(|i| i.name.as_str()).collect();
assert_eq!(total, 3, "healthy pod excluded: {names:?}");
assert!(!names.contains(&"ok"), "healthy excluded: {names:?}");
// Worst-first: the crashloop (Err) ranks above the warnings.
assert_eq!(items[0].name, "crash");
assert_eq!(items[0].severity, Severity::Err);
let (errs, warns) = App::triage_counts(&items);
assert_eq!((errs, warns), (1, 2));
let slow = items.iter().find(|i| i.name == "slow").expect("slow");
assert_eq!(slow.reason, "NotReady");
}
#[test]
fn xray_arrow_keys_collapse_and_expand() {
let mut app = test_app();
@@ -3561,7 +3666,7 @@ mod tests {
"CrashLoopBackOff",
)));
let snap = render_snapshot(&mut app, 120, 32);
let snap = render_snapshot(&mut app, 200, 32);
assert!(snap.contains("[CTX]"));
assert!(snap.contains("[PULSE] Cluster Pulse"));
assert!(snap.contains("[LIVE]"));
+10
View File
@@ -399,6 +399,16 @@ impl App {
self.show_xray_overlay(namespace);
false
}
"triage" | "issues" => {
// :triage [namespace|all] — default to the current namespace; `all` = whole cluster.
let namespace = match args.first() {
Some(token) if token.eq_ignore_ascii_case("all") => None,
Some(token) => Some(token.to_string()),
None => self.current_tab().namespace.clone(),
};
self.show_triage_overlay(namespace);
false
}
"pulse" | "pulses" | "pu" | "popeye" | "pop" | "plugins" | "plugin" => {
self.status_line =
format!("Command ':{cmd}' is recognized but not implemented yet");
+7 -3
View File
@@ -266,7 +266,7 @@ impl App {
*scroll = scroll.saturating_add(delta as u16);
}
}
Some(Overlay::Xray { selected, .. }) => {
Some(Overlay::Xray { selected, .. } | Overlay::Triage { selected, .. }) => {
if delta < 0 {
*selected = selected.saturating_sub(delta.unsigned_abs() as usize);
} else {
@@ -359,7 +359,9 @@ impl App {
pub(super) fn overlay_home(&mut self) {
match &mut self.overlay {
Some(Overlay::Text { scroll, .. }) => *scroll = 0,
Some(Overlay::Xray { selected, .. }) => *selected = 0,
Some(Overlay::Xray { selected, .. } | Overlay::Triage { selected, .. }) => {
*selected = 0
}
Some(Overlay::Contexts {
contexts,
selected,
@@ -395,7 +397,9 @@ impl App {
match &mut self.overlay {
Some(Overlay::Text { scroll, .. }) => *scroll = u16::MAX,
// Clamped to the row count in render.
Some(Overlay::Xray { selected, .. }) => *selected = usize::MAX,
Some(Overlay::Xray { selected, .. } | Overlay::Triage { selected, .. }) => {
*selected = usize::MAX
}
Some(Overlay::Contexts {
contexts,
selected,
+125 -12
View File
@@ -477,6 +477,11 @@ impl App {
} else {
None
};
let triage_data = if let Some(Overlay::Triage { namespace, .. }) = &self.overlay {
Some(self.triage_items(namespace.as_deref()))
} else {
None
};
if let Some(overlay) = &mut self.overlay {
match overlay {
@@ -564,6 +569,83 @@ impl App {
frame.render_stateful_widget(table, chunks[2], &mut state);
}
}
Overlay::Triage {
namespace,
selected,
} => {
let scope = namespace.as_deref().unwrap_or("all namespaces");
let (items, total) = triage_data.unwrap_or_default();
let (errs, warns) = App::triage_counts(&items);
let shown = items.len();
let title = if total == 0 {
format!("[TRIAGE] {scope} · ✓ nothing needs attention")
} else {
let capped = if total > shown {
format!(" · showing {shown}/{total}")
} else {
String::new()
};
format!(
"[TRIAGE] {scope} · {errs} critical · {warns} warning{capped} | j/k move · esc close"
)
};
let block = Block::default().borders(Borders::ALL).title(title);
if items.is_empty() {
frame.render_widget(
Paragraph::new(
"✓ no crashloops, OOMs, pending, not-ready, or restart-hot pods in scope",
)
.block(block)
.style(theme.block),
chunks[2],
);
} else {
*selected = (*selected).min(items.len().saturating_sub(1));
let header = Row::new(vec![
Cell::from(""),
Cell::from("NAMESPACE"),
Cell::from("POD"),
Cell::from("REASON"),
Cell::from("RESTARTS"),
Cell::from("READY"),
Cell::from("AGE"),
])
.style(theme.table_header);
let rows: Vec<Row<'_>> = items
.iter()
.map(|item| {
let style = severity_style(&theme, item.severity);
Row::new(vec![
Cell::from(severity_tag(item.severity)),
Cell::from(item.namespace.clone()),
Cell::from(item.name.clone()),
Cell::from(item.reason.clone()),
Cell::from(item.restarts.to_string()),
Cell::from(if item.ready { "yes" } else { "no" }),
Cell::from(item.age.clone()),
])
.style(style)
})
.collect();
let widths = [
Constraint::Length(4),
Constraint::Length(20),
Constraint::Min(24),
Constraint::Length(20),
Constraint::Length(8),
Constraint::Length(5),
Constraint::Length(6),
];
let table = Table::new(rows, widths)
.header(header)
.column_spacing(2)
.block(block)
.row_highlight_style(theme.row_highlight);
let mut state =
ratatui::widgets::TableState::default().with_selected(Some(*selected));
frame.render_stateful_widget(table, chunks[2], &mut state);
}
}
Overlay::Contexts {
title,
contexts,
@@ -730,8 +812,23 @@ impl App {
let status = format!("{} {}", severity_tag(sev), row.status);
let cells = if pods_view {
let usage = self.pod_usage(key.namespace.as_deref(), &key.name);
let res =
self.store.get(key).and_then(|e| e.extracted.pod_resources);
let entity = self.store.get(key);
let res = entity.and_then(|e| e.extracted.pod_resources);
let restarts = entity.map(|e| e.extracted.restarts).unwrap_or(0);
let restart_sev = if restarts >= 10 {
Severity::Err
} else if restarts >= 3 {
Severity::Warn
} else {
Severity::Ok
};
let dash = || "-".to_string();
let ip = entity
.and_then(|e| e.extracted.pod_ip.clone())
.unwrap_or_else(dash);
let node = entity
.and_then(|e| e.extracted.node_name.clone())
.unwrap_or_else(dash);
let cpu = pod_usage_cells(
usage.map(|(c, _)| c),
res.map(|r| r.cpu_request_m).unwrap_or(0),
@@ -754,12 +851,15 @@ impl App {
Cell::from(row.name),
Cell::from(status),
Cell::from(row.age),
num(restarts.to_string(), restart_sev),
num(cpu.used, Severity::Ok),
num(cpu.req_pct, cpu.req_sev),
num(cpu.lim_pct, cpu.lim_sev),
num(mem.used, Severity::Ok),
num(mem.req_pct, mem.req_sev),
num(mem.lim_pct, mem.lim_sev),
Cell::from(ip),
Cell::from(node),
]
} else {
let mut cells = vec![
@@ -797,24 +897,30 @@ impl App {
mark("Name", SortColumn::Name),
mark("Status", SortColumn::Status),
mark("Age", SortColumn::Age),
num_head("RST"),
num_head("CPU"),
num_head("CR"),
num_head("CL"),
num_head("%CPU/R"),
num_head("%CPU/L"),
num_head("MEM"),
num_head("MR"),
num_head("ML"),
num_head("%MEM/R"),
num_head("%MEM/L"),
Cell::from("IP"),
Cell::from("NODE"),
],
vec![
Constraint::Length(16),
Constraint::Min(20),
Constraint::Min(18),
Constraint::Length(16),
Constraint::Length(6),
Constraint::Length(4),
Constraint::Length(8),
Constraint::Length(6),
Constraint::Length(6),
Constraint::Length(7),
Constraint::Length(7),
Constraint::Length(9),
Constraint::Length(6),
Constraint::Length(6),
Constraint::Length(7),
Constraint::Length(7),
Constraint::Length(16),
Constraint::Min(18),
],
)
} else {
@@ -849,7 +955,7 @@ impl App {
let legend = if self.pod_metrics.is_empty() {
"CPU/MEM: metrics-server n/a"
} else {
"CPU/MEM used · CR/CL = cpu %req/%lim · MR/ML = mem %req/%lim"
"CPU/MEM = live usage · %·/R vs request · %·/L vs limit"
};
format!("[KIND] {} ({}) · {legend}", active.kind(), vm.len())
}
@@ -1208,6 +1314,13 @@ impl App {
"Esc close",
]
.join(" | "),
Overlay::Triage { .. } => [
"overlay:triage",
"j/k or up/down move",
"g/G top/bottom",
"Esc close",
]
.join(" | "),
};
}
+101
View File
@@ -0,0 +1,101 @@
use super::*;
/// Flag a pod once its restarts reach this, even if it currently looks healthy (recovered crashloop).
const RESTART_ATTENTION: u32 = 3;
/// Cap triage rows so a melting-down cluster can't produce an unbounded list (sorted worst-first).
const TRIAGE_MAX_ROWS: usize = 500;
/// One row of the triage board: a pod that needs an operator's attention.
pub(super) struct TriageItem {
pub severity: Severity,
pub namespace: String,
pub name: String,
pub reason: String,
pub restarts: u32,
pub ready: bool,
pub age: String,
}
impl App {
/// Open the live triage board ("what needs attention"). `namespace` None = whole cluster.
pub(super) fn show_triage_overlay(&mut self, namespace: Option<String>) {
self.overlay = Some(Overlay::Triage {
namespace,
selected: 0,
});
self.status_line = "triage".to_string();
}
/// Compute the triage rows from current store state (rebuilt each frame), worst severity first
/// then most restarts. Returns `(rows, total_before_cap)`.
pub(super) fn triage_items(&self, namespace: Option<&str>) -> (Vec<TriageItem>, usize) {
let context = self.current_tab().context.clone();
let mut items: Vec<TriageItem> = self
.store
.list(&context, ResourceKind::Pods, namespace)
.into_iter()
.filter_map(|pod| triage_item(pod))
.collect();
// Worst first; within a severity, most restarts; then newest (likely the active incident).
items.sort_by(|a, b| {
severity_rank(b.severity)
.cmp(&severity_rank(a.severity))
.then(b.restarts.cmp(&a.restarts))
.then(a.name.cmp(&b.name))
});
let total = items.len();
items.truncate(TRIAGE_MAX_ROWS);
(items, total)
}
/// Counts by severity over the full (pre-cap) item set, for the header summary.
pub(super) fn triage_counts(items: &[TriageItem]) -> (usize, usize) {
let err = items.iter().filter(|i| i.severity == Severity::Err).count();
let warn = items
.iter()
.filter(|i| i.severity == Severity::Warn)
.count();
(err, warn)
}
}
/// Build a triage row for a pod if it needs attention, else None.
fn triage_item(pod: &crate::model::ResourceEntity) -> Option<TriageItem> {
let status = &pod.status;
let ready = pod.extracted.ready;
let restarts = pod.extracted.restarts;
let status_severity = classify_status_severity(status);
// The status string already flags a problem (CrashLoopBackOff, OOMKilled, Pending, …).
if status_severity != Severity::Ok {
return Some(item(pod, status_severity, status.clone()));
}
// Otherwise surface the two signals a plain phase ("Running") hides.
if !ready {
return Some(item(pod, Severity::Warn, "NotReady".to_string()));
}
if restarts >= RESTART_ATTENTION {
return Some(item(pod, Severity::Warn, format!("Restarts×{restarts}")));
}
None // healthy: Running + Ready + few restarts
}
fn item(pod: &crate::model::ResourceEntity, severity: Severity, reason: String) -> TriageItem {
TriageItem {
severity,
namespace: pod.key.namespace.clone().unwrap_or_else(|| "-".to_string()),
name: pod.key.name.clone(),
reason,
restarts: pod.extracted.restarts,
ready: pod.extracted.ready,
age: short_age(pod.age),
}
}
fn severity_rank(severity: Severity) -> u8 {
match severity {
Severity::Err => 2,
Severity::Warn => 1,
Severity::Ok => 0,
}
}
+2
View File
@@ -52,6 +52,8 @@ pub(crate) fn command_names() -> &'static [&'static str] {
"pulses",
"pu",
"xray",
"triage",
"issues",
"popeye",
"pop",
"plugins",
+2
View File
@@ -172,6 +172,8 @@ pub(crate) fn classify_status_severity(status: &str) -> Severity {
|| lower.contains("fail")
|| lower.contains("crash")
|| lower.contains("oom")
|| lower.contains("backoff")
|| lower.contains("imagepull")
|| lower.contains("forbidden")
|| lower.contains("denied")
|| lower.contains("blocked")