@skyhook-io/radar-app 1.17.1 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +10 -11
- package/src/App.tsx +36 -36
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +396 -105
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
- package/src/components/diagnose/investigationEvidence/types.ts +26 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +28 -11
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +69 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +5 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +28 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +46 -69
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +21 -67
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +89 -14
- package/src/components/ui/RadarOmnibar.test.tsx +183 -0
- package/src/components/ui/RadarOmnibar.tsx +38 -4
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +2 -1
- package/src/components/ui/UpdateNotification.tsx +29 -5
- package/src/components/ui/omnibar-match.test.ts +37 -0
- package/src/components/ui/omnibar-match.ts +23 -0
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +43 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +2 -4
- package/src/index.ts +7 -0
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import type {
|
|
8
|
+
Diagnosis,
|
|
9
|
+
DiagnosisEvidenceItem,
|
|
10
|
+
} from "../../../../api/diagnose";
|
|
11
|
+
import { ResultCard } from "../../AssessmentCard";
|
|
12
|
+
import { InvestigationEvidencePane } from "../../InvestigationEvidencePane";
|
|
13
|
+
import { resolveInvestigationCase } from "../../investigationCase";
|
|
14
|
+
import { investigationEvidenceCoverageLimited } from "../../investigationState";
|
|
15
|
+
import { StoryExcerpt } from "../../StoryExcerpt";
|
|
16
|
+
import { InventoryBody, namedInventoryRows } from "../bodies/inventory";
|
|
17
|
+
import type { InvestigationEvidenceTimelineItem } from "../types";
|
|
18
|
+
import { evidenceRef, groupsOf, project, tool } from "../evidenceFixtures";
|
|
19
|
+
|
|
20
|
+
// The list_resources results a partial read returns over MCP: narrowed to the
|
|
21
|
+
// namespaces Radar collects (alpha, gamma), with gamma still loading. internal/mcp
|
|
22
|
+
// pins them to the producer and internal/ai proves every agent backend hands
|
|
23
|
+
// their joined text blocks to Findings unchanged; this suite projects that
|
|
24
|
+
// text the way Findings does.
|
|
25
|
+
const FIXTURE = resolve(
|
|
26
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
27
|
+
"../../../../../../testdata/mcp/list-resources-partial-coverage.json",
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
interface FixtureCase {
|
|
31
|
+
name: string;
|
|
32
|
+
arguments: Record<string, unknown>;
|
|
33
|
+
result: { content: { type: string; text: string }[] };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const cases: FixtureCase[] = JSON.parse(readFileSync(FIXTURE, "utf8")).cases;
|
|
37
|
+
|
|
38
|
+
function projectCase(
|
|
39
|
+
name: string,
|
|
40
|
+
ref?: string,
|
|
41
|
+
preceding: InvestigationEvidenceTimelineItem[] = [],
|
|
42
|
+
) {
|
|
43
|
+
const fixture = cases.find((item) => item.name === name);
|
|
44
|
+
if (!fixture) throw new Error(`no fixture case ${name}`);
|
|
45
|
+
return project([
|
|
46
|
+
...preceding,
|
|
47
|
+
tool(
|
|
48
|
+
"list",
|
|
49
|
+
"list_resources",
|
|
50
|
+
fixture.result.content.map((block) => block.text).join(""),
|
|
51
|
+
{ summary: JSON.stringify(fixture.arguments), evidenceRef: ref },
|
|
52
|
+
),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe("a list Radar read only in some of the namespaces it collects", () => {
|
|
57
|
+
it("shows the rows it read with the namespaces they came from", () => {
|
|
58
|
+
const projection = projectCase("partial", undefined, [
|
|
59
|
+
tool("diagnose", "diagnose", {
|
|
60
|
+
resource: {
|
|
61
|
+
apiVersion: "apps/v1",
|
|
62
|
+
kind: "Deployment",
|
|
63
|
+
metadata: { name: "api", namespace: "shop" },
|
|
64
|
+
},
|
|
65
|
+
pods: 0,
|
|
66
|
+
events: [],
|
|
67
|
+
recentChanges: [],
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
71
|
+
if (inventory?.latest.data.type !== "inventory") {
|
|
72
|
+
throw new Error("expected an inventory card");
|
|
73
|
+
}
|
|
74
|
+
expect(
|
|
75
|
+
inventory.latest.data.resources.map((row) => [row.namespace, row.name]),
|
|
76
|
+
).toEqual([["alpha", "alpha-object"]]);
|
|
77
|
+
expect(inventory.latest.summary).toBe("1 returned · only alpha read");
|
|
78
|
+
// The rows carry Radar's own sentence: why gamma is missing, and who can
|
|
79
|
+
// widen the read, not just which namespace was read.
|
|
80
|
+
expect(inventory.latest.data.coverageNote).toBe(
|
|
81
|
+
'Partial: 1 Service from namespace "alpha". Unknown: namespace "gamma", because Radar is still loading services there. Other namespaces are unknown: Radar collects services only in namespaces "alpha", "gamma". Whoever runs Radar can widen its collection.',
|
|
82
|
+
);
|
|
83
|
+
expect(
|
|
84
|
+
renderToStaticMarkup(
|
|
85
|
+
createElement(InventoryBody, { data: inventory.latest.data }),
|
|
86
|
+
),
|
|
87
|
+
).toContain("because Radar is still loading services there");
|
|
88
|
+
expect(inventory.latest.data.namespacesRead).toEqual(["alpha"]);
|
|
89
|
+
expect(projection.limitations).toEqual([]);
|
|
90
|
+
const coverageLimited = investigationEvidenceCoverageLimited(
|
|
91
|
+
projection,
|
|
92
|
+
"Deployment",
|
|
93
|
+
);
|
|
94
|
+
expect(coverageLimited).toBe(false);
|
|
95
|
+
const html = renderToStaticMarkup(
|
|
96
|
+
createElement(ResultCard, {
|
|
97
|
+
diagnosis: {
|
|
98
|
+
healthy: true,
|
|
99
|
+
rootCause: "",
|
|
100
|
+
report: "The workload appears healthy.",
|
|
101
|
+
remediation: [],
|
|
102
|
+
} as Diagnosis,
|
|
103
|
+
coverageLimited,
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
expect(html).toContain("border-emerald-500/30");
|
|
107
|
+
expect(html).not.toContain("No problem identified in available evidence");
|
|
108
|
+
expect(html).not.toContain("Evidence coverage is limited");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("does not present an empty partial read as an empty cluster", () => {
|
|
112
|
+
const projection = projectCase("partial and empty");
|
|
113
|
+
expect(groupsOf(projection.groups, "inventory")).toEqual([]);
|
|
114
|
+
expect(projection.limitations.map((item) => item.message)).toEqual([
|
|
115
|
+
'Partial: no services in namespace "alpha". Unknown: namespace "gamma", because Radar is still loading services there. Other namespaces are unknown: Radar collects services only in namespaces "alpha", "gamma". Whoever runs Radar can widen its collection.',
|
|
116
|
+
]);
|
|
117
|
+
expect(investigationEvidenceCoverageLimited(projection, "Service")).toBe(
|
|
118
|
+
true,
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("says what a listing that read unnamed namespaces shows about a citation", () => {
|
|
123
|
+
const namespaces = Array.from(
|
|
124
|
+
{ length: 40 },
|
|
125
|
+
(_, index) => `team-${String(index + 1).padStart(2, "0")}`,
|
|
126
|
+
);
|
|
127
|
+
const coverage = {
|
|
128
|
+
status: "partial",
|
|
129
|
+
scope: { type: "all_namespaces" },
|
|
130
|
+
read: {
|
|
131
|
+
type: "namespaces",
|
|
132
|
+
namespaces: { count: 40 },
|
|
133
|
+
},
|
|
134
|
+
gaps: [{ code: "radar_namespace_not_collected" }],
|
|
135
|
+
};
|
|
136
|
+
const summary =
|
|
137
|
+
"These are the services in 40 namespaces only. Not read: part of the scope, because Radar doesn't collect services there. Services may exist there that this list doesn't show.";
|
|
138
|
+
const rows = [
|
|
139
|
+
{ kind: "Service", name: "present", namespace: namespaces[0] },
|
|
140
|
+
{ kind: "Service", name: "observed", namespace: "team-39" },
|
|
141
|
+
];
|
|
142
|
+
const projection = project([
|
|
143
|
+
tool(
|
|
144
|
+
"list",
|
|
145
|
+
"list_resources",
|
|
146
|
+
{ summary, coverage, items: rows },
|
|
147
|
+
{
|
|
148
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
149
|
+
},
|
|
150
|
+
),
|
|
151
|
+
]);
|
|
152
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
153
|
+
if (inventory.latest.data.type !== "inventory") {
|
|
154
|
+
throw new Error("expected an inventory card");
|
|
155
|
+
}
|
|
156
|
+
const data = inventory.latest.data;
|
|
157
|
+
expect(data.namespacesRead).toEqual([]);
|
|
158
|
+
expect(data.namespacesReadOmitted).toBe(40);
|
|
159
|
+
expect(inventory.latest.summary).toBe(
|
|
160
|
+
"2 returned · only 40 namespaces read",
|
|
161
|
+
);
|
|
162
|
+
const entries = namedInventoryRows(
|
|
163
|
+
data.resources,
|
|
164
|
+
[
|
|
165
|
+
{ subject: { kind: "Service", name: "api" } },
|
|
166
|
+
{ subject: { kind: "Service", name: "api", namespace: "team-40" } },
|
|
167
|
+
{ subject: { kind: "Service", name: "api", namespace: "unread" } },
|
|
168
|
+
{ subject: { kind: "Service", name: "api", namespace: "team-39" } },
|
|
169
|
+
],
|
|
170
|
+
undefined,
|
|
171
|
+
data.namespacesRead,
|
|
172
|
+
data.namespacesReadOmitted,
|
|
173
|
+
);
|
|
174
|
+
expect(entries[0].readUnnamed).toEqual({ count: 40, namespace: undefined });
|
|
175
|
+
expect(entries[1].readUnnamed).toEqual({ count: 40, namespace: "team-40" });
|
|
176
|
+
expect(entries[2].readUnnamed).toEqual({ count: 40, namespace: "unread" });
|
|
177
|
+
expect(entries[2].notRead).toBeUndefined();
|
|
178
|
+
expect(entries[3].readUnnamed).toBeUndefined();
|
|
179
|
+
expect(entries[3].notRead).toBeUndefined();
|
|
180
|
+
const html = renderToStaticMarkup(
|
|
181
|
+
createElement(StoryExcerpt, {
|
|
182
|
+
excerpt: { kind: "rows", entries },
|
|
183
|
+
data,
|
|
184
|
+
prominence: "primary",
|
|
185
|
+
open: false,
|
|
186
|
+
canExpand: false,
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
expect(html).toContain("api: not in the 40 namespaces read");
|
|
190
|
+
expect(html).toContain(
|
|
191
|
+
"team-40/api: not in this listing, which read 40 namespaces without naming them all; team-40 may not have been one",
|
|
192
|
+
);
|
|
193
|
+
expect(html).not.toContain("team-04");
|
|
194
|
+
expect(html).not.toContain("Not in this listing: team-40/api");
|
|
195
|
+
expect(html).toContain("Not in this listing: team-39/api");
|
|
196
|
+
expect(html).not.toContain("unread/api: unread was not read");
|
|
197
|
+
expect(html).toContain(
|
|
198
|
+
"unread/api: not in this listing, which read 40 namespaces without naming them all; unread may not have been one",
|
|
199
|
+
);
|
|
200
|
+
const empty = project([
|
|
201
|
+
tool("empty", "list_resources", { summary, coverage, items: [] }),
|
|
202
|
+
]);
|
|
203
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([summary]);
|
|
204
|
+
expect(empty.limitations[0].message).not.toContain("team-09");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("names the resource Radar read, not the alias the agent asked for", () => {
|
|
208
|
+
const projection = projectCase("partial and empty, kind by alias");
|
|
209
|
+
const [message] = projection.limitations.map((item) => item.message);
|
|
210
|
+
expect(message).toContain("no services in namespace");
|
|
211
|
+
expect(message).not.toMatch(/svcs/i);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("says a cited name's namespace was not read instead of calling it absent", () => {
|
|
215
|
+
const ref = evidenceRef("a", "b");
|
|
216
|
+
const projection = projectCase("partial", ref);
|
|
217
|
+
const evidence: DiagnosisEvidenceItem[] = [
|
|
218
|
+
{ namespace: "beta", claim: "Service api is missing from beta." },
|
|
219
|
+
{ namespace: "alpha", claim: "Service api is missing from alpha." },
|
|
220
|
+
{ namespace: undefined, claim: "No Service api exists." },
|
|
221
|
+
].map(({ namespace, claim }) => ({
|
|
222
|
+
status: "linked",
|
|
223
|
+
ref,
|
|
224
|
+
role: "cause",
|
|
225
|
+
claim,
|
|
226
|
+
subject: { kind: "Service", namespace, name: "api" },
|
|
227
|
+
}));
|
|
228
|
+
const investigationCase = resolveInvestigationCase(
|
|
229
|
+
projection,
|
|
230
|
+
{ evidence },
|
|
231
|
+
0,
|
|
232
|
+
);
|
|
233
|
+
expect(investigationCase.items.map((item) => item.placement)).toEqual([
|
|
234
|
+
"card",
|
|
235
|
+
"card",
|
|
236
|
+
"card",
|
|
237
|
+
]);
|
|
238
|
+
const html = renderToStaticMarkup(
|
|
239
|
+
createElement(InvestigationEvidencePane, {
|
|
240
|
+
projection,
|
|
241
|
+
investigationCase,
|
|
242
|
+
story: {
|
|
243
|
+
report: "The Ingress has no backend.\n\n[[radar:evidence=0]]",
|
|
244
|
+
evidence,
|
|
245
|
+
},
|
|
246
|
+
collecting: false,
|
|
247
|
+
animateGroupIds: new Set<string>(),
|
|
248
|
+
onViewSource: () => {},
|
|
249
|
+
onViewActivity: () => {},
|
|
250
|
+
}),
|
|
251
|
+
);
|
|
252
|
+
const start = html.indexOf("data-story-inventory-rows");
|
|
253
|
+
expect(start).toBeGreaterThan(-1);
|
|
254
|
+
const block = html.slice(start, html.indexOf('-body"', start));
|
|
255
|
+
// beta was never read, so the listing cannot say api is missing there.
|
|
256
|
+
expect(block).toContain("beta/api: beta was not read");
|
|
257
|
+
expect(block).not.toContain("Not in this listing: beta/api");
|
|
258
|
+
// alpha was read and has no api: there the listing does show absence.
|
|
259
|
+
expect(block).toContain("Not in this listing: alpha/api");
|
|
260
|
+
// An unqualified name was looked for only where the listing read.
|
|
261
|
+
expect(block).toContain("api: not in the namespaces read (alpha)");
|
|
262
|
+
expect(block).not.toContain("Not in this listing: api<");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("keeps a complete list's rows and copy unchanged", () => {
|
|
266
|
+
const complete = project([
|
|
267
|
+
tool(
|
|
268
|
+
"list",
|
|
269
|
+
"list_resources",
|
|
270
|
+
[{ kind: "Service", name: "alpha-object", namespace: "alpha" }],
|
|
271
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
272
|
+
),
|
|
273
|
+
]);
|
|
274
|
+
const [inventory] = groupsOf(complete.groups, "inventory");
|
|
275
|
+
expect(inventory.latest.summary).toBe("1 returned");
|
|
276
|
+
expect(inventory.latest.data).not.toHaveProperty("namespacesRead");
|
|
277
|
+
expect(complete.limitations).toEqual([]);
|
|
278
|
+
const empty = project([
|
|
279
|
+
tool("list", "list_resources", [], {
|
|
280
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
281
|
+
}),
|
|
282
|
+
]);
|
|
283
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
284
|
+
"Radar found no matching resources for services resources. Anything you do not have permission to read was not searched.",
|
|
285
|
+
]);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("does not guess at a coverage object it cannot read", () => {
|
|
289
|
+
for (const payload of [
|
|
290
|
+
{ items: [], coverage: { complete: false } },
|
|
291
|
+
{ items: [], coverage: { complete: true, namespaces: ["alpha"] } },
|
|
292
|
+
{ items: {}, coverage: { complete: false, namespaces: ["alpha"] } },
|
|
293
|
+
]) {
|
|
294
|
+
const projection = project([
|
|
295
|
+
tool("list", "list_resources", payload, {
|
|
296
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
297
|
+
}),
|
|
298
|
+
]);
|
|
299
|
+
expect(projection.groups).toEqual([]);
|
|
300
|
+
expect(projection.limitations.map((item) => item.message)).toEqual([
|
|
301
|
+
"Radar couldn't summarize this investigation step. Review it in Activity.",
|
|
302
|
+
]);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe("a list Radar read all of", () => {
|
|
308
|
+
const rows = [{ kind: "Service", name: "api", namespace: "alpha" }];
|
|
309
|
+
|
|
310
|
+
it("shows rows without a coverage caveat when nothing narrowed the scope", () => {
|
|
311
|
+
const coverage = {
|
|
312
|
+
status: "complete",
|
|
313
|
+
scope: { type: "all_namespaces" },
|
|
314
|
+
read: { type: "all_namespaces" },
|
|
315
|
+
gaps: [],
|
|
316
|
+
};
|
|
317
|
+
const projection = project([
|
|
318
|
+
tool(
|
|
319
|
+
"list",
|
|
320
|
+
"list_resources",
|
|
321
|
+
{
|
|
322
|
+
summary: "These are all the services in every namespace.",
|
|
323
|
+
coverage,
|
|
324
|
+
items: rows,
|
|
325
|
+
},
|
|
326
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
327
|
+
),
|
|
328
|
+
]);
|
|
329
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
330
|
+
expect(inventory.latest.summary).toBe("1 returned");
|
|
331
|
+
expect(projection.limitations).toEqual([]);
|
|
332
|
+
const empty = project([
|
|
333
|
+
tool(
|
|
334
|
+
"empty",
|
|
335
|
+
"list_resources",
|
|
336
|
+
{
|
|
337
|
+
summary: "There are no services in any namespace.",
|
|
338
|
+
coverage,
|
|
339
|
+
items: [],
|
|
340
|
+
},
|
|
341
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
342
|
+
),
|
|
343
|
+
]);
|
|
344
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
345
|
+
"There are no services in any namespace.",
|
|
346
|
+
]);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("keeps a narrowed scope from reading as the cluster", () => {
|
|
350
|
+
const coverage = {
|
|
351
|
+
status: "complete",
|
|
352
|
+
scope: {
|
|
353
|
+
type: "namespaces",
|
|
354
|
+
namespaces: { count: 2, names: ["alpha", "beta"] },
|
|
355
|
+
},
|
|
356
|
+
narrowedBy: ["user_access"],
|
|
357
|
+
read: {
|
|
358
|
+
type: "namespaces",
|
|
359
|
+
namespaces: { count: 2, names: ["alpha", "beta"] },
|
|
360
|
+
},
|
|
361
|
+
gaps: [],
|
|
362
|
+
};
|
|
363
|
+
const summary =
|
|
364
|
+
'These are the services in namespaces "alpha", "beta" only: your access covers only those namespaces. Other namespaces may have services this list doesn\'t show.';
|
|
365
|
+
const emptySummary =
|
|
366
|
+
'There are no services in namespaces "alpha", "beta": your access covers only those namespaces. Other namespaces may have services this list doesn\'t show.';
|
|
367
|
+
const projection = project([
|
|
368
|
+
tool(
|
|
369
|
+
"list",
|
|
370
|
+
"list_resources",
|
|
371
|
+
{ summary, coverage, items: rows },
|
|
372
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
373
|
+
),
|
|
374
|
+
]);
|
|
375
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
376
|
+
expect(inventory.latest.summary).toBe("1 returned · only alpha, beta read");
|
|
377
|
+
const empty = project([
|
|
378
|
+
tool(
|
|
379
|
+
"empty",
|
|
380
|
+
"list_resources",
|
|
381
|
+
{ summary: emptySummary, coverage, items: [] },
|
|
382
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
383
|
+
),
|
|
384
|
+
]);
|
|
385
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
386
|
+
emptySummary,
|
|
387
|
+
]);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it("never reads an older Radar's bare array as complete", () => {
|
|
391
|
+
const empty = project([
|
|
392
|
+
tool("empty", "list_resources", [], {
|
|
393
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
394
|
+
}),
|
|
395
|
+
]);
|
|
396
|
+
expect(empty.limitations[0].message).toContain(
|
|
397
|
+
"Anything you do not have permission to read was not searched.",
|
|
398
|
+
);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("rejects a list that does not explain itself in words", () => {
|
|
402
|
+
const projection = project([
|
|
403
|
+
tool("list", "list_resources", {
|
|
404
|
+
coverage: {
|
|
405
|
+
status: "partial",
|
|
406
|
+
scope: { type: "all_namespaces" },
|
|
407
|
+
read: { type: "all_namespaces" },
|
|
408
|
+
gaps: [{ code: "kind_sync_pending" }],
|
|
409
|
+
},
|
|
410
|
+
items: rows,
|
|
411
|
+
}),
|
|
412
|
+
]);
|
|
413
|
+
expect(groupsOf(projection.groups, "inventory")).toEqual([]);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
@@ -620,6 +620,14 @@ const METRIC_FAMILY_LABELS: Record<string, string> = {
|
|
|
620
620
|
container_fs_usage_bytes: "Filesystem usage",
|
|
621
621
|
up: "Scrape target up",
|
|
622
622
|
};
|
|
623
|
+
|
|
624
|
+
function optionalStringList(value: unknown): boolean {
|
|
625
|
+
return (
|
|
626
|
+
value === undefined ||
|
|
627
|
+
(Array.isArray(value) && value.every((item) => typeof item === "string"))
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
|
|
623
631
|
export function adaptQueryPrometheus(
|
|
624
632
|
builder: ProjectionBuilder,
|
|
625
633
|
source: InvestigationEvidenceSource,
|
|
@@ -635,7 +643,12 @@ export function adaptQueryPrometheus(
|
|
|
635
643
|
!Array.isArray(value.selectors) ||
|
|
636
644
|
(value.selectorsUnknown !== undefined &&
|
|
637
645
|
typeof value.selectorsUnknown !== "boolean") ||
|
|
638
|
-
(value.truncated !== undefined && typeof value.truncated !== "boolean")
|
|
646
|
+
(value.truncated !== undefined && typeof value.truncated !== "boolean") ||
|
|
647
|
+
(value.partial !== undefined && typeof value.partial !== "boolean") ||
|
|
648
|
+
!optionalStringList(value.warnings) ||
|
|
649
|
+
!optionalStringList(value.infos) ||
|
|
650
|
+
(value.annotationsOmitted !== undefined &&
|
|
651
|
+
typeof value.annotationsOmitted !== "number")
|
|
639
652
|
) {
|
|
640
653
|
invalidPayload(builder, source, "Prometheus query");
|
|
641
654
|
return;
|
|
@@ -653,6 +666,43 @@ export function adaptQueryPrometheus(
|
|
|
653
666
|
invalidPayload(builder, source, "Prometheus query");
|
|
654
667
|
return;
|
|
655
668
|
}
|
|
669
|
+
if (value.partial === true) {
|
|
670
|
+
builder.limit(
|
|
671
|
+
source,
|
|
672
|
+
"Prometheus query",
|
|
673
|
+
"The metrics backend returned a partial result, so some series may be missing.",
|
|
674
|
+
"unknown",
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
const warnings = (value.warnings as string[] | undefined) ?? [];
|
|
678
|
+
const infos = (value.infos as string[] | undefined) ?? [];
|
|
679
|
+
if (warnings.length > 0) {
|
|
680
|
+
builder.limit(
|
|
681
|
+
source,
|
|
682
|
+
"Prometheus query",
|
|
683
|
+
`The metrics backend returned ${warnings.length === 1 ? "a warning" : `${warnings.length} warnings`} with this result: ${warnings.join("; ")}`,
|
|
684
|
+
"unknown",
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
if (infos.length > 0) {
|
|
688
|
+
builder.limit(
|
|
689
|
+
source,
|
|
690
|
+
"Prometheus query",
|
|
691
|
+
`Prometheus noted about this query: ${infos.join("; ")}`,
|
|
692
|
+
"unknown",
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
if (
|
|
696
|
+
typeof value.annotationsOmitted === "number" &&
|
|
697
|
+
value.annotationsOmitted > 0
|
|
698
|
+
) {
|
|
699
|
+
builder.limit(
|
|
700
|
+
source,
|
|
701
|
+
"Prometheus query",
|
|
702
|
+
`${value.annotationsOmitted} more backend ${value.annotationsOmitted === 1 ? "message was" : "messages were"} left out to keep the result small.`,
|
|
703
|
+
"unknown",
|
|
704
|
+
);
|
|
705
|
+
}
|
|
656
706
|
const selectorsUnknown = value.selectorsUnknown === true;
|
|
657
707
|
const relevance = metricsScope(
|
|
658
708
|
builder.target,
|
|
@@ -663,7 +713,19 @@ export function adaptQueryPrometheus(
|
|
|
663
713
|
const start = nonEmptyString(value.start) ? value.start : undefined;
|
|
664
714
|
const end = nonEmptyString(value.end) ? value.end : undefined;
|
|
665
715
|
const step = nonEmptyString(value.step) ? value.step : undefined;
|
|
666
|
-
const
|
|
716
|
+
const qualifications = [
|
|
717
|
+
warnings.length > 0
|
|
718
|
+
? `Backend warning${warnings.length === 1 ? "" : "s"}: ${warnings.join("; ")}.`
|
|
719
|
+
: "",
|
|
720
|
+
infos.length > 0 ? `Prometheus noted: ${infos.join("; ")}.` : "",
|
|
721
|
+
typeof value.annotationsOmitted === "number" && value.annotationsOmitted > 0
|
|
722
|
+
? `${value.annotationsOmitted} more backend ${value.annotationsOmitted === 1 ? "message" : "messages"} left out.`
|
|
723
|
+
: "",
|
|
724
|
+
].filter(Boolean);
|
|
725
|
+
const note =
|
|
726
|
+
[nonEmptyString(value.note) ? value.note : "", ...qualifications]
|
|
727
|
+
.filter(Boolean)
|
|
728
|
+
.join(" ") || undefined;
|
|
667
729
|
if (value.truncated === true) {
|
|
668
730
|
const summary = record(value.summary);
|
|
669
731
|
const cardinality = record(summary?.labelCardinality);
|
|
@@ -79,3 +79,40 @@ describe("resource cards scaled by an HPA", () => {
|
|
|
79
79
|
expect(card.summary).toBe("5/5 replicas ready");
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
describe("resource cards with Pod/template differences", () => {
|
|
84
|
+
it("shows the first difference as a card warning, not a finding", () => {
|
|
85
|
+
const result = project([
|
|
86
|
+
tool("workload", "diagnose", {
|
|
87
|
+
resource: {
|
|
88
|
+
apiVersion: "apps/v1",
|
|
89
|
+
kind: "Deployment",
|
|
90
|
+
metadata: { namespace: "shop", name: "api" },
|
|
91
|
+
},
|
|
92
|
+
resourceContext: {
|
|
93
|
+
tier: "diagnostic",
|
|
94
|
+
templateDivergence: {
|
|
95
|
+
summary: "1 of 3 current Pods differ.",
|
|
96
|
+
podsCompared: 3,
|
|
97
|
+
podsDiffering: 1,
|
|
98
|
+
podsNotCompared: 1,
|
|
99
|
+
examplePod: "api-2",
|
|
100
|
+
baseline: "ReplicaSet api-1",
|
|
101
|
+
differences: [
|
|
102
|
+
"containers[api].resources.limits.memory is 16Mi; template specifies 256Mi",
|
|
103
|
+
"containers[api].resources.requests.memory is 16Mi; template specifies 128Mi",
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
]);
|
|
109
|
+
const card = groupsOf(result.groups, "resource")[0].latest;
|
|
110
|
+
expect(card.tone).toBe("neutral");
|
|
111
|
+
if (card.data.type === "resource") {
|
|
112
|
+
expect(card.data.warnings).toEqual([
|
|
113
|
+
"1 of 3 compared Pods differ from their template, 1 more not compared: containers[api].resources.limits.memory is 16Mi; template specifies 256Mi (and more)",
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
expect(groupsOf(result.groups, "issue")).toHaveLength(0);
|
|
117
|
+
});
|
|
118
|
+
});
|