@skyhook-io/radar-app 1.20.1 → 1.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +12 -7
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +218 -11
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +1 -9
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
- package/src/components/helm/HelmView.tsx +5 -3
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +65 -8
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +22 -10
- package/src/components/home/HelmSummary.tsx +15 -15
- package/src/components/home/mcpToolCatalog.ts +2 -2
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/traffic/TrafficView.tsx +27 -27
- package/src/components/traffic/trafficFilters.test.ts +18 -1
- package/src/components/traffic/trafficFilters.ts +30 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.test.tsx +23 -1
- package/src/components/ui/UpdateNotification.tsx +26 -2
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +51 -11
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
5
|
+
import { ClusterHealthCard } from './ClusterHealthCard'
|
|
6
|
+
import type { DashboardResponse } from '../../api/client'
|
|
7
|
+
|
|
8
|
+
vi.mock('./HomeAgentBlock', () => ({ HomeAgentBlock: () => null }))
|
|
9
|
+
|
|
10
|
+
const counts: DashboardResponse['resourceCounts'] = {
|
|
11
|
+
pods: { total: 0, running: 0, pending: 0, failed: 0, succeeded: 0 },
|
|
12
|
+
deployments: { total: 0, available: 0, unavailable: 0 },
|
|
13
|
+
statefulSets: { total: 0, ready: 0, unready: 0 },
|
|
14
|
+
daemonSets: { total: 0, ready: 0, unready: 0 },
|
|
15
|
+
services: 0,
|
|
16
|
+
ingresses: 0,
|
|
17
|
+
nodes: { total: 0, ready: 0, notReady: 0, cordoned: 0 },
|
|
18
|
+
namespaces: 0,
|
|
19
|
+
jobs: { total: 0, active: 0, succeeded: 0, failed: 0 },
|
|
20
|
+
cronJobs: { total: 0, active: 0, suspended: 0 },
|
|
21
|
+
configMaps: 0,
|
|
22
|
+
secrets: 0,
|
|
23
|
+
pvcs: { total: 0, bound: 0, pending: 0, unbound: 0 },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let root: Root | undefined
|
|
27
|
+
let host: HTMLDivElement | undefined
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
act(() => root?.unmount())
|
|
30
|
+
host?.remove()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
function render(context: string) {
|
|
34
|
+
const cluster: DashboardResponse['cluster'] = { name: context, kubeconfigCluster: 'gitlab_com', platform: 'kind', version: '', connected: true }
|
|
35
|
+
act(() => {
|
|
36
|
+
root!.render(
|
|
37
|
+
<ClusterHealthCard
|
|
38
|
+
health={{ healthy: 0, warning: 0, error: 0, warningEvents: 0 }}
|
|
39
|
+
counts={counts}
|
|
40
|
+
cluster={cluster}
|
|
41
|
+
metrics={null}
|
|
42
|
+
metricsServerAvailable={false}
|
|
43
|
+
issueCount={0}
|
|
44
|
+
hasCriticalIssues={false}
|
|
45
|
+
nodeVersionSkew={null}
|
|
46
|
+
onNavigateToKind={() => {}}
|
|
47
|
+
onNavigateToView={() => {}}
|
|
48
|
+
/>,
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
return host!.querySelector('h2')!
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
it('names the heading with the full context, which the middle cut hides from screen readers', () => {
|
|
55
|
+
host = document.createElement('div')
|
|
56
|
+
document.body.append(host)
|
|
57
|
+
root = createRoot(host)
|
|
58
|
+
const a = 'gitlab-org/infra/platform/k8s-agents:production-eu-west-agent'
|
|
59
|
+
expect(render(a).getAttribute('aria-label')).toBe(a)
|
|
60
|
+
const b = 'gitlab-org/infra/platform/k8s-agents:staging-us-east-agent'
|
|
61
|
+
expect(render(b).getAttribute('aria-label')).toBe(b)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('names an OpenShift heading with the full context, so two projects on one server stay apart', () => {
|
|
65
|
+
host = document.createElement('div')
|
|
66
|
+
document.body.append(host)
|
|
67
|
+
root = createRoot(host)
|
|
68
|
+
const a = 'proj-a/api-prod-example-com:6443/alice'
|
|
69
|
+
const heading = render(a)
|
|
70
|
+
expect(heading.getAttribute('aria-label')).toBe(a)
|
|
71
|
+
expect(heading.textContent).not.toBe(a)
|
|
72
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { minorsBehind } from "./ClusterHealthCard";
|
|
2
|
+
import { clusterIdentity, minorsBehind } from "./ClusterHealthCard";
|
|
3
3
|
|
|
4
4
|
describe("minorsBehind", () => {
|
|
5
5
|
it("counts minors between plain versions", () => {
|
|
@@ -29,3 +29,46 @@ describe("minorsBehind", () => {
|
|
|
29
29
|
expect(minorsBehind("1.33", "")).toBe(0);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
+
|
|
33
|
+
describe("clusterIdentity", () => {
|
|
34
|
+
it("names contexts that share one kubeconfig cluster entry apart", () => {
|
|
35
|
+
const a = clusterIdentity({ name: "agent-a", kubeconfigCluster: "gitlab_com" });
|
|
36
|
+
const b = clusterIdentity({ name: "agent-b", kubeconfigCluster: "gitlab_com" });
|
|
37
|
+
expect(a.headline).toBe("agent-a");
|
|
38
|
+
expect(b.headline).toBe("agent-b");
|
|
39
|
+
expect(a.raw).toBe("agent-a");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("shortens cloud contexts the same way the switcher does", () => {
|
|
43
|
+
const id = clusterIdentity({ name: "gke_proj_us-east1-b_my-cluster", kubeconfigCluster: "gke_proj_us-east1-b_my-cluster" });
|
|
44
|
+
expect(id.headline).toBe("my-cluster");
|
|
45
|
+
expect(id.location).toBe("proj · us-east1-b");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("shows the server host for an OpenShift context, keeping the full context as raw", () => {
|
|
49
|
+
const id = clusterIdentity({ name: "myproject/api-prod-example-com:6443/alice", kubeconfigCluster: "api-prod-example-com:6443" });
|
|
50
|
+
expect(id.headline).toBe("api-prod-example-com");
|
|
51
|
+
expect(id.raw).toBe("myproject/api-prod-example-com:6443/alice");
|
|
52
|
+
expect(id.location).toBe("");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("keeps the cluster entry's account and region for a renamed cloud context", () => {
|
|
56
|
+
const id = clusterIdentity({ name: "prod-eks-alias", kubeconfigCluster: "arn:aws:eks:us-west-2:123456789012:cluster/orders" });
|
|
57
|
+
expect(id.headline).toBe("prod-eks-alias");
|
|
58
|
+
expect(id.location).toBe("123456789012 · us-west-2");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("shows no location when neither name is a cloud name", () => {
|
|
62
|
+
expect(clusterIdentity({ name: "group/project:agent", kubeconfigCluster: "gitlab_com" }).location).toBe("");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("reads an older Radar that sends only the cluster entry as name", () => {
|
|
66
|
+
expect(clusterIdentity({ name: "gitlab_com" }).headline).toBe("gitlab_com");
|
|
67
|
+
expect(clusterIdentity({ name: "arn:aws:eks:us-west-2:123456789012:cluster/orders" }).location).toBe("123456789012 · us-west-2");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("falls back to Cluster with no name", () => {
|
|
71
|
+
expect(clusterIdentity({ name: "in-cluster" }).headline).toBe("in-cluster");
|
|
72
|
+
expect(clusterIdentity({ name: "" }).headline).toBe("Cluster");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -10,7 +10,7 @@ import { clsx } from 'clsx'
|
|
|
10
10
|
import { formatCPUMillicores, formatMemoryMiB } from '../../utils/format'
|
|
11
11
|
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
12
12
|
import { HomeAgentBlock } from './HomeAgentBlock'
|
|
13
|
-
import { assetUrl, pluralize, parseContextName, CertaintyGlyph } from '@skyhook-io/k8s-ui'
|
|
13
|
+
import { assetUrl, pluralize, parseContextName, CertaintyGlyph, MiddleEllipsis } from '@skyhook-io/k8s-ui'
|
|
14
14
|
import { Tooltip } from '../ui/Tooltip'
|
|
15
15
|
import { mcpEndpointUrl } from '../../api/config'
|
|
16
16
|
import { parseMajorMinor } from '../../utils/version'
|
|
@@ -219,12 +219,11 @@ export function ClusterHealthCard({
|
|
|
219
219
|
// has no meaningful kubeconfig context — bootstrap sets it to
|
|
220
220
|
// the literal "in-cluster" sentinel. Fall back to the platform
|
|
221
221
|
// label ("Google Kubernetes Engine") which IS recognizable.
|
|
222
|
-
// 3. Last resort: the
|
|
222
|
+
// 3. Last resort: the raw cluster.name, or "Cluster".
|
|
223
223
|
// When the card is rendered embedded (cloud mode), the H2 itself is
|
|
224
224
|
// suppressed below — the hub shell already shows the cluster name in
|
|
225
225
|
// its top bar.
|
|
226
|
-
const
|
|
227
|
-
const rawHeadline = parsedContext.clusterName || cluster.name || 'Cluster'
|
|
226
|
+
const { raw: rawName, location, headline: rawHeadline } = clusterIdentity(cluster)
|
|
228
227
|
const headlineName = isInCluster ? platformInfo.name : rawHeadline
|
|
229
228
|
|
|
230
229
|
return (
|
|
@@ -251,17 +250,19 @@ export function ClusterHealthCard({
|
|
|
251
250
|
// the visible text falls back to the platform label. Render no
|
|
252
251
|
// tooltip in that case; local mode keeps it so users can hover
|
|
253
252
|
// to see the full kubeconfig context path.
|
|
254
|
-
<Tooltip content={isInCluster ? '' :
|
|
255
|
-
<h2 className="text-xl font-semibold text-theme-text-primary
|
|
256
|
-
{
|
|
253
|
+
<Tooltip content={isInCluster ? '' : rawName} wrapperClassName="!block min-w-0">
|
|
254
|
+
<h2 aria-label={isInCluster ? headlineName : rawName} className="text-xl font-semibold text-theme-text-primary leading-tight mb-1.5">
|
|
255
|
+
{/* Generated contexts often share a long prefix and differ only at the end.
|
|
256
|
+
MiddleEllipsis exposes only the cut text to screen readers; aria-label keeps the full name. */}
|
|
257
|
+
<MiddleEllipsis text={headlineName} />
|
|
257
258
|
</h2>
|
|
258
259
|
</Tooltip>
|
|
259
260
|
)}
|
|
260
261
|
<div className="flex flex-col gap-0.5 text-xs text-theme-text-tertiary">
|
|
261
|
-
{
|
|
262
|
-
<Tooltip content={
|
|
262
|
+
{location && (
|
|
263
|
+
<Tooltip content={location} wrapperClassName="min-w-0">
|
|
263
264
|
<span className="truncate font-mono">
|
|
264
|
-
{
|
|
265
|
+
{location}
|
|
265
266
|
</span>
|
|
266
267
|
</Tooltip>
|
|
267
268
|
)}
|
|
@@ -522,6 +523,17 @@ export function ClusterHealthCard({
|
|
|
522
523
|
)
|
|
523
524
|
}
|
|
524
525
|
|
|
526
|
+
// `name` is the kubeconfig context. A renamed cloud context
|
|
527
|
+
// (`aws eks update-kubeconfig --alias`) no longer parses, but its kubeconfig
|
|
528
|
+
// cluster entry still carries the account and region.
|
|
529
|
+
export function clusterIdentity(cluster: Pick<DashboardResponse['cluster'], 'name' | 'kubeconfigCluster'>) {
|
|
530
|
+
const raw = cluster.name || ''
|
|
531
|
+
const parsed = parseContextName(raw)
|
|
532
|
+
const located = parsed.provider ? parsed : parseContextName(cluster.kubeconfigCluster || '')
|
|
533
|
+
const location = [located.account, located.region].filter(Boolean).join(' · ')
|
|
534
|
+
return { raw, headline: parsed.clusterName || raw || 'Cluster', location }
|
|
535
|
+
}
|
|
536
|
+
|
|
525
537
|
// How many minors the running version trails the newest one the upgrade-impact
|
|
526
538
|
// catalog covers. Cross-major comparisons return 0 — better a missing hint than
|
|
527
539
|
// a wrong count on an exotic version string.
|
|
@@ -3,6 +3,7 @@ import { Package, ArrowRight, Shield } from 'lucide-react'
|
|
|
3
3
|
import { clsx } from 'clsx'
|
|
4
4
|
import { Tooltip } from '../ui/Tooltip'
|
|
5
5
|
import { SEVERITY_TEXT } from '../../utils/badge-colors'
|
|
6
|
+
import { NotCheckedBadge } from '../helm/NotCheckedBadge'
|
|
6
7
|
|
|
7
8
|
interface HelmSummaryProps {
|
|
8
9
|
data?: DashboardHelmSummary
|
|
@@ -115,25 +116,24 @@ export function HelmSummary({ data, onNavigate }: HelmSummaryProps) {
|
|
|
115
116
|
) : (
|
|
116
117
|
<div className="divide-y divide-theme-border">
|
|
117
118
|
{data.releases.map((release) => (
|
|
119
|
+
// One flex row so space runs out in order: the chart text first,
|
|
120
|
+
// then the namespace, then the name. The badges never shrink.
|
|
118
121
|
<div
|
|
119
122
|
key={`${release.namespace}/${release.name}`}
|
|
120
|
-
className="flex items-center
|
|
123
|
+
className="flex items-center gap-2 px-3 py-1.5 overflow-hidden"
|
|
121
124
|
>
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<Tooltip content={`${release.chart} ${release.chartVersion}`} delay={100}>
|
|
129
|
-
<span className="text-[10px] text-theme-text-tertiary hidden sm:inline truncate max-w-[150px]">
|
|
130
|
-
{release.chart} {release.chartVersion}
|
|
131
|
-
</span>
|
|
132
|
-
</Tooltip>
|
|
133
|
-
<span className={clsx('badge-sm shrink-0', getStatusBadgeClass(release.status))}>
|
|
134
|
-
{release.status}
|
|
125
|
+
<span className={clsx('w-1.5 h-1.5 rounded-full shrink-0', getHealthDot(release.resourceHealth))} />
|
|
126
|
+
<span className="min-w-[3rem] text-xs text-theme-text-primary truncate">{release.name}</span>
|
|
127
|
+
<span className="min-w-0 shrink-[20] text-[10px] text-theme-text-tertiary truncate">{release.namespace}</span>
|
|
128
|
+
<Tooltip content={`${release.chart} ${release.chartVersion}`} delay={100} wrapperClassName="ml-auto min-w-0 shrink-[400]">
|
|
129
|
+
<span className="text-[10px] text-theme-text-tertiary hidden sm:inline truncate max-w-[150px]">
|
|
130
|
+
{release.chart} {release.chartVersion}
|
|
135
131
|
</span>
|
|
136
|
-
</
|
|
132
|
+
</Tooltip>
|
|
133
|
+
<NotCheckedBadge count={release.statusUnreadCount} />
|
|
134
|
+
<span className={clsx('badge-sm shrink-0', getStatusBadgeClass(release.status))}>
|
|
135
|
+
{release.status}
|
|
136
|
+
</span>
|
|
137
137
|
</div>
|
|
138
138
|
))}
|
|
139
139
|
</div>
|
|
@@ -376,9 +376,9 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
376
376
|
{
|
|
377
377
|
name: 'manage_workload',
|
|
378
378
|
write: true,
|
|
379
|
-
desc: 'Operate on a workload: restart triggers a rolling restart, scale changes the replica count, rollback reverts to a previous revision. Roll back a native Helm release\'s workload as the Helm release, not the workload alone. Rollout rollback re-runs every canary step — pair it with manage_rollout promote-full, or abort instead.',
|
|
379
|
+
desc: 'Operate on a workload: restart triggers a rolling restart, scale changes the replica count, rollback reverts to a previous revision, pause holds a Deployment\'s rollouts until resume releases them. Roll back a native Helm release\'s workload as the Helm release, not the workload alone. Rollout rollback re-runs every canary step — pair it with manage_rollout promote-full, or abort instead.',
|
|
380
380
|
params: [
|
|
381
|
-
{ arg: 'action', required: true, desc: 'restart, scale, or
|
|
381
|
+
{ arg: 'action', required: true, desc: 'restart, scale, rollback, pause, or resume (pause and resume are Deployment only)' },
|
|
382
382
|
{ arg: 'kind', required: true, desc: 'deployment, statefulset, daemonset, or rollout' },
|
|
383
383
|
{ arg: 'namespace', required: true, desc: 'workload namespace' },
|
|
384
384
|
{ arg: 'name', required: true, desc: 'workload name' },
|
|
@@ -3,6 +3,7 @@ import type { RightsizingRow } from '../../api/client'
|
|
|
3
3
|
import {
|
|
4
4
|
getRightsizingExplanation,
|
|
5
5
|
getRightsizingPresentation,
|
|
6
|
+
podLevelOverUseNote,
|
|
6
7
|
RIGHTSIZING_METHODOLOGY,
|
|
7
8
|
RIGHTSIZING_DOCS_URL,
|
|
8
9
|
RIGHTSIZING_SUMMARY,
|
|
@@ -145,3 +146,59 @@ describe('live pod inventory', () => {
|
|
|
145
146
|
)
|
|
146
147
|
})
|
|
147
148
|
})
|
|
149
|
+
|
|
150
|
+
describe('pod-level request rows', () => {
|
|
151
|
+
it('explains the pod-level value instead of promising a per-container verdict', () => {
|
|
152
|
+
const message = getRightsizingExplanation(
|
|
153
|
+
row({
|
|
154
|
+
fit: 'pod_level_request',
|
|
155
|
+
recommendationReason: 'pod_level_request',
|
|
156
|
+
podLevelRequest: '128Mi',
|
|
157
|
+
resource: 'memory',
|
|
158
|
+
}),
|
|
159
|
+
)
|
|
160
|
+
expect(message).toContain('128Mi')
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('labels a fit this frontend does not know instead of rendering nothing', () => {
|
|
164
|
+
const unknownFit = 'future_fit' as unknown as Parameters<typeof getRightsizingPresentation>[0]
|
|
165
|
+
expect(getRightsizingPresentation(unknownFit).label).toBe('future_fit')
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
describe('pod-level request below one container\'s usage', () => {
|
|
170
|
+
const podLevel = (observed: number, formatted: string) =>
|
|
171
|
+
row({
|
|
172
|
+
fit: 'pod_level_request',
|
|
173
|
+
recommendationReason: 'pod_level_request',
|
|
174
|
+
podLevelRequest: '200m',
|
|
175
|
+
podLevelRequestValue: 0.2,
|
|
176
|
+
observed: { name: 'P95', value: observed, formatted },
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('names the overuse when one container alone used more than the pod request', () => {
|
|
180
|
+
const message = getRightsizingExplanation(podLevel(0.44, '440m'))
|
|
181
|
+
expect(message).toContain('440m')
|
|
182
|
+
expect(podLevelOverUseNote(podLevel(0.44, '440m'))).toBe(message)
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('says nothing about overuse when the container stayed under the pod request', () => {
|
|
186
|
+
expect(podLevelOverUseNote(podLevel(0.15, '150m'))).toBeUndefined()
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('does not ask to raise the request when an HPA scales on it', () => {
|
|
190
|
+
const note = podLevelOverUseNote({ ...podLevel(0.44, '440m'), hpaManaged: true })
|
|
191
|
+
expect(note).toContain('440m')
|
|
192
|
+
expect(note).toContain('HPA')
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
it('asks for an autoscaling check when Radar could not read HPAs', () => {
|
|
196
|
+
const note = podLevelOverUseNote({ ...podLevel(0.44, '440m'), hpaEvidenceAvailable: false })
|
|
197
|
+
expect(note).toContain('440m')
|
|
198
|
+
expect(note).toContain('HPA')
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('stays quiet before six hours of samples', () => {
|
|
202
|
+
expect(podLevelOverUseNote({ ...podLevel(0.44, '440m'), sampleCount: 1, coverage: 0 })).toBeUndefined()
|
|
203
|
+
})
|
|
204
|
+
})
|
|
@@ -213,10 +213,10 @@ function FitCard({ row, window }: { row: RightsizingRow; window: string }) {
|
|
|
213
213
|
<div className="flex items-baseline gap-2 tabular-nums">
|
|
214
214
|
<div>
|
|
215
215
|
<div className="text-[10px] uppercase tracking-wide text-theme-text-quaternary">
|
|
216
|
-
Current request
|
|
216
|
+
{row.podLevelRequest ? 'Pod-level request' : 'Current request'}
|
|
217
217
|
</div>
|
|
218
218
|
<div className="text-lg font-semibold text-theme-text-primary">
|
|
219
|
-
{row.currentRequest ?? 'Unset'}
|
|
219
|
+
{row.podLevelRequest ?? row.currentRequest ?? 'Unset'}
|
|
220
220
|
</div>
|
|
221
221
|
</div>
|
|
222
222
|
<ArrowRight className="h-4 w-4 text-theme-text-quaternary" />
|
|
@@ -247,7 +247,9 @@ function CompactFitRow({ row }: { row: RightsizingRow }) {
|
|
|
247
247
|
<span className="w-12 text-[10px] uppercase tracking-wide text-theme-text-quaternary">
|
|
248
248
|
{row.resource}
|
|
249
249
|
</span>
|
|
250
|
-
<span className="min-w-14 text-theme-text-secondary">
|
|
250
|
+
<span className="min-w-14 text-theme-text-secondary">
|
|
251
|
+
{row.podLevelRequest ? `pod ${row.podLevelRequest}` : (row.currentRequest ?? 'unset')}
|
|
252
|
+
</span>
|
|
251
253
|
{row.recommendedRequest && (
|
|
252
254
|
<>
|
|
253
255
|
<ArrowRight className="h-3 w-3 text-theme-text-quaternary" />
|
|
@@ -298,6 +300,7 @@ export function getRightsizingPresentation(fit: RightsizingFit, queryError?: str
|
|
|
298
300
|
under_requested: 'Under-requested',
|
|
299
301
|
missing_request: 'Missing request',
|
|
300
302
|
insufficient_history: 'Insufficient history',
|
|
303
|
+
pod_level_request: 'Pod-level request',
|
|
301
304
|
}
|
|
302
305
|
const severities: Record<RightsizingFit, 'success' | 'info' | 'warning' | 'neutral'> = {
|
|
303
306
|
balanced: 'success',
|
|
@@ -305,8 +308,10 @@ export function getRightsizingPresentation(fit: RightsizingFit, queryError?: str
|
|
|
305
308
|
under_requested: 'warning',
|
|
306
309
|
missing_request: 'warning',
|
|
307
310
|
insufficient_history: 'neutral',
|
|
311
|
+
pod_level_request: 'neutral',
|
|
308
312
|
}
|
|
309
|
-
|
|
313
|
+
// An older frontend can meet a fit added by a newer agent.
|
|
314
|
+
return { label: labels[fit] ?? fit, severity: severities[fit] ?? ('neutral' as const) }
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
function FitExplanation({ row }: { row: RightsizingRow }) {
|
|
@@ -327,6 +332,8 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
|
|
|
327
332
|
'Radar could not verify recent OOM history, so it withheld a lower memory request.',
|
|
328
333
|
recommended_request_exceeds_limit:
|
|
329
334
|
'The evidence-based request would exceed the current limit; review the limit first.',
|
|
335
|
+
requests_exceed_pod_limit:
|
|
336
|
+
"Together with the other containers' requests and suggested increases, this request would take the pod above its pod-level limit (spec.resources), which Kubernetes rejects. Decide how to split the limit between containers, or raise the pod limit.",
|
|
330
337
|
}
|
|
331
338
|
// A denied pod read leaves currentPodOOM unknown rather than false, so it
|
|
332
339
|
// qualifies whatever else is said instead of replacing it — including a
|
|
@@ -336,6 +343,8 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
|
|
|
336
343
|
? "Radar could not read this workload's pods, so it could not check them for out-of-memory restarts."
|
|
337
344
|
: undefined
|
|
338
345
|
const qualified = (base: string) => (inventoryNote ? `${base} ${inventoryNote}` : base)
|
|
346
|
+
if (row.fit === 'pod_level_request' && row.podLevelRequest && !row.queryError)
|
|
347
|
+
return qualified(podLevelRequestExplanation(row, row.podLevelRequest))
|
|
339
348
|
if (row.reductionLimited && row.calculatedRequest && row.recommendedRequest) {
|
|
340
349
|
const burstNote = row.bursty && row.peak ? ` CPU P99 reached ${row.peak.formatted}.` : ''
|
|
341
350
|
return qualified(
|
|
@@ -352,6 +361,46 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
|
|
|
352
361
|
)
|
|
353
362
|
}
|
|
354
363
|
|
|
364
|
+
function podLevelRequestExplanation(row: RightsizingRow, podLevelRequest: string): string {
|
|
365
|
+
const overUse = podLevelOverUseNote(row)
|
|
366
|
+
if (overUse) return overUse
|
|
367
|
+
const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
|
|
368
|
+
const own = row.currentRequest
|
|
369
|
+
? ` This container's own request (${row.currentRequest}) no longer decides what is reserved.`
|
|
370
|
+
: ''
|
|
371
|
+
return `This pod sets one ${resource} request for all its containers: ${podLevelRequest} in spec.resources. The scheduler reserves that instead of container requests, so Radar doesn't suggest a request per container; check the pod-level request against the usage of its containers.${own}`
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* One container's usage above the pod's whole request is a sound lower bound on
|
|
376
|
+
* the pod's own use. Adding containers up would overstate it, so only this case
|
|
377
|
+
* is called out.
|
|
378
|
+
*/
|
|
379
|
+
export function podLevelOverUseNote(row: RightsizingRow): string | undefined {
|
|
380
|
+
if (
|
|
381
|
+
row.fit !== 'pod_level_request' ||
|
|
382
|
+
row.sampleCount < RIGHTSIZING_MIN_SAMPLES ||
|
|
383
|
+
!row.observed ||
|
|
384
|
+
!row.podLevelRequest ||
|
|
385
|
+
row.podLevelRequestValue == null ||
|
|
386
|
+
row.observed.value <= row.podLevelRequestValue
|
|
387
|
+
)
|
|
388
|
+
return undefined
|
|
389
|
+
const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
|
|
390
|
+
const finding = `This container alone used ${row.observed.formatted} (${row.observed.name}), more than the pod's whole ${row.podLevelRequest} ${resource} request. Radar can't size pod-level requests yet.`
|
|
391
|
+
// An HPA scaling on this resource divides usage by the pod request, so
|
|
392
|
+
// raising it changes scaling; Radar never suggests that unreviewed.
|
|
393
|
+
if (row.hpaManaged)
|
|
394
|
+
return `${finding} The HPA scales on this request, so review its target before raising spec.resources.requests.${row.resource}.`
|
|
395
|
+
if (!row.hpaEvidenceAvailable)
|
|
396
|
+
return `${finding} Radar couldn't check for an HPA on this resource, so check autoscaling before raising spec.resources.requests.${row.resource}.`
|
|
397
|
+
return `${finding} Consider raising spec.resources.requests.${row.resource}.`
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Mirrors rightsizingMinSamples (six hours of 5-minute samples) in
|
|
401
|
+
// internal/prometheus/rightsizing.go: below it Radar draws no conclusion.
|
|
402
|
+
const RIGHTSIZING_MIN_SAMPLES = 72
|
|
403
|
+
|
|
355
404
|
function confidenceLabel(row: RightsizingRow) {
|
|
356
405
|
return `${row.confidence[0].toUpperCase()}${row.confidence.slice(1)} confidence`
|
|
357
406
|
}
|
|
@@ -5,17 +5,24 @@ import { afterEach, expect, it, vi } from 'vitest'
|
|
|
5
5
|
import { ImageFilesystemModal } from './ImageFilesystemModal'
|
|
6
6
|
import { ApiError } from '../../api/client'
|
|
7
7
|
|
|
8
|
-
const state = vi.hoisted(() => ({
|
|
8
|
+
const state = vi.hoisted(() => ({
|
|
9
|
+
authEnabled: false,
|
|
10
|
+
showMetadata: false,
|
|
11
|
+
metadataImage: 'gcr.io/project/app:v1',
|
|
12
|
+
errorStatus: 401,
|
|
13
|
+
errorData: { registryType: 'google' } as Record<string, unknown>,
|
|
14
|
+
refetch: (() => {}) as () => void,
|
|
15
|
+
}))
|
|
9
16
|
vi.mock('../../contexts/CapabilitiesContext', () => ({ useIsAuthEnabled: () => state.authEnabled }))
|
|
10
17
|
vi.mock('../../api/client', () => ({
|
|
11
18
|
ApiError: class extends Error {
|
|
12
|
-
status =
|
|
13
|
-
data =
|
|
19
|
+
status = state.errorStatus
|
|
20
|
+
data = state.errorData
|
|
14
21
|
},
|
|
15
22
|
useImageMetadata: () => state.showMetadata ? ({
|
|
16
|
-
data: { image:
|
|
17
|
-
refetch:
|
|
18
|
-
}) : ({ error: new ApiError('Authentication required', 401), refetch:
|
|
23
|
+
data: { image: state.metadataImage, digest: 'sha256:abc', platform: 'linux/amd64', totalSize: 1024, layerCount: 1, authMethod: 'google', cached: false },
|
|
24
|
+
refetch: state.refetch,
|
|
25
|
+
}) : ({ error: new ApiError('Authentication required', 401), refetch: state.refetch }),
|
|
19
26
|
}))
|
|
20
27
|
|
|
21
28
|
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
@@ -24,8 +31,22 @@ let root: ReturnType<typeof createRoot>
|
|
|
24
31
|
afterEach(async () => {
|
|
25
32
|
await act(async () => root.unmount())
|
|
26
33
|
state.showMetadata = false
|
|
34
|
+
state.metadataImage = 'gcr.io/project/app:v1'
|
|
35
|
+
state.errorStatus = 401
|
|
36
|
+
state.errorData = { registryType: 'google' }
|
|
37
|
+
state.refetch = () => {}
|
|
38
|
+
vi.unstubAllGlobals()
|
|
39
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
27
40
|
})
|
|
28
41
|
|
|
42
|
+
async function renderModal(props: { onSwitchToPodFiles?: () => void } = {}) {
|
|
43
|
+
root = createRoot(document.createElement('div'))
|
|
44
|
+
await act(async () => {
|
|
45
|
+
root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} {...props} />)
|
|
46
|
+
})
|
|
47
|
+
return document.body.textContent || ''
|
|
48
|
+
}
|
|
49
|
+
|
|
29
50
|
it.each([true, false])('shows private-image guidance for authEnabled=%s', async (authEnabled) => {
|
|
30
51
|
state.authEnabled = authEnabled
|
|
31
52
|
root = createRoot(document.createElement('div'))
|
|
@@ -66,3 +87,50 @@ it.each([true, false])('shows download confirmation for authEnabled=%s', async (
|
|
|
66
87
|
expect(text).toContain('gcloud')
|
|
67
88
|
}
|
|
68
89
|
})
|
|
90
|
+
|
|
91
|
+
it.each(['node_only', 'registry_unreachable'])('explains a %s image instead of a generic or sign-in error', async (reason) => {
|
|
92
|
+
state.errorStatus = reason === 'node_only' ? 404 : 502
|
|
93
|
+
state.errorData = { error: 'x', reason, registry: 'registry.example' }
|
|
94
|
+
const refetch = vi.fn()
|
|
95
|
+
state.refetch = refetch
|
|
96
|
+
const text = await renderModal({ onSwitchToPodFiles: () => {} })
|
|
97
|
+
expect(text).toContain('registry.example')
|
|
98
|
+
expect(text).toContain('Browse live files from running pod below')
|
|
99
|
+
expect(text).not.toContain('Failed to inspect image')
|
|
100
|
+
expect(text).not.toContain('Authentication Required')
|
|
101
|
+
const retry = [...document.body.querySelectorAll('button')].find((b) => b.textContent?.includes('Retry'))
|
|
102
|
+
if (reason === 'node_only') {
|
|
103
|
+
expect(retry).toBeUndefined()
|
|
104
|
+
} else {
|
|
105
|
+
await act(async () => retry?.click())
|
|
106
|
+
expect(refetch).toHaveBeenCalledTimes(1)
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('keeps the generic error box for an error without a known reason', async () => {
|
|
111
|
+
state.errorStatus = 500
|
|
112
|
+
state.errorData = { error: 'Failed to inspect image' }
|
|
113
|
+
const text = await renderModal()
|
|
114
|
+
expect(text).toContain('Failed to inspect image')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('shows the pulled digest and downloads that exact image, not the tag', async () => {
|
|
118
|
+
const digest = 'sha256:' + 'a'.repeat(64)
|
|
119
|
+
state.showMetadata = true
|
|
120
|
+
state.metadataImage = 'gcr.io/project/app@' + digest
|
|
121
|
+
const fetchMock = vi.fn(async () => new Response(JSON.stringify({ image: state.metadataImage, root: { name: '/', path: '/', type: 'dir' }, totalFiles: 0, totalSize: 0 })))
|
|
122
|
+
vi.stubGlobal('fetch', fetchMock)
|
|
123
|
+
const text = await renderModal()
|
|
124
|
+
expect(text).toContain(digest)
|
|
125
|
+
const download = [...document.body.querySelectorAll('button')].find((b) => b.textContent === 'Download & View')
|
|
126
|
+
await act(async () => download?.click())
|
|
127
|
+
expect(fetchMock).toHaveBeenCalledTimes(1)
|
|
128
|
+
const url = new URL(String((fetchMock.mock.calls[0] as unknown[])[0]), 'http://radar.test')
|
|
129
|
+
expect(url.searchParams.get('image')).toBe(state.metadataImage)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('shows no pulled digest when the server inspects the tag as given', async () => {
|
|
133
|
+
state.showMetadata = true
|
|
134
|
+
const text = await renderModal()
|
|
135
|
+
expect(text).not.toContain('sha256:')
|
|
136
|
+
})
|