@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { beforeAll, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
|
|
4
|
+
const volume = { apiVersion: 'longhorn.io/v1beta2', kind: 'Volume', metadata: { name: 'pvc-1', namespace: 'longhorn-system' }, spec: { numberOfReplicas: 3 }, status: { state: 'attached', robustness: 'healthy', kubernetesStatus: { namespace: 'shop', pvcName: 'data-db-0', lastPVCRefAt: '' } } }
|
|
5
|
+
|
|
6
|
+
async function render(engines: { data?: any[]; error?: unknown; isLoading?: boolean; coverage?: { status: string } }, namespaces?: { name: string }[], authEnabled?: boolean) {
|
|
7
|
+
vi.resetModules()
|
|
8
|
+
vi.doMock('../../../api/client', () => ({
|
|
9
|
+
useResources: () => ({ data: engines.data, coverage: engines.coverage, error: engines.error ?? null, isError: !!engines.error, isLoading: !!engines.isLoading }),
|
|
10
|
+
useNamespaces: () => ({ data: namespaces }),
|
|
11
|
+
useAuthMe: () => ({ data: authEnabled === undefined ? undefined : { authEnabled } }),
|
|
12
|
+
}))
|
|
13
|
+
const { LonghornVolumeRenderer } = await import('./LonghornVolumeRenderer')
|
|
14
|
+
const html = renderToStaticMarkup(<LonghornVolumeRenderer data={volume} />)
|
|
15
|
+
vi.doUnmock('../../../api/client')
|
|
16
|
+
return html
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('LonghornVolumeRenderer (host)', () => {
|
|
20
|
+
// The first dynamic import transforms the renderer's whole k8s-ui graph; pay
|
|
21
|
+
// that once here so each test's own timeout still catches a real hang.
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
await render({})
|
|
24
|
+
}, 30_000)
|
|
25
|
+
|
|
26
|
+
it('counts healthy replicas from the volume\'s own Engine', async () => {
|
|
27
|
+
const html = await render({ data: [
|
|
28
|
+
{ spec: { volumeName: 'other' }, status: { replicaModeMap: { x: 'RW' } } },
|
|
29
|
+
{ spec: { volumeName: 'pvc-1' }, status: { replicaModeMap: { a: 'RW', b: 'RW', c: 'RW' } } },
|
|
30
|
+
] })
|
|
31
|
+
expect(html).toContain('3 of 3')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('says when it could not read the Engine instead of looking checked', async () => {
|
|
35
|
+
const html = await render({ error: new Error('boom') })
|
|
36
|
+
expect(html).toContain('? of 3')
|
|
37
|
+
expect(html).toContain('Could not check')
|
|
38
|
+
expect(html).not.toContain('Engine not running')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('reads the active Engine while a volume migrates, and unknown when none is active', async () => {
|
|
42
|
+
const migrating = await render({ data: [
|
|
43
|
+
{ spec: { volumeName: 'pvc-1', active: false }, status: { replicaModeMap: { a: 'RW' } } },
|
|
44
|
+
{ spec: { volumeName: 'pvc-1', active: true }, status: { replicaModeMap: { a: 'RW', b: 'RW', c: 'RW' } } },
|
|
45
|
+
] })
|
|
46
|
+
expect(migrating).toContain('3 of 3')
|
|
47
|
+
const ambiguous = await render({ data: [
|
|
48
|
+
{ spec: { volumeName: 'pvc-1', active: false }, status: { replicaModeMap: { a: 'RW' } } },
|
|
49
|
+
{ spec: { volumeName: 'pvc-1', active: false }, status: { replicaModeMap: { a: 'RW', b: 'RW' } } },
|
|
50
|
+
] })
|
|
51
|
+
expect(ambiguous).toContain('? of 3')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('does not call the Engine stopped while the lookup is still loading', async () => {
|
|
55
|
+
const html = await render({ isLoading: true })
|
|
56
|
+
expect(html).toContain('? of 3')
|
|
57
|
+
expect(html).not.toContain('Engine not running')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('says the Engine is not running once the lookup finds none for this volume', async () => {
|
|
61
|
+
const html = await render({ data: [{ spec: { volumeName: 'other' }, status: { replicaModeMap: { x: 'RW' } } }], coverage: { status: 'complete' } })
|
|
62
|
+
expect(html).toContain('? of 3 (Engine not running)')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('shows Longhorn\'s recorded PVC only when the caller\'s namespace list includes it', async () => {
|
|
66
|
+
expect(await render({ data: [] }, [{ name: 'shop' }])).toContain('shop/data-db-0')
|
|
67
|
+
expect(await render({ data: [] }, [{ name: 'other' }])).not.toContain('data-db-0')
|
|
68
|
+
expect(await render({ data: [] })).not.toContain('data-db-0')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('keeps the history of a deleted namespace when auth is off, and decides from the list while the auth status loads', async () => {
|
|
72
|
+
expect(await render({ data: [] }, [{ name: 'other' }], false)).toContain('shop/data-db-0')
|
|
73
|
+
expect(await render({ data: [] }, undefined, false)).toContain('shop/data-db-0')
|
|
74
|
+
expect(await render({ data: [] }, [{ name: 'other' }], undefined)).not.toContain('data-db-0')
|
|
75
|
+
expect(await render({ data: [] }, [{ name: 'shop' }], undefined)).toContain('shop/data-db-0')
|
|
76
|
+
expect(await render({ data: [] }, [{ name: 'other' }], true)).not.toContain('data-db-0')
|
|
77
|
+
expect(await render({ data: [] }, undefined, true)).not.toContain('data-db-0')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('does not call the Engine stopped when the read was partial or its coverage unknown', async () => {
|
|
81
|
+
for (const coverage of [{ status: 'partial' }, { status: 'unknown' }, undefined]) {
|
|
82
|
+
const html = await render({ data: [], coverage })
|
|
83
|
+
expect(html).toContain('? of 3')
|
|
84
|
+
expect(html).not.toContain('Engine not running')
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('reads unknown when more than one Engine is marked active', async () => {
|
|
89
|
+
const html = await render({ data: [
|
|
90
|
+
{ spec: { volumeName: 'pvc-1', active: true }, status: { replicaModeMap: { a: 'RW' } } },
|
|
91
|
+
{ spec: { volumeName: 'pvc-1', active: true }, status: { replicaModeMap: { a: 'RW', b: 'RW' } } },
|
|
92
|
+
], coverage: { status: 'complete' } })
|
|
93
|
+
expect(html).toContain('? of 3')
|
|
94
|
+
expect(html).not.toContain('1 of 3')
|
|
95
|
+
expect(html).not.toContain('2 of 3')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('drops the last count when a refresh fails', async () => {
|
|
99
|
+
const html = await render({ data: [{ spec: { volumeName: 'pvc-1', active: true }, status: { replicaModeMap: { a: 'RW', b: 'RW', c: 'RW' } } }], error: new Error('boom') })
|
|
100
|
+
expect(html).toContain('? of 3')
|
|
101
|
+
expect(html).not.toContain('3 of 3')
|
|
102
|
+
expect(html).toContain('Could not check')
|
|
103
|
+
})
|
|
104
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LonghornVolumeRenderer as BaseLonghornVolumeRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/LonghornVolumeRenderer'
|
|
2
|
+
import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
|
|
3
|
+
import { LONGHORN_GROUP } from '@skyhook-io/k8s-ui/components/resources/resource-utils-longhorn'
|
|
4
|
+
import { useAuthMe, useNamespaces, useResources } from '../../../api/client'
|
|
5
|
+
|
|
6
|
+
/** Host wrapper: reads the Volume's Engine, the only source of healthy replicas and rebuild progress. */
|
|
7
|
+
export function LonghornVolumeRenderer({ data }: { data: any }) {
|
|
8
|
+
const engines = useResources<any>('engines', data?.metadata?.namespace ?? '', LONGHORN_GROUP)
|
|
9
|
+
const name = data?.metadata?.name
|
|
10
|
+
// A migrating volume has two Engines; Longhorn's current one is spec.active.
|
|
11
|
+
// After a failed refresh the query keeps the last list; don't show a count from it.
|
|
12
|
+
const candidates = engines.error ? [] : engines.data?.filter((e) => e?.spec?.volumeName === name) ?? []
|
|
13
|
+
const active = candidates.filter((e) => e?.spec?.active === true)
|
|
14
|
+
const engine = candidates.length === 1 ? candidates[0] : active.length === 1 ? active[0] : undefined
|
|
15
|
+
const engineUnknown = !!engines.error || (candidates.length > 1 && !engine)
|
|
16
|
+
// Only a complete read proves the volume has no Engine.
|
|
17
|
+
const engineLookedUp = !engines.isLoading && !engines.error && engines.coverage?.status === 'complete'
|
|
18
|
+
// With auth off every namespace is readable, including a deleted one whose
|
|
19
|
+
// history matters most. Otherwise the caller's own namespace list decides;
|
|
20
|
+
// while it or the auth status load, Longhorn's recorded names stay hidden.
|
|
21
|
+
// Capabilities omit authEnabled when it is false, so only /auth/me says "off".
|
|
22
|
+
const authOff = useAuthMe().data?.authEnabled === false
|
|
23
|
+
const readable = useNamespaces().data
|
|
24
|
+
const canReadNamespace = (ns: string) => authOff || !!readable?.some((n) => n.name === ns)
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<BaseLonghornVolumeRenderer data={data} engine={engine} engineUnknown={engineUnknown} engineLookedUp={engineLookedUp} canReadNamespace={canReadNamespace} />
|
|
28
|
+
<LookupFailureNote errors={[engines.error]} what="this volume's engine (healthy replicas, rebuilds)" />
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RIGHTSIZING_SCAN_PATH } from '../../utils/page-links'
|
|
2
|
+
import type { ComponentPropsWithoutRef } from 'react'
|
|
3
|
+
import { Link, useLocation } from 'react-router-dom'
|
|
4
|
+
import { useNavCustomization } from '../../context/NavCustomization'
|
|
5
|
+
|
|
6
|
+
export function RightsizingScanLink(props: Omit<ComponentPropsWithoutRef<'a'>, 'href' | 'onClick' | 'target'>) {
|
|
7
|
+
const { search } = useLocation()
|
|
8
|
+
const { fleetTakeoverHref, onHostNavigate } = useNavCustomization()
|
|
9
|
+
const href = fleetTakeoverHref?.('rightsizing', search)
|
|
10
|
+
if (!href) return <Link {...props} to={{ pathname: RIGHTSIZING_SCAN_PATH, search }} />
|
|
11
|
+
return (
|
|
12
|
+
<a
|
|
13
|
+
{...props}
|
|
14
|
+
href={href}
|
|
15
|
+
onClick={(event) => {
|
|
16
|
+
if (!onHostNavigate || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return
|
|
17
|
+
event.preventDefault()
|
|
18
|
+
onHostNavigate(href)
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|