@skyhook-io/radar-app 1.18.0 → 1.18.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/README.md +6 -0
- package/package.json +2 -3
- package/src/App.tsx +43 -12
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +197 -57
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/cnpg/actions/useCNPGWriteGuard.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/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +60 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
- package/src/components/diagnose/InvestigationView.tsx +47 -13
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/assessmentCopy.ts +11 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +16 -2
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/observations.ts +8 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +81 -4
- package/src/components/diagnose/investigationEvidence/types.ts +15 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/storyParts.test.tsx +53 -0
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.tsx +6 -4
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +62 -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 +9 -8
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
- package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +28 -21
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/mcpToolCatalog.ts +39 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +30 -68
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +9 -55
- 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 +82 -18
- package/src/components/ui/RadarOmnibar.test.tsx +201 -0
- package/src/components/ui/RadarOmnibar.tsx +39 -4
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +4 -1
- package/src/components/ui/UpdateNotification.tsx +61 -10
- package/src/components/ui/omnibar-match.test.ts +15 -8
- package/src/components/ui/omnibar-match.ts +11 -6
- 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/usage-data/UsageDataPrompt.tsx +19 -1
- 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/WorkloadView.tsx +18 -6
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +87 -4
- package/src/index.ts +7 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import paused from "./testdata/crossplane-paused-get-resource.json";
|
|
4
|
+
import { groupsOf, project, tool } from "../evidenceFixtures";
|
|
5
|
+
import { ResourceBody } from "../bodies/workload";
|
|
6
|
+
import { evidenceHasDetails } from "../bodies";
|
|
7
|
+
import { conditionStatusTone } from "../cardParts";
|
|
8
|
+
|
|
9
|
+
function card(payload: typeof paused) {
|
|
10
|
+
return groupsOf(project([tool("captured-pause", "get_resource", payload)]).groups, "resource")[0].latest;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
it("keeps a captured get_resource pause neutral with its raw observation and visible context", () => {
|
|
14
|
+
const captured = card(paused);
|
|
15
|
+
expect(captured.tone).toBe("neutral");
|
|
16
|
+
expect(captured.data.type).toBe("resource");
|
|
17
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
18
|
+
expect(evidenceHasDetails(captured.data)).toBe(true);
|
|
19
|
+
const html = renderToStaticMarkup(<ResourceBody data={captured.data} />);
|
|
20
|
+
expect(html).toContain("Paused");
|
|
21
|
+
expect(html).toContain("controller last reported reconciliation paused");
|
|
22
|
+
expect(html).toContain("Synced=False");
|
|
23
|
+
expect(html).toContain("ReconcilePaused");
|
|
24
|
+
expect(html).toContain("Readiness and errors are last reported");
|
|
25
|
+
expect(conditionStatusTone(paused.resource.status.conditions[1], captured.data.resource)).toBe("neutral");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("keeps a captured independent readiness error adverse and visible alongside pause", () => {
|
|
29
|
+
const payload = structuredClone(paused);
|
|
30
|
+
const failed = { type: "Ready", status: "False", reason: "Unavailable", message: "Fixture access denied" };
|
|
31
|
+
payload.resource.status.conditions[0] = failed;
|
|
32
|
+
payload.resourceContext.statusSummary.conditions[0] = failed;
|
|
33
|
+
const captured = card(payload);
|
|
34
|
+
expect(captured.tone).toBe("warning");
|
|
35
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
36
|
+
const html = renderToStaticMarkup(<ResourceBody data={captured.data} />);
|
|
37
|
+
expect(html).toContain("Ready=False");
|
|
38
|
+
expect(html).toContain("Fixture access denied");
|
|
39
|
+
expect(html).toContain("Paused");
|
|
40
|
+
expect(conditionStatusTone(failed, captured.data.resource)).toBe("unhealthy");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("keeps a requested pause with a reconciliation error adverse", () => {
|
|
44
|
+
const payload = structuredClone(paused);
|
|
45
|
+
payload.resource.status.conditions[1].reason = "ReconcileError";
|
|
46
|
+
payload.resourceContext.statusSummary.conditions[1].reason = "ReconcileError";
|
|
47
|
+
const captured = card(payload);
|
|
48
|
+
expect(captured.tone).toBe("warning");
|
|
49
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
50
|
+
const html = renderToStaticMarkup(<ResourceBody data={captured.data} />);
|
|
51
|
+
expect(html).toContain("Pause requested");
|
|
52
|
+
expect(html).toContain("recorded conditions do not confirm the pause");
|
|
53
|
+
expect(html).toContain("ReconcileError");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("keeps uncorroborated controller pause adverse without inventing a resume failure", () => {
|
|
57
|
+
const payload = structuredClone(paused);
|
|
58
|
+
payload.resource.metadata.annotations["crossplane.io/paused"] = "false";
|
|
59
|
+
const captured = card(payload);
|
|
60
|
+
expect(captured.tone).toBe("warning");
|
|
61
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
62
|
+
const html = renderToStaticMarkup(<ResourceBody data={captured.data} />);
|
|
63
|
+
expect(html).toContain("ReconcilePaused");
|
|
64
|
+
expect(html).not.toContain("controller last reported reconciliation paused");
|
|
65
|
+
expect(conditionStatusTone(payload.resource.status.conditions[1], captured.data.resource)).toBe("unhealthy");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
it("keeps captured pause context before a resource has composition references", () => {
|
|
70
|
+
const payload = { ...paused, resource: { ...paused.resource, kind: "EarlyXR", spec: {} } };
|
|
71
|
+
const captured = groupsOf(project([tool("early-pause", "get_resource", payload)]).groups, "resource")[0].latest;
|
|
72
|
+
expect(captured.tone).toBe("neutral");
|
|
73
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
74
|
+
expect(renderToStaticMarkup(<ResourceBody data={captured.data} />)).toContain("controller last reported reconciliation paused");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("keeps the captured deletion caution with recorded pause context", () => {
|
|
78
|
+
const payload = { ...paused, resource: { ...paused.resource, metadata: { ...paused.resource.metadata, deletionTimestamp: "2026-10-26T08:00:00Z" } } };
|
|
79
|
+
const captured = card(payload);
|
|
80
|
+
expect(captured.tone).toBe("neutral");
|
|
81
|
+
if (captured.data.type !== "resource") throw new Error("Expected resource evidence");
|
|
82
|
+
const html = renderToStaticMarkup(<ResourceBody data={captured.data} />);
|
|
83
|
+
expect(html).toContain("Deletion has been requested. Paused reconciliation may defer");
|
|
84
|
+
expect(html).toContain("controller last reported reconciliation paused");
|
|
85
|
+
});
|
|
@@ -148,6 +148,7 @@ export function adaptIssues(
|
|
|
148
148
|
"Issue-related changes",
|
|
149
149
|
"Radar's change history is incomplete for part of the window, so earlier changes may be missing.",
|
|
150
150
|
"unknown",
|
|
151
|
+
"history",
|
|
151
152
|
);
|
|
152
153
|
}
|
|
153
154
|
if (nonEmptyString(value.recent_changes_error)) {
|
|
@@ -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
|
+
});
|
|
@@ -974,7 +974,8 @@ describe("query_prometheus evidence", () => {
|
|
|
974
974
|
]);
|
|
975
975
|
expect(groupsOf(projection.groups, "metrics")).toHaveLength(0);
|
|
976
976
|
expect(projection.limitations).toHaveLength(1);
|
|
977
|
-
expect(projection.limitations[0].kind).toBe("
|
|
977
|
+
expect(projection.limitations[0].kind).toBe("unknown");
|
|
978
|
+
expect(projection.limitations[0].presentation).toBeUndefined();
|
|
978
979
|
expect(projection.limitations[0].message).toContain("812 series");
|
|
979
980
|
expect(projection.limitations[0].message).toContain(
|
|
980
981
|
"812 distinct pod values",
|
|
@@ -747,7 +747,8 @@ export function adaptQueryPrometheus(
|
|
|
747
747
|
source,
|
|
748
748
|
"Prometheus query",
|
|
749
749
|
`The result of \`${value.query}\` was too large to keep${parts.length ? ` (${parts.join(", ")})` : ""}, so Radar cannot chart it.${note ? ` ${note}` : ""}`,
|
|
750
|
-
|
|
750
|
+
// No series is kept, so this is an unknown, not a sample of the answer.
|
|
751
|
+
"unknown",
|
|
751
752
|
);
|
|
752
753
|
return;
|
|
753
754
|
}
|
|
@@ -226,20 +226,94 @@ export function adaptListNamespaces(
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
// list_resources arrives as `{summary, coverage, items}`. summary says in
|
|
230
|
+
// words what the rows cover and what was not read; coverage.read names the
|
|
231
|
+
// namespaces Radar read when that is a namespace set. A bare array is an older
|
|
232
|
+
// Radar's list (or a run recorded from one): it carries no coverage, so
|
|
233
|
+
// nothing about it may read as complete.
|
|
234
|
+
type ListCoverage = {
|
|
235
|
+
partial: boolean;
|
|
236
|
+
narrowed: boolean;
|
|
237
|
+
/** Set when Radar read a finite namespace set: rows prove nothing outside it. */
|
|
238
|
+
namespacesRead?: string[];
|
|
239
|
+
namespacesReadOmitted: number;
|
|
240
|
+
summary: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
function listedRows(
|
|
244
|
+
payload: unknown,
|
|
245
|
+
): { rows: unknown[]; coverage?: ListCoverage } | undefined {
|
|
246
|
+
if (Array.isArray(payload)) return { rows: payload };
|
|
247
|
+
const value = record(payload);
|
|
248
|
+
const coverage = record(value?.coverage);
|
|
249
|
+
const status = coverage?.status;
|
|
250
|
+
if (
|
|
251
|
+
!value ||
|
|
252
|
+
!Array.isArray(value.items) ||
|
|
253
|
+
!nonEmptyString(value.summary) ||
|
|
254
|
+
(status !== "complete" && status !== "partial")
|
|
255
|
+
) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
const summary = value.summary;
|
|
259
|
+
const read = record(coverage?.read);
|
|
260
|
+
const narrowed =
|
|
261
|
+
Array.isArray(coverage?.narrowedBy) && coverage.narrowedBy.length > 0;
|
|
262
|
+
if (read?.type !== "namespaces") {
|
|
263
|
+
return {
|
|
264
|
+
rows: value.items,
|
|
265
|
+
coverage: {
|
|
266
|
+
partial: status === "partial",
|
|
267
|
+
narrowed,
|
|
268
|
+
namespacesReadOmitted: 0,
|
|
269
|
+
summary,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
// A set lists every name or, when it is too large, none: then which
|
|
274
|
+
// namespaces were read is unknown and only the count is.
|
|
275
|
+
const set = record(read.namespaces);
|
|
276
|
+
const count = set?.count;
|
|
277
|
+
const names = set?.names === undefined ? [] : stringArray(set.names);
|
|
278
|
+
if (
|
|
279
|
+
!names ||
|
|
280
|
+
typeof count !== "number" ||
|
|
281
|
+
!Number.isInteger(count) ||
|
|
282
|
+
(set?.names !== undefined && names.length !== count)
|
|
283
|
+
) {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
rows: value.items,
|
|
288
|
+
coverage: {
|
|
289
|
+
partial: status === "partial",
|
|
290
|
+
narrowed,
|
|
291
|
+
namespacesRead: names,
|
|
292
|
+
namespacesReadOmitted: count - names.length,
|
|
293
|
+
summary,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
229
298
|
export function adaptListResources(
|
|
230
299
|
builder: ProjectionBuilder,
|
|
231
300
|
source: InvestigationEvidenceSource,
|
|
232
301
|
payload: unknown,
|
|
233
302
|
options: { title?: string } = {},
|
|
234
303
|
): void {
|
|
235
|
-
|
|
304
|
+
const listed = listedRows(payload);
|
|
305
|
+
if (!listed) {
|
|
236
306
|
invalidPayload(builder, source);
|
|
237
307
|
return;
|
|
238
308
|
}
|
|
239
|
-
const
|
|
309
|
+
const { rows, coverage } = listed;
|
|
310
|
+
const namespacesRead = coverage?.namespacesRead;
|
|
311
|
+
const namespacesReadCount =
|
|
312
|
+
(namespacesRead?.length ?? 0) + (coverage?.namespacesReadOmitted ?? 0);
|
|
313
|
+
const resources = rows
|
|
240
314
|
.map(resourceSummary)
|
|
241
315
|
.filter((item): item is InvestigationResourceSummary => Boolean(item));
|
|
242
|
-
if (resources.length !==
|
|
316
|
+
if (resources.length !== rows.length) {
|
|
243
317
|
invalidPayload(builder, source);
|
|
244
318
|
return;
|
|
245
319
|
}
|
|
@@ -257,12 +331,16 @@ export function adaptListResources(
|
|
|
257
331
|
: undefined;
|
|
258
332
|
const title = options.title ?? (namespace ? `${noun} in ${namespace}` : noun);
|
|
259
333
|
if (resources.length === 0) {
|
|
260
|
-
//
|
|
261
|
-
//
|
|
334
|
+
// An older Radar returns [] for some RBAC-filtered reads, so a bare array
|
|
335
|
+
// cannot prove absence. Otherwise the copy is the server's summary: the
|
|
336
|
+
// requested kind may be an alias ("svc"), and the summary names the
|
|
337
|
+
// resource it resolved.
|
|
262
338
|
builder.limit(
|
|
263
339
|
source,
|
|
264
340
|
"Resource inventory",
|
|
265
|
-
|
|
341
|
+
!coverage
|
|
342
|
+
? `Radar found no matching resources for ${scope}. Anything you do not have permission to read was not searched.`
|
|
343
|
+
: coverage.summary,
|
|
266
344
|
"unknown",
|
|
267
345
|
);
|
|
268
346
|
return;
|
|
@@ -288,8 +366,29 @@ export function adaptListResources(
|
|
|
288
366
|
relevance: "broader",
|
|
289
367
|
tone: hasAdverseResource ? "warning" : "neutral",
|
|
290
368
|
title,
|
|
291
|
-
summary:
|
|
292
|
-
|
|
369
|
+
summary: [
|
|
370
|
+
`${resources.length} returned`,
|
|
371
|
+
nonEmptyString(args?.group) ? args.group : undefined,
|
|
372
|
+
namespacesRead && (coverage?.partial || coverage?.narrowed)
|
|
373
|
+
? `only ${namespacesReadCount > 2 ? `${namespacesReadCount} namespaces` : namespacesRead.join(", ")} read`
|
|
374
|
+
: undefined,
|
|
375
|
+
]
|
|
376
|
+
.filter(Boolean)
|
|
377
|
+
.join(" · "),
|
|
378
|
+
data: {
|
|
379
|
+
type: "inventory",
|
|
380
|
+
resources,
|
|
381
|
+
scope,
|
|
382
|
+
...(namespacesRead
|
|
383
|
+
? {
|
|
384
|
+
namespacesRead,
|
|
385
|
+
namespacesReadOmitted: coverage!.namespacesReadOmitted,
|
|
386
|
+
}
|
|
387
|
+
: {}),
|
|
388
|
+
...(coverage && (coverage.partial || coverage.narrowed)
|
|
389
|
+
? { coverageNote: coverage.summary }
|
|
390
|
+
: {}),
|
|
391
|
+
},
|
|
293
392
|
},
|
|
294
393
|
);
|
|
295
394
|
}
|