@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,150 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import type { RightsizingRow } from '../../api/client'
|
|
3
|
-
import { getResourceRequestPresentation } from './presentation'
|
|
4
|
-
|
|
5
|
-
function metric(overrides: Partial<RightsizingRow> = {}): RightsizingRow {
|
|
6
|
-
return {
|
|
7
|
-
container: 'app',
|
|
8
|
-
resource: 'cpu',
|
|
9
|
-
fit: 'balanced',
|
|
10
|
-
confidence: 'high',
|
|
11
|
-
sampleCount: 2017,
|
|
12
|
-
expectedSamples: 2017,
|
|
13
|
-
coverage: 1,
|
|
14
|
-
hpaManaged: false,
|
|
15
|
-
hpaEvidenceAvailable: true,
|
|
16
|
-
oomEvidenceAvailable: true,
|
|
17
|
-
...overrides,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('rightsizing request presentation', () => {
|
|
22
|
-
it('shows configured and suggested values in a consistent comparison', () => {
|
|
23
|
-
expect(
|
|
24
|
-
getResourceRequestPresentation(
|
|
25
|
-
metric({
|
|
26
|
-
fit: 'oversized',
|
|
27
|
-
currentRequest: '1500m',
|
|
28
|
-
currentRequestValue: 1.5,
|
|
29
|
-
recommendedRequest: '750m',
|
|
30
|
-
recommendedRequestValue: 0.75,
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
).toEqual({
|
|
34
|
-
primary: '1500m → 750m',
|
|
35
|
-
secondary: 'Reduce request',
|
|
36
|
-
signals: [],
|
|
37
|
-
tone: 'reduction',
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('makes missing requests explicit', () => {
|
|
42
|
-
expect(
|
|
43
|
-
getResourceRequestPresentation(
|
|
44
|
-
metric({
|
|
45
|
-
fit: 'missing_request',
|
|
46
|
-
recommendedRequest: '100m',
|
|
47
|
-
recommendedRequestValue: 0.1,
|
|
48
|
-
}),
|
|
49
|
-
),
|
|
50
|
-
).toEqual({
|
|
51
|
-
primary: 'Unset → 100m',
|
|
52
|
-
secondary: 'Add request',
|
|
53
|
-
signals: [],
|
|
54
|
-
tone: 'increase',
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('keeps the configured value visible when safety signals require review', () => {
|
|
59
|
-
expect(
|
|
60
|
-
getResourceRequestPresentation(
|
|
61
|
-
metric({
|
|
62
|
-
fit: 'oversized',
|
|
63
|
-
currentRequest: '200m',
|
|
64
|
-
currentRequestValue: 0.2,
|
|
65
|
-
recommendedRequest: '100m',
|
|
66
|
-
recommendedRequestValue: 0.1,
|
|
67
|
-
bursty: true,
|
|
68
|
-
throttleRatio: 0.2,
|
|
69
|
-
}),
|
|
70
|
-
),
|
|
71
|
-
).toEqual({
|
|
72
|
-
primary: '200m current',
|
|
73
|
-
secondary: 'Review before reducing',
|
|
74
|
-
signals: ['bursty', 'throttling'],
|
|
75
|
-
tone: 'review',
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
it('places resource-specific safety evidence with the request it qualifies', () => {
|
|
80
|
-
expect(
|
|
81
|
-
getResourceRequestPresentation(
|
|
82
|
-
metric({
|
|
83
|
-
resource: 'memory',
|
|
84
|
-
currentRequest: '128Mi',
|
|
85
|
-
currentRequestValue: 128 * 1024 * 1024,
|
|
86
|
-
recommendationReason: 'oom_evidence',
|
|
87
|
-
windowOomEvidence: true,
|
|
88
|
-
}),
|
|
89
|
-
),
|
|
90
|
-
).toEqual({
|
|
91
|
-
primary: '128Mi current',
|
|
92
|
-
secondary: 'Keep current request',
|
|
93
|
-
signals: ['oom'],
|
|
94
|
-
tone: 'review',
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('keeps no-change and unavailable data neutral', () => {
|
|
99
|
-
expect(getResourceRequestPresentation(metric()).tone).toBe('neutral')
|
|
100
|
-
expect(getResourceRequestPresentation(metric({ queryError: 'query failed' })).tone).toBe(
|
|
101
|
-
'neutral',
|
|
102
|
-
)
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
describe('pod-level request presentation', () => {
|
|
107
|
-
it('shows the pod-level value and asks for review instead of a per-container change', () => {
|
|
108
|
-
const result = getResourceRequestPresentation(
|
|
109
|
-
metric({
|
|
110
|
-
fit: 'pod_level_request',
|
|
111
|
-
podLevelRequest: '200m',
|
|
112
|
-
recommendationReason: 'pod_level_request',
|
|
113
|
-
}),
|
|
114
|
-
)
|
|
115
|
-
expect(result.primary).toContain('200m')
|
|
116
|
-
expect(result.tone).toBe('review')
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
describe('pod-level limit conflict presentation', () => {
|
|
121
|
-
it('points at the pod limit rather than the container limit', () => {
|
|
122
|
-
const podLimit = getResourceRequestPresentation(
|
|
123
|
-
metric({
|
|
124
|
-
fit: 'under_requested',
|
|
125
|
-
limitConflict: true,
|
|
126
|
-
recommendationReason: 'requests_exceed_pod_limit',
|
|
127
|
-
}),
|
|
128
|
-
)
|
|
129
|
-
const containerLimit = getResourceRequestPresentation(
|
|
130
|
-
metric({
|
|
131
|
-
fit: 'under_requested',
|
|
132
|
-
limitConflict: true,
|
|
133
|
-
recommendationReason: 'recommended_request_exceeds_limit',
|
|
134
|
-
}),
|
|
135
|
-
)
|
|
136
|
-
expect(podLimit.tone).toBe('review')
|
|
137
|
-
expect(podLimit.secondary).not.toBe(containerLimit.secondary)
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
describe('pod-level request without usage evidence', () => {
|
|
142
|
-
it('still shows the pod-level request instead of Unset', () => {
|
|
143
|
-
for (const row of [
|
|
144
|
-
metric({ fit: 'insufficient_history', podLevelRequest: '128Mi' }),
|
|
145
|
-
metric({ fit: 'insufficient_history', podLevelRequest: '128Mi', queryError: 'usage query failed' }),
|
|
146
|
-
]) {
|
|
147
|
-
expect(getResourceRequestPresentation(row).primary).toContain('128Mi')
|
|
148
|
-
}
|
|
149
|
-
})
|
|
150
|
-
})
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { RightsizingRow } from '../../api/client'
|
|
2
|
-
|
|
3
|
-
export type ResourceSignal = 'hpa' | 'oom' | 'bursty' | 'throttling' | 'query_error'
|
|
4
|
-
export type RightsizingActionTone = 'reduction' | 'increase' | 'review' | 'neutral'
|
|
5
|
-
|
|
6
|
-
export const RIGHTSIZING_ACTION_SEVERITY = {
|
|
7
|
-
reduction: 'info',
|
|
8
|
-
increase: 'warning',
|
|
9
|
-
review: 'neutral',
|
|
10
|
-
} as const
|
|
11
|
-
|
|
12
|
-
export interface ResourceRequestPresentation {
|
|
13
|
-
primary: string
|
|
14
|
-
secondary: string
|
|
15
|
-
signals: ResourceSignal[]
|
|
16
|
-
tone: RightsizingActionTone
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getResourceRequestPresentation(
|
|
20
|
-
row?: RightsizingRow,
|
|
21
|
-
scaledToZero = false,
|
|
22
|
-
): ResourceRequestPresentation {
|
|
23
|
-
if (!row) return { primary: '—', secondary: 'No result returned', signals: [], tone: 'neutral' }
|
|
24
|
-
|
|
25
|
-
const current = row.currentRequest && row.currentRequestValue !== 0 ? row.currentRequest : 'Unset'
|
|
26
|
-
// A pod-level request is what the pod reserves, whether or not usage evidence arrived.
|
|
27
|
-
const currentOnly = row.podLevelRequest
|
|
28
|
-
? `${row.podLevelRequest} for the pod`
|
|
29
|
-
: current === 'Unset'
|
|
30
|
-
? current
|
|
31
|
-
: `${current} current`
|
|
32
|
-
const signals = resourceSignals(row)
|
|
33
|
-
const reason = row.recommendationReason
|
|
34
|
-
|
|
35
|
-
if (row.queryError)
|
|
36
|
-
return { primary: currentOnly, secondary: 'Metrics query failed', signals, tone: 'neutral' }
|
|
37
|
-
if (row.fit === 'pod_level_request')
|
|
38
|
-
return {
|
|
39
|
-
primary: currentOnly,
|
|
40
|
-
secondary: 'Review the pod-level request',
|
|
41
|
-
signals,
|
|
42
|
-
tone: 'review',
|
|
43
|
-
}
|
|
44
|
-
if (row.fit === 'insufficient_history')
|
|
45
|
-
return { primary: currentOnly, secondary: 'Not enough history', signals, tone: 'neutral' }
|
|
46
|
-
if (scaledToZero)
|
|
47
|
-
return { primary: currentOnly, secondary: 'Review before workload runs again', signals, tone: 'review' }
|
|
48
|
-
if (row.hpaManaged)
|
|
49
|
-
return { primary: currentOnly, secondary: 'Review with autoscaling', signals, tone: 'review' }
|
|
50
|
-
if (reason === 'hpa_evidence_unavailable')
|
|
51
|
-
return {
|
|
52
|
-
primary: currentOnly,
|
|
53
|
-
secondary: 'Review — autoscaling status unavailable',
|
|
54
|
-
signals,
|
|
55
|
-
tone: 'review',
|
|
56
|
-
}
|
|
57
|
-
if (reason === 'oom_evidence')
|
|
58
|
-
return { primary: currentOnly, secondary: 'Keep current request', signals, tone: 'review' }
|
|
59
|
-
if (reason === 'oom_evidence_unavailable')
|
|
60
|
-
return {
|
|
61
|
-
primary: currentOnly,
|
|
62
|
-
secondary: 'Review — restart history incomplete',
|
|
63
|
-
signals,
|
|
64
|
-
tone: 'review',
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const isReduction =
|
|
68
|
-
row.recommendedRequestValue != null &&
|
|
69
|
-
row.currentRequestValue != null &&
|
|
70
|
-
row.recommendedRequestValue < row.currentRequestValue
|
|
71
|
-
const comparison = row.recommendedRequest
|
|
72
|
-
? `${current} → ${row.recommendedRequest}`
|
|
73
|
-
: currentOnly
|
|
74
|
-
|
|
75
|
-
if (row.limitConflict)
|
|
76
|
-
return {
|
|
77
|
-
primary: comparison,
|
|
78
|
-
secondary:
|
|
79
|
-
reason === 'requests_exceed_pod_limit'
|
|
80
|
-
? 'Review against the pod limit'
|
|
81
|
-
: 'Raise the limit before changing',
|
|
82
|
-
signals,
|
|
83
|
-
tone: 'review',
|
|
84
|
-
}
|
|
85
|
-
if (row.resource === 'cpu' && isReduction && (row.bursty || (row.throttleRatio ?? 0) >= 0.1))
|
|
86
|
-
return { primary: currentOnly, secondary: 'Review before reducing', signals, tone: 'review' }
|
|
87
|
-
if (row.recommendedRequest) {
|
|
88
|
-
if (current === 'Unset')
|
|
89
|
-
return { primary: comparison, secondary: 'Add request', signals, tone: 'increase' }
|
|
90
|
-
const increase = (row.recommendedRequestValue ?? 0) > (row.currentRequestValue ?? 0)
|
|
91
|
-
return {
|
|
92
|
-
primary: comparison,
|
|
93
|
-
secondary: increase ? 'Increase request' : 'Reduce request',
|
|
94
|
-
signals,
|
|
95
|
-
tone: increase ? 'increase' : 'reduction',
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return { primary: currentOnly, secondary: 'No meaningful change', signals, tone: 'neutral' }
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function resourceSignals(row: RightsizingRow): ResourceSignal[] {
|
|
102
|
-
const signals: ResourceSignal[] = []
|
|
103
|
-
if (row.hpaManaged) signals.push('hpa')
|
|
104
|
-
if (row.resource === 'memory' && (row.currentPodOOM || row.windowOomEvidence)) signals.push('oom')
|
|
105
|
-
if (row.resource === 'cpu' && row.bursty) signals.push('bursty')
|
|
106
|
-
if (row.resource === 'cpu' && (row.throttleRatio ?? 0) >= 0.1) signals.push('throttling')
|
|
107
|
-
if (row.queryError) signals.push('query_error')
|
|
108
|
-
return signals
|
|
109
|
-
}
|