@skyhook-io/radar-app 1.21.2 → 1.21.4
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/README.md +11 -0
- package/package.json +2 -2
- package/src/App.tsx +53 -28
- package/src/api/actions.test.ts +11 -0
- package/src/api/actions.ts +5 -0
- package/src/api/apiResources.navigation.test.tsx +58 -0
- package/src/api/apiResources.ts +22 -16
- package/src/api/client.diagnostics.test.ts +52 -0
- package/src/api/client.triggerCronJob.test.tsx +49 -0
- package/src/api/client.ts +140 -120
- package/src/api/connectionBinding.test.tsx +82 -0
- package/src/api/connectionBinding.ts +52 -0
- package/src/api/contextSwitch.test.ts +11 -0
- package/src/api/contextSwitch.ts +58 -0
- package/src/api/radarFeatures.ts +6 -0
- package/src/api/vulnerabilities.export.test.ts +44 -0
- package/src/api/vulnerabilities.ts +73 -4
- package/src/components/ConnectionErrorView.tsx +13 -0
- package/src/components/ContextSwitchActions.tsx +43 -0
- package/src/components/ContextSwitcher.tsx +13 -6
- package/src/components/SwitchAwareConnectionError.tsx +2 -2
- package/src/components/audit/VulnerabilitiesView.test.tsx +177 -0
- package/src/components/audit/VulnerabilitiesView.tsx +197 -48
- package/src/components/cost/ApplicationCostTab.test.ts +16 -0
- package/src/components/cost/ApplicationCostTab.tsx +41 -9
- package/src/components/cost/CostTrendChart.tsx +25 -2
- package/src/components/cost/CostTrendWithheld.render.test.tsx +105 -0
- package/src/components/cost/CostView.tsx +10 -2
- package/src/components/cost/CostViewTabs.test.tsx +18 -0
- package/src/components/cost/CostViewTabs.tsx +14 -22
- package/src/components/cost/WorkloadCostTab.test.ts +15 -0
- package/src/components/cost/WorkloadCostTab.tsx +42 -8
- package/src/components/cost/source.test.ts +16 -1
- package/src/components/cost/source.ts +34 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +35 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +16 -1
- package/src/components/dock/NodeTerminalTab.test.tsx +4 -2
- package/src/components/dock/NodeTerminalTab.tsx +8 -8
- package/src/components/dock/TerminalTab.test.tsx +12 -1
- package/src/components/dock/TerminalTab.tsx +6 -3
- package/src/components/home/CostCard.test.tsx +49 -0
- package/src/components/home/CostCard.tsx +98 -63
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/resource/DatadogRightsizingPanel.test.tsx +118 -0
- package/src/components/resource/DatadogRightsizingPanel.tsx +68 -0
- package/src/components/resource/DatadogWorkloadCharts.tsx +149 -0
- package/src/components/resource/HPACharts.render.test.tsx +42 -0
- package/src/components/resource/HPACharts.tsx +34 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +126 -3
- package/src/components/resource/PrometheusChartsGrid.tsx +58 -25
- package/src/components/resource/RestartChart.render.test.tsx +72 -0
- package/src/components/resource/RestartChart.tsx +31 -3
- package/src/components/resource/RightsizingPanel.access.test.tsx +24 -0
- package/src/components/resource/RightsizingStrip.render.test.tsx +44 -0
- package/src/components/resource/RightsizingStrip.test.ts +1 -188
- package/src/components/resource/RightsizingStrip.tsx +27 -300
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +22 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +14 -4
- package/src/components/resource/nameMatchedScope.ts +39 -0
- package/src/components/resources/pod-file-upload.ts +3 -0
- package/src/components/resources/renderers/CAPIClusterRenderer.tsx +5 -2
- package/src/components/resources/renderers/LonghornVolumeRenderer.test.tsx +104 -0
- package/src/components/resources/renderers/LonghornVolumeRenderer.tsx +31 -0
- package/src/components/rightsizing/RightsizingScanLink.tsx +22 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +65 -528
- package/src/components/rightsizing/model.test.ts +20 -9
- package/src/components/rightsizing/model.ts +17 -176
- package/src/components/rightsizing/notices.test.tsx +30 -29
- package/src/components/traffic/TrafficGraph.export.test.tsx +57 -0
- package/src/components/traffic/TrafficGraph.tsx +9 -4
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +1 -0
- package/src/components/traffic/TrafficView.tsx +17 -2
- package/src/components/ui/DiagnosticsOverlay.test.ts +3 -2
- package/src/components/ui/DiagnosticsOverlay.tsx +23 -13
- package/src/components/ui/command-items.ts +3 -4
- package/src/components/useContextSwitchFlow.test.tsx +9 -0
- package/src/components/useContextSwitchFlow.tsx +43 -5
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.test.tsx +30 -1
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +3 -2
- package/src/components/vulnerabilities/parts.test.ts +59 -3
- package/src/components/vulnerabilities/parts.tsx +199 -5
- package/src/components/workload/WorkloadRightsizingSource.test.tsx +83 -0
- package/src/components/workload/WorkloadView.test.ts +22 -1
- package/src/components/workload/WorkloadView.tsx +57 -16
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +58 -15
- package/src/context/ConnectionProvider.connectionId.test.tsx +92 -0
- package/src/context/ConnectionProvider.retry.test.tsx +174 -1
- package/src/context/ContextSwitchContext.tsx +15 -1
- package/src/context/NavCustomization.tsx +6 -3
- package/src/hooks/useDesktopDownload.test.tsx +57 -0
- package/src/hooks/useDesktopDownload.ts +31 -9
- package/src/hooks/useEventSource.test.tsx +85 -0
- package/src/hooks/useEventSource.ts +43 -16
- package/src/hooks/useResetViewsOnContextChange.test.tsx +34 -0
- package/src/hooks/useResetViewsOnContextChange.ts +27 -0
- package/src/index.ts +3 -0
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/navigation.ts +1 -15
- package/src/utils/page-links.ts +6 -0
- package/src/components/rightsizing/presentation.test.ts +0 -150
- package/src/components/rightsizing/presentation.ts +0 -109
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ExternalLink, Gauge, HelpCircle } from 'lucide-react'
|
|
2
|
+
import { RightsizingScanLink } from '../rightsizing/RightsizingScanLink'
|
|
3
|
+
import {
|
|
4
|
+
RightsizingEvidence,
|
|
5
|
+
RightsizingEmptyState as EmptyState,
|
|
6
|
+
} from '@skyhook-io/k8s-ui/components/rightsizing/RightsizingEvidence'
|
|
7
|
+
import { ClusterScopeNote } from '@skyhook-io/k8s-ui/components/ui/ClusterScopeNote'
|
|
8
|
+
import { isClusterScopeWithheld } from '@skyhook-io/k8s-ui/types/cluster-scope'
|
|
4
9
|
import {
|
|
5
10
|
usePrometheusRightsizing,
|
|
6
11
|
usePrometheusStatus,
|
|
7
12
|
useAutoPromConnect,
|
|
8
13
|
type PrometheusRightsizing,
|
|
9
|
-
type RightsizingFit,
|
|
10
|
-
type RightsizingRow,
|
|
11
14
|
} from '../../api/client'
|
|
12
15
|
import { Tooltip } from '../ui/Tooltip'
|
|
13
16
|
|
|
@@ -35,7 +38,6 @@ function useRightsizingEvidence({ kind, namespace, name }: RightsizingProps) {
|
|
|
35
38
|
|
|
36
39
|
export function RightsizingPanel(props: RightsizingProps) {
|
|
37
40
|
const state = useRightsizingEvidence(props)
|
|
38
|
-
const { search } = useLocation()
|
|
39
41
|
if (!state.supported) return null
|
|
40
42
|
|
|
41
43
|
return (
|
|
@@ -45,7 +47,9 @@ export function RightsizingPanel(props: RightsizingProps) {
|
|
|
45
47
|
<Gauge className="mt-0.5 h-4 w-4 text-theme-text-tertiary" />
|
|
46
48
|
<div>
|
|
47
49
|
<div className="flex items-center gap-1.5">
|
|
48
|
-
<h3 className="text-sm font-semibold text-theme-text-primary">
|
|
50
|
+
<h3 className="text-sm font-semibold text-theme-text-primary">
|
|
51
|
+
Rightsizing · Prometheus
|
|
52
|
+
</h3>
|
|
49
53
|
<Tooltip content={RIGHTSIZING_METHODOLOGY}>
|
|
50
54
|
<HelpCircle className="h-3.5 w-3.5 text-theme-text-tertiary" />
|
|
51
55
|
</Tooltip>
|
|
@@ -65,13 +69,12 @@ export function RightsizingPanel(props: RightsizingProps) {
|
|
|
65
69
|
</div>
|
|
66
70
|
</div>
|
|
67
71
|
<div className="flex items-center gap-3">
|
|
68
|
-
{state.data && <RightsizingContext data={state.data} />}
|
|
69
|
-
<
|
|
70
|
-
to={{ pathname: '/cost/rightsizing', search }}
|
|
72
|
+
{!state.error && state.data && <RightsizingContext data={state.data} />}
|
|
73
|
+
<RightsizingScanLink
|
|
71
74
|
className="text-xs font-medium text-accent-text hover:underline"
|
|
72
75
|
>
|
|
73
76
|
Scan visible workloads
|
|
74
|
-
</
|
|
77
|
+
</RightsizingScanLink>
|
|
75
78
|
</div>
|
|
76
79
|
</header>
|
|
77
80
|
<div className="p-4">
|
|
@@ -88,23 +91,28 @@ export function RightsizingStrip(props: RightsizingProps) {
|
|
|
88
91
|
<section className="mb-3 rounded-lg border border-theme-border bg-theme-surface/40 p-3">
|
|
89
92
|
<header className="mb-2 flex items-center justify-between gap-3">
|
|
90
93
|
<div className="flex items-center gap-1.5">
|
|
91
|
-
<h3 className="text-sm font-medium text-theme-text-primary">Rightsizing</h3>
|
|
94
|
+
<h3 className="text-sm font-medium text-theme-text-primary">Rightsizing · Prometheus</h3>
|
|
92
95
|
<Tooltip content={RIGHTSIZING_METHODOLOGY}>
|
|
93
96
|
<HelpCircle className="h-3.5 w-3.5 text-theme-text-tertiary" />
|
|
94
97
|
</Tooltip>
|
|
95
98
|
</div>
|
|
96
|
-
{state.data && <RightsizingContext data={state.data} compact />}
|
|
99
|
+
{!state.error && state.data && <RightsizingContext data={state.data} compact />}
|
|
97
100
|
</header>
|
|
98
101
|
<RightsizingBody state={state} compact />
|
|
99
102
|
</section>
|
|
100
103
|
)
|
|
101
104
|
}
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
type RightsizingBodyState = Pick<
|
|
107
|
+
ReturnType<typeof useRightsizingEvidence>,
|
|
108
|
+
'statusLoading' | 'connected' | 'isLoading' | 'error' | 'data'
|
|
109
|
+
>
|
|
110
|
+
|
|
111
|
+
export function RightsizingBody({
|
|
104
112
|
state,
|
|
105
113
|
compact,
|
|
106
114
|
}: {
|
|
107
|
-
state:
|
|
115
|
+
state: RightsizingBodyState
|
|
108
116
|
compact: boolean
|
|
109
117
|
}) {
|
|
110
118
|
if (state.statusLoading) {
|
|
@@ -116,156 +124,15 @@ function RightsizingBody({
|
|
|
116
124
|
if (state.isLoading && !state.data) {
|
|
117
125
|
return <EmptyState text="Analyzing seven days of workload demand…" loading />
|
|
118
126
|
}
|
|
119
|
-
if (state.error
|
|
127
|
+
if (state.error) {
|
|
120
128
|
const message = state.error instanceof Error ? state.error.message : String(state.error)
|
|
121
129
|
return <EmptyState text={`Rightsizing unavailable — ${message}`} />
|
|
122
130
|
}
|
|
123
131
|
if (!state.data) return null
|
|
124
|
-
if (
|
|
125
|
-
return <
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const byContainer = new Map<string, RightsizingRow[]>()
|
|
129
|
-
for (const row of state.data.rows) {
|
|
130
|
-
const rows = byContainer.get(row.container) ?? []
|
|
131
|
-
rows.push(row)
|
|
132
|
-
byContainer.set(row.container, rows)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (compact) {
|
|
136
|
-
return (
|
|
137
|
-
<div className="space-y-2">
|
|
138
|
-
{Array.from(byContainer.entries()).map(([container, rows]) => (
|
|
139
|
-
<div key={container}>
|
|
140
|
-
<div className="mb-1 text-xs font-medium text-theme-text-secondary">{container}</div>
|
|
141
|
-
<div className="space-y-1 pl-2">
|
|
142
|
-
{rows.map((row) => (
|
|
143
|
-
<CompactFitRow key={row.resource} row={row} />
|
|
144
|
-
))}
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
))}
|
|
148
|
-
</div>
|
|
149
|
-
)
|
|
132
|
+
if (isClusterScopeWithheld(state.data.clusterScope)) {
|
|
133
|
+
return <ClusterScopeNote scope={state.data.clusterScope} title="Recommendations withheld" />
|
|
150
134
|
}
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<div className="space-y-4">
|
|
154
|
-
{(state.data.scaledToZero || state.data.ownerCoverage === 'current_pods') && (
|
|
155
|
-
<div className="flex flex-wrap gap-2">
|
|
156
|
-
{state.data.scaledToZero && (
|
|
157
|
-
<Badge severity="neutral" size="sm">
|
|
158
|
-
No current replicas · showing retained evidence
|
|
159
|
-
</Badge>
|
|
160
|
-
)}
|
|
161
|
-
{state.data.ownerCoverage === 'current_pods' && (
|
|
162
|
-
<Badge severity="info" size="sm">
|
|
163
|
-
Current pods only · confidence capped
|
|
164
|
-
</Badge>
|
|
165
|
-
)}
|
|
166
|
-
</div>
|
|
167
|
-
)}
|
|
168
|
-
{Array.from(byContainer.entries()).map(([container, rows]) => (
|
|
169
|
-
<div key={container}>
|
|
170
|
-
<h4 className="mb-2 text-xs font-semibold text-theme-text-secondary">{container}</h4>
|
|
171
|
-
<div className="grid gap-3 md:grid-cols-2">
|
|
172
|
-
{rows.map((row) => (
|
|
173
|
-
<FitCard key={row.resource} row={row} window={state.data!.window} />
|
|
174
|
-
))}
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
))}
|
|
178
|
-
</div>
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function FitCard({ row, window }: { row: RightsizingRow; window: string }) {
|
|
183
|
-
return (
|
|
184
|
-
<div className="rounded-md border border-theme-border bg-theme-base/60 p-3">
|
|
185
|
-
<div className="mb-3 flex flex-wrap items-center justify-between gap-2">
|
|
186
|
-
<span className="text-xs font-semibold uppercase tracking-wide text-theme-text-tertiary">
|
|
187
|
-
{row.resource}
|
|
188
|
-
</span>
|
|
189
|
-
<div className="flex flex-wrap items-center justify-end gap-1.5">
|
|
190
|
-
<FitBadge fit={row.fit} queryError={row.queryError} />
|
|
191
|
-
{row.hpaManaged && (
|
|
192
|
-
<Badge severity="info" size="sm">
|
|
193
|
-
HPA-managed
|
|
194
|
-
</Badge>
|
|
195
|
-
)}
|
|
196
|
-
{row.bursty && (
|
|
197
|
-
<Badge severity="warning" size="sm">
|
|
198
|
-
Bursty CPU
|
|
199
|
-
</Badge>
|
|
200
|
-
)}
|
|
201
|
-
{row.throttleRatio != null && row.throttleRatio >= 0.1 && (
|
|
202
|
-
<Badge severity="alert" size="sm">
|
|
203
|
-
Throttling observed
|
|
204
|
-
</Badge>
|
|
205
|
-
)}
|
|
206
|
-
{(row.currentPodOOM || row.windowOomEvidence) && (
|
|
207
|
-
<Badge severity="error" size="sm">
|
|
208
|
-
OOM evidence
|
|
209
|
-
</Badge>
|
|
210
|
-
)}
|
|
211
|
-
</div>
|
|
212
|
-
</div>
|
|
213
|
-
<div className="flex items-baseline gap-2 tabular-nums">
|
|
214
|
-
<div>
|
|
215
|
-
<div className="text-[10px] uppercase tracking-wide text-theme-text-quaternary">
|
|
216
|
-
{row.podLevelRequest ? 'Pod-level request' : 'Current request'}
|
|
217
|
-
</div>
|
|
218
|
-
<div className="text-lg font-semibold text-theme-text-primary">
|
|
219
|
-
{row.podLevelRequest ?? row.currentRequest ?? 'Unset'}
|
|
220
|
-
</div>
|
|
221
|
-
</div>
|
|
222
|
-
<ArrowRight className="h-4 w-4 text-theme-text-quaternary" />
|
|
223
|
-
<div>
|
|
224
|
-
<div className="text-[10px] uppercase tracking-wide text-theme-text-quaternary">
|
|
225
|
-
Suggested next step
|
|
226
|
-
</div>
|
|
227
|
-
<div className="text-lg font-semibold text-theme-text-primary">
|
|
228
|
-
{row.recommendedRequest ?? '—'}
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
</div>
|
|
232
|
-
<div className="mt-3 grid grid-cols-2 gap-3 border-t border-theme-border pt-3 text-xs">
|
|
233
|
-
<Metric
|
|
234
|
-
label={`${row.observed?.name ?? (row.resource === 'cpu' ? 'P95' : 'Max')} observed`}
|
|
235
|
-
value={row.observed?.formatted ?? 'No samples'}
|
|
236
|
-
/>
|
|
237
|
-
<Metric label={`Evidence · ${window}`} value={`${confidenceLabel(row)} · 5m samples`} />
|
|
238
|
-
</div>
|
|
239
|
-
<FitExplanation row={row} />
|
|
240
|
-
</div>
|
|
241
|
-
)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function CompactFitRow({ row }: { row: RightsizingRow }) {
|
|
245
|
-
return (
|
|
246
|
-
<div className="flex flex-wrap items-center gap-2 text-xs tabular-nums text-theme-text-tertiary">
|
|
247
|
-
<span className="w-12 text-[10px] uppercase tracking-wide text-theme-text-quaternary">
|
|
248
|
-
{row.resource}
|
|
249
|
-
</span>
|
|
250
|
-
<span className="min-w-14 text-theme-text-secondary">
|
|
251
|
-
{row.podLevelRequest ? `pod ${row.podLevelRequest}` : (row.currentRequest ?? 'unset')}
|
|
252
|
-
</span>
|
|
253
|
-
{row.recommendedRequest && (
|
|
254
|
-
<>
|
|
255
|
-
<ArrowRight className="h-3 w-3 text-theme-text-quaternary" />
|
|
256
|
-
<span className="min-w-14 text-theme-text-primary">{row.recommendedRequest}</span>
|
|
257
|
-
</>
|
|
258
|
-
)}
|
|
259
|
-
{row.observed && (
|
|
260
|
-
<span className="text-[10px] text-theme-text-quaternary">
|
|
261
|
-
({row.observed.name} {row.observed.formatted})
|
|
262
|
-
</span>
|
|
263
|
-
)}
|
|
264
|
-
<span className="ml-auto">
|
|
265
|
-
<FitBadge fit={row.fit} queryError={row.queryError} />
|
|
266
|
-
</span>
|
|
267
|
-
</div>
|
|
268
|
-
)
|
|
135
|
+
return <RightsizingEvidence data={state.data} compact={compact} />
|
|
269
136
|
}
|
|
270
137
|
|
|
271
138
|
function RightsizingContext({
|
|
@@ -282,143 +149,3 @@ function RightsizingContext({
|
|
|
282
149
|
</span>
|
|
283
150
|
)
|
|
284
151
|
}
|
|
285
|
-
|
|
286
|
-
function FitBadge({ fit, queryError }: { fit: RightsizingFit; queryError?: string }) {
|
|
287
|
-
const presentation = getRightsizingPresentation(fit, queryError)
|
|
288
|
-
return (
|
|
289
|
-
<Badge severity={presentation.severity} size="sm">
|
|
290
|
-
{presentation.label}
|
|
291
|
-
</Badge>
|
|
292
|
-
)
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
export function getRightsizingPresentation(fit: RightsizingFit, queryError?: string) {
|
|
296
|
-
if (queryError) return { label: 'Query failed', severity: 'error' as const }
|
|
297
|
-
const labels: Record<RightsizingFit, string> = {
|
|
298
|
-
balanced: 'Balanced',
|
|
299
|
-
oversized: 'Oversized',
|
|
300
|
-
under_requested: 'Under-requested',
|
|
301
|
-
missing_request: 'Missing request',
|
|
302
|
-
insufficient_history: 'Insufficient history',
|
|
303
|
-
pod_level_request: 'Pod-level request',
|
|
304
|
-
}
|
|
305
|
-
const severities: Record<RightsizingFit, 'success' | 'info' | 'warning' | 'neutral'> = {
|
|
306
|
-
balanced: 'success',
|
|
307
|
-
oversized: 'info',
|
|
308
|
-
under_requested: 'warning',
|
|
309
|
-
missing_request: 'warning',
|
|
310
|
-
insufficient_history: 'neutral',
|
|
311
|
-
pod_level_request: 'neutral',
|
|
312
|
-
}
|
|
313
|
-
// An older frontend can meet a fit added by a newer agent.
|
|
314
|
-
return { label: labels[fit] ?? fit, severity: severities[fit] ?? ('neutral' as const) }
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function FitExplanation({ row }: { row: RightsizingRow }) {
|
|
318
|
-
const message = getRightsizingExplanation(row)
|
|
319
|
-
if (!message) return null
|
|
320
|
-
return <p className="mt-3 text-xs text-theme-text-tertiary">{message}</p>
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export function getRightsizingExplanation(row: RightsizingRow): string | undefined {
|
|
324
|
-
const messages: Record<string, string> = {
|
|
325
|
-
request_within_fit_range: 'The configured request is within 30% of the evidence-based target.',
|
|
326
|
-
insufficient_history: 'At least six hours of samples are required before suggesting a request.',
|
|
327
|
-
hpa_managed: `The HPA manages ${row.resource}; review its target before changing this request.`,
|
|
328
|
-
hpa_evidence_unavailable:
|
|
329
|
-
'Radar could not verify HPA ownership, so it withheld a suggested request.',
|
|
330
|
-
oom_evidence: 'A lower memory request is withheld because OOM evidence exists.',
|
|
331
|
-
oom_evidence_unavailable:
|
|
332
|
-
'Radar could not verify recent OOM history, so it withheld a lower memory request.',
|
|
333
|
-
recommended_request_exceeds_limit:
|
|
334
|
-
'The evidence-based request would exceed the current limit; review the limit first.',
|
|
335
|
-
requests_exceed_pod_limit:
|
|
336
|
-
"Together with the other containers' requests and suggested increases, this request would take the pod above its pod-level limit (spec.resources), which Kubernetes rejects. Decide how to split the limit between containers, or raise the pod limit.",
|
|
337
|
-
}
|
|
338
|
-
// A denied pod read leaves currentPodOOM unknown rather than false, so it
|
|
339
|
-
// qualifies whatever else is said instead of replacing it — including a
|
|
340
|
-
// staged reduction, which is exactly where an unchecked pod matters most.
|
|
341
|
-
const inventoryNote =
|
|
342
|
-
row.liveInventoryUnavailable && row.resource === 'memory'
|
|
343
|
-
? "Radar could not read this workload's pods, so it could not check them for out-of-memory restarts."
|
|
344
|
-
: undefined
|
|
345
|
-
const qualified = (base: string) => (inventoryNote ? `${base} ${inventoryNote}` : base)
|
|
346
|
-
if (row.fit === 'pod_level_request' && row.podLevelRequest && !row.queryError)
|
|
347
|
-
return qualified(podLevelRequestExplanation(row, row.podLevelRequest))
|
|
348
|
-
if (row.reductionLimited && row.calculatedRequest && row.recommendedRequest) {
|
|
349
|
-
const burstNote = row.bursty && row.peak ? ` CPU P99 reached ${row.peak.formatted}.` : ''
|
|
350
|
-
return qualified(
|
|
351
|
-
`Demand-based target: ${row.calculatedRequest}. Radar suggests ${row.recommendedRequest} as a conservative next step; observe another full window before reducing further.${burstNote}`,
|
|
352
|
-
)
|
|
353
|
-
}
|
|
354
|
-
const message = row.queryError
|
|
355
|
-
? `Partial result: ${row.queryError}.`
|
|
356
|
-
: messages[row.recommendationReason ?? '']
|
|
357
|
-
const throttleUnavailable = row.resource === 'cpu' && !row.throttleAvailable
|
|
358
|
-
if (!message && !throttleUnavailable) return inventoryNote
|
|
359
|
-
return qualified(
|
|
360
|
-
message ?? 'CPU throttling metrics are unavailable; no throttling conclusion was drawn.',
|
|
361
|
-
)
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function podLevelRequestExplanation(row: RightsizingRow, podLevelRequest: string): string {
|
|
365
|
-
const overUse = podLevelOverUseNote(row)
|
|
366
|
-
if (overUse) return overUse
|
|
367
|
-
const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
|
|
368
|
-
const own = row.currentRequest
|
|
369
|
-
? ` This container's own request (${row.currentRequest}) no longer decides what is reserved.`
|
|
370
|
-
: ''
|
|
371
|
-
return `This pod sets one ${resource} request for all its containers: ${podLevelRequest} in spec.resources. The scheduler reserves that instead of container requests, so Radar doesn't suggest a request per container; check the pod-level request against the usage of its containers.${own}`
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* One container's usage above the pod's whole request is a sound lower bound on
|
|
376
|
-
* the pod's own use. Adding containers up would overstate it, so only this case
|
|
377
|
-
* is called out.
|
|
378
|
-
*/
|
|
379
|
-
export function podLevelOverUseNote(row: RightsizingRow): string | undefined {
|
|
380
|
-
if (
|
|
381
|
-
row.fit !== 'pod_level_request' ||
|
|
382
|
-
row.sampleCount < RIGHTSIZING_MIN_SAMPLES ||
|
|
383
|
-
!row.observed ||
|
|
384
|
-
!row.podLevelRequest ||
|
|
385
|
-
row.podLevelRequestValue == null ||
|
|
386
|
-
row.observed.value <= row.podLevelRequestValue
|
|
387
|
-
)
|
|
388
|
-
return undefined
|
|
389
|
-
const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
|
|
390
|
-
const finding = `This container alone used ${row.observed.formatted} (${row.observed.name}), more than the pod's whole ${row.podLevelRequest} ${resource} request. Radar can't size pod-level requests yet.`
|
|
391
|
-
// An HPA scaling on this resource divides usage by the pod request, so
|
|
392
|
-
// raising it changes scaling; Radar never suggests that unreviewed.
|
|
393
|
-
if (row.hpaManaged)
|
|
394
|
-
return `${finding} The HPA scales on this request, so review its target before raising spec.resources.requests.${row.resource}.`
|
|
395
|
-
if (!row.hpaEvidenceAvailable)
|
|
396
|
-
return `${finding} Radar couldn't check for an HPA on this resource, so check autoscaling before raising spec.resources.requests.${row.resource}.`
|
|
397
|
-
return `${finding} Consider raising spec.resources.requests.${row.resource}.`
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// Mirrors rightsizingMinSamples (six hours of 5-minute samples) in
|
|
401
|
-
// internal/prometheus/rightsizing.go: below it Radar draws no conclusion.
|
|
402
|
-
const RIGHTSIZING_MIN_SAMPLES = 72
|
|
403
|
-
|
|
404
|
-
function confidenceLabel(row: RightsizingRow) {
|
|
405
|
-
return `${row.confidence[0].toUpperCase()}${row.confidence.slice(1)} confidence`
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function Metric({ label, value }: { label: string; value: string }) {
|
|
409
|
-
return (
|
|
410
|
-
<div>
|
|
411
|
-
<div className="text-theme-text-quaternary">{label}</div>
|
|
412
|
-
<div className="mt-0.5 text-theme-text-secondary">{value}</div>
|
|
413
|
-
</div>
|
|
414
|
-
)
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
function EmptyState({ text, loading = false }: { text: string; loading?: boolean }) {
|
|
418
|
-
return (
|
|
419
|
-
<div className="flex min-h-16 items-center justify-center text-sm text-theme-text-tertiary">
|
|
420
|
-
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
421
|
-
{text}
|
|
422
|
-
</div>
|
|
423
|
-
)
|
|
424
|
-
}
|
|
@@ -5,6 +5,11 @@ import type { WorkloadMetrics, WorkloadMetricPanel } from '../../api/workloadMet
|
|
|
5
5
|
|
|
6
6
|
let result: { data?: WorkloadMetrics; isLoading?: boolean; isPlaceholderData?: boolean; error?: Error } = {}
|
|
7
7
|
vi.mock('../../api/workloadMetrics', () => ({ useWorkloadMetrics: () => result }))
|
|
8
|
+
let chartScopes: Record<string, { state: string; note: string } | undefined> = {}
|
|
9
|
+
vi.mock('../../api/client', async (importActual) => ({
|
|
10
|
+
...(await importActual<typeof import('../../api/client')>()),
|
|
11
|
+
usePrometheusResourceMetrics: (_kind: string, _ns: string, _name: string, category: string) => ({ data: { unit: 'cores', clusterScope: chartScopes[category] } }),
|
|
12
|
+
}))
|
|
8
13
|
const { WorkloadMetricsSection } = await import('./WorkloadMetricsSection')
|
|
9
14
|
const panel = (value: number, unit = 'requests/s'): WorkloadMetricPanel => ({
|
|
10
15
|
state: 'available', unit,
|
|
@@ -13,6 +18,7 @@ const panel = (value: number, unit = 'requests/s'): WorkloadMetricPanel => ({
|
|
|
13
18
|
const render = () => renderToString(<MemoryRouter><WorkloadMetricsSection kind="Deployment" namespace="shop" name="checkout" range="1h" /></MemoryRouter>)
|
|
14
19
|
|
|
15
20
|
beforeEach(() => {
|
|
21
|
+
chartScopes = {}
|
|
16
22
|
result = { data: {
|
|
17
23
|
state: 'available', source: 'beyla',
|
|
18
24
|
sources: [{ id: 'beyla', label: 'Beyla', state: 'available' }],
|
|
@@ -75,6 +81,22 @@ describe('Workload metrics interpretation', () => {
|
|
|
75
81
|
expect(html).toContain('History lookup failed')
|
|
76
82
|
expect(html).not.toContain('Existing memory chart')
|
|
77
83
|
})
|
|
84
|
+
it('says name-matched charts were kept to this cluster when their scope was verified', () => {
|
|
85
|
+
result.data!.panels.cpu = { state: 'error', unit: 'cores', reason: 'History lookup failed', series: [] }
|
|
86
|
+
chartScopes = { cpu: { state: 'scoped_verified', note: 'Matched by cluster labels confirmed against this cluster\'s Pods.' } }
|
|
87
|
+
const html = renderToString(<MemoryRouter><WorkloadMetricsSection kind="Deployment" namespace="shop" name="checkout" range="1h" nameMatchedCharts={{ cpu: <span>Existing CPU chart</span> }} /></MemoryRouter>).replaceAll('<!-- -->', '')
|
|
88
|
+
expect(html).toContain('Basic CPU · matched by cluster label')
|
|
89
|
+
expect(html).toContain('kept to this cluster by its cluster labels')
|
|
90
|
+
expect(html).not.toContain('may include another cluster')
|
|
91
|
+
expect(html).not.toContain('identity unverified')
|
|
92
|
+
})
|
|
93
|
+
it('keeps the name-matched caveat for an unlabeled store', () => {
|
|
94
|
+
result.data!.panels.cpu = { state: 'error', unit: 'cores', reason: 'History lookup failed', series: [] }
|
|
95
|
+
chartScopes = { cpu: { state: 'unlabeled', note: 'No cluster label.' } }
|
|
96
|
+
const html = renderToString(<MemoryRouter><WorkloadMetricsSection kind="Deployment" namespace="shop" name="checkout" range="1h" nameMatchedCharts={{ cpu: <span>Existing CPU chart</span> }} /></MemoryRouter>).replaceAll('<!-- -->', '')
|
|
97
|
+
expect(html).toContain('Basic CPU · identity unverified')
|
|
98
|
+
expect(html).toContain('These charts match current Pod names, not Pod UIDs or historical workload ownership; matching names in a shared backend may include another cluster.')
|
|
99
|
+
})
|
|
78
100
|
it('does not flash name-matched charts during the initial request', () => {
|
|
79
101
|
result = { isLoading: true }
|
|
80
102
|
const html = renderToString(<MemoryRouter><WorkloadMetricsSection kind="Deployment" namespace="shop" name="checkout" range="1h" nameMatchedCharts={{ cpu: <span>Existing CPU chart</span> }} /></MemoryRouter>)
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
formatMetricValue,
|
|
10
10
|
type ReferenceLine,
|
|
11
11
|
} from "@skyhook-io/k8s-ui/components/charts";
|
|
12
|
-
import { type PrometheusTimeRange } from "../../api/client";
|
|
12
|
+
import { usePrometheusResourceMetrics, type PrometheusTimeRange } from "../../api/client";
|
|
13
13
|
import {
|
|
14
14
|
useWorkloadMetrics,
|
|
15
15
|
type WorkloadMetricPanel,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { latestWorkloadValue, workloadPodValues } from "./workloadMetricValues";
|
|
20
20
|
import { WorkloadMetricsHelpDialog } from './WorkloadMetricsHelpDialog';
|
|
21
21
|
import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure';
|
|
22
|
+
import { leastCertainScope, NAME_MATCHED_CLUSTER_NOTE, NAME_MATCHED_SUMMARY } from './nameMatchedScope';
|
|
22
23
|
|
|
23
24
|
interface Props {
|
|
24
25
|
kind: string;
|
|
@@ -30,6 +31,7 @@ interface Props {
|
|
|
30
31
|
restartLane?: ReactNode;
|
|
31
32
|
nameMatchedCharts?: Partial<Record<'cpu' | 'memory', ReactNode>>;
|
|
32
33
|
controls?: ReactNode;
|
|
34
|
+
workloadTotals?: ReactNode;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
export function WorkloadMetricsSection(props: Props) {
|
|
@@ -51,6 +53,11 @@ export function WorkloadMetricsSection(props: Props) {
|
|
|
51
53
|
const panel = data?.panels[key];
|
|
52
54
|
return (data || error) && props.nameMatchedCharts?.[key] && (!panel || ['detecting', 'error', 'unavailable'].includes(panel.state));
|
|
53
55
|
});
|
|
56
|
+
// Read from the cache the name-matched charts fill; never fetches itself.
|
|
57
|
+
const cpuNameMatched = usePrometheusResourceMetrics(props.kind, props.namespace, props.name, 'cpu', props.range, false).data;
|
|
58
|
+
const memoryNameMatched = usePrometheusResourceMetrics(props.kind, props.namespace, props.name, 'memory', props.range, false).data;
|
|
59
|
+
const nameMatchedScope = leastCertainScope(nameMatchedFallbacks.map((key) => (key === 'cpu' ? cpuNameMatched : memoryNameMatched)?.clusterScope));
|
|
60
|
+
const nameMatchedNote = NAME_MATCHED_CLUSTER_NOTE[nameMatchedScope];
|
|
54
61
|
const resourceNotice = sameResourceScope ? sharedPanelNotice([data?.panels.cpu, data?.panels.memory, data?.panels.throttling]) : undefined;
|
|
55
62
|
const hasHistoricalTotals = (['cpu', 'memory'] as const).some((key) => data?.history[key]?.mode === 'workload-history');
|
|
56
63
|
const hasResourceDetails = hasHistoricalTotals || data?.history.throttling?.mode === 'workload-history' || resourceNotice?.state === 'stale';
|
|
@@ -67,9 +74,10 @@ export function WorkloadMetricsSection(props: Props) {
|
|
|
67
74
|
{data?.state === 'partial' && data.reason && <p role="status" className={`text-xs ${SEVERITY_TEXT.warning}`}>{data.reason}</p>}
|
|
68
75
|
{isPlaceholderData && <p role="status" className="text-xs text-theme-text-secondary">Loading selected request source… Resources show previous samples.</p>}
|
|
69
76
|
<WorkloadRequests data={data} isLoading={isLoading || isPlaceholderData} error={error} setSource={setSource} />
|
|
77
|
+
{props.workloadTotals}
|
|
70
78
|
<section aria-label="Workload resource pressure">
|
|
71
79
|
{(data?.panels.cpu || data?.panels.memory || data?.panels.throttling) && <div className="mb-2 flex flex-wrap items-baseline gap-x-3 gap-y-1">
|
|
72
|
-
<h3 className="text-sm font-semibold text-theme-text-primary">Resources</h3>
|
|
80
|
+
<h3 className="text-sm font-semibold text-theme-text-primary">{props.workloadTotals ? 'Prometheus resources' : 'Resources'}</h3>
|
|
73
81
|
{sameResourceScope && <HistoryNotice scope={data?.history.cpu} omitReason={data?.panels.cpu?.reason} />}
|
|
74
82
|
</div>}
|
|
75
83
|
{props.restartLane}
|
|
@@ -97,8 +105,10 @@ export function WorkloadMetricsSection(props: Props) {
|
|
|
97
105
|
</Disclosure>}
|
|
98
106
|
</section>
|
|
99
107
|
{nameMatchedFallbacks.length > 0 && <details aria-label="Name-matched resource metrics">
|
|
100
|
-
<summary className="mb-2 cursor-pointer text-xs text-theme-text-secondary">Basic {nameMatchedFallbacks.map((key) => key === 'cpu' ? 'CPU' : 'memory').join(' / ')} ·
|
|
101
|
-
|
|
108
|
+
<summary className="mb-2 cursor-pointer text-xs text-theme-text-secondary">Basic {nameMatchedFallbacks.map((key) => key === 'cpu' ? 'CPU' : 'memory').join(' / ')} · {NAME_MATCHED_SUMMARY[nameMatchedScope]}</summary>
|
|
109
|
+
{nameMatchedNote
|
|
110
|
+
? <p className={`mb-2 max-w-2xl text-sm ${nameMatchedScope === 'withheld' ? SEVERITY_TEXT.warning : 'text-theme-text-secondary'}`}>These charts match current Pod names, not Pod UIDs or historical workload ownership. {nameMatchedNote}</p>
|
|
111
|
+
: <p className={`mb-2 max-w-2xl text-sm ${SEVERITY_TEXT.warning}`}>These charts match current Pod names, not Pod UIDs or historical workload ownership; matching names in a shared backend may include another cluster.</p>}
|
|
102
112
|
<div className="metrics-chart-grid">{nameMatchedFallbacks.map((key) => <div key={key}>{props.nameMatchedCharts?.[key]}</div>)}</div>
|
|
103
113
|
</details>}
|
|
104
114
|
{data && (data.comparison.cpu || data.comparison.memory || data.comparison.throttling) && <PodComparison
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isClusterScopeWithheld, type ClusterScope } from "@skyhook-io/k8s-ui/types/cluster-scope";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How the Pod-name-matched charts in one section were kept to this cluster.
|
|
5
|
+
* `caveat` keeps the "may include another cluster" wording: an unlabeled
|
|
6
|
+
* store, older Radar (no clusterScope), or a chart that hasn't answered yet.
|
|
7
|
+
*/
|
|
8
|
+
export type NameMatchedScope = "scoped" | "asserted" | "withheld" | "caveat";
|
|
9
|
+
|
|
10
|
+
// Least certain first. A chart drawn without a cluster check outranks a
|
|
11
|
+
// withheld one: it shows numbers that may mix clusters, the withheld one none.
|
|
12
|
+
const RANK: NameMatchedScope[] = ["caveat", "withheld", "asserted", "scoped"];
|
|
13
|
+
|
|
14
|
+
function classify(scope: ClusterScope | null | undefined): NameMatchedScope {
|
|
15
|
+
if (scope?.state === "scoped_configured" || scope?.state === "scoped_verified") return "scoped";
|
|
16
|
+
if (scope?.state === "single_cluster_asserted") return "asserted";
|
|
17
|
+
return isClusterScopeWithheld(scope) ? "withheld" : "caveat";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The least certain scope among a section's charts. */
|
|
21
|
+
export function leastCertainScope(scopes: (ClusterScope | null | undefined)[]): NameMatchedScope {
|
|
22
|
+
if (scopes.length === 0) return "caveat";
|
|
23
|
+
return scopes.map(classify).reduce((a, b) => (RANK.indexOf(a) <= RANK.indexOf(b) ? a : b));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const NAME_MATCHED_SUMMARY: Record<NameMatchedScope, string> = {
|
|
27
|
+
scoped: "matched by cluster label",
|
|
28
|
+
asserted: "operator declared single-cluster",
|
|
29
|
+
withheld: "identity unverified",
|
|
30
|
+
caveat: "identity unverified",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The sentence that replaces "may include another cluster", or undefined to keep it. */
|
|
34
|
+
export const NAME_MATCHED_CLUSTER_NOTE: Record<NameMatchedScope, string | undefined> = {
|
|
35
|
+
scoped: "They're kept to this cluster by its cluster labels.",
|
|
36
|
+
asserted: "An operator declared this metrics store single-cluster, so they don't include another cluster.",
|
|
37
|
+
withheld: "Charts that couldn't be kept to this cluster say why in place of their data.",
|
|
38
|
+
caveat: undefined,
|
|
39
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FileNode } from '../../types'
|
|
2
2
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
3
3
|
import { formatBytes } from '../../utils/format'
|
|
4
|
+
import { CONNECTION_HEADER, connectionHeaderValue } from '../../api/connectionBinding'
|
|
4
5
|
|
|
5
6
|
export const POD_FILE_PERSISTENCE_NOTE =
|
|
6
7
|
"Changes apply to the running container immediately. Files in the container's own filesystem are lost when it's recreated; files on volumes may persist. For lasting changes, update the source (image, ConfigMap, manifest)."
|
|
@@ -235,6 +236,8 @@ export function uploadPodFile(req: UploadRequest): Promise<UploadResult> {
|
|
|
235
236
|
xhr.open('POST', url)
|
|
236
237
|
xhr.withCredentials = getCredentialsMode() === 'include'
|
|
237
238
|
for (const [k, v] of Object.entries(getAuthHeaders())) xhr.setRequestHeader(k, v)
|
|
239
|
+
const connection = connectionHeaderValue()
|
|
240
|
+
if (connection) xhr.setRequestHeader(CONNECTION_HEADER, connection)
|
|
238
241
|
xhr.setRequestHeader('Content-Type', 'application/octet-stream')
|
|
239
242
|
xhr.upload.onprogress = (e) => {
|
|
240
243
|
if (e.lengthComputable) req.onProgress?.(e.loaded, e.total)
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CAPIClusterRenderer as BaseCAPIClusterRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/CAPIClusterRenderer'
|
|
2
2
|
import type { ResourceRef } from '@skyhook-io/k8s-ui'
|
|
3
|
-
import { useCapabilities } from '../../../api/client'
|
|
3
|
+
import { apiFetch, useCapabilities } from '../../../api/client'
|
|
4
|
+
import { apiUrl } from '../../../api/config'
|
|
5
|
+
|
|
6
|
+
const request = (path: string, init?: RequestInit) => apiFetch(apiUrl(path), init)
|
|
4
7
|
|
|
5
8
|
export function CAPIClusterRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
|
|
6
9
|
const { data: capabilities } = useCapabilities()
|
|
7
|
-
return <BaseCAPIClusterRenderer data={data} onNavigate={onNavigate} canConnect={capabilities != null && capabilities.configManagement !== 'operator'} />
|
|
10
|
+
return <BaseCAPIClusterRenderer data={data} onNavigate={onNavigate} request={request} canConnect={capabilities != null && capabilities.configManagement !== 'operator'} />
|
|
8
11
|
}
|