@skyhook-io/radar-app 1.22.0 → 1.22.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/package.json +1 -1
- package/src/App.tsx +2 -1
- package/src/api/client.ts +12 -0
- package/src/api/cnpg-history.ts +3 -3
- package/src/api/cnpg-storage.ts +3 -3
- package/src/api/diagnose.test.ts +34 -0
- package/src/api/diagnose.ts +17 -4
- package/src/api/radarFeatures.test.ts +13 -1
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceActions.test.ts +829 -0
- package/src/api/resourceActions.ts +584 -0
- package/src/api/resourceActions.ui.test.tsx +1882 -0
- package/src/api/reviewedActionMutation.ts +56 -28
- package/src/api/substrateHealth.ts +2 -3
- package/src/api/traffic.ts +13 -5
- package/src/api/workloadMetrics.test.ts +11 -2
- package/src/api/workloadMetrics.ts +2 -2
- package/src/components/diagnose/AnalysisStory.test.tsx +12 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +34 -1
- package/src/components/diagnose/DiagnoseContext.tsx +28 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -4
- package/src/components/diagnose/Home.tsx +3 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +61 -0
- package/src/components/diagnose/InvestigationView.followupFailure.test.tsx +122 -0
- package/src/components/diagnose/InvestigationView.tsx +10 -2
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +1 -1
- package/src/components/diagnose/LocalDiagnoseAction.tsx +2 -2
- package/src/components/diagnose/QuestionComposer.test.tsx +16 -2
- package/src/components/diagnose/QuestionComposer.tsx +13 -8
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +47 -8
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +153 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +9 -13
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +21 -5
- package/src/components/diagnose/investigationEvidence/bodies/network.tsx +63 -26
- package/src/components/diagnose/launch.ts +1 -1
- package/src/components/dock/PodDebugSession.test.tsx +66 -0
- package/src/components/dock/PodDebugSession.tsx +3 -1
- package/src/components/dock/TerminalTab.test.tsx +43 -3
- package/src/components/dock/TerminalTab.tsx +10 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +1 -1
- package/src/components/helm/InstallWizard.tsx +1 -1
- package/src/components/home/mcpToolCatalog.ts +1 -1
- package/src/components/resources/PodEvictAction.test.tsx +951 -0
- package/src/components/resources/PodEvictAction.tsx +167 -0
- package/src/components/resources/ResourcesView.tsx +3 -0
- package/src/components/resources/renderers/WorkloadRenderer.tsx +3 -0
- package/src/components/settings/LocalConnectionSettings.tsx +4 -4
- package/src/components/settings/SettingsDialog.tsx +23 -18
- package/src/components/settings/integrationQueries.test.ts +98 -0
- package/src/components/settings/integrationQueries.ts +36 -0
- package/src/components/traffic/TrafficView.reconnect.test.tsx +229 -0
- package/src/components/traffic/TrafficView.tsx +91 -35
- package/src/components/ui/Markdown.test.tsx +37 -0
- package/src/components/ui/Markdown.tsx +15 -2
- package/src/components/useContextSwitchFlow.test.tsx +27 -2
- package/src/components/useContextSwitchFlow.tsx +20 -22
- package/src/components/workload/WorkloadView.tsx +16 -3
|
@@ -86,13 +86,13 @@ function DiagnoseResourceButton({
|
|
|
86
86
|
: `Ask ${d.agentLabel} about this resource — reads its spec, events & logs.`
|
|
87
87
|
: problem
|
|
88
88
|
? `Investigate with your own ${d.agentLabel} — runs locally and reads this resource's spec, events & logs.`
|
|
89
|
-
: d.
|
|
89
|
+
: d.targetQuestions
|
|
90
90
|
? `Ask your own ${d.agentLabel} a question about this resource — runs locally, reads its spec, events & logs.`
|
|
91
91
|
: `Ask your own ${d.agentLabel} about this resource — runs locally, reads its spec, events & logs.`;
|
|
92
92
|
// While an investigation is live, the button advertises it (and clicking focuses
|
|
93
93
|
// the existing run rather than starting a new one — openInvestigation dedups).
|
|
94
94
|
const showLabel = problem || running;
|
|
95
|
-
const asks = d.
|
|
95
|
+
const asks = d.targetQuestions && !problem && !running;
|
|
96
96
|
// Asking about a resource with no live problem means saying what to ask; a
|
|
97
97
|
// problem, or a run already live, opens straight away.
|
|
98
98
|
const act = () => {
|
|
@@ -75,8 +75,8 @@ afterEach(async () => {
|
|
|
75
75
|
document.body.replaceChildren();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
async function render() {
|
|
79
|
-
await act(async () => root.render(<QuestionComposer />));
|
|
78
|
+
async function render(requireResource = false) {
|
|
79
|
+
await act(async () => root.render(<QuestionComposer requireResource={requireResource} />));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function textarea() {
|
|
@@ -551,3 +551,17 @@ describe("QuestionComposer", () => {
|
|
|
551
551
|
expect(document.body.textContent).toContain("Still loading");
|
|
552
552
|
});
|
|
553
553
|
});
|
|
554
|
+
|
|
555
|
+
it("requires a resource before starting a target-only question, including Enter after unpinning", async () => {
|
|
556
|
+
state.questionDraft = { seq: 1, pin: { kind: "Deployment", group: "apps", namespace: "shop", name: "checkout" } };
|
|
557
|
+
await render(true);
|
|
558
|
+
await type("Can we scale checkout to five replicas?");
|
|
559
|
+
const submit = document.querySelector<HTMLButtonElement>('button[type="submit"]')!;
|
|
560
|
+
expect(submit.disabled).toBe(false);
|
|
561
|
+
await act(async () => document.querySelector<HTMLButtonElement>('[aria-label="Unpin resource"]')!.click());
|
|
562
|
+
expect(submit.disabled).toBe(true);
|
|
563
|
+
expect(document.body.textContent).toContain("Choose a resource");
|
|
564
|
+
expect(document.body.textContent).not.toContain("Start in");
|
|
565
|
+
await press("Enter");
|
|
566
|
+
expect(state.openInvestigation).not.toHaveBeenCalled();
|
|
567
|
+
});
|
|
@@ -53,9 +53,11 @@ const actionClass =
|
|
|
53
53
|
export function QuestionComposer({
|
|
54
54
|
onBrowseIssues,
|
|
55
55
|
onOpenExample,
|
|
56
|
+
requireResource = false,
|
|
56
57
|
}: {
|
|
57
58
|
onBrowseIssues?: () => void;
|
|
58
59
|
onOpenExample?: () => void;
|
|
60
|
+
requireResource?: boolean;
|
|
59
61
|
}) {
|
|
60
62
|
const { openInvestigation, agentLabel, questionDraft, saveQuestionDraft } =
|
|
61
63
|
useDiagnose();
|
|
@@ -74,7 +76,7 @@ export function QuestionComposer({
|
|
|
74
76
|
? { text: questionDraft.text.trim(), askedAt: questionDraft.askedAt }
|
|
75
77
|
: null,
|
|
76
78
|
);
|
|
77
|
-
const [pickerOpen, setPickerOpen] = useState(!!questionDraft?.pickResource);
|
|
79
|
+
const [pickerOpen, setPickerOpen] = useState(!!questionDraft?.pickResource || (requireResource && !questionDraft?.pin));
|
|
78
80
|
const textRef = useRef<HTMLTextAreaElement>(null);
|
|
79
81
|
const pickerInputRef = useRef<HTMLInputElement>(null);
|
|
80
82
|
// Focus now so typing straight away lands in the box; once new text has
|
|
@@ -124,8 +126,8 @@ export function QuestionComposer({
|
|
|
124
126
|
(pin
|
|
125
127
|
? suggestionsForPin(pinIssues ?? [], pin)
|
|
126
128
|
: suggestionsFromIssues(issuesData?.issues ?? [])
|
|
127
|
-
).filter((suggestion) => !asked.includes(suggestion.question)),
|
|
128
|
-
[pin, pinIssues, issuesData, asked],
|
|
129
|
+
).filter((suggestion) => (!requireResource || pin || suggestion.pin) && !asked.includes(suggestion.question)),
|
|
130
|
+
[pin, pinIssues, issuesData, asked, requireResource],
|
|
129
131
|
);
|
|
130
132
|
|
|
131
133
|
useEffect(() => {
|
|
@@ -210,8 +212,9 @@ export function QuestionComposer({
|
|
|
210
212
|
|
|
211
213
|
const question = text.trim();
|
|
212
214
|
const tooLong = [...question].length > MAX_QUESTION_LENGTH;
|
|
215
|
+
const canSubmit = !!question && !tooLong && (!requireResource || !!pin);
|
|
213
216
|
const submit = () => {
|
|
214
|
-
if (!
|
|
217
|
+
if (!canSubmit) return;
|
|
215
218
|
submitted.current = true;
|
|
216
219
|
openInvestigation({
|
|
217
220
|
fromComposer: true,
|
|
@@ -248,7 +251,7 @@ export function QuestionComposer({
|
|
|
248
251
|
What are you seeing?
|
|
249
252
|
</h1>
|
|
250
253
|
<p className="mt-1 text-sm text-theme-text-tertiary">
|
|
251
|
-
Describe a problem, or ask whether something looks right. {agentLabel}{" "}
|
|
254
|
+
{requireResource ? "Choose a resource and describe what you want to investigate or change." : "Describe a problem, or ask whether something looks right."} {agentLabel}{" "}
|
|
252
255
|
investigates it with Radar’s read-only tools and shows what it found,
|
|
253
256
|
with the evidence.
|
|
254
257
|
</p>
|
|
@@ -302,7 +305,7 @@ export function QuestionComposer({
|
|
|
302
305
|
</span>
|
|
303
306
|
<button
|
|
304
307
|
type="button"
|
|
305
|
-
onClick={() => setPin(null)}
|
|
308
|
+
onClick={() => { setPin(null); if (requireResource) setPickerOpen(true); }}
|
|
306
309
|
aria-label="Unpin resource"
|
|
307
310
|
className="rounded text-theme-text-tertiary hover:text-theme-text-primary"
|
|
308
311
|
>
|
|
@@ -311,6 +314,7 @@ export function QuestionComposer({
|
|
|
311
314
|
</span>
|
|
312
315
|
) : (
|
|
313
316
|
<>
|
|
317
|
+
{!requireResource && <>
|
|
314
318
|
<span className="text-xs text-theme-text-tertiary">Start in</span>
|
|
315
319
|
{startIn.length === 0 ? (
|
|
316
320
|
<Tooltip
|
|
@@ -357,6 +361,7 @@ export function QuestionComposer({
|
|
|
357
361
|
))}
|
|
358
362
|
</select>
|
|
359
363
|
)}
|
|
364
|
+
</>}
|
|
360
365
|
<button
|
|
361
366
|
type="button"
|
|
362
367
|
onClick={() => setPickerOpen((open) => !open)}
|
|
@@ -364,7 +369,7 @@ export function QuestionComposer({
|
|
|
364
369
|
className={actionClass}
|
|
365
370
|
>
|
|
366
371
|
<AtSign className="h-3 w-3" />
|
|
367
|
-
Pin a resource
|
|
372
|
+
{requireResource ? "Choose a resource" : "Pin a resource"}
|
|
368
373
|
</button>
|
|
369
374
|
</>
|
|
370
375
|
)}
|
|
@@ -395,7 +400,7 @@ export function QuestionComposer({
|
|
|
395
400
|
</span>
|
|
396
401
|
<button
|
|
397
402
|
type="submit"
|
|
398
|
-
disabled={!
|
|
403
|
+
disabled={!canSubmit}
|
|
399
404
|
className="btn-brand ml-1 inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium disabled:opacity-50"
|
|
400
405
|
>
|
|
401
406
|
Investigate
|
|
@@ -142,16 +142,55 @@ export interface DiagnosisChangeContext {
|
|
|
142
142
|
evidence?: string;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// A rewrite or template rule copied from a stored CoreDNS Corefile. It is what
|
|
146
|
+
// the ConfigMap says, with no verdict.
|
|
147
|
+
export interface DiagnosisCoreDNSRule {
|
|
148
|
+
kind: string;
|
|
149
|
+
namespace: string;
|
|
150
|
+
name: string;
|
|
151
|
+
key: string;
|
|
152
|
+
line: number;
|
|
153
|
+
text: string;
|
|
154
|
+
truncated?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// A verdict on a CoreDNS ConfigMap, in the `coreDNSFindings` shape. Some Radar
|
|
158
|
+
// versions send it in place of `coreDNSRules`, and Radar Hub shows their
|
|
159
|
+
// clusters with this UI.
|
|
160
|
+
export interface DiagnosisLegacyCoreDNSFinding {
|
|
161
|
+
kind: string;
|
|
162
|
+
namespace: string;
|
|
163
|
+
name: string;
|
|
164
|
+
severity?: string;
|
|
165
|
+
reason?: string;
|
|
166
|
+
message?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
145
169
|
export interface DiagnosisDNSContext {
|
|
146
170
|
signals?: string[];
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
171
|
+
coreDNSRules?: DiagnosisCoreDNSRule[];
|
|
172
|
+
// Stored rules left out of coreDNSRules by the server's cap.
|
|
173
|
+
omittedCoreDNSRules?: number;
|
|
174
|
+
coreDNSFindings?: DiagnosisLegacyCoreDNSFinding[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The configuration facts Radar sends as DNS signals. Each names a resource, so
|
|
178
|
+
// its text is never searched for failure words: a workload can be called
|
|
179
|
+
// "errors-api".
|
|
180
|
+
const DNS_CONFIGURATION_SIGNAL =
|
|
181
|
+
/ uses dnsPolicy=| sets dnsConfig\.|^CoreDNS Deployment |^Radar observed ConfigMap /;
|
|
182
|
+
|
|
183
|
+
// Whether a DNS signal reports a failed lookup, as opposed to a configuration
|
|
184
|
+
// fact such as a pod's dnsPolicy or a CoreDNS rollout.
|
|
185
|
+
export function dnsSignalReportsFailure(signal: string): boolean {
|
|
186
|
+
return (
|
|
187
|
+
!DNS_CONFIGURATION_SIGNAL.test(signal) &&
|
|
188
|
+
/\b(errors?|failed|failures?|timeouts?|nxdomain|servfail)\b/i.test(signal)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function coreDNSRulesSummary(count: number): string {
|
|
193
|
+
return `${count} CoreDNS rule${count === 1 ? "" : "s"}`;
|
|
155
194
|
}
|
|
156
195
|
|
|
157
196
|
export type DiagnosisEvidenceTone =
|
|
@@ -9,7 +9,160 @@ import {
|
|
|
9
9
|
warningEvent,
|
|
10
10
|
} from "../evidenceFixtures";
|
|
11
11
|
|
|
12
|
+
const storedRule = {
|
|
13
|
+
kind: "ConfigMap",
|
|
14
|
+
namespace: "kube-system",
|
|
15
|
+
name: "coredns",
|
|
16
|
+
key: "Corefile",
|
|
17
|
+
line: 5,
|
|
18
|
+
text: "rewrite name regex .*\\.nodes\\.vcluster\\.com kubernetes.default.svc.cluster.local",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// The `coreDNSFindings` shape: a verdict on the ConfigMap.
|
|
22
|
+
const legacyFinding = {
|
|
23
|
+
kind: "ConfigMap",
|
|
24
|
+
namespace: "kube-system",
|
|
25
|
+
name: "coredns",
|
|
26
|
+
severity: "warning",
|
|
27
|
+
reason: "CoreDNS service DNS rewrite",
|
|
28
|
+
};
|
|
29
|
+
|
|
12
30
|
describe("semantic diagnose evidence projection", () => {
|
|
31
|
+
// The exact strings the server emits (internal/mcp/tools_diagnose.go,
|
|
32
|
+
// internal/issues/provider.go), and the "errors" wording some versions use. A
|
|
33
|
+
// stored CoreDNS rule is configuration; only these make DNS evidence adverse.
|
|
34
|
+
it.each([
|
|
35
|
+
"pod logs contain DNS resolution failures",
|
|
36
|
+
"warning events contain DNS resolution failures",
|
|
37
|
+
"pod logs contain DNS resolution errors",
|
|
38
|
+
"warning events contain DNS resolution errors",
|
|
39
|
+
])("treats %j as a DNS failure with or without stored rules", (signal) => {
|
|
40
|
+
for (const coreDNSRules of [undefined, [storedRule]]) {
|
|
41
|
+
const result = project([
|
|
42
|
+
tool("dns-failure", "diagnose", {
|
|
43
|
+
resource: deployment,
|
|
44
|
+
resourceContext: { tier: "basic" },
|
|
45
|
+
pods: 0,
|
|
46
|
+
events: [],
|
|
47
|
+
dnsContext: { signals: [signal], coreDNSRules },
|
|
48
|
+
}),
|
|
49
|
+
]);
|
|
50
|
+
expect(groupsOf(result.groups, "dns")[0].latest).toMatchObject({
|
|
51
|
+
tone: "warning",
|
|
52
|
+
title: "DNS failure signals",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("keeps stored CoreDNS rules neutral when no lookup failed", () => {
|
|
58
|
+
const result = project([
|
|
59
|
+
tool("dns-config", "diagnose", {
|
|
60
|
+
resource: deployment,
|
|
61
|
+
resourceContext: { tier: "basic" },
|
|
62
|
+
pods: 0,
|
|
63
|
+
events: [],
|
|
64
|
+
dnsContext: {
|
|
65
|
+
signals: ["api uses dnsPolicy=None"],
|
|
66
|
+
coreDNSRules: [storedRule],
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
expect(groupsOf(result.groups, "dns")[0].latest).toMatchObject({
|
|
71
|
+
tier: "context",
|
|
72
|
+
tone: "info",
|
|
73
|
+
title: "DNS configuration",
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// The server's configuration signals, with resource names that contain
|
|
78
|
+
// failure words (internal/mcp/tools_diagnose.go, internal/issues/provider.go).
|
|
79
|
+
it.each([
|
|
80
|
+
"errors-api uses dnsPolicy=None",
|
|
81
|
+
"servfail-exporter sets dnsConfig.nameservers",
|
|
82
|
+
"failed-jobs sets dnsConfig.searches",
|
|
83
|
+
"CoreDNS Deployment kube-system/coredns-errors rolled 2m ago (generation=3, 2 owned ReplicaSets, newest=coredns-errors-abc)",
|
|
84
|
+
"Radar observed ConfigMap kube-system/coredns-failures update 4m ago",
|
|
85
|
+
])("reads %j as configuration, whatever the resource is called", (signal) => {
|
|
86
|
+
const result = project([
|
|
87
|
+
tool("dns-config-name", "diagnose", {
|
|
88
|
+
resource: deployment,
|
|
89
|
+
resourceContext: { tier: "basic" },
|
|
90
|
+
pods: 0,
|
|
91
|
+
events: [],
|
|
92
|
+
dnsContext: { signals: [signal], coreDNSRules: [storedRule] },
|
|
93
|
+
}),
|
|
94
|
+
]);
|
|
95
|
+
expect(groupsOf(result.groups, "dns")[0].latest).toMatchObject({
|
|
96
|
+
tone: "info",
|
|
97
|
+
title: "DNS configuration",
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("reads the issues DNS context sent under the dns key", () => {
|
|
102
|
+
const result = project([
|
|
103
|
+
tool("issues-dns-legacy", "issues", {
|
|
104
|
+
issues: [],
|
|
105
|
+
total: 0,
|
|
106
|
+
total_matched: 0,
|
|
107
|
+
cluster_context: {
|
|
108
|
+
dns: {
|
|
109
|
+
signals: ["CoreDNS Deployment kube-system/coredns rolled 2m ago"],
|
|
110
|
+
findings: [legacyFinding],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
]);
|
|
115
|
+
expect(groupsOf(result.groups, "dns")[0].latest).toMatchObject({
|
|
116
|
+
tone: "info",
|
|
117
|
+
data: { type: "dns", dns: { coreDNSFindings: [legacyFinding] } },
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("does not let a CoreDNS verdict make the card adverse", () => {
|
|
122
|
+
const result = project([
|
|
123
|
+
tool("dns-legacy", "diagnose", {
|
|
124
|
+
resource: deployment,
|
|
125
|
+
resourceContext: { tier: "basic" },
|
|
126
|
+
pods: 0,
|
|
127
|
+
events: [],
|
|
128
|
+
dnsContext: { coreDNSFindings: [legacyFinding] },
|
|
129
|
+
}),
|
|
130
|
+
]);
|
|
131
|
+
expect(groupsOf(result.groups, "dns")[0].latest).toMatchObject({
|
|
132
|
+
tone: "info",
|
|
133
|
+
title: "DNS configuration",
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("warns on cluster DNS context only when a lookup failure was seen", () => {
|
|
138
|
+
const tones = [
|
|
139
|
+
"Warning events in namespace shop contain DNS resolution failures",
|
|
140
|
+
"CoreDNS Deployment kube-system/coredns rolled out 2m ago",
|
|
141
|
+
].map((signal) => {
|
|
142
|
+
const result = project([
|
|
143
|
+
tool("issues-dns", "issues", {
|
|
144
|
+
issues: [],
|
|
145
|
+
total: 0,
|
|
146
|
+
total_matched: 0,
|
|
147
|
+
cluster_context: {
|
|
148
|
+
dns_config: {
|
|
149
|
+
signals: [signal],
|
|
150
|
+
rules: [storedRule],
|
|
151
|
+
omitted_rules: 2,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
]);
|
|
156
|
+
const latest = groupsOf(result.groups, "dns")[0].latest;
|
|
157
|
+
expect(latest.data).toMatchObject({
|
|
158
|
+
type: "dns",
|
|
159
|
+
dns: { coreDNSRules: [storedRule], omittedCoreDNSRules: 2 },
|
|
160
|
+
});
|
|
161
|
+
return latest.tone;
|
|
162
|
+
});
|
|
163
|
+
expect(tones).toEqual(["warning", "info"]);
|
|
164
|
+
});
|
|
165
|
+
|
|
13
166
|
it("promotes only classified smoking guns and audits every partiality signal", () => {
|
|
14
167
|
const result = project([
|
|
15
168
|
tool("diagnose-1", "diagnose", {
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
type DiagnosisResourceRef,
|
|
10
10
|
type DiagnosisStartupBlocker,
|
|
11
11
|
diagnosisSeverityTone,
|
|
12
|
+
dnsSignalReportsFailure,
|
|
13
|
+
coreDNSRulesSummary,
|
|
12
14
|
} from "../../diagnoseEvidenceTypes";
|
|
13
15
|
import { metricsWindowLabel } from "./prometheus";
|
|
14
16
|
import {
|
|
@@ -836,17 +838,13 @@ export function adaptDiagnose(
|
|
|
836
838
|
const dns = record(value.dnsContext);
|
|
837
839
|
if (dns) {
|
|
838
840
|
const signals = stringArray(dns.signals) ?? [];
|
|
839
|
-
const findings =
|
|
840
|
-
?
|
|
841
|
-
|
|
841
|
+
const findings = [dns.coreDNSRules, dns.coreDNSFindings].flatMap((list) =>
|
|
842
|
+
Array.isArray(list) ? list : [],
|
|
843
|
+
);
|
|
842
844
|
if (signals.length > 0 || findings.length > 0) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
/\b(error|failed|failures?|timeouts?|nxdomain|servfail)\b/i.test(
|
|
847
|
-
signal,
|
|
848
|
-
),
|
|
849
|
-
);
|
|
845
|
+
// Stored CoreDNS rules are configuration. Only a reported failure
|
|
846
|
+
// makes this card adverse.
|
|
847
|
+
const adverse = signals.some(dnsSignalReportsFailure);
|
|
850
848
|
builder.observe(`dns:${scopeFromArgs(source)}`, "dns", source, {
|
|
851
849
|
tier: evidenceTierForRelevance(
|
|
852
850
|
adverse ? "supporting" : "context",
|
|
@@ -855,9 +853,7 @@ export function adaptDiagnose(
|
|
|
855
853
|
relevance: relatedRelevance,
|
|
856
854
|
tone: adverse ? "warning" : "info",
|
|
857
855
|
title: adverse ? "DNS failure signals" : "DNS configuration",
|
|
858
|
-
summary:
|
|
859
|
-
signals[0] ||
|
|
860
|
-
`${findings.length} CoreDNS finding${findings.length === 1 ? "" : "s"}`,
|
|
856
|
+
summary: signals[0] || coreDNSRulesSummary(findings.length),
|
|
861
857
|
data: { type: "dns", dns: dns as unknown as DiagnosisDNSContext },
|
|
862
858
|
});
|
|
863
859
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Issue, type IssueRecentChange } from "@skyhook-io/k8s-ui";
|
|
2
2
|
import { type UncheckedSource } from "../../../../api/client";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type DiagnosisDNSContext,
|
|
5
|
+
dnsSignalReportsFailure,
|
|
6
|
+
coreDNSRulesSummary,
|
|
7
|
+
} from "../../diagnoseEvidenceTypes";
|
|
4
8
|
import {
|
|
5
9
|
ProjectionBuilder,
|
|
6
10
|
addChanges,
|
|
@@ -111,26 +115,38 @@ export function adaptIssues(
|
|
|
111
115
|
invalidPayload(builder, source, "Issue-related changes");
|
|
112
116
|
}
|
|
113
117
|
addClusterScopedChanges(builder, source, value.cluster_scoped_changes);
|
|
114
|
-
|
|
118
|
+
// `dns_config` holds `rules`. A response may carry `dns` instead, whose
|
|
119
|
+
// `findings` are verdicts on a CoreDNS ConfigMap.
|
|
120
|
+
const clusterContext = record(value.cluster_context);
|
|
121
|
+
const clusterDNS =
|
|
122
|
+
record(clusterContext?.dns_config) ?? record(clusterContext?.dns);
|
|
115
123
|
if (clusterDNS) {
|
|
116
124
|
const signals = stringArray(clusterDNS.signals) ?? [];
|
|
125
|
+
const rules = Array.isArray(clusterDNS.rules) ? clusterDNS.rules : [];
|
|
117
126
|
const findings = Array.isArray(clusterDNS.findings)
|
|
118
127
|
? clusterDNS.findings
|
|
119
128
|
: [];
|
|
120
|
-
if (signals.length > 0 || findings.length > 0) {
|
|
129
|
+
if (signals.length > 0 || rules.length > 0 || findings.length > 0) {
|
|
121
130
|
builder.observe(`dns:issues:${scopeFromArgs(source)}`, "dns", source, {
|
|
122
131
|
tier: "context",
|
|
123
132
|
relevance: "broader",
|
|
124
|
-
|
|
133
|
+
// A CoreDNS rollout or config change with stored rules is context.
|
|
134
|
+
// Only a reported failure is a warning.
|
|
135
|
+
tone: signals.some(dnsSignalReportsFailure) ? "warning" : "info",
|
|
125
136
|
title: "Cluster DNS signals",
|
|
126
137
|
summary:
|
|
127
138
|
signals[0] ||
|
|
128
|
-
|
|
139
|
+
coreDNSRulesSummary(rules.length + findings.length),
|
|
129
140
|
data: {
|
|
130
141
|
type: "dns",
|
|
131
142
|
dns: {
|
|
132
143
|
signals,
|
|
144
|
+
coreDNSRules: rules as DiagnosisDNSContext["coreDNSRules"],
|
|
133
145
|
coreDNSFindings: findings as DiagnosisDNSContext["coreDNSFindings"],
|
|
146
|
+
omittedCoreDNSRules:
|
|
147
|
+
typeof clusterDNS.omitted_rules === "number"
|
|
148
|
+
? clusterDNS.omitted_rules
|
|
149
|
+
: undefined,
|
|
134
150
|
},
|
|
135
151
|
},
|
|
136
152
|
});
|
|
@@ -2,10 +2,32 @@ import { useContext } from "react";
|
|
|
2
2
|
import { AlertTriangle } from "lucide-react";
|
|
3
3
|
import { Badge, StatusDot, ResourceLink } from "@skyhook-io/k8s-ui";
|
|
4
4
|
import { EvidenceNavigationContext } from "../navigation";
|
|
5
|
-
import { type EvidenceDataOf
|
|
5
|
+
import { type EvidenceDataOf } from "../cardParts";
|
|
6
6
|
|
|
7
7
|
export function DNSBody({ data }: { data: EvidenceDataOf<"dns"> }) {
|
|
8
8
|
const { onOpenResource } = useContext(EvidenceNavigationContext);
|
|
9
|
+
const rules = data.dns.coreDNSRules ?? [];
|
|
10
|
+
const source = (ref: { kind: string; namespace: string; name: string }) => (
|
|
11
|
+
<>
|
|
12
|
+
<Badge tone="structural" size="sm">
|
|
13
|
+
{ref.kind}
|
|
14
|
+
</Badge>
|
|
15
|
+
<span className="font-mono text-xs">
|
|
16
|
+
<ResourceLink
|
|
17
|
+
name={ref.name}
|
|
18
|
+
kind={ref.kind}
|
|
19
|
+
namespace={ref.namespace}
|
|
20
|
+
group=""
|
|
21
|
+
label={`${ref.namespace}/${ref.name}`}
|
|
22
|
+
onNavigate={
|
|
23
|
+
ref.kind.toLowerCase() === "configmap" && onOpenResource
|
|
24
|
+
? (target) => onOpenResource(target)
|
|
25
|
+
: undefined
|
|
26
|
+
}
|
|
27
|
+
/>
|
|
28
|
+
</span>
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
9
31
|
return (
|
|
10
32
|
<div className="space-y-2">
|
|
11
33
|
{(data.dns.signals ?? []).map((signal) => (
|
|
@@ -16,37 +38,52 @@ export function DNSBody({ data }: { data: EvidenceDataOf<"dns"> }) {
|
|
|
16
38
|
{signal}
|
|
17
39
|
</p>
|
|
18
40
|
))}
|
|
19
|
-
{
|
|
41
|
+
{rules.length > 0 && (
|
|
42
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
43
|
+
Rewrite and template rules in the CoreDNS config
|
|
44
|
+
</p>
|
|
45
|
+
)}
|
|
46
|
+
{rules.map((rule) => (
|
|
20
47
|
<div
|
|
21
|
-
key={`${
|
|
48
|
+
key={`${rule.namespace}-${rule.name}-${rule.key}-${rule.line}`}
|
|
22
49
|
className="rounded-md border border-theme-border bg-theme-base/40 p-2"
|
|
23
50
|
>
|
|
24
51
|
<div className="flex flex-wrap gap-1.5">
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<span className="font-mono text-xs">
|
|
29
|
-
<ResourceLink
|
|
30
|
-
name={finding.name}
|
|
31
|
-
kind={finding.kind}
|
|
32
|
-
namespace={finding.namespace}
|
|
33
|
-
group=""
|
|
34
|
-
label={`${finding.namespace}/${finding.name}`}
|
|
35
|
-
onNavigate={
|
|
36
|
-
finding.kind.toLowerCase() === "configmap" && onOpenResource
|
|
37
|
-
? (ref) => onOpenResource(ref)
|
|
38
|
-
: undefined
|
|
39
|
-
}
|
|
40
|
-
/>
|
|
52
|
+
{source(rule)}
|
|
53
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
54
|
+
{rule.key}, line {rule.line}
|
|
41
55
|
</span>
|
|
42
|
-
<Badge severity={severityBadge(finding.severity)} size="sm">
|
|
43
|
-
{finding.severity}
|
|
44
|
-
</Badge>
|
|
45
56
|
</div>
|
|
46
|
-
<
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
<pre className="mt-1 overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs text-theme-text-secondary">
|
|
58
|
+
{rule.text}
|
|
59
|
+
</pre>
|
|
60
|
+
{rule.truncated && (
|
|
61
|
+
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
62
|
+
Cut short. Open the ConfigMap for the whole rule.
|
|
63
|
+
</p>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
))}
|
|
67
|
+
{(data.dns.omittedCoreDNSRules ?? 0) > 0 && (
|
|
68
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
69
|
+
{data.dns.omittedCoreDNSRules} more{" "}
|
|
70
|
+
{data.dns.omittedCoreDNSRules === 1 ? "rule is" : "rules are"} not
|
|
71
|
+
shown.
|
|
72
|
+
</p>
|
|
73
|
+
)}
|
|
74
|
+
{/* A `coreDNSFindings` entry is a verdict on the ConfigMap. Its reason
|
|
75
|
+
and message are shown as text, without its severity. */}
|
|
76
|
+
{(data.dns.coreDNSFindings ?? []).map((finding, index) => (
|
|
77
|
+
<div
|
|
78
|
+
key={`legacy-${finding.namespace}-${finding.name}-${index}`}
|
|
79
|
+
className="rounded-md border border-theme-border bg-theme-base/40 p-2"
|
|
80
|
+
>
|
|
81
|
+
<div className="flex flex-wrap gap-1.5">{source(finding)}</div>
|
|
82
|
+
{(finding.reason || finding.message) && (
|
|
83
|
+
<p className="mt-1 text-xs text-theme-text-secondary">
|
|
84
|
+
{[finding.reason, finding.message].filter(Boolean).join(": ")}
|
|
85
|
+
</p>
|
|
86
|
+
)}
|
|
50
87
|
</div>
|
|
51
88
|
))}
|
|
52
89
|
</div>
|
|
@@ -50,7 +50,7 @@ export function openInTerminal(command: string, title: string) {
|
|
|
50
50
|
// buildLaunchCommand resumes the investigation's ACTUAL agent session interactively
|
|
51
51
|
// (not a re-seeded prompt), so the full transcript — every tool call, finding, and
|
|
52
52
|
// the agent's reasoning — carries over. Returns null when there's no resumable
|
|
53
|
-
// session yet (first turn still running) or the run is stale (
|
|
53
|
+
// session yet (first turn still running) or the run is stale (its connection closed).
|
|
54
54
|
// The MCP server is re-attached on resume (it's configured per-launch, not stored
|
|
55
55
|
// in the session).
|
|
56
56
|
export function buildLaunchCommand(
|
|
@@ -58,3 +58,69 @@ it.each([
|
|
|
58
58
|
await until(message)
|
|
59
59
|
expect(document.body.textContent).not.toContain('attached')
|
|
60
60
|
})
|
|
61
|
+
|
|
62
|
+
it('keeps a running debug terminal mounted when its connection is replaced, so the terminal can say why it ended', async () => {
|
|
63
|
+
const { observeConnectionStatus, resetConnectionBindingForTest } = await import('../../api/connectionBinding')
|
|
64
|
+
resetConnectionBindingForTest()
|
|
65
|
+
observeConnectionStatus({ connectionId: 'c-1' })
|
|
66
|
+
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply({ running: {} })))
|
|
67
|
+
const bound = { ...session, connectionId: 'c-1' }
|
|
68
|
+
const host = document.createElement('div')
|
|
69
|
+
document.body.append(host)
|
|
70
|
+
root = createRoot(host)
|
|
71
|
+
const render = () => root.render(<QueryClientProvider client={client}><PodDebugSession {...opts} session={bound}><b>attached</b></PodDebugSession></QueryClientProvider>)
|
|
72
|
+
await act(async () => render())
|
|
73
|
+
await vi.waitFor(() => expect(document.body.textContent).toContain('attached'))
|
|
74
|
+
await act(async () => observeConnectionStatus({ connectionId: 'c-2' }))
|
|
75
|
+
expect(document.body.textContent).toContain('attached')
|
|
76
|
+
expect(document.body.textContent).not.toContain('The cluster connection changed')
|
|
77
|
+
resetConnectionBindingForTest()
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('says the connection changed for a debug session that never reached its terminal', async () => {
|
|
81
|
+
const { observeConnectionStatus, resetConnectionBindingForTest } = await import('../../api/connectionBinding')
|
|
82
|
+
resetConnectionBindingForTest()
|
|
83
|
+
observeConnectionStatus({ connectionId: 'c-2' })
|
|
84
|
+
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply({ running: {} })))
|
|
85
|
+
const host = document.createElement('div')
|
|
86
|
+
document.body.append(host)
|
|
87
|
+
root = createRoot(host)
|
|
88
|
+
await act(async () => root.render(<QueryClientProvider client={client}><PodDebugSession {...opts} session={{ ...session, connectionId: 'c-1' }}><b>attached</b></PodDebugSession></QueryClientProvider>))
|
|
89
|
+
expect(document.body.textContent).toContain('The cluster connection changed')
|
|
90
|
+
expect(document.body.textContent).not.toContain('attached')
|
|
91
|
+
resetConnectionBindingForTest()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('replaces a running debug terminal that recorded no connection once one is adopted', async () => {
|
|
95
|
+
const { observeConnectionStatus, resetConnectionBindingForTest } = await import('../../api/connectionBinding')
|
|
96
|
+
resetConnectionBindingForTest()
|
|
97
|
+
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply({ running: {} })))
|
|
98
|
+
await mount()
|
|
99
|
+
await vi.waitFor(() => expect(document.body.textContent).toContain('attached'))
|
|
100
|
+
await act(async () => observeConnectionStatus({ connectionId: 'c-1' }))
|
|
101
|
+
expect(document.body.textContent).toContain('The cluster connection changed')
|
|
102
|
+
resetConnectionBindingForTest()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('keeps a running bound debug terminal mounted when the API base changes', async () => {
|
|
106
|
+
const { observeConnectionStatus, resetConnectionBindingForTest } = await import('../../api/connectionBinding')
|
|
107
|
+
const config = await import('../../api/config')
|
|
108
|
+
const original = config.getApiBase()
|
|
109
|
+
resetConnectionBindingForTest()
|
|
110
|
+
observeConnectionStatus({ connectionId: 'c-1' })
|
|
111
|
+
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(reply({ running: {} })))
|
|
112
|
+
const host = document.createElement('div')
|
|
113
|
+
document.body.append(host)
|
|
114
|
+
root = createRoot(host)
|
|
115
|
+
const render = () => root.render(<QueryClientProvider client={client}><PodDebugSession {...opts} session={{ ...session, apiBase: original, connectionId: 'c-1' }}><b>attached</b></PodDebugSession></QueryClientProvider>)
|
|
116
|
+
try {
|
|
117
|
+
await act(async () => render())
|
|
118
|
+
await vi.waitFor(() => expect(document.body.textContent).toContain('attached'))
|
|
119
|
+
config.setApiBase('/clusters/other/api')
|
|
120
|
+
await act(async () => render())
|
|
121
|
+
expect(document.body.textContent).toContain('attached')
|
|
122
|
+
} finally {
|
|
123
|
+
config.setApiBase(original)
|
|
124
|
+
resetConnectionBindingForTest()
|
|
125
|
+
}
|
|
126
|
+
})
|
|
@@ -68,7 +68,9 @@ export function PodDebugSession({ namespace, podName, containerName, session, is
|
|
|
68
68
|
})
|
|
69
69
|
|
|
70
70
|
if (!connected && !query.error && query.data?.state === 'running' && current()) setConnected(true)
|
|
71
|
-
|
|
71
|
+
// A running terminal bound to a connection keeps its scrollback and shows its own ended notice.
|
|
72
|
+
const changed = currentConnection !== session.connectionId || getApiBase() !== session.apiBase
|
|
73
|
+
if (changed && (!connected || !session.connectionId)) return <div role="status" className="p-5 text-sm text-theme-text-secondary">The cluster connection changed. Reopen the Pod to inspect this debug session.</div>
|
|
72
74
|
if (connected) return <>{children}</>
|
|
73
75
|
|
|
74
76
|
const status = query.data
|