@skyhook-io/radar-app 1.22.0 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +98 -29
- package/src/RadarApp.tsx +5 -0
- package/src/api/client.ts +18 -1
- package/src/api/cnpg-history.ts +3 -3
- package/src/api/cnpg-storage.ts +3 -3
- package/src/api/diagnose.test.ts +34 -0
- package/src/api/diagnose.ts +17 -4
- package/src/api/radarFeatures.test.ts +13 -1
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceActions.test.ts +829 -0
- package/src/api/resourceActions.ts +584 -0
- package/src/api/resourceActions.ui.test.tsx +1882 -0
- package/src/api/reviewedActionMutation.ts +56 -28
- package/src/api/substrateHealth.ts +2 -3
- package/src/api/traffic.ts +13 -5
- package/src/api/workloadMetrics.test.ts +11 -2
- package/src/api/workloadMetrics.ts +2 -2
- package/src/api/workloadSource.test.tsx +857 -0
- package/src/api/workloadSource.ts +292 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AnalysisStory.test.tsx +12 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +34 -1
- package/src/components/diagnose/DiagnoseContext.tsx +28 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -4
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +13 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +61 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.followupFailure.test.tsx +122 -0
- package/src/components/diagnose/InvestigationView.tsx +130 -25
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +1 -1
- package/src/components/diagnose/LocalDiagnoseAction.tsx +2 -2
- package/src/components/diagnose/QuestionComposer.test.tsx +16 -2
- package/src/components/diagnose/QuestionComposer.tsx +13 -8
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +47 -8
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +153 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +9 -13
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +21 -5
- package/src/components/diagnose/investigationEvidence/bodies/network.tsx +63 -26
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/launch.ts +1 -1
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/dock/PodDebugSession.test.tsx +66 -0
- package/src/components/dock/PodDebugSession.tsx +3 -1
- package/src/components/dock/TerminalTab.test.tsx +43 -3
- package/src/components/dock/TerminalTab.tsx +10 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +1 -1
- package/src/components/helm/InstallWizard.tsx +1 -1
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeView.tsx +6 -26
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/resources/PodEvictAction.test.tsx +951 -0
- package/src/components/resources/PodEvictAction.tsx +167 -0
- package/src/components/resources/ResourcesView.tsx +3 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +7 -1
- package/src/components/settings/LocalConnectionSettings.tsx +4 -4
- package/src/components/settings/SettingsDialog.tsx +23 -18
- package/src/components/settings/integrationQueries.test.ts +98 -0
- package/src/components/settings/integrationQueries.ts +36 -0
- package/src/components/traffic/TrafficView.reconnect.test.tsx +229 -0
- package/src/components/traffic/TrafficView.tsx +91 -35
- package/src/components/ui/Markdown.test.tsx +37 -0
- package/src/components/ui/Markdown.tsx +15 -2
- package/src/components/useContextSwitchFlow.test.tsx +27 -2
- package/src/components/useContextSwitchFlow.tsx +20 -22
- package/src/components/workload/WorkloadView.tsx +83 -4
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
2
|
import type { DashboardResponse, DashboardMetrics, DashboardCRDCount } from '../../api/client'
|
|
3
|
+
import type { ReadNameSet } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
3
4
|
import { HealthRing } from './HealthRing'
|
|
4
5
|
import {
|
|
5
6
|
AlertTriangle, CheckCircle, XCircle,
|
|
@@ -10,7 +11,7 @@ import { clsx } from 'clsx'
|
|
|
10
11
|
import { formatCPUMillicores, formatMemoryMiB } from '../../utils/format'
|
|
11
12
|
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
12
13
|
import { HomeAgentBlock } from './HomeAgentBlock'
|
|
13
|
-
import { assetUrl, pluralize, parseContextName, CertaintyGlyph, MiddleEllipsis } from '@skyhook-io/k8s-ui'
|
|
14
|
+
import { assetUrl, pluralize, parseContextName, CertaintyGlyph, MiddleEllipsis, TruncatedText } from '@skyhook-io/k8s-ui'
|
|
14
15
|
import { Tooltip } from '../ui/Tooltip'
|
|
15
16
|
import { mcpEndpointUrl } from '../../api/config'
|
|
16
17
|
import { parseMajorMinor } from '../../utils/version'
|
|
@@ -28,6 +29,7 @@ interface ClusterHealthCardProps {
|
|
|
28
29
|
cluster: DashboardResponse['cluster']
|
|
29
30
|
metrics: DashboardMetrics | null
|
|
30
31
|
metricsServerAvailable: boolean
|
|
32
|
+
selectedNamespaces?: string[]
|
|
31
33
|
topCRDs?: DashboardCRDCount[] // Loaded lazily, may be undefined
|
|
32
34
|
issueCount: number
|
|
33
35
|
hasCriticalIssues: boolean
|
|
@@ -135,6 +137,7 @@ export function ClusterHealthCard({
|
|
|
135
137
|
cluster,
|
|
136
138
|
metrics,
|
|
137
139
|
metricsServerAvailable,
|
|
140
|
+
selectedNamespaces,
|
|
138
141
|
topCRDs: _topCRDs,
|
|
139
142
|
issueCount,
|
|
140
143
|
hasCriticalIssues,
|
|
@@ -228,6 +231,10 @@ export function ClusterHealthCard({
|
|
|
228
231
|
const { raw: rawName, location, headline: rawHeadline } = clusterIdentity(cluster)
|
|
229
232
|
const headlineName = isInCluster ? platformInfo.name : rawHeadline
|
|
230
233
|
|
|
234
|
+
const requestsScope = resolveRequestsScope(metrics?.requestsNamespaces, selectedNamespaces)
|
|
235
|
+
const requestsScopeLabel = requestsScope && requestsScope.count > 0 ? formatRequestsScopeLabel(requestsScope) : undefined
|
|
236
|
+
const requestsScopeTooltip = requestsScope ? formatRequestsScopeTooltip(requestsScope) : undefined
|
|
237
|
+
|
|
231
238
|
return (
|
|
232
239
|
<div className="rounded-xl bg-theme-surface shadow-theme-sm overflow-hidden">
|
|
233
240
|
{/* Main health section - three columns; stacked on phones */}
|
|
@@ -408,17 +415,26 @@ export function ClusterHealthCard({
|
|
|
408
415
|
{metricsServerAvailable && (
|
|
409
416
|
<ResourceBar
|
|
410
417
|
label="Used"
|
|
418
|
+
scope={requestsScope ? 'whole cluster' : undefined}
|
|
411
419
|
used={formatCPUMillicores(metrics.cpu.usageMillis)}
|
|
412
420
|
total={formatCPUMillicores(metrics.cpu.capacityMillis)}
|
|
413
421
|
percent={metrics.cpu.usagePercent}
|
|
414
422
|
/>
|
|
415
423
|
)}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
424
|
+
{requestsScope && requestsScope.count === 0 ? (
|
|
425
|
+
<div className="text-[10px] text-theme-text-tertiary">
|
|
426
|
+
Requested: unavailable (no pods read in this scope)
|
|
427
|
+
</div>
|
|
428
|
+
) : (
|
|
429
|
+
<ResourceBar
|
|
430
|
+
label="Requested"
|
|
431
|
+
scope={requestsScopeLabel}
|
|
432
|
+
scopeTooltip={requestsScopeTooltip}
|
|
433
|
+
used={formatCPUMillicores(metrics.cpu.requestsMillis)}
|
|
434
|
+
total={formatCPUMillicores(metrics.cpu.capacityMillis)}
|
|
435
|
+
percent={metrics.cpu.requestPercent}
|
|
436
|
+
/>
|
|
437
|
+
)}
|
|
422
438
|
</div>
|
|
423
439
|
)}
|
|
424
440
|
{metrics?.memory && (
|
|
@@ -430,17 +446,26 @@ export function ClusterHealthCard({
|
|
|
430
446
|
{metricsServerAvailable && (
|
|
431
447
|
<ResourceBar
|
|
432
448
|
label="Used"
|
|
449
|
+
scope={requestsScope ? 'whole cluster' : undefined}
|
|
433
450
|
used={formatMemoryMiB(metrics.memory.usageMillis)}
|
|
434
451
|
total={formatMemoryMiB(metrics.memory.capacityMillis)}
|
|
435
452
|
percent={metrics.memory.usagePercent}
|
|
436
453
|
/>
|
|
437
454
|
)}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
455
|
+
{requestsScope && requestsScope.count === 0 ? (
|
|
456
|
+
<div className="text-[10px] text-theme-text-tertiary">
|
|
457
|
+
Requested: unavailable (no pods read in this scope)
|
|
458
|
+
</div>
|
|
459
|
+
) : (
|
|
460
|
+
<ResourceBar
|
|
461
|
+
label="Requested"
|
|
462
|
+
scope={requestsScopeLabel}
|
|
463
|
+
scopeTooltip={requestsScopeTooltip}
|
|
464
|
+
used={formatMemoryMiB(metrics.memory.requestsMillis)}
|
|
465
|
+
total={formatMemoryMiB(metrics.memory.capacityMillis)}
|
|
466
|
+
percent={metrics.memory.requestPercent}
|
|
467
|
+
/>
|
|
468
|
+
)}
|
|
444
469
|
</div>
|
|
445
470
|
)}
|
|
446
471
|
{!metricsServerAvailable && (isRestricted('nodes') ? (
|
|
@@ -633,13 +658,45 @@ function RestrictedRing({ label }: { label: string }) {
|
|
|
633
658
|
)
|
|
634
659
|
}
|
|
635
660
|
|
|
661
|
+
function resolveRequestsScope(
|
|
662
|
+
serverScope: ReadNameSet | undefined,
|
|
663
|
+
selectedNamespaces?: string[],
|
|
664
|
+
): ReadNameSet | null {
|
|
665
|
+
if (serverScope) return serverScope
|
|
666
|
+
// An older Radar omits requestsNamespaces; fall back to the picker selection
|
|
667
|
+
// the UI sent so picked namespaces still show their scope.
|
|
668
|
+
if (selectedNamespaces && selectedNamespaces.length > 0) {
|
|
669
|
+
const unique = [...new Set(selectedNamespaces)].sort()
|
|
670
|
+
return { count: unique.length, names: unique }
|
|
671
|
+
}
|
|
672
|
+
return null
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function formatRequestsScopeLabel(scope: ReadNameSet): string {
|
|
676
|
+
if (scope.count === 1 && scope.names?.length === 1) {
|
|
677
|
+
return `in ${scope.names[0]}`
|
|
678
|
+
}
|
|
679
|
+
return `in ${pluralize(scope.count, 'namespace')}`
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function formatRequestsScopeTooltip(scope: ReadNameSet): string | undefined {
|
|
683
|
+
if (!scope.names || scope.names.length <= 1) return undefined
|
|
684
|
+
const maxShown = 8
|
|
685
|
+
if (scope.names.length <= maxShown) return scope.names.join(', ')
|
|
686
|
+
return `${scope.names.slice(0, maxShown).join(', ')} and ${scope.count - maxShown} more`
|
|
687
|
+
}
|
|
688
|
+
|
|
636
689
|
function ResourceBar({
|
|
637
690
|
label,
|
|
691
|
+
scope,
|
|
692
|
+
scopeTooltip,
|
|
638
693
|
used,
|
|
639
694
|
total,
|
|
640
695
|
percent,
|
|
641
696
|
}: {
|
|
642
697
|
label: string
|
|
698
|
+
scope?: string
|
|
699
|
+
scopeTooltip?: string
|
|
643
700
|
used: string
|
|
644
701
|
total: string
|
|
645
702
|
percent: number
|
|
@@ -648,10 +705,27 @@ function ResourceBar({
|
|
|
648
705
|
|
|
649
706
|
return (
|
|
650
707
|
<div>
|
|
651
|
-
|
|
652
|
-
<
|
|
653
|
-
|
|
654
|
-
|
|
708
|
+
{scope ? (
|
|
709
|
+
<div className="mb-0.5 space-y-0.5">
|
|
710
|
+
<TruncatedText
|
|
711
|
+
text={`${label} (${scope})`}
|
|
712
|
+
tooltip={scopeTooltip}
|
|
713
|
+
className="text-[10px] text-theme-text-secondary"
|
|
714
|
+
>
|
|
715
|
+
<span>{label}</span>{' '}
|
|
716
|
+
<span className="text-theme-text-tertiary">({scope})</span>
|
|
717
|
+
</TruncatedText>
|
|
718
|
+
<div className="flex justify-between items-baseline">
|
|
719
|
+
<span className="text-[10px] text-theme-text-tertiary font-mono">{used} / {total}</span>
|
|
720
|
+
<span className="text-[10px] font-medium text-theme-text-secondary font-mono">{percent}%</span>
|
|
721
|
+
</div>
|
|
722
|
+
</div>
|
|
723
|
+
) : (
|
|
724
|
+
<div className="flex justify-between items-baseline mb-0.5">
|
|
725
|
+
<span className="text-[10px] text-theme-text-tertiary font-mono">{label}: {used} / {total}</span>
|
|
726
|
+
<span className="text-[10px] font-medium text-theme-text-secondary font-mono">{percent}%</span>
|
|
727
|
+
</div>
|
|
728
|
+
)}
|
|
655
729
|
<div className="h-2 bg-theme-border rounded overflow-hidden">
|
|
656
730
|
<div
|
|
657
731
|
className={clsx('h-full transition-all', barColor)}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { renderToString } from "react-dom/server";
|
|
4
|
+
import type { DashboardMetrics, DashboardResourceCounts } from "../../api/client";
|
|
5
|
+
import { ClusterHealthCard } from "./ClusterHealthCard";
|
|
6
|
+
|
|
7
|
+
vi.mock("./HomeAgentBlock", () => ({ HomeAgentBlock: () => null }));
|
|
8
|
+
|
|
9
|
+
const baseCounts: DashboardResourceCounts = {
|
|
10
|
+
pods: { total: 10, running: 10, pending: 0, failed: 0, succeeded: 0 },
|
|
11
|
+
deployments: { total: 2, available: 2, unavailable: 0 },
|
|
12
|
+
statefulSets: { total: 0, ready: 0, unready: 0 },
|
|
13
|
+
daemonSets: { total: 0, ready: 0, unready: 0 },
|
|
14
|
+
services: 2,
|
|
15
|
+
ingresses: 0,
|
|
16
|
+
nodes: { total: 2, ready: 2, notReady: 0, cordoned: 0 },
|
|
17
|
+
namespaces: 5,
|
|
18
|
+
jobs: { total: 0, active: 0, succeeded: 0, failed: 0 },
|
|
19
|
+
cronJobs: { total: 0, active: 0, suspended: 0 },
|
|
20
|
+
configMaps: 0,
|
|
21
|
+
secrets: 0,
|
|
22
|
+
pvcs: { total: 0, bound: 0, pending: 0, unbound: 0 },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function baseMetrics(overrides: Partial<DashboardMetrics> = {}): DashboardMetrics {
|
|
26
|
+
return {
|
|
27
|
+
usageAvailable: true,
|
|
28
|
+
cpu: {
|
|
29
|
+
usageMillis: 2500,
|
|
30
|
+
requestsMillis: 500,
|
|
31
|
+
capacityMillis: 8000,
|
|
32
|
+
usagePercent: 31,
|
|
33
|
+
requestPercent: 6,
|
|
34
|
+
},
|
|
35
|
+
memory: {
|
|
36
|
+
usageMillis: 32 * 1024,
|
|
37
|
+
requestsMillis: 2 * 1024,
|
|
38
|
+
capacityMillis: 64 * 1024,
|
|
39
|
+
usagePercent: 50,
|
|
40
|
+
requestPercent: 3,
|
|
41
|
+
},
|
|
42
|
+
...overrides,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function renderCard({
|
|
47
|
+
metrics = baseMetrics(),
|
|
48
|
+
metricsServerAvailable = true,
|
|
49
|
+
selectedNamespaces,
|
|
50
|
+
}: {
|
|
51
|
+
metrics?: DashboardMetrics | null;
|
|
52
|
+
metricsServerAvailable?: boolean;
|
|
53
|
+
selectedNamespaces?: string[];
|
|
54
|
+
}): string {
|
|
55
|
+
return renderToString(
|
|
56
|
+
<ClusterHealthCard
|
|
57
|
+
health={{ healthy: 10, warning: 0, error: 0, warningEvents: 0 }}
|
|
58
|
+
counts={baseCounts}
|
|
59
|
+
cluster={{ name: "test", platform: "eks", version: "1.32", connected: true }}
|
|
60
|
+
metrics={metrics}
|
|
61
|
+
metricsServerAvailable={metricsServerAvailable}
|
|
62
|
+
selectedNamespaces={selectedNamespaces}
|
|
63
|
+
issueCount={0}
|
|
64
|
+
hasCriticalIssues={false}
|
|
65
|
+
nodeVersionSkew={null}
|
|
66
|
+
onNavigateToKind={() => {}}
|
|
67
|
+
onNavigateToView={() => {}}
|
|
68
|
+
/>,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function textContent(html: string): string {
|
|
73
|
+
const div = document.createElement("div");
|
|
74
|
+
div.innerHTML = html;
|
|
75
|
+
return div.textContent ?? "";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe("ClusterHealthCard resource utilization scope labels", () => {
|
|
79
|
+
it("keeps plain Used and Requested labels when metrics are cluster-wide", () => {
|
|
80
|
+
const text = textContent(renderCard({ selectedNamespaces: [] }));
|
|
81
|
+
expect(text).toContain("Used: 2.5 cores / 8 cores");
|
|
82
|
+
expect(text).toContain("Requested: 0.50 cores / 8 cores");
|
|
83
|
+
expect(text).toContain("Used: 32 GiB / 64 GiB");
|
|
84
|
+
expect(text).toContain("Requested: 2.0 GiB / 64 GiB");
|
|
85
|
+
expect(text).not.toContain("whole cluster");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("labels cluster usage and single-namespace requests when one namespace is picked", () => {
|
|
89
|
+
const text = textContent(
|
|
90
|
+
renderCard({
|
|
91
|
+
metrics: baseMetrics({ requestsNamespaces: { count: 1, names: ["istio-system"] } }),
|
|
92
|
+
selectedNamespaces: ["istio-system"],
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
expect(text).toContain("Used (whole cluster)");
|
|
96
|
+
expect(text).toContain("Requested (in istio-system)");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("labels multi-namespace requests by count", () => {
|
|
100
|
+
const text = textContent(
|
|
101
|
+
renderCard({
|
|
102
|
+
metrics: baseMetrics({ requestsNamespaces: { count: 3, names: ["app", "istio-system", "payments"] } }),
|
|
103
|
+
selectedNamespaces: ["app", "istio-system", "payments"],
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
expect(text).toContain("Used (whole cluster)");
|
|
107
|
+
expect(text).toContain("Requested (in 3 namespaces)");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("uses server requestsNamespaces for a restricted user with no picker selection", () => {
|
|
111
|
+
const text = textContent(
|
|
112
|
+
renderCard({
|
|
113
|
+
metrics: baseMetrics({ requestsNamespaces: { count: 2, names: ["team-a", "team-b"] } }),
|
|
114
|
+
selectedNamespaces: [],
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
117
|
+
expect(text).toContain("Used (whole cluster)");
|
|
118
|
+
expect(text).toContain("Requested (in 2 namespaces)");
|
|
119
|
+
|
|
120
|
+
const largeText = textContent(
|
|
121
|
+
renderCard({
|
|
122
|
+
metrics: baseMetrics({ requestsNamespaces: { count: 70 } }),
|
|
123
|
+
selectedNamespaces: [],
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
expect(largeText).toContain("Requested (in 70 namespaces)");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("keeps the requests scope when metrics-server usage is unavailable", () => {
|
|
130
|
+
const text = textContent(
|
|
131
|
+
renderCard({
|
|
132
|
+
metrics: baseMetrics({
|
|
133
|
+
usageAvailable: false,
|
|
134
|
+
requestsNamespaces: { count: 1, names: ["istio-system"] },
|
|
135
|
+
}),
|
|
136
|
+
metricsServerAvailable: false,
|
|
137
|
+
selectedNamespaces: ["istio-system"],
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
expect(text).not.toContain("Used (whole cluster)");
|
|
141
|
+
expect(text).toContain("Requested (in istio-system)");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("handles older Radar without requestsNamespaces by falling back to picked namespaces", () => {
|
|
145
|
+
const single = textContent(
|
|
146
|
+
renderCard({
|
|
147
|
+
metrics: baseMetrics({ requestsNamespaces: undefined }),
|
|
148
|
+
selectedNamespaces: ["istio-system"],
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
expect(single).toContain("Used (whole cluster)");
|
|
152
|
+
expect(single).toContain("Requested (in istio-system)");
|
|
153
|
+
|
|
154
|
+
const multi = textContent(
|
|
155
|
+
renderCard({
|
|
156
|
+
metrics: baseMetrics({ requestsNamespaces: undefined }),
|
|
157
|
+
selectedNamespaces: ["app-b", "app-a"],
|
|
158
|
+
}),
|
|
159
|
+
);
|
|
160
|
+
expect(multi).toContain("Requested (in 2 namespaces)");
|
|
161
|
+
|
|
162
|
+
const unscoped = textContent(
|
|
163
|
+
renderCard({
|
|
164
|
+
metrics: baseMetrics({ requestsNamespaces: undefined }),
|
|
165
|
+
selectedNamespaces: [],
|
|
166
|
+
}),
|
|
167
|
+
);
|
|
168
|
+
expect(unscoped).not.toContain("whole cluster");
|
|
169
|
+
expect(unscoped).toContain("Used: 32 GiB / 64 GiB");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("shows requests as unavailable instead of 0% when no pod namespaces were read", () => {
|
|
173
|
+
const text = textContent(
|
|
174
|
+
renderCard({
|
|
175
|
+
metrics: baseMetrics({
|
|
176
|
+
cpu: { usageMillis: 2500, requestsMillis: 0, capacityMillis: 8000, usagePercent: 31, requestPercent: 0 },
|
|
177
|
+
memory: { usageMillis: 32 * 1024, requestsMillis: 0, capacityMillis: 64 * 1024, usagePercent: 50, requestPercent: 0 },
|
|
178
|
+
requestsNamespaces: { count: 0, names: [] },
|
|
179
|
+
}),
|
|
180
|
+
selectedNamespaces: ["uncollected-ns"],
|
|
181
|
+
}),
|
|
182
|
+
);
|
|
183
|
+
expect(text).toContain("Used (whole cluster)");
|
|
184
|
+
expect(text).toContain("Requested: unavailable (no pods read in this scope)");
|
|
185
|
+
expect(text).not.toMatch(/(?<!\d)0%/);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
2
|
import { useCloudConnectSelf, useDashboard, useDashboardCRDs, useDashboardHelm, useIssues, useVersionCheck, type IssuesResponse } from '../../api/client'
|
|
3
3
|
import { useConnection } from '../../context/ConnectionContext'
|
|
4
4
|
import type { ClusterLoadState } from '../../types/clusterLoadState'
|
|
5
|
-
import type { ExtendedMainView,
|
|
5
|
+
import type { ExtendedMainView, SelectedResource } from '../../types'
|
|
6
6
|
import { TopologyPreview } from './TopologyPreview'
|
|
7
7
|
import { HelmSummary } from './HelmSummary'
|
|
8
8
|
import { ActivitySummary } from './ActivitySummary'
|
|
@@ -44,7 +44,6 @@ import { HOVER_REVEAL_ACTION, HOVER_REVEAL_HIT, HOVER_REVEAL_REST } from '../../
|
|
|
44
44
|
|
|
45
45
|
interface HomeViewProps {
|
|
46
46
|
namespaces: string[]
|
|
47
|
-
topology: Topology | null
|
|
48
47
|
onNavigateToView: (view: ExtendedMainView, params?: Record<string, string>) => void
|
|
49
48
|
onNavigateToIssue?: (id: string) => void
|
|
50
49
|
onNavigateToResourceKind: (kind: string, group?: string, filters?: Record<string, string[]>) => void
|
|
@@ -63,7 +62,7 @@ interface HomeViewProps {
|
|
|
63
62
|
onNavigateToManagerPath?: (path: string) => void
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
export function HomeView({ namespaces,
|
|
65
|
+
export function HomeView({ namespaces, fallbackClusterLoadState, onNavigateToView, onNavigateToIssue, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
|
|
67
66
|
// The card itself decides whether the cluster has a capacity story
|
|
68
67
|
// (available, softened-denied, or karpenterless-with-managers/groups) and
|
|
69
68
|
// returns null otherwise — the outer gate only excludes states with nothing
|
|
@@ -87,25 +86,6 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
87
86
|
&& getVersionUpdateStatus(versionInfo.currentVersion, versionInfo.latestVersion).tier !== 'none'
|
|
88
87
|
const { data: installationManager, isLoading: installationManagerLoading } = useCloudConnectSelf(showHomeUpgrade)
|
|
89
88
|
|
|
90
|
-
// SSE is cluster-wide on small/medium clusters; the picker only narrows the
|
|
91
|
-
// dashboard summary, so re-apply the filter here or the legend disagrees.
|
|
92
|
-
const scopedTopology = useMemo<Topology | null>(() => {
|
|
93
|
-
if (!topology) return null
|
|
94
|
-
if (namespaces.length === 0) return topology
|
|
95
|
-
const nsSet = new Set(namespaces)
|
|
96
|
-
const nodes = topology.nodes.filter(n => {
|
|
97
|
-
const ns = n.data.namespace as string | undefined
|
|
98
|
-
return !ns || nsSet.has(ns)
|
|
99
|
-
})
|
|
100
|
-
const nodeIds = new Set(nodes.map(n => n.id))
|
|
101
|
-
const edges = topology.edges.filter(e => nodeIds.has(e.source) && nodeIds.has(e.target))
|
|
102
|
-
// Carry the frame's own flags through the filter. A large cluster serves an
|
|
103
|
-
// empty graph flagged requiresNamespaceFilter until SSE picks the pick up
|
|
104
|
-
// server-side, and a consumer that sees only nodes/edges reads that
|
|
105
|
-
// declined build as a namespace holding nothing.
|
|
106
|
-
return { ...topology, nodes, edges }
|
|
107
|
-
}, [topology, namespaces])
|
|
108
|
-
const networkPolicyTarget = getNetworkPolicyResourceTarget(scopedTopology)
|
|
109
89
|
// CRDs and Helm load lazily after main dashboard to keep initial load fast
|
|
110
90
|
const { data: crdsData } = useDashboardCRDs(namespaces)
|
|
111
91
|
const { data: helmData } = useDashboardHelm(namespaces)
|
|
@@ -175,6 +155,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
175
155
|
cluster={data.cluster}
|
|
176
156
|
metrics={data.metrics}
|
|
177
157
|
metricsServerAvailable={data.metricsServerAvailable}
|
|
158
|
+
selectedNamespaces={namespaces}
|
|
178
159
|
topCRDs={crdsData?.topCRDs}
|
|
179
160
|
issueCount={issueCount}
|
|
180
161
|
hasCriticalIssues={hasCriticalIssues}
|
|
@@ -194,13 +175,11 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
194
175
|
These are the richest visuals and the most-used live views, so they get the width. */}
|
|
195
176
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
|
196
177
|
<TopologyPreview
|
|
197
|
-
|
|
198
|
-
namespaceSelected={namespaces.length > 0}
|
|
178
|
+
counts={data.resourceCounts}
|
|
199
179
|
onNavigate={() => onNavigateToView('topology')}
|
|
200
180
|
/>
|
|
201
181
|
<ActivitySummary
|
|
202
182
|
namespaces={namespaces}
|
|
203
|
-
topology={scopedTopology}
|
|
204
183
|
onNavigate={() => onNavigateToView('timeline')}
|
|
205
184
|
/>
|
|
206
185
|
</div>
|
|
@@ -244,6 +223,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
244
223
|
<NetworkPolicyCoverageCard
|
|
245
224
|
data={data.networkPolicyCoverage}
|
|
246
225
|
onNavigate={() => {
|
|
226
|
+
const networkPolicyTarget = getNetworkPolicyResourceTarget(data.networkPolicyCoverage)
|
|
247
227
|
if (networkPolicyTarget) {
|
|
248
228
|
onNavigateToResourceKind(networkPolicyTarget.kind, networkPolicyTarget.group)
|
|
249
229
|
} else {
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import { act } from 'react'
|
|
3
3
|
import { createRoot, type Root } from 'react-dom/client'
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
-
import type {
|
|
5
|
+
import type { DashboardResourceCounts } from '../../api/client'
|
|
6
6
|
import { TopologyPreview } from './TopologyPreview'
|
|
7
7
|
|
|
8
8
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} as
|
|
10
|
+
const workloads = (total: number) => ({ total, ready: total, unready: 0 })
|
|
11
|
+
const counts = (over: Partial<DashboardResourceCounts> = {}) => ({
|
|
12
|
+
services: 12,
|
|
13
|
+
deployments: { total: 7, available: 7, unavailable: 0 },
|
|
14
|
+
statefulSets: workloads(2),
|
|
15
|
+
daemonSets: workloads(3),
|
|
16
|
+
...over,
|
|
17
|
+
}) as DashboardResourceCounts
|
|
18
18
|
|
|
19
19
|
let container: HTMLDivElement
|
|
20
20
|
let root: Root
|
|
@@ -30,43 +30,44 @@ afterEach(() => {
|
|
|
30
30
|
container.remove()
|
|
31
31
|
})
|
|
32
32
|
|
|
33
|
-
function render(
|
|
34
|
-
act(() => root.render(<TopologyPreview
|
|
33
|
+
function render(resourceCounts: DashboardResourceCounts, onNavigate = vi.fn()) {
|
|
34
|
+
act(() => root.render(<TopologyPreview counts={resourceCounts} onNavigate={onNavigate} />))
|
|
35
35
|
return onNavigate
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const header = () => container.querySelector('button > div > div')!.textContent
|
|
39
39
|
|
|
40
40
|
describe('TopologyPreview', () => {
|
|
41
|
-
it('
|
|
42
|
-
render(
|
|
43
|
-
expect(header()).toContain('
|
|
41
|
+
it('counts the services and workloads the picture connects', () => {
|
|
42
|
+
render(counts())
|
|
43
|
+
expect(header()).toContain('12 services · 12 workloads')
|
|
44
44
|
expect(container.textContent).toContain('How ingresses, services and workloads connect, grouped by namespace.')
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
it('
|
|
48
|
-
render(
|
|
49
|
-
|
|
50
|
-
render(
|
|
51
|
-
expect(header()).
|
|
52
|
-
expect(container.querySelector('[data-testid="topology-counts-loading"]')).toBeNull()
|
|
53
|
-
expect(container.querySelector('svg')!.innerHTML.replace(/_r_\w+_/g, '')).toBe(smallDrawing)
|
|
47
|
+
it('shows an empty scope as an honest zero, in the singular where it reads so', () => {
|
|
48
|
+
render(counts({ services: 1, deployments: { total: 0, available: 0, unavailable: 0 }, statefulSets: workloads(0), daemonSets: workloads(1) }))
|
|
49
|
+
expect(header()).toContain('1 service · 1 workload')
|
|
50
|
+
render(counts({ services: 0, deployments: { total: 0, available: 0, unavailable: 0 }, statefulSets: workloads(0), daemonSets: workloads(0) }))
|
|
51
|
+
expect(header()).toContain('0 services · 0 workloads')
|
|
54
52
|
})
|
|
55
53
|
|
|
56
|
-
it('
|
|
57
|
-
render(
|
|
58
|
-
expect(
|
|
54
|
+
it('leaves out a count the user cannot fully list rather than showing it short', () => {
|
|
55
|
+
render(counts({ restricted: ['statefulsets'] }))
|
|
56
|
+
expect(header()).toContain('12 services')
|
|
57
|
+
expect(header()).not.toContain('workload')
|
|
58
|
+
render(counts({ restricted: ['services', 'deployments'] }))
|
|
59
|
+
expect(header()).toBe('Topology')
|
|
59
60
|
})
|
|
60
61
|
|
|
61
|
-
it('
|
|
62
|
-
render(
|
|
63
|
-
|
|
64
|
-
render(
|
|
65
|
-
expect(container.querySelector('
|
|
62
|
+
it('draws the same picture whatever the cluster holds', () => {
|
|
63
|
+
render(counts())
|
|
64
|
+
const drawing = container.querySelector('svg')!.innerHTML.replace(/_r_\w+_/g, '')
|
|
65
|
+
render(counts({ services: 900 }))
|
|
66
|
+
expect(container.querySelector('svg')!.innerHTML.replace(/_r_\w+_/g, '')).toBe(drawing)
|
|
66
67
|
})
|
|
67
68
|
|
|
68
69
|
it('opens Topology from anywhere on the card', () => {
|
|
69
|
-
const onNavigate = render(
|
|
70
|
+
const onNavigate = render(counts())
|
|
70
71
|
act(() => container.querySelector('svg')!.dispatchEvent(new MouseEvent('click', { bubbles: true })))
|
|
71
72
|
expect(onNavigate).toHaveBeenCalledTimes(1)
|
|
72
73
|
})
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { useId
|
|
2
|
-
import type {
|
|
1
|
+
import { useId } from 'react'
|
|
2
|
+
import type { DashboardResourceCounts } from '../../api/client'
|
|
3
3
|
import { Network } from 'lucide-react'
|
|
4
4
|
import { useElementSize } from '../../hooks/useElementSize'
|
|
5
5
|
import { HomeDiagramCard } from './HomeDiagramCard'
|
|
6
6
|
|
|
7
7
|
interface TopologyPreviewProps {
|
|
8
|
-
|
|
9
|
-
namespaceSelected: boolean
|
|
8
|
+
counts: DashboardResourceCounts
|
|
10
9
|
onNavigate: () => void
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -112,31 +111,23 @@ function TopologySchematic() {
|
|
|
112
111
|
)
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// honest zero.
|
|
130
|
-
const counts = useMemo(() => {
|
|
131
|
-
if (!topology || topology.requiresNamespaceFilter) return null
|
|
132
|
-
return { nodeCount: topology.nodes.length, edgeCount: topology.edges.length }
|
|
133
|
-
}, [topology])
|
|
114
|
+
// What the graph connects, counted from the dashboard's own totals rather than
|
|
115
|
+
// a graph build: it says Radar knows this cluster's services and workloads,
|
|
116
|
+
// not what Topology will draw after its filters. A count the user can't fully
|
|
117
|
+
// list is left out rather than shown short.
|
|
118
|
+
function topologyFact(counts: DashboardResourceCounts): string | undefined {
|
|
119
|
+
const restricted = new Set(counts.restricted ?? [])
|
|
120
|
+
const parts: string[] = []
|
|
121
|
+
if (!restricted.has('services')) parts.push(`${counts.services} ${counts.services === 1 ? 'service' : 'services'}`)
|
|
122
|
+
if (!['deployments', 'statefulsets', 'daemonsets'].some(kind => restricted.has(kind))) {
|
|
123
|
+
const workloads = counts.deployments.total + counts.statefulSets.total + counts.daemonSets.total
|
|
124
|
+
parts.push(`${workloads} ${workloads === 1 ? 'workload' : 'workloads'}`)
|
|
125
|
+
}
|
|
126
|
+
return parts.length > 0 ? parts.join(' · ') : undefined
|
|
127
|
+
}
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
) : needsNamespaceFilter ? undefined : (
|
|
138
|
-
<span data-testid="topology-counts-loading" className="inline-block h-3 w-28 rounded bg-theme-text-tertiary/20 animate-pulse align-middle" />
|
|
139
|
-
)
|
|
129
|
+
export function TopologyPreview({ counts, onNavigate }: TopologyPreviewProps) {
|
|
130
|
+
const fact = topologyFact(counts)
|
|
140
131
|
|
|
141
132
|
return (
|
|
142
133
|
<HomeDiagramCard
|
|
@@ -27,9 +27,9 @@ export interface MCPToolInfo {
|
|
|
27
27
|
|
|
28
28
|
export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
29
29
|
{
|
|
30
|
-
name: '
|
|
31
|
-
desc: '
|
|
32
|
-
params: [{ arg: 'namespace', desc: '
|
|
30
|
+
name: 'get_cluster_overview',
|
|
31
|
+
desc: 'Where am I and where should I look: which cluster this is, its nodes and workload counts, what you can see, and live issue counts by severity, category and namespace with a few headlines. Start here, then call issues for the problems themselves.',
|
|
32
|
+
params: [{ arg: 'namespace', desc: 'orient on one namespace' }],
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
name: 'top_resources',
|
|
@@ -59,7 +59,7 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
59
59
|
{ arg: 'name', required: true, desc: 'resource name' },
|
|
60
60
|
{ arg: 'namespace', desc: 'omit for cluster-scoped kinds (Node, ClusterRole, IngressClass, etc.)' },
|
|
61
61
|
{ arg: 'group', desc: 'API group when the kind is ambiguous (e.g. serving.knative.dev for Knative Service vs core Service)' },
|
|
62
|
-
{ arg: 'include', desc: 'events, metrics, changes, issues, drain-plan (Node pod/PDB estimate), revisions (rollback targets for Deployment/StatefulSet/DaemonSet/Rollout)' },
|
|
62
|
+
{ arg: 'include', desc: 'identity (observed UID and resourceVersion), events, metrics, changes, issues, drain-plan (Node pod/PDB estimate), revisions (rollback targets for Deployment/StatefulSet/DaemonSet/Rollout)' },
|
|
63
63
|
{ arg: 'context', desc: 'resourceContext tier: basic (default) or none' },
|
|
64
64
|
{ arg: 'relationship', desc: 'one relationship field a partial-preview warning named (e.g. dependents), returned with up to 200 entries' },
|
|
65
65
|
],
|