@skyhook-io/radar-app 1.22.1 → 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 +96 -28
- package/src/RadarApp.tsx +5 -0
- package/src/api/client.ts +6 -1
- 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/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- 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/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- 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 +3 -3
- 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 +4 -1
- package/src/components/workload/WorkloadView.tsx +67 -1
- 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
|
@@ -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',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
1
2
|
import { JobRenderer as BaseJobRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/JobRenderer'
|
|
2
3
|
import { JobSetRenderer as BaseJobSetRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/JobSetRenderer'
|
|
3
4
|
import type { ResourceRef } from '@skyhook-io/k8s-ui'
|
|
4
5
|
import { KueueAdmission } from '../../execution/JobSetAdmission'
|
|
5
6
|
|
|
6
|
-
type Props = { data: any; onNavigate?: (ref: ResourceRef) => void }
|
|
7
|
+
type Props = { data: any; onNavigate?: (ref: ResourceRef) => void; sourceSection?: ReactNode }
|
|
7
8
|
|
|
8
|
-
export function JobRenderer({ data, onNavigate }: Props) {
|
|
9
|
-
if (data.apiVersion !== 'batch/v1' || data.kind !== 'Job') return <BaseJobRenderer data={data} />
|
|
9
|
+
export function JobRenderer({ data, onNavigate, sourceSection }: Props) {
|
|
10
|
+
if (data.apiVersion !== 'batch/v1' || data.kind !== 'Job') return <BaseJobRenderer data={data} sourceSection={sourceSection} />
|
|
10
11
|
return <KueueAdmission presentation="drawer" resource={data} namespace={data.metadata.namespace} name={data.metadata.name} onNavigate={onNavigate}>
|
|
11
|
-
{(admissionContent, kueueManaged) => <BaseJobRenderer data={data} admissionContent={admissionContent} kueueManaged={kueueManaged} />}
|
|
12
|
+
{(admissionContent, kueueManaged) => <BaseJobRenderer data={data} admissionContent={admissionContent} kueueManaged={kueueManaged} sourceSection={sourceSection} />}
|
|
12
13
|
</KueueAdmission>
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
1
2
|
import { RolloutRenderer as BaseRolloutRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/RolloutRenderer'
|
|
2
3
|
import {
|
|
3
4
|
useRolloutAction,
|
|
@@ -11,9 +12,10 @@ import {
|
|
|
11
12
|
interface RolloutRendererProps {
|
|
12
13
|
data: any
|
|
13
14
|
onNavigate?: (ref: { kind: string; namespace: string; name: string }) => void
|
|
15
|
+
sourceSection?: ReactNode
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function RolloutRenderer({ data, onNavigate }: RolloutRendererProps) {
|
|
18
|
+
export function RolloutRenderer({ data, onNavigate, sourceSection }: RolloutRendererProps) {
|
|
17
19
|
const namespace = data?.metadata?.namespace ?? ''
|
|
18
20
|
const name = data?.metadata?.name ?? ''
|
|
19
21
|
const { data: capabilities } = useRolloutCapabilities(namespace, name)
|
|
@@ -33,6 +35,7 @@ export function RolloutRenderer({ data, onNavigate }: RolloutRendererProps) {
|
|
|
33
35
|
analysisRunHistoryError={analysisRunsError}
|
|
34
36
|
revisions={revisions}
|
|
35
37
|
pods={podsResponse?.pods}
|
|
38
|
+
sourceSection={sourceSection}
|
|
36
39
|
/>
|
|
37
40
|
)
|
|
38
41
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
1
2
|
import { WorkloadRenderer as BaseWorkloadRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/WorkloadRenderer'
|
|
2
3
|
import { useNavigate } from 'react-router-dom'
|
|
3
4
|
import { useScaleWorkload, fetchJSON } from '../../../api/client'
|
|
@@ -34,9 +35,10 @@ interface WorkloadRendererProps {
|
|
|
34
35
|
relationships?: Relationships
|
|
35
36
|
scaleBlockedBy?: ResourceRef[]
|
|
36
37
|
workloadPods?: WorkloadPodInfo[]
|
|
38
|
+
sourceSection?: ReactNode
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
export function WorkloadRenderer({ kind, data, onNavigate, scaleBlockedBy, workloadPods }: WorkloadRendererProps) {
|
|
41
|
+
export function WorkloadRenderer({ kind, data, onNavigate, scaleBlockedBy, workloadPods, sourceSection }: WorkloadRendererProps) {
|
|
40
42
|
const navigate = useNavigate()
|
|
41
43
|
const queryClient = useQueryClient()
|
|
42
44
|
const scaleMutation = useScaleWorkload()
|
|
@@ -102,6 +104,7 @@ export function WorkloadRenderer({ kind, data, onNavigate, scaleBlockedBy, workl
|
|
|
102
104
|
rbacData={rbacData ?? null}
|
|
103
105
|
rbacLoading={rbacLoading}
|
|
104
106
|
rbacError={rbacError as Error | null}
|
|
107
|
+
sourceSection={sourceSection}
|
|
105
108
|
policyData={policyData ?? null}
|
|
106
109
|
policyLoading={policyLoading}
|
|
107
110
|
policyError={policyError as Error | null}
|
|
@@ -10,6 +10,7 @@ import { workloadPodAwaitsScheduling } from '../capacity/podDemandGate'
|
|
|
10
10
|
import { Stethoscope } from 'lucide-react'
|
|
11
11
|
import {
|
|
12
12
|
WorkloadView as BaseWorkloadView,
|
|
13
|
+
WorkloadSourceSection,
|
|
13
14
|
EditableYamlView,
|
|
14
15
|
FetchResult,
|
|
15
16
|
Section,
|
|
@@ -120,6 +121,12 @@ import { WorkloadCostTab } from '../cost/WorkloadCostTab'
|
|
|
120
121
|
import { isOpenCostWorkloadKind } from '../cost/kinds'
|
|
121
122
|
import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
|
|
122
123
|
import { useResourceActionAdapter } from '../../api/resourceActions'
|
|
124
|
+
import { getApiBase } from '../../api/config'
|
|
125
|
+
import {
|
|
126
|
+
supportsWorkloadSource,
|
|
127
|
+
toWorkloadSourceState,
|
|
128
|
+
useWorkloadSource,
|
|
129
|
+
} from '../../api/workloadSource'
|
|
123
130
|
import { useTrafficAvailable } from '../../api/traffic'
|
|
124
131
|
import { useIssueExpansion, useIssueRowNotes } from '../issues/useIssueExpansion'
|
|
125
132
|
import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
|
|
@@ -753,6 +760,10 @@ export function WorkloadView({
|
|
|
753
760
|
queryKey: ['workload-pods', apiKind, namespace, name],
|
|
754
761
|
...(apiKind === 'rayclusters' ? { type: 'active' as const } : {}),
|
|
755
762
|
}),
|
|
763
|
+
queryClient.refetchQueries({
|
|
764
|
+
queryKey: ['workload-source', getApiBase(), apiKind.toLowerCase(), namespace, name],
|
|
765
|
+
type: 'active',
|
|
766
|
+
}),
|
|
756
767
|
])
|
|
757
768
|
}, [apiKind, effectiveGroup, name, namespace, queryClient, refetchResource, resource?.metadata?.uid, resource?.spec?.clusterSelector, onRefresh])
|
|
758
769
|
const podWorkloadOwner = useMemo(
|
|
@@ -1289,8 +1300,52 @@ export function WorkloadView({
|
|
|
1289
1300
|
[],
|
|
1290
1301
|
)
|
|
1291
1302
|
|
|
1303
|
+
const drawerScopeKey = `${apiKind}|${namespace}|${name}|${rest.initialTab ?? 'detail'}`
|
|
1304
|
+
const [drawerViewState, setDrawerViewState] = useState<{
|
|
1305
|
+
scope: string
|
|
1306
|
+
view: 'overview' | 'yaml' | 'spec'
|
|
1307
|
+
}>(() => ({
|
|
1308
|
+
scope: drawerScopeKey,
|
|
1309
|
+
view: rest.initialTab === 'yaml' ? 'yaml' : 'overview',
|
|
1310
|
+
}))
|
|
1311
|
+
const drawerView: 'overview' | 'yaml' | 'spec' =
|
|
1312
|
+
drawerViewState.scope === drawerScopeKey
|
|
1313
|
+
? drawerViewState.view
|
|
1314
|
+
: rest.initialTab === 'yaml'
|
|
1315
|
+
? 'yaml'
|
|
1316
|
+
: 'overview'
|
|
1317
|
+
const handleDrawerViewChange = useCallback(
|
|
1318
|
+
(view: 'overview' | 'yaml' | 'spec') => {
|
|
1319
|
+
setDrawerViewState({ scope: drawerScopeKey, view })
|
|
1320
|
+
},
|
|
1321
|
+
[drawerScopeKey],
|
|
1322
|
+
)
|
|
1323
|
+
|
|
1292
1324
|
const supportsWorkloadPods = ['deployments', 'statefulsets', 'daemonsets', 'rollouts'].includes(apiKind)
|
|
1293
1325
|
const workloadPodsQuery = useWorkloadPods(supportsWorkloadPods ? apiKind : '', namespace, name)
|
|
1326
|
+
const workloadSourceSupported = Boolean(namespace) && supportsWorkloadSource(apiKind, effectiveGroup)
|
|
1327
|
+
const workloadSourceVisible = expanded ? migratedTab === 'overview' : drawerView === 'overview'
|
|
1328
|
+
const workloadSourceEnabled =
|
|
1329
|
+
workloadSourceSupported &&
|
|
1330
|
+
Boolean(resource) &&
|
|
1331
|
+
rest.active !== false &&
|
|
1332
|
+
!isNotFoundError(resourceError) &&
|
|
1333
|
+
workloadSourceVisible
|
|
1334
|
+
const workloadSourceUid =
|
|
1335
|
+
typeof resource?.metadata?.uid === 'string' && resource.metadata.uid ? resource.metadata.uid : undefined
|
|
1336
|
+
const workloadSourceQuery = useWorkloadSource(
|
|
1337
|
+
apiKind,
|
|
1338
|
+
namespace,
|
|
1339
|
+
name,
|
|
1340
|
+
workloadSourceEnabled,
|
|
1341
|
+
workloadSourceUid,
|
|
1342
|
+
)
|
|
1343
|
+
const workloadSource =
|
|
1344
|
+
workloadSourceSupported &&
|
|
1345
|
+
!isNotFoundError(resourceError) &&
|
|
1346
|
+
(workloadSourceEnabled || workloadSourceQuery.data || workloadSourceQuery.cachedData)
|
|
1347
|
+
? toWorkloadSourceState(workloadSourceQuery)
|
|
1348
|
+
: undefined
|
|
1294
1349
|
const workloadAwaitsCapacity =
|
|
1295
1350
|
karpenter?.state === 'available' &&
|
|
1296
1351
|
(workloadPodsQuery.data?.pods ?? []).some(workloadPodAwaitsScheduling)
|
|
@@ -1356,6 +1411,7 @@ export function WorkloadView({
|
|
|
1356
1411
|
}
|
|
1357
1412
|
workloadPodsLoading={supportsWorkloadPods ? workloadPodsQuery.isLoading : false}
|
|
1358
1413
|
workloadPodsError={supportsWorkloadPods ? (workloadPodsQuery.error as Error | null) : null}
|
|
1414
|
+
workloadSource={workloadSource}
|
|
1359
1415
|
servingResources={servingResources}
|
|
1360
1416
|
renderServicePortAction={renderServicePortAction}
|
|
1361
1417
|
renderServicePortPanel={renderServicePortPanel}
|
|
@@ -1398,6 +1454,7 @@ export function WorkloadView({
|
|
|
1398
1454
|
activeTab={migratedTab}
|
|
1399
1455
|
extraTabsComplete={migratedTab === 'deploys' ? true : undefined}
|
|
1400
1456
|
onTabChange={handleTabChange}
|
|
1457
|
+
onDrawerViewChange={handleDrawerViewChange}
|
|
1401
1458
|
// Render props
|
|
1402
1459
|
renderLogsTab={(props) => (
|
|
1403
1460
|
<LogsTabContent
|
|
@@ -1423,7 +1480,16 @@ export function WorkloadView({
|
|
|
1423
1480
|
name={n}
|
|
1424
1481
|
resource={res}
|
|
1425
1482
|
selectedRunKey={selectedRunKey}
|
|
1426
|
-
leadContent={
|
|
1483
|
+
leadContent={
|
|
1484
|
+
workloadSource ? (
|
|
1485
|
+
<>
|
|
1486
|
+
{leadContent}
|
|
1487
|
+
<WorkloadSourceSection state={workloadSource} variant="card" />
|
|
1488
|
+
</>
|
|
1489
|
+
) : (
|
|
1490
|
+
leadContent
|
|
1491
|
+
)
|
|
1492
|
+
}
|
|
1427
1493
|
canViewLogs={baseActionsBarProps.canViewLogs}
|
|
1428
1494
|
onSelectRun={handleSelectedRunChange}
|
|
1429
1495
|
onSwitchToLogs={() => handleTabChange('logs')}
|