@skyhook-io/radar-app 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +42 -7
- package/src/api/apiResources.test.ts +11 -0
- package/src/api/apiResources.ts +51 -12
- package/src/api/client.capacity.test.ts +92 -0
- package/src/api/client.ts +2884 -2075
- package/src/api/diagnose.ts +5 -0
- package/src/components/ConnectionErrorView.test.tsx +88 -0
- package/src/components/ConnectionErrorView.tsx +128 -22
- package/src/components/capacity/CapacityActivity.tsx +787 -0
- package/src/components/capacity/CapacityDemand.tsx +961 -0
- package/src/components/capacity/CapacityOverview.tsx +1529 -0
- package/src/components/capacity/CapacityPoolDetail.tsx +1626 -0
- package/src/components/capacity/CapacityView.test.tsx +2287 -0
- package/src/components/capacity/CapacityView.tsx +85 -0
- package/src/components/capacity/ClusterSchedulingCard.tsx +603 -0
- package/src/components/capacity/DemandNomination.test.tsx +151 -0
- package/src/components/capacity/certaintyGlyph.test.tsx +191 -0
- package/src/components/capacity/coverageCertainty.test.ts +162 -0
- package/src/components/capacity/podDemandGate.test.ts +47 -0
- package/src/components/capacity/podDemandGate.ts +22 -0
- package/src/components/capacity/schedulingBar.test.ts +244 -0
- package/src/components/capacity/shared.tsx +1841 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +117 -0
- package/src/components/diagnose/DiagnoseContext.tsx +51 -10
- package/src/components/diagnose/DiagnoseSurface.tsx +20 -7
- package/src/components/diagnose/LocalDiagnoseAction.tsx +50 -27
- package/src/components/diagnose/agentCatalog.ts +30 -0
- package/src/components/home/CapacityCard.test.tsx +150 -0
- package/src/components/home/CapacityCard.tsx +125 -0
- package/src/components/home/HomeView.tsx +15 -1
- package/src/components/issues/IssuesPane.test.ts +142 -0
- package/src/components/issues/IssuesPane.tsx +142 -38
- package/src/components/nav/PrimaryNavRail.test.tsx +20 -0
- package/src/components/nav/PrimaryNavRail.tsx +191 -103
- package/src/components/resources/renderers/KarpenterNodePoolRenderer.tsx +29 -1
- package/src/components/resources/renderers/PodRenderer.tsx +32 -3
- package/src/components/ui/command-items.ts +222 -98
- package/src/components/workload/WorkloadView.tsx +16 -83
- package/src/context/ConnectionContext.test.ts +39 -0
- package/src/context/ConnectionContext.tsx +155 -51
- package/src/utils/shell-safe.test.ts +55 -0
- package/src/utils/shell-safe.ts +21 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Layers3 } from 'lucide-react'
|
|
2
|
+
import { clsx } from 'clsx'
|
|
3
|
+
import { useCapacityOverview } from '../../api/client'
|
|
4
|
+
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
5
|
+
import { coverageIsLowerBound, humanizeCode } from '../capacity/shared'
|
|
6
|
+
|
|
7
|
+
// CapacityCard surfaces the cluster's capacity posture on the Home dashboard
|
|
8
|
+
// so morning triage reaches the Capacity view without knowing it exists. It
|
|
9
|
+
// renders whenever the cluster has a capacity story: Karpenter available, a
|
|
10
|
+
// Karpenter the caller is denied (softened rows, honest header — the denied
|
|
11
|
+
// Overview shape carries real node/pod truth), or detected managers/groups on
|
|
12
|
+
// a Karpenter-less cluster. Bare clusters with no story keep a quiet Home.
|
|
13
|
+
// Numbers the backend omitted (RBAC-denied / unobserved) render as "—",
|
|
14
|
+
// never zero.
|
|
15
|
+
export function CapacityCard({ onNavigate }: { onNavigate: () => void }) {
|
|
16
|
+
const karpenterState = useCapabilitiesContext().karpenter?.state
|
|
17
|
+
const mayHaveStory =
|
|
18
|
+
karpenterState === 'available' || karpenterState === 'denied' || karpenterState === 'not_detected'
|
|
19
|
+
const { data } = useCapacityOverview({ enabled: mayHaveStory })
|
|
20
|
+
if (!mayHaveStory || !data) return null
|
|
21
|
+
const karpenterDenied = data.state === 'denied'
|
|
22
|
+
const karpenterless = data.state === 'not_detected'
|
|
23
|
+
if (!karpenterDenied && !karpenterless && data.state !== 'available') return null
|
|
24
|
+
if (karpenterless && (data.summary.managers?.length ?? 0) === 0 && data.groups.length === 0)
|
|
25
|
+
return null
|
|
26
|
+
|
|
27
|
+
const actions = data.summary.actions ?? []
|
|
28
|
+
const worst = actions.find((a) => a.highestSeverity === 'critical') ?? actions.find((a) => a.highestSeverity === 'warning')
|
|
29
|
+
// A denied Karpenter must not read as healthy: "no signals" would be a
|
|
30
|
+
// claim about a fleet this identity cannot see.
|
|
31
|
+
const headerTone = karpenterDenied
|
|
32
|
+
? 'text-theme-text-tertiary'
|
|
33
|
+
: worst
|
|
34
|
+
? worst.highestSeverity === 'critical'
|
|
35
|
+
? 'text-red-500'
|
|
36
|
+
: 'text-amber-400'
|
|
37
|
+
: 'text-emerald-500'
|
|
38
|
+
const headerLabel = karpenterDenied
|
|
39
|
+
? 'Karpenter view unavailable'
|
|
40
|
+
: worst
|
|
41
|
+
? humanizeCode(worst.code)
|
|
42
|
+
: 'No active signals'
|
|
43
|
+
|
|
44
|
+
// Namespace-scoped pod coverage hides pending pods this identity cannot see,
|
|
45
|
+
// so the count is a floor — it must not read as the cluster total.
|
|
46
|
+
const pendingIsLowerBound = coverageIsLowerBound(data.coverage.pods)
|
|
47
|
+
const pendingStat = {
|
|
48
|
+
label: 'Pending pods',
|
|
49
|
+
value: absentAsDash(data.summary.pendingPodCount, pendingIsLowerBound ? '≥' : ''),
|
|
50
|
+
}
|
|
51
|
+
const stats: { label: string; value: string }[] = karpenterless
|
|
52
|
+
? [
|
|
53
|
+
{ label: 'Node groups', value: `${data.groups.length}` },
|
|
54
|
+
pendingStat,
|
|
55
|
+
{ label: 'Managers', value: `${data.summary.managers?.length ?? 0}` },
|
|
56
|
+
{ label: 'Nodes', value: absentAsDash(data.summary.nodeCount) },
|
|
57
|
+
]
|
|
58
|
+
: [
|
|
59
|
+
{ label: 'NodePools', value: absentAsDash(data.summary.poolCount) },
|
|
60
|
+
pendingStat,
|
|
61
|
+
{ label: 'NodeClaims', value: absentAsDash(data.summary.claimCount) },
|
|
62
|
+
{ label: 'Nodes', value: absentAsDash(data.summary.nodeCount) },
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={onNavigate}
|
|
69
|
+
className="group h-[260px] rounded-xl bg-theme-surface shadow-theme-sm hover:-translate-y-1 hover:shadow-theme-md transition-all duration-200 text-left animate-fade-in-up"
|
|
70
|
+
>
|
|
71
|
+
<div className="flex flex-col h-full w-full">
|
|
72
|
+
<div className="flex items-center justify-between px-5 py-3 border-b border-theme-border/50">
|
|
73
|
+
<div className="flex items-center gap-2">
|
|
74
|
+
<Layers3 className={clsx('h-4 w-4', headerTone)} />
|
|
75
|
+
<span className={clsx('text-xs font-semibold uppercase tracking-wider', headerTone)}>
|
|
76
|
+
Capacity
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
<span className={clsx('max-w-[55%] truncate text-[11px] font-medium', headerTone)}>{headerLabel}</span>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div className="flex-1 min-h-0 px-5 py-3">
|
|
83
|
+
<div className="grid grid-cols-2 gap-x-4 gap-y-3">
|
|
84
|
+
{stats.map((stat) => (
|
|
85
|
+
<div key={stat.label}>
|
|
86
|
+
<div className="text-lg font-semibold tabular-nums text-theme-text-primary">{stat.value}</div>
|
|
87
|
+
<div className="text-[11px] text-theme-text-tertiary">{stat.label}</div>
|
|
88
|
+
</div>
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
{actions.length > 0 && (
|
|
92
|
+
<div className="mt-3 space-y-1">
|
|
93
|
+
{actions.slice(0, 2).map((action) => (
|
|
94
|
+
<div key={action.code} className="flex items-center gap-1.5 text-[11px] text-theme-text-secondary">
|
|
95
|
+
<span
|
|
96
|
+
className={clsx(
|
|
97
|
+
'h-1.5 w-1.5 shrink-0 rounded-full',
|
|
98
|
+
action.highestSeverity === 'critical'
|
|
99
|
+
? 'bg-red-500'
|
|
100
|
+
: action.highestSeverity === 'warning'
|
|
101
|
+
? 'bg-amber-400'
|
|
102
|
+
: 'bg-sky-400',
|
|
103
|
+
)}
|
|
104
|
+
/>
|
|
105
|
+
<span className="truncate">
|
|
106
|
+
{humanizeCode(action.code)}
|
|
107
|
+
{action.count > 1 ? ` (${action.count})` : ''}
|
|
108
|
+
</span>
|
|
109
|
+
</div>
|
|
110
|
+
))}
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div className="px-5 py-2.5 border-t border-theme-border/50 text-[11px] text-theme-text-tertiary group-hover:text-theme-text-secondary transition-colors">
|
|
116
|
+
Open Capacity →
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</button>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function absentAsDash(value: number | undefined, prefix = ''): string {
|
|
124
|
+
return value === undefined ? '—' : `${prefix}${value}`
|
|
125
|
+
}
|
|
@@ -11,6 +11,8 @@ import { CertificateHealthCard } from './CertificateHealthCard'
|
|
|
11
11
|
import { NetworkPolicyCoverageCard } from './NetworkPolicyCoverageCard'
|
|
12
12
|
import { CostCard } from './CostCard'
|
|
13
13
|
import { GitOpsControllersCard } from './GitOpsControllersCard'
|
|
14
|
+
import { CapacityCard } from './CapacityCard'
|
|
15
|
+
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
14
16
|
import { Tooltip } from '../ui/Tooltip'
|
|
15
17
|
import {
|
|
16
18
|
AuditCard,
|
|
@@ -45,6 +47,13 @@ interface HomeViewProps {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts }: HomeViewProps) {
|
|
50
|
+
// The card itself decides whether the cluster has a capacity story
|
|
51
|
+
// (available, softened-denied, or karpenterless-with-managers/groups) and
|
|
52
|
+
// returns null otherwise — the outer gate only excludes states with nothing
|
|
53
|
+
// to fetch against.
|
|
54
|
+
const karpenterState = useCapabilitiesContext().karpenter?.state
|
|
55
|
+
const capacityCardPossible =
|
|
56
|
+
karpenterState === 'available' || karpenterState === 'denied' || karpenterState === 'not_detected'
|
|
48
57
|
const { data, isLoading, error, dataUpdatedAt, refetch } = useDashboard(namespaces)
|
|
49
58
|
const { connection } = useConnection()
|
|
50
59
|
const { data: issuesData, isLoading: issuesLoading, isFetching: issuesFetching, error: issuesError } = useIssues(namespaces)
|
|
@@ -175,7 +184,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
175
184
|
{/* Posture band — same flex-grow wrap so any subset of compliance cards
|
|
176
185
|
fills its row instead of stranding the last one (the old 3-col grid
|
|
177
186
|
left Cluster Audit alone with two empty cells beside it). */}
|
|
178
|
-
{(data.certificateHealth || data.networkPolicyCoverage || data.audit || data.gitopsControllers) && (
|
|
187
|
+
{(data.certificateHealth || data.networkPolicyCoverage || data.audit || data.gitopsControllers || capacityCardPossible) && (
|
|
179
188
|
<div className="flex flex-wrap gap-6">
|
|
180
189
|
{data.certificateHealth && (
|
|
181
190
|
<BandItem>
|
|
@@ -201,6 +210,11 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
201
210
|
/>
|
|
202
211
|
</BandItem>
|
|
203
212
|
)}
|
|
213
|
+
{capacityCardPossible && (
|
|
214
|
+
<BandItem>
|
|
215
|
+
<CapacityCard onNavigate={() => onNavigateToView('capacity')} />
|
|
216
|
+
</BandItem>
|
|
217
|
+
)}
|
|
204
218
|
{data.audit && (
|
|
205
219
|
<BandItem>
|
|
206
220
|
<AuditCard
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { Issue } from "@skyhook-io/k8s-ui";
|
|
3
|
+
import { capacityHrefForIssue } from "./IssuesPane";
|
|
4
|
+
|
|
5
|
+
function issue(partial: Partial<Issue>): Issue {
|
|
6
|
+
return {
|
|
7
|
+
id: "1",
|
|
8
|
+
severity: "critical",
|
|
9
|
+
source: "problem",
|
|
10
|
+
category: "x",
|
|
11
|
+
category_group: "x",
|
|
12
|
+
grouping_scope: "x",
|
|
13
|
+
kind: "Pod",
|
|
14
|
+
name: "p",
|
|
15
|
+
reason: "r",
|
|
16
|
+
...partial,
|
|
17
|
+
} as Issue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("capacityHrefForIssue", () => {
|
|
21
|
+
it("returns null when Karpenter is not detected", () => {
|
|
22
|
+
expect(capacityHrefForIssue(issue({ source: "scheduling" }), false)).toBeNull();
|
|
23
|
+
expect(
|
|
24
|
+
capacityHrefForIssue(
|
|
25
|
+
issue({ kind: "NodePool", group: "karpenter.sh", name: "core" }),
|
|
26
|
+
false),
|
|
27
|
+
).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("links a backend-flagged capacity-relevant pod to the Demand queue", () => {
|
|
31
|
+
expect(
|
|
32
|
+
capacityHrefForIssue(
|
|
33
|
+
issue({ source: "scheduling", capacity_relevant: true }),
|
|
34
|
+
true),
|
|
35
|
+
).toBe("/capacity/demand");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("preserves namespace scope on the Demand link", () => {
|
|
39
|
+
expect(
|
|
40
|
+
capacityHrefForIssue(
|
|
41
|
+
issue({
|
|
42
|
+
source: "scheduling",
|
|
43
|
+
capacity_relevant: true,
|
|
44
|
+
namespace: "payments",
|
|
45
|
+
owner: { kind: "Deployment", name: "api" },
|
|
46
|
+
}),
|
|
47
|
+
true),
|
|
48
|
+
).toBe(`/capacity/demand?owner=${encodeURIComponent("payments/Deployment/api")}`);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("does NOT link a scheduling failure the backend did not flag", () => {
|
|
52
|
+
// Generic unschedulable (insufficient cpu, node-pinned, zonal, non-Karpenter
|
|
53
|
+
// node group): the backend leaves capacity_relevant unset → no link, even in
|
|
54
|
+
// a Karpenter cluster. No message parsing is involved.
|
|
55
|
+
expect(
|
|
56
|
+
capacityHrefForIssue(
|
|
57
|
+
issue({
|
|
58
|
+
source: "scheduling",
|
|
59
|
+
message: "Unschedulable — Insufficient cpu (0/9 nodes available)",
|
|
60
|
+
}),
|
|
61
|
+
true),
|
|
62
|
+
).toBeNull();
|
|
63
|
+
expect(
|
|
64
|
+
capacityHrefForIssue(
|
|
65
|
+
issue({ source: "scheduling", capacity_relevant: false }),
|
|
66
|
+
true),
|
|
67
|
+
).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("links a NodePool-subject issue to its pool detail", () => {
|
|
71
|
+
expect(
|
|
72
|
+
capacityHrefForIssue(
|
|
73
|
+
issue({
|
|
74
|
+
kind: "NodePool",
|
|
75
|
+
group: "karpenter.sh",
|
|
76
|
+
name: "core-on-demand",
|
|
77
|
+
source: "condition",
|
|
78
|
+
}),
|
|
79
|
+
true),
|
|
80
|
+
).toBe("/capacity/pools/core-on-demand");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("does not link non-Karpenter issues even when Karpenter is present", () => {
|
|
84
|
+
expect(
|
|
85
|
+
capacityHrefForIssue(issue({ source: "problem", kind: "Service" }), true),
|
|
86
|
+
).toBeNull();
|
|
87
|
+
// A NodePool from a different API group must not be treated as Karpenter's.
|
|
88
|
+
expect(
|
|
89
|
+
capacityHrefForIssue(
|
|
90
|
+
issue({ kind: "NodePool", group: "example.com", name: "x" }),
|
|
91
|
+
true),
|
|
92
|
+
).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("capacityHrefForIssue subject carry", () => {
|
|
97
|
+
it("carries the grouped subject (the workload) into a filtered Demand", () => {
|
|
98
|
+
expect(
|
|
99
|
+
capacityHrefForIssue(
|
|
100
|
+
issue({
|
|
101
|
+
source: "scheduling",
|
|
102
|
+
capacity_relevant: true,
|
|
103
|
+
kind: "Deployment",
|
|
104
|
+
namespace: "shop",
|
|
105
|
+
name: "web",
|
|
106
|
+
}),
|
|
107
|
+
true,
|
|
108
|
+
),
|
|
109
|
+
).toBe("/capacity/demand?owner=shop%2FDeployment%2Fweb");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("prefers the flat row's owner over its Pod subject", () => {
|
|
113
|
+
expect(
|
|
114
|
+
capacityHrefForIssue(
|
|
115
|
+
issue({
|
|
116
|
+
source: "scheduling",
|
|
117
|
+
capacity_relevant: true,
|
|
118
|
+
kind: "Pod",
|
|
119
|
+
namespace: "shop",
|
|
120
|
+
name: "web-abc12",
|
|
121
|
+
owner: { kind: "Deployment", name: "web" },
|
|
122
|
+
}),
|
|
123
|
+
true,
|
|
124
|
+
),
|
|
125
|
+
).toBe("/capacity/demand?owner=shop%2FDeployment%2Fweb");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("fails closed to the unfiltered link when no complete subject exists", () => {
|
|
129
|
+
expect(
|
|
130
|
+
capacityHrefForIssue(
|
|
131
|
+
issue({
|
|
132
|
+
source: "scheduling",
|
|
133
|
+
capacity_relevant: true,
|
|
134
|
+
kind: "Pod",
|
|
135
|
+
namespace: "shop",
|
|
136
|
+
name: "orphan-abc12",
|
|
137
|
+
}),
|
|
138
|
+
true,
|
|
139
|
+
),
|
|
140
|
+
).toBe("/capacity/demand");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { useMemo, useState } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import { useNavigate } from "react-router-dom";
|
|
3
|
+
import { useIssues } from "../../api/client";
|
|
4
|
+
import { useAPIResources, karpenterCapacityAvailable } from "../../api/apiResources";
|
|
5
|
+
import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
|
|
6
|
+
import { useConnection } from "../../context/ConnectionContext";
|
|
7
|
+
import type { SelectedResource } from "../../types";
|
|
5
8
|
import {
|
|
6
9
|
IssuesView,
|
|
7
10
|
PaneLoader,
|
|
@@ -10,18 +13,73 @@ import {
|
|
|
10
13
|
FreshnessControl,
|
|
11
14
|
ISSUE_SEVERITIES,
|
|
12
15
|
ISSUE_SEVERITY_LABEL,
|
|
16
|
+
type Issue,
|
|
13
17
|
type IssueResourceRef,
|
|
14
18
|
type IssueSeverity,
|
|
15
19
|
type SummaryTone,
|
|
16
|
-
} from
|
|
17
|
-
import { AlertTriangle } from
|
|
18
|
-
import { IssueDiagnoseButton } from
|
|
20
|
+
} from "@skyhook-io/k8s-ui";
|
|
21
|
+
import { AlertTriangle } from "lucide-react";
|
|
22
|
+
import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
// A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
|
|
25
|
+
// always single-cluster (unlike Argo hub-and-spoke), so the issue and the
|
|
26
|
+
// Capacity view are guaranteed to be the same cluster — the deep link is
|
|
27
|
+
// unambiguous.
|
|
28
|
+
//
|
|
29
|
+
// Fail closed: return null unless the issue is *definitely* Karpenter's, so the
|
|
30
|
+
// link can't mislead. Only two signals qualify — (1) the subject IS a Karpenter
|
|
31
|
+
// NodePool, or (2) the backend has flagged an unschedulable pod as requiring a
|
|
32
|
+
// Karpenter NodePool (issue.capacity_relevant — a structural pod-spec check
|
|
33
|
+
// server-side, not message parsing). A generic scheduling failure (insufficient
|
|
34
|
+
// cpu, node-pinned, zonal PVC, a non-Karpenter managed node group) is NOT
|
|
35
|
+
// Karpenter's to solve and gets no link, even in a Karpenter cluster. Clusters
|
|
36
|
+
// without Karpenter never reach the signal checks (hasKarpenter is false).
|
|
37
|
+
export function capacityHrefForIssue(
|
|
38
|
+
issue: Issue,
|
|
39
|
+
hasKarpenter: boolean,
|
|
40
|
+
): string | null {
|
|
41
|
+
if (!hasKarpenter) return null;
|
|
42
|
+
// (1) A NodePool-subject issue (not ready, limit pressure, …) → its pool detail.
|
|
43
|
+
if (issue.kind === "NodePool" && issue.group === "karpenter.sh") {
|
|
44
|
+
return `/capacity/pools/${encodeURIComponent(issue.name)}`;
|
|
45
|
+
}
|
|
46
|
+
// (2) A pod the backend flagged as requiring a Karpenter NodePool → the Demand
|
|
47
|
+
// queue, which groups pending pods by scheduling signature and shows which
|
|
48
|
+
// pools can (or can't) take them. The link carries its subject (?owner=) so
|
|
49
|
+
// Demand lands filtered server-side: grouped scheduling issues have the
|
|
50
|
+
// workload AS their subject (grouping promotes the owner); flat pod rows
|
|
51
|
+
// carry issue.owner. Fail closed to the unfiltered link when no complete
|
|
52
|
+
// subject exists. No STATE filter on purpose — the issue doesn't map cleanly
|
|
53
|
+
// to a single demand state (blocked vs awaiting capacity), and a state filter
|
|
54
|
+
// could hide the very group being investigated. Capacity is deliberately
|
|
55
|
+
// cluster-wide — no namespace view-filter forwarding.
|
|
56
|
+
if (issue.capacity_relevant) {
|
|
57
|
+
const owner =
|
|
58
|
+
issue.owner?.kind && issue.owner.name
|
|
59
|
+
? {
|
|
60
|
+
kind: issue.owner.kind,
|
|
61
|
+
namespace: issue.owner.namespace ?? issue.namespace,
|
|
62
|
+
name: issue.owner.name,
|
|
63
|
+
}
|
|
64
|
+
: issue.kind && issue.kind !== "Pod" && issue.name
|
|
65
|
+
? { kind: issue.kind, namespace: issue.namespace, name: issue.name }
|
|
66
|
+
: undefined;
|
|
67
|
+
if (owner?.namespace) {
|
|
68
|
+
return `/capacity/demand?owner=${encodeURIComponent(`${owner.namespace}/${owner.kind}/${owner.name}`)}`;
|
|
69
|
+
}
|
|
70
|
+
return "/capacity/demand";
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const SEVERITY_TONE: Record<IssueSeverity, SummaryTone> = {
|
|
76
|
+
critical: "error",
|
|
77
|
+
warning: "warning",
|
|
78
|
+
};
|
|
21
79
|
|
|
22
80
|
interface IssuesPaneProps {
|
|
23
|
-
namespaces: string[]
|
|
24
|
-
onNavigateToResource: (resource: SelectedResource) => void
|
|
81
|
+
namespaces: string[];
|
|
82
|
+
onNavigateToResource: (resource: SelectedResource) => void;
|
|
25
83
|
}
|
|
26
84
|
|
|
27
85
|
// The per-cluster Issues surface. Renders the same shared triage queue
|
|
@@ -32,31 +90,51 @@ interface IssuesPaneProps {
|
|
|
32
90
|
// (IssuesView is a pure list); single-cluster gets a light severity filter via
|
|
33
91
|
// the header status tiles (clickable → filter), matching the Applications /
|
|
34
92
|
// GitOps header-tile pattern rather than Hub's fleet facet sidebar.
|
|
35
|
-
export function IssuesPane({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
93
|
+
export function IssuesPane({
|
|
94
|
+
namespaces,
|
|
95
|
+
onNavigateToResource,
|
|
96
|
+
}: IssuesPaneProps) {
|
|
97
|
+
const { data, isLoading, error, dataUpdatedAt, refetch } =
|
|
98
|
+
useIssues(namespaces);
|
|
99
|
+
const { connection } = useConnection();
|
|
100
|
+
const navigate = useNavigate();
|
|
101
|
+
const apiResources = useAPIResources();
|
|
102
|
+
const hasKarpenter = karpenterCapacityAvailable(
|
|
103
|
+
useCapabilitiesContext().karpenter,
|
|
104
|
+
apiResources.data,
|
|
105
|
+
);
|
|
106
|
+
const [severityFilter, setSeverityFilter] = useState<Set<IssueSeverity>>(
|
|
107
|
+
new Set(),
|
|
108
|
+
);
|
|
39
109
|
|
|
40
|
-
const allIssues = useMemo(() => data?.issues ?? [], [data])
|
|
110
|
+
const allIssues = useMemo(() => data?.issues ?? [], [data]);
|
|
41
111
|
const totals = useMemo(() => {
|
|
42
|
-
const t: Record<IssueSeverity, number> = { critical: 0, warning: 0 }
|
|
43
|
-
for (const i of allIssues) t[i.severity] = (t[i.severity] ?? 0) + 1
|
|
44
|
-
return t
|
|
45
|
-
}, [allIssues])
|
|
46
|
-
const shown = severityFilter.size
|
|
112
|
+
const t: Record<IssueSeverity, number> = { critical: 0, warning: 0 };
|
|
113
|
+
for (const i of allIssues) t[i.severity] = (t[i.severity] ?? 0) + 1;
|
|
114
|
+
return t;
|
|
115
|
+
}, [allIssues]);
|
|
116
|
+
const shown = severityFilter.size
|
|
117
|
+
? allIssues.filter((i) => severityFilter.has(i.severity))
|
|
118
|
+
: allIssues;
|
|
47
119
|
|
|
48
120
|
const toggleSeverity = (s: IssueSeverity) =>
|
|
49
121
|
setSeverityFilter((prev) => {
|
|
50
|
-
const next = new Set(prev)
|
|
51
|
-
if (next.has(s)) next.delete(s);
|
|
52
|
-
|
|
53
|
-
|
|
122
|
+
const next = new Set(prev);
|
|
123
|
+
if (next.has(s)) next.delete(s);
|
|
124
|
+
else next.add(s);
|
|
125
|
+
return next;
|
|
126
|
+
});
|
|
54
127
|
|
|
55
128
|
const onResourceClick = (ref: IssueResourceRef) =>
|
|
56
|
-
onNavigateToResource({
|
|
129
|
+
onNavigateToResource({
|
|
130
|
+
kind: ref.kind,
|
|
131
|
+
namespace: ref.namespace ?? "",
|
|
132
|
+
name: ref.name,
|
|
133
|
+
group: ref.group ?? "",
|
|
134
|
+
});
|
|
57
135
|
|
|
58
136
|
if (isLoading) {
|
|
59
|
-
return <PaneLoader label="Loading issues…" className="flex-1"
|
|
137
|
+
return <PaneLoader label="Loading issues…" className="flex-1" />;
|
|
60
138
|
}
|
|
61
139
|
|
|
62
140
|
if (error) {
|
|
@@ -64,7 +142,7 @@ export function IssuesPane({ namespaces, onNavigateToResource }: IssuesPaneProps
|
|
|
64
142
|
<div className="flex-1 flex items-center justify-center text-theme-text-secondary">
|
|
65
143
|
<p>Failed to load issues</p>
|
|
66
144
|
</div>
|
|
67
|
-
)
|
|
145
|
+
);
|
|
68
146
|
}
|
|
69
147
|
|
|
70
148
|
return (
|
|
@@ -83,7 +161,10 @@ export function IssuesPane({ namespaces, onNavigateToResource }: IssuesPaneProps
|
|
|
83
161
|
/>
|
|
84
162
|
{allIssues.length > 0 && (
|
|
85
163
|
<>
|
|
86
|
-
<SummaryTile
|
|
164
|
+
<SummaryTile
|
|
165
|
+
label={allIssues.length === 1 ? "issue" : "issues"}
|
|
166
|
+
value={allIssues.length}
|
|
167
|
+
/>
|
|
87
168
|
{ISSUE_SEVERITIES.map((s) =>
|
|
88
169
|
totals[s] > 0 || severityFilter.has(s) ? (
|
|
89
170
|
<SummaryTile
|
|
@@ -108,17 +189,22 @@ export function IssuesPane({ namespaces, onNavigateToResource }: IssuesPaneProps
|
|
|
108
189
|
{data?.visibility?.impact && (
|
|
109
190
|
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
|
|
110
191
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" />
|
|
111
|
-
<span>
|
|
192
|
+
<span>
|
|
193
|
+
Limited visibility — {data.visibility.impact} Results may be
|
|
194
|
+
incomplete.
|
|
195
|
+
</span>
|
|
112
196
|
</div>
|
|
113
197
|
)}
|
|
114
198
|
|
|
115
199
|
{/* Truncation honesty: when more issues matched than were returned, say
|
|
116
200
|
so — don't present a capped list as the complete picture. */}
|
|
117
|
-
{data?.total_matched != null &&
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
201
|
+
{data?.total_matched != null &&
|
|
202
|
+
data.total_matched > (data.issues?.length ?? 0) && (
|
|
203
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
204
|
+
Showing {data.issues?.length ?? 0} of {data.total_matched} issues
|
|
205
|
+
(capped) — narrow by namespace to see the rest.
|
|
206
|
+
</p>
|
|
207
|
+
)}
|
|
122
208
|
|
|
123
209
|
{/* Filtered-empty is NOT the healthy empty state: when a severity filter
|
|
124
210
|
hides every row but issues still exist, say "no matches" rather than
|
|
@@ -141,11 +227,29 @@ export function IssuesPane({ namespaces, onNavigateToResource }: IssuesPaneProps
|
|
|
141
227
|
issues={shown}
|
|
142
228
|
anyData={!!data}
|
|
143
229
|
onResourceClick={onResourceClick}
|
|
144
|
-
renderActions={({ issue }) =>
|
|
145
|
-
|
|
146
|
-
|
|
230
|
+
renderActions={({ issue }) => {
|
|
231
|
+
const capacityHref = capacityHrefForIssue(issue, hasKarpenter);
|
|
232
|
+
return (
|
|
233
|
+
<div className="flex items-center gap-2">
|
|
234
|
+
{capacityHref && (
|
|
235
|
+
<button
|
|
236
|
+
type="button"
|
|
237
|
+
onClick={() => navigate(capacityHref)}
|
|
238
|
+
className="rounded-md border border-theme-border px-2 py-1 text-xs font-medium text-accent-text transition-colors hover:bg-theme-hover"
|
|
239
|
+
>
|
|
240
|
+
View in Capacity →
|
|
241
|
+
</button>
|
|
242
|
+
)}
|
|
243
|
+
<IssueDiagnoseButton
|
|
244
|
+
kind={issue.kind}
|
|
245
|
+
namespace={issue.namespace ?? ""}
|
|
246
|
+
name={issue.name}
|
|
247
|
+
/>
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
}}
|
|
147
251
|
/>
|
|
148
252
|
)}
|
|
149
253
|
</div>
|
|
150
|
-
)
|
|
254
|
+
);
|
|
151
255
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { renderToString } from "react-dom/server";
|
|
3
|
+
import { PrimaryNavRail } from "./PrimaryNavRail";
|
|
4
|
+
|
|
5
|
+
function renderRail() {
|
|
6
|
+
return renderToString(
|
|
7
|
+
<PrimaryNavRail
|
|
8
|
+
activeView="home"
|
|
9
|
+
onNavigate={() => {}}
|
|
10
|
+
pinned
|
|
11
|
+
onTogglePinned={() => {}}
|
|
12
|
+
/>,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe("PrimaryNavRail", () => {
|
|
17
|
+
it("always surfaces Capacity — the view reads cluster capacity across every node manager, not just Karpenter", () => {
|
|
18
|
+
expect(renderRail()).toContain("Capacity");
|
|
19
|
+
});
|
|
20
|
+
});
|