@skyhook-io/radar-app 1.21.2 → 1.21.3
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 +50 -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 +5 -0
- 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/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/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/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/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,43 +1,34 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
|
2
2
|
import { useNavigate, useSearchParams } from 'react-router-dom'
|
|
3
3
|
import { AlertTriangle, Coins, ExternalLink, Gauge, Loader2, RefreshCw } from 'lucide-react'
|
|
4
|
+
import { ClusterScopeNote } from '@skyhook-io/k8s-ui/components/ui/ClusterScopeNote'
|
|
5
|
+
import { isClusterScopeWithheld } from '@skyhook-io/k8s-ui/types/cluster-scope'
|
|
4
6
|
import {
|
|
5
7
|
Collapse,
|
|
6
8
|
CollapseChevron,
|
|
7
9
|
EmptyState,
|
|
8
10
|
PageHeader,
|
|
9
|
-
SearchBox,
|
|
10
|
-
SelectMenu,
|
|
11
11
|
pluralize,
|
|
12
12
|
useDisclosure,
|
|
13
13
|
} from '@skyhook-io/k8s-ui'
|
|
14
|
-
import { Badge } from '@skyhook-io/k8s-ui/components/ui/Badge'
|
|
15
14
|
import {
|
|
16
15
|
useAutoPromConnect,
|
|
17
16
|
useClusterInfo,
|
|
18
17
|
usePrometheusStatus,
|
|
19
18
|
useRightsizingScan,
|
|
20
|
-
type RightsizingRow,
|
|
21
19
|
} from '../../api/client'
|
|
22
|
-
import {
|
|
20
|
+
import { RIGHTSIZING_DOCS_URL } from '../resource/RightsizingStrip'
|
|
23
21
|
import { buildWorkloadPath } from '../../utils/navigation'
|
|
24
22
|
import { CostViewTabs } from '../cost/CostViewTabs'
|
|
25
23
|
import {
|
|
26
24
|
flattenScanResults,
|
|
27
|
-
isActionableClass,
|
|
28
|
-
scanClassCounts,
|
|
29
25
|
type RightsizingScanRow,
|
|
30
|
-
type ScanClass,
|
|
31
26
|
} from './model'
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type ResourceSignal,
|
|
36
|
-
type RightsizingActionTone,
|
|
37
|
-
} from './presentation'
|
|
27
|
+
import { matchesResultClass, matchesResultIdentity, readResultFilters, resultFilterKeys, scanClassCounts, type ClassFilter, type ScanClass } from '@skyhook-io/k8s-ui/components/rightsizing/results-model'
|
|
28
|
+
import { RightsizingActionFilters, RightsizingResultFilters } from '@skyhook-io/k8s-ui/components/rightsizing/RightsizingFilters'
|
|
29
|
+
import { RightsizingResultsTable } from '@skyhook-io/k8s-ui/components/rightsizing/RightsizingResultsTable'
|
|
38
30
|
import { useNavCustomization } from '../../context/NavCustomization'
|
|
39
31
|
import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings'
|
|
40
|
-
import { clsx } from 'clsx'
|
|
41
32
|
|
|
42
33
|
export const RIGHTSIZING_SCAN_DESCRIPTION =
|
|
43
34
|
'Find CPU and memory requests to increase, reduce, or review. Radar never changes them.'
|
|
@@ -84,30 +75,8 @@ interface RightsizingScanViewProps {
|
|
|
84
75
|
}
|
|
85
76
|
|
|
86
77
|
type ScanResult = NonNullable<ReturnType<typeof useRightsizingScan>['data']>
|
|
87
|
-
type ClassFilter = ScanClass | 'actions'
|
|
88
78
|
const ROW_PAGE_SIZE = 50
|
|
89
79
|
|
|
90
|
-
const ACTION_META: Record<
|
|
91
|
-
'increase' | 'reduction' | 'review',
|
|
92
|
-
{ label: string; severity: 'warning' | 'info' | 'neutral'; helper: string }
|
|
93
|
-
> = {
|
|
94
|
-
increase: {
|
|
95
|
-
label: 'Increase or add',
|
|
96
|
-
severity: RIGHTSIZING_ACTION_SEVERITY.increase,
|
|
97
|
-
helper: 'Reduce reliability risk',
|
|
98
|
-
},
|
|
99
|
-
review: {
|
|
100
|
-
label: 'Review first',
|
|
101
|
-
severity: RIGHTSIZING_ACTION_SEVERITY.review,
|
|
102
|
-
helper: 'Check safety signals or workloads with no replicas',
|
|
103
|
-
},
|
|
104
|
-
reduction: {
|
|
105
|
-
label: 'Reduce requests',
|
|
106
|
-
severity: RIGHTSIZING_ACTION_SEVERITY.reduction,
|
|
107
|
-
helper: 'Reclaim meaningful capacity',
|
|
108
|
-
},
|
|
109
|
-
}
|
|
110
|
-
|
|
111
80
|
export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
112
81
|
useAutoPromConnect()
|
|
113
82
|
const settingsAvailable = !useNavCustomization().embedded
|
|
@@ -142,13 +111,11 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
142
111
|
}
|
|
143
112
|
|
|
144
113
|
const rows = useMemo(() => (result ? flattenScanResults(result) : []), [result])
|
|
145
|
-
const
|
|
114
|
+
const filters = readResultFilters(params, 'actions')
|
|
115
|
+
const { includeSystem, classFilter, search, kindFilter, namespaceFilter } = filters
|
|
146
116
|
const scopeRows = includeSystem ? rows : rows.filter((row) => !row.system)
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
const search = params.get('rfQ') ?? ''
|
|
150
|
-
const kindFilter = params.get('rfKind') ?? ''
|
|
151
|
-
const namespaceFilter = params.get('rfNs') ?? ''
|
|
117
|
+
const matching = scopeRows.filter((row) => matchesResultIdentity(row, filters))
|
|
118
|
+
const counts = scanClassCounts(matching)
|
|
152
119
|
const setFilter = (key: string, value?: string) => {
|
|
153
120
|
const next = new URLSearchParams(params)
|
|
154
121
|
if (value) next.set(key, value)
|
|
@@ -157,27 +124,10 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
157
124
|
}
|
|
158
125
|
const clearFilters = () => {
|
|
159
126
|
const next = new URLSearchParams(params)
|
|
160
|
-
for (const key of
|
|
127
|
+
for (const key of resultFilterKeys) next.delete(key)
|
|
161
128
|
setParams(next, { replace: true })
|
|
162
129
|
}
|
|
163
|
-
const filteredRows =
|
|
164
|
-
if (
|
|
165
|
-
classFilter === 'actions'
|
|
166
|
-
? !isActionableClass(row.classification)
|
|
167
|
-
: row.classification !== classFilter
|
|
168
|
-
)
|
|
169
|
-
return false
|
|
170
|
-
if (kindFilter && row.kind !== kindFilter) return false
|
|
171
|
-
if (namespaceFilter && row.namespace !== namespaceFilter) return false
|
|
172
|
-
if (
|
|
173
|
-
search &&
|
|
174
|
-
!`${row.namespace} ${row.name} ${row.container} ${row.kind}`
|
|
175
|
-
.toLowerCase()
|
|
176
|
-
.includes(search.toLowerCase())
|
|
177
|
-
)
|
|
178
|
-
return false
|
|
179
|
-
return true
|
|
180
|
-
})
|
|
130
|
+
const filteredRows = matching.filter((row) => matchesResultClass(row, classFilter))
|
|
181
131
|
const visibleRows = filteredRows.slice(0, visibleLimit)
|
|
182
132
|
|
|
183
133
|
useEffect(() => {
|
|
@@ -188,7 +138,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
188
138
|
const resultNamespaces = [...new Set(scopeRows.map((row) => row.namespace))].sort()
|
|
189
139
|
const activeFilters =
|
|
190
140
|
classFilter !== 'actions' || Boolean(search || kindFilter || namespaceFilter || includeSystem)
|
|
191
|
-
const
|
|
141
|
+
const hasSystem = rows.some((row) => row.system)
|
|
192
142
|
const onlySystemRowsAreHidden = !includeSystem && rows.length > 0 && scopeRows.length === 0
|
|
193
143
|
const surfaceState = getRightsizingScanSurfaceState({
|
|
194
144
|
statusLoading,
|
|
@@ -313,19 +263,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
313
263
|
}
|
|
314
264
|
/>
|
|
315
265
|
) : surfaceState === 'unavailable' && result ? (
|
|
316
|
-
<
|
|
317
|
-
title="Rightsizing is unavailable"
|
|
318
|
-
body={unavailableMessage(result.reason)}
|
|
319
|
-
action={
|
|
320
|
-
<button
|
|
321
|
-
type="button"
|
|
322
|
-
onClick={runScan}
|
|
323
|
-
className="btn-brand px-3 py-1.5 text-xs font-medium"
|
|
324
|
-
>
|
|
325
|
-
Try again
|
|
326
|
-
</button>
|
|
327
|
-
}
|
|
328
|
-
/>
|
|
266
|
+
<ScanUnavailableState result={result} onRun={runScan} />
|
|
329
267
|
) : result ? (
|
|
330
268
|
<div
|
|
331
269
|
className="flex flex-col gap-4"
|
|
@@ -363,7 +301,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
363
301
|
/>
|
|
364
302
|
) : (
|
|
365
303
|
<section className="overflow-visible rounded-xl border border-theme-border bg-theme-surface shadow-theme-sm">
|
|
366
|
-
<
|
|
304
|
+
<RightsizingResultFilters
|
|
367
305
|
search={search}
|
|
368
306
|
onSearch={(value) => setFilter('rfQ', value || undefined)}
|
|
369
307
|
kind={kindFilter}
|
|
@@ -373,7 +311,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
373
311
|
namespaces={resultNamespaces}
|
|
374
312
|
onNamespace={(value) => setFilter('rfNs', value || undefined)}
|
|
375
313
|
includeSystem={includeSystem}
|
|
376
|
-
|
|
314
|
+
hasSystem={hasSystem}
|
|
377
315
|
onScope={(value) => setFilter('rfScope', value === 'all' ? 'all' : undefined)}
|
|
378
316
|
shown={filteredRows.length}
|
|
379
317
|
total={scopeRows.length}
|
|
@@ -397,36 +335,28 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
397
335
|
/>
|
|
398
336
|
) : (
|
|
399
337
|
<div>
|
|
400
|
-
<
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
{visibleRows.map((row) => (
|
|
409
|
-
<ScanResultRow
|
|
410
|
-
key={row.id}
|
|
411
|
-
row={row}
|
|
412
|
-
open={openRow === row.id}
|
|
413
|
-
onToggle={() => setOpenRow(openRow === row.id ? null : row.id)}
|
|
414
|
-
onOpen={() => openWorkload(row)}
|
|
415
|
-
/>
|
|
416
|
-
))}
|
|
417
|
-
{visibleRows.length < filteredRows.length && (
|
|
418
|
-
<div className="flex justify-center border-t border-theme-border px-4 py-3">
|
|
419
|
-
<button
|
|
420
|
-
type="button"
|
|
421
|
-
onClick={() => setVisibleLimit((value) => value + ROW_PAGE_SIZE)}
|
|
422
|
-
className="text-xs font-medium text-accent-text hover:underline"
|
|
423
|
-
>
|
|
424
|
-
Show {Math.min(ROW_PAGE_SIZE, filteredRows.length - visibleRows.length)}{' '}
|
|
425
|
-
more
|
|
426
|
-
</button>
|
|
427
|
-
</div>
|
|
338
|
+
<RightsizingResultsTable
|
|
339
|
+
rows={visibleRows}
|
|
340
|
+
openRowId={openRow}
|
|
341
|
+
onOpenRowChange={setOpenRow}
|
|
342
|
+
renderWorkloadLink={row => (
|
|
343
|
+
<button type="button" onClick={() => openWorkload(row)} className="self-start text-xs font-medium text-accent-text hover:underline">
|
|
344
|
+
Open workload
|
|
345
|
+
</button>
|
|
428
346
|
)}
|
|
429
|
-
|
|
347
|
+
/>
|
|
348
|
+
{visibleRows.length < filteredRows.length && (
|
|
349
|
+
<div className="flex justify-center border-t border-theme-border px-4 py-3">
|
|
350
|
+
<button
|
|
351
|
+
type="button"
|
|
352
|
+
onClick={() => setVisibleLimit((value) => value + ROW_PAGE_SIZE)}
|
|
353
|
+
className="text-xs font-medium text-accent-text hover:underline"
|
|
354
|
+
>
|
|
355
|
+
Show {Math.min(ROW_PAGE_SIZE, filteredRows.length - visibleRows.length)}{' '}
|
|
356
|
+
more
|
|
357
|
+
</button>
|
|
358
|
+
</div>
|
|
359
|
+
)}
|
|
430
360
|
</div>
|
|
431
361
|
)}
|
|
432
362
|
</section>
|
|
@@ -560,60 +490,20 @@ export function ScanSummary({
|
|
|
560
490
|
</span>
|
|
561
491
|
<span className="text-theme-text-tertiary"> · Change scan scope in the top bar</span>
|
|
562
492
|
</p>
|
|
563
|
-
<
|
|
564
|
-
{
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
</Badge>
|
|
578
|
-
</div>
|
|
579
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">{meta.helper}</p>
|
|
580
|
-
</button>
|
|
581
|
-
)
|
|
582
|
-
})}
|
|
583
|
-
</div>
|
|
584
|
-
<div className="mt-3 flex flex-wrap items-center justify-between gap-2 text-xs text-theme-text-tertiary">
|
|
585
|
-
<span>
|
|
586
|
-
{result.coverage.workloadsEvaluated} of {result.coverage.workloadsDiscovered} workloads
|
|
587
|
-
attempted{result.scanStatus === 'running' ? ' so far' : ''}
|
|
588
|
-
{' · '}
|
|
589
|
-
{result.coverage.workloadsWithData} with usage data · {result.window} window
|
|
590
|
-
</span>
|
|
591
|
-
<span className="flex items-center gap-3">
|
|
592
|
-
<button
|
|
593
|
-
type="button"
|
|
594
|
-
onClick={() => onSelect('in_range')}
|
|
595
|
-
className="hover:text-theme-text-primary"
|
|
596
|
-
>
|
|
597
|
-
{pluralize(counts.in_range, 'container')} · no meaningful change
|
|
598
|
-
</button>
|
|
599
|
-
<button
|
|
600
|
-
type="button"
|
|
601
|
-
onClick={() => onSelect('need_data')}
|
|
602
|
-
className="hover:text-theme-text-primary"
|
|
603
|
-
>
|
|
604
|
-
{pluralize(counts.need_data, 'container')} · needs evidence
|
|
605
|
-
</button>
|
|
606
|
-
{selected !== 'actions' && (
|
|
607
|
-
<button
|
|
608
|
-
type="button"
|
|
609
|
-
onClick={() => onSelect('actions')}
|
|
610
|
-
className="font-medium text-accent-text hover:underline"
|
|
611
|
-
>
|
|
612
|
-
Recommended actions
|
|
613
|
-
</button>
|
|
614
|
-
)}
|
|
615
|
-
</span>
|
|
616
|
-
</div>
|
|
493
|
+
<RightsizingActionFilters
|
|
494
|
+
counts={counts}
|
|
495
|
+
selected={selected}
|
|
496
|
+
defaultClass="actions"
|
|
497
|
+
onSelect={onSelect}
|
|
498
|
+
coverage={
|
|
499
|
+
<span>
|
|
500
|
+
{result.coverage.workloadsEvaluated} of {result.coverage.workloadsDiscovered} workloads
|
|
501
|
+
attempted{result.scanStatus === 'running' ? ' so far' : ''}
|
|
502
|
+
{' · '}
|
|
503
|
+
{result.coverage.workloadsWithData} with usage data · {result.window} window
|
|
504
|
+
</span>
|
|
505
|
+
}
|
|
506
|
+
/>
|
|
617
507
|
</section>
|
|
618
508
|
)
|
|
619
509
|
}
|
|
@@ -701,356 +591,29 @@ function Notice({ text, tone, loading }: { text: string; tone?: 'warning'; loadi
|
|
|
701
591
|
)
|
|
702
592
|
}
|
|
703
593
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
namespace: string
|
|
711
|
-
namespaces: string[]
|
|
712
|
-
onNamespace: (value: string) => void
|
|
713
|
-
includeSystem: boolean
|
|
714
|
-
hiddenSystem: number
|
|
715
|
-
onScope: (value: string) => void
|
|
716
|
-
shown: number
|
|
717
|
-
total: number
|
|
718
|
-
active: boolean
|
|
719
|
-
onClear: () => void
|
|
720
|
-
}) {
|
|
594
|
+
// A withheld cluster scope replaces the whole result: no workload was
|
|
595
|
+
// measured, so none may read as needing no change.
|
|
596
|
+
export function ScanUnavailableState({ result, onRun }: { result: ScanResult; onRun: () => void }) {
|
|
597
|
+
if (isClusterScopeWithheld(result.clusterScope)) {
|
|
598
|
+
return <ClusterScopeNote scope={result.clusterScope} title="Recommendations withheld for this cluster" />
|
|
599
|
+
}
|
|
721
600
|
return (
|
|
722
|
-
<
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
onChange={props.onSearch}
|
|
727
|
-
scope="global"
|
|
728
|
-
shortcutId="rightsizing-search"
|
|
729
|
-
placeholder="Search workloads…"
|
|
730
|
-
className="mr-auto w-60 2xl:w-72"
|
|
731
|
-
/>
|
|
732
|
-
<SelectMenu
|
|
733
|
-
ariaLabel="Filter results by namespace"
|
|
734
|
-
value={props.namespace}
|
|
735
|
-
onChange={props.onNamespace}
|
|
736
|
-
className="w-52"
|
|
737
|
-
options={[
|
|
738
|
-
{ value: '', label: 'All scanned namespaces' },
|
|
739
|
-
...props.namespaces.map((value) => ({ value, label: value })),
|
|
740
|
-
]}
|
|
741
|
-
/>
|
|
742
|
-
<SelectMenu
|
|
743
|
-
ariaLabel="Filter by workload kind"
|
|
744
|
-
value={props.kind}
|
|
745
|
-
onChange={props.onKind}
|
|
746
|
-
className="w-36"
|
|
747
|
-
options={[
|
|
748
|
-
{ value: '', label: 'All kinds' },
|
|
749
|
-
...props.kinds.map((value) => ({ value, label: value })),
|
|
750
|
-
]}
|
|
751
|
-
/>
|
|
752
|
-
{props.hiddenSystem > 0 && (
|
|
753
|
-
<SelectMenu
|
|
754
|
-
ariaLabel="Choose workload scope"
|
|
755
|
-
value={props.includeSystem ? 'all' : 'applications'}
|
|
756
|
-
onChange={props.onScope}
|
|
757
|
-
className="w-44 2xl:w-48"
|
|
758
|
-
options={[
|
|
759
|
-
{ value: 'applications', label: 'Hide system workloads' },
|
|
760
|
-
{
|
|
761
|
-
value: 'all',
|
|
762
|
-
label: `Include system workloads (+${props.hiddenSystem})`,
|
|
763
|
-
},
|
|
764
|
-
]}
|
|
765
|
-
/>
|
|
766
|
-
)}
|
|
767
|
-
<span className="shrink-0 text-xs tabular-nums text-theme-text-tertiary">
|
|
768
|
-
{props.shown} of {props.total} containers
|
|
769
|
-
</span>
|
|
770
|
-
{props.active && (
|
|
601
|
+
<CenteredState
|
|
602
|
+
title="Rightsizing is unavailable"
|
|
603
|
+
body={unavailableMessage(result.reason)}
|
|
604
|
+
action={
|
|
771
605
|
<button
|
|
772
606
|
type="button"
|
|
773
|
-
onClick={
|
|
774
|
-
className="
|
|
607
|
+
onClick={onRun}
|
|
608
|
+
className="btn-brand px-3 py-1.5 text-xs font-medium"
|
|
775
609
|
>
|
|
776
|
-
|
|
610
|
+
Try again
|
|
777
611
|
</button>
|
|
778
|
-
)}
|
|
779
|
-
</div>
|
|
780
|
-
)
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
function ScanResultRow({
|
|
784
|
-
row,
|
|
785
|
-
open,
|
|
786
|
-
onToggle,
|
|
787
|
-
onOpen,
|
|
788
|
-
}: {
|
|
789
|
-
row: RightsizingScanRow
|
|
790
|
-
open: boolean
|
|
791
|
-
onToggle: () => void
|
|
792
|
-
onOpen: () => void
|
|
793
|
-
}) {
|
|
794
|
-
return (
|
|
795
|
-
<div>
|
|
796
|
-
<button
|
|
797
|
-
type="button"
|
|
798
|
-
onClick={onToggle}
|
|
799
|
-
aria-expanded={open}
|
|
800
|
-
className={clsx('grid w-full grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] items-center gap-3 text-left hover:bg-theme-hover/50', 'px-3.5 py-2.5' /* TABLE_DENSITY.cellClass in k8s-ui */)}
|
|
801
|
-
>
|
|
802
|
-
<div className="min-w-0">
|
|
803
|
-
<div className="flex items-center gap-2">
|
|
804
|
-
<Badge kind={row.kind} size="sm">
|
|
805
|
-
{row.kind}
|
|
806
|
-
</Badge>
|
|
807
|
-
<span className="truncate text-sm font-medium text-theme-text-primary">{row.name}</span>
|
|
808
|
-
</div>
|
|
809
|
-
<div className="mt-1 truncate text-xs text-theme-text-tertiary">
|
|
810
|
-
{row.namespace} · {row.container}
|
|
811
|
-
</div>
|
|
812
|
-
</div>
|
|
813
|
-
<ResourceRequestCell row={row.cpu} scaledToZero={row.scaledToZero} />
|
|
814
|
-
<ResourceRequestCell row={row.memory} scaledToZero={row.scaledToZero} />
|
|
815
|
-
<ImpactCell row={row} />
|
|
816
|
-
<CollapseChevron open={open} className="h-4 w-4" />
|
|
817
|
-
</button>
|
|
818
|
-
<Collapse open={open} mountLazily>
|
|
819
|
-
<div className="grid gap-4 border-t border-theme-border bg-theme-base/40 px-4 py-3 md:grid-cols-[1fr_1fr_auto]">
|
|
820
|
-
<FitWhy label="CPU" row={row.cpu} />
|
|
821
|
-
<FitWhy label="Memory" row={row.memory} />
|
|
822
|
-
<button
|
|
823
|
-
type="button"
|
|
824
|
-
onClick={onOpen}
|
|
825
|
-
className="self-start text-xs font-medium text-accent-text hover:underline"
|
|
826
|
-
>
|
|
827
|
-
Open workload
|
|
828
|
-
</button>
|
|
829
|
-
</div>
|
|
830
|
-
</Collapse>
|
|
831
|
-
</div>
|
|
832
|
-
)
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
function ResourceRequestCell({
|
|
836
|
-
row,
|
|
837
|
-
scaledToZero,
|
|
838
|
-
}: {
|
|
839
|
-
row?: RightsizingRow
|
|
840
|
-
scaledToZero: boolean
|
|
841
|
-
}) {
|
|
842
|
-
const presentation = getResourceRequestPresentation(row, scaledToZero)
|
|
843
|
-
return (
|
|
844
|
-
<div className="min-w-0 text-xs">
|
|
845
|
-
<div className="truncate font-medium tabular-nums text-theme-text-primary">
|
|
846
|
-
{presentation.primary}
|
|
847
|
-
</div>
|
|
848
|
-
<div className={`mt-0.5 ${requestToneClass(presentation.tone)}`}>
|
|
849
|
-
{presentation.secondary}
|
|
850
|
-
</div>
|
|
851
|
-
{presentation.signals.length > 0 && (
|
|
852
|
-
<div className="mt-1 flex flex-wrap gap-1">
|
|
853
|
-
{presentation.signals.map((signal) => (
|
|
854
|
-
<SignalBadge key={signal} signal={signal} />
|
|
855
|
-
))}
|
|
856
|
-
</div>
|
|
857
|
-
)}
|
|
858
|
-
</div>
|
|
859
|
-
)
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
function requestToneClass(tone: RightsizingActionTone): string {
|
|
863
|
-
if (tone === 'reduction') return 'text-accent-text'
|
|
864
|
-
if (tone === 'increase') return 'text-warning-text'
|
|
865
|
-
return 'text-theme-text-tertiary'
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
function ImpactCell({ row }: { row: RightsizingScanRow }) {
|
|
869
|
-
if (row.classification === 'in_range') {
|
|
870
|
-
return <div className="text-xs text-theme-text-tertiary">Below action threshold</div>
|
|
871
|
-
}
|
|
872
|
-
const changes: string[] = []
|
|
873
|
-
if (row.impact.cpuChange !== 0) changes.push(formatCPUChange(row.impact.cpuChange))
|
|
874
|
-
if (row.impact.memoryChange !== 0) changes.push(formatMemoryChange(row.impact.memoryChange))
|
|
875
|
-
return (
|
|
876
|
-
<div className="min-w-0 text-xs text-theme-text-secondary">
|
|
877
|
-
<div>{row.replicas === 1 ? '1 replica' : `${row.replicas} replicas`}</div>
|
|
878
|
-
{row.scaledToZero ? (
|
|
879
|
-
<div className="mt-0.5 text-theme-text-tertiary">No current capacity impact</div>
|
|
880
|
-
) : changes.length > 0 ? (
|
|
881
|
-
changes.map((change) => (
|
|
882
|
-
<div key={change} className="mt-0.5 tabular-nums text-theme-text-tertiary">
|
|
883
|
-
{change}
|
|
884
|
-
</div>
|
|
885
|
-
))
|
|
886
|
-
) : (
|
|
887
|
-
<div className="mt-0.5 text-theme-text-tertiary">No suggested change</div>
|
|
888
|
-
)}
|
|
889
|
-
</div>
|
|
890
|
-
)
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
function SignalBadge({ signal }: { signal: ResourceSignal }) {
|
|
894
|
-
return (
|
|
895
|
-
<Badge
|
|
896
|
-
severity={
|
|
897
|
-
signal === 'oom' || signal === 'query_error'
|
|
898
|
-
? 'error'
|
|
899
|
-
: signal === 'throttling'
|
|
900
|
-
? 'warning'
|
|
901
|
-
: 'neutral'
|
|
902
612
|
}
|
|
903
|
-
|
|
904
|
-
>
|
|
905
|
-
{signalLabel(signal)}
|
|
906
|
-
</Badge>
|
|
907
|
-
)
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
export function FitWhy({ label, row }: { label: string; row?: RightsizingRow }) {
|
|
911
|
-
if (!row)
|
|
912
|
-
return (
|
|
913
|
-
<div>
|
|
914
|
-
<div className="text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
|
|
915
|
-
{label}
|
|
916
|
-
</div>
|
|
917
|
-
<p className="mt-1 text-xs text-theme-text-secondary">No result returned.</p>
|
|
918
|
-
</div>
|
|
919
|
-
)
|
|
920
|
-
const history =
|
|
921
|
-
row.coverage >= 0.95
|
|
922
|
-
? 'Full 7-day history.'
|
|
923
|
-
: `${Math.max(row.coverage * 7, 0).toFixed(1)} days of usable history.`
|
|
924
|
-
const observation = row.observed
|
|
925
|
-
? row.observed.name === 'Max'
|
|
926
|
-
? `${label} peaked at ${row.observed.formatted} during the measured period. `
|
|
927
|
-
: `${label} stayed below ${row.observed.formatted} for ${row.observed.name === 'P95' ? '95%' : '99%'} of the measured period. `
|
|
928
|
-
: ''
|
|
929
|
-
return (
|
|
930
|
-
<div>
|
|
931
|
-
<div className="text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
|
|
932
|
-
Why this {label.toLowerCase()} guidance
|
|
933
|
-
</div>
|
|
934
|
-
<p className="mt-1 text-xs text-theme-text-secondary">
|
|
935
|
-
{row.queryError
|
|
936
|
-
? 'Metrics could not be queried, so usable history could not be determined. Retry the scan, or select fewer namespaces in the top bar.'
|
|
937
|
-
: `${observation}${history}`}
|
|
938
|
-
</p>
|
|
939
|
-
<EvidenceNote row={row} />
|
|
940
|
-
</div>
|
|
941
|
-
)
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
function EvidenceNote({ row }: { row: RightsizingRow }) {
|
|
945
|
-
const primary = primaryEvidenceNote(row)
|
|
946
|
-
// A denied pod read qualifies whichever reason applies rather than standing in
|
|
947
|
-
// for it: a row can both be unable to check its pods and have a limit conflict,
|
|
948
|
-
// and hiding either one behind the other loses something the reader needs.
|
|
949
|
-
const inventory =
|
|
950
|
-
row.liveInventoryUnavailable && row.resource === 'memory' ? (
|
|
951
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
952
|
-
Radar could not read this workload's pods, so it could not check them for
|
|
953
|
-
out-of-memory restarts.
|
|
954
|
-
</p>
|
|
955
|
-
) : null
|
|
956
|
-
if (!primary && !inventory) return null
|
|
957
|
-
return (
|
|
958
|
-
<>
|
|
959
|
-
{primary}
|
|
960
|
-
{inventory}
|
|
961
|
-
</>
|
|
613
|
+
/>
|
|
962
614
|
)
|
|
963
615
|
}
|
|
964
616
|
|
|
965
|
-
function primaryEvidenceNote(row: RightsizingRow) {
|
|
966
|
-
if (row.fit === 'pod_level_request' && !row.queryError)
|
|
967
|
-
return (
|
|
968
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
969
|
-
{podLevelOverUseNote(row) ??
|
|
970
|
-
"This pod sets a pod-level request in spec.resources, which the scheduler reserves instead of container requests. Radar shows this container's usage but doesn't size the pod-level request."}
|
|
971
|
-
</p>
|
|
972
|
-
)
|
|
973
|
-
if (row.hpaManaged)
|
|
974
|
-
return (
|
|
975
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
976
|
-
The HPA uses this request when calculating scale, so Radar does not suggest changing it
|
|
977
|
-
directly.
|
|
978
|
-
</p>
|
|
979
|
-
)
|
|
980
|
-
if (row.recommendationReason === 'oom_evidence')
|
|
981
|
-
return (
|
|
982
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
983
|
-
A recent out-of-memory restart makes a lower memory request unsafe to suggest.
|
|
984
|
-
</p>
|
|
985
|
-
)
|
|
986
|
-
if (row.recommendationReason === 'hpa_evidence_unavailable')
|
|
987
|
-
return (
|
|
988
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
989
|
-
Radar could not verify whether autoscaling depends on this request.
|
|
990
|
-
</p>
|
|
991
|
-
)
|
|
992
|
-
if (row.recommendationReason === 'oom_evidence_unavailable')
|
|
993
|
-
return (
|
|
994
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
995
|
-
Radar could not verify restart history before suggesting a lower memory request.
|
|
996
|
-
</p>
|
|
997
|
-
)
|
|
998
|
-
if (row.recommendationReason === 'requests_exceed_pod_limit')
|
|
999
|
-
return (
|
|
1000
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1001
|
-
Together with the other containers' requests and suggested increases, the calculated
|
|
1002
|
-
request would take the pod above its pod-level limit. Decide how to split the limit, or
|
|
1003
|
-
raise it.
|
|
1004
|
-
</p>
|
|
1005
|
-
)
|
|
1006
|
-
if (row.limitConflict)
|
|
1007
|
-
return (
|
|
1008
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1009
|
-
The calculated request would exceed the current limit.
|
|
1010
|
-
</p>
|
|
1011
|
-
)
|
|
1012
|
-
if (row.fit === 'insufficient_history' && !row.queryError)
|
|
1013
|
-
return (
|
|
1014
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1015
|
-
Wait for more runtime history before changing this request.
|
|
1016
|
-
</p>
|
|
1017
|
-
)
|
|
1018
|
-
const isReduction =
|
|
1019
|
-
row.recommendedRequestValue != null &&
|
|
1020
|
-
row.currentRequestValue != null &&
|
|
1021
|
-
row.recommendedRequestValue < row.currentRequestValue
|
|
1022
|
-
if (row.resource === 'cpu' && isReduction && (row.throttleRatio ?? 0) >= 0.1)
|
|
1023
|
-
return (
|
|
1024
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1025
|
-
CPU limit throttling was observed. Review the limit and burst behavior before reducing this
|
|
1026
|
-
request.
|
|
1027
|
-
</p>
|
|
1028
|
-
)
|
|
1029
|
-
if (row.resource === 'cpu' && isReduction && row.bursty)
|
|
1030
|
-
return (
|
|
1031
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1032
|
-
CPU usage was bursty during the measured period. Review the peak before reducing this
|
|
1033
|
-
request.
|
|
1034
|
-
</p>
|
|
1035
|
-
)
|
|
1036
|
-
if (row.reductionLimited && row.calculatedRequest && row.recommendedRequest) {
|
|
1037
|
-
return (
|
|
1038
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1039
|
-
Demand-based target: {row.calculatedRequest}. Radar suggests {row.recommendedRequest} as a
|
|
1040
|
-
conservative next step; observe another full window before reducing further.
|
|
1041
|
-
{row.bursty && row.peak ? ` CPU P99 reached ${row.peak.formatted}.` : ''}
|
|
1042
|
-
</p>
|
|
1043
|
-
)
|
|
1044
|
-
}
|
|
1045
|
-
if (row.recommendedRequest)
|
|
1046
|
-
return (
|
|
1047
|
-
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1048
|
-
The target includes 15% headroom, a practical minimum, and scale-aware rounding.
|
|
1049
|
-
</p>
|
|
1050
|
-
)
|
|
1051
|
-
return null
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
617
|
function CenteredState({
|
|
1055
618
|
loading,
|
|
1056
619
|
title,
|
|
@@ -1078,32 +641,6 @@ function CenteredState({
|
|
|
1078
641
|
)
|
|
1079
642
|
}
|
|
1080
643
|
|
|
1081
|
-
function formatCPUChange(value: number): string {
|
|
1082
|
-
const prefix = value > 0 ? '+' : '−'
|
|
1083
|
-
const absolute = Math.abs(value)
|
|
1084
|
-
return absolute >= 1
|
|
1085
|
-
? `${prefix}${absolute.toFixed(1)} CPU requested`
|
|
1086
|
-
: `${prefix}${Math.round(absolute * 1000)}m CPU requested`
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
function formatMemoryChange(value: number): string {
|
|
1090
|
-
const prefix = value > 0 ? '+' : '−'
|
|
1091
|
-
const mib = Math.abs(value) / (1024 * 1024)
|
|
1092
|
-
return mib >= 1024
|
|
1093
|
-
? `${prefix}${(mib / 1024).toFixed(1)}Gi memory requested`
|
|
1094
|
-
: `${prefix}${Math.round(mib)}Mi memory requested`
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
function signalLabel(signal: ResourceSignal): string {
|
|
1098
|
-
return {
|
|
1099
|
-
hpa: 'HPA',
|
|
1100
|
-
oom: 'OOM restart',
|
|
1101
|
-
bursty: 'Bursty usage',
|
|
1102
|
-
throttling: 'Throttling',
|
|
1103
|
-
query_error: 'Metrics unavailable',
|
|
1104
|
-
}[signal]
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
644
|
function errorMessage(error: unknown): string {
|
|
1108
645
|
return error instanceof Error ? error.message : 'An unexpected error occurred.'
|
|
1109
646
|
}
|