@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
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { HomeView } from './components/home/HomeView'
|
|
|
9
9
|
import { DebugOverlay } from './components/DebugOverlay'
|
|
10
10
|
import { GlobalDiagnoseButton } from './components/diagnose/LocalDiagnoseAction'
|
|
11
11
|
import { switchInProgress } from './api/contextSwitch'
|
|
12
|
+
import { connectionHeaderValue } from './api/connectionBinding'
|
|
12
13
|
import { ContextSwitchActions } from './components/ContextSwitchActions'
|
|
13
14
|
import { investigationWorkspaceSearch, isInvestigationWorkspacePath, useDiagnoseLayout } from './components/diagnose/DiagnoseContext'
|
|
14
15
|
import { DiagnoseSurface } from './components/diagnose/DiagnoseSurface'
|
|
@@ -2787,7 +2788,7 @@ function App({ manageDocumentTitle = false, documentTitleSuffix, onClusterLoadSt
|
|
|
2787
2788
|
<CapabilitiesProvider>
|
|
2788
2789
|
<RadarUpgradeProvider>
|
|
2789
2790
|
<ContextSwitchProvider>
|
|
2790
|
-
<DockProvider>
|
|
2791
|
+
<DockProvider connectionId={connectionHeaderValue}>
|
|
2791
2792
|
<KeyboardShortcutProvider>
|
|
2792
2793
|
<AppInner
|
|
2793
2794
|
manageDocumentTitle={manageDocumentTitle}
|
package/src/api/client.ts
CHANGED
|
@@ -199,13 +199,19 @@ export function apiFetch(
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
let authMode: string | undefined;
|
|
202
|
+
let errorCode: string | undefined;
|
|
202
203
|
try {
|
|
203
204
|
const body = await response.clone().json();
|
|
204
205
|
authMode = body.authMode;
|
|
206
|
+
if (typeof body.code === "string") errorCode = body.code;
|
|
205
207
|
} catch {
|
|
206
208
|
console.warn("Authentication required (unable to determine auth mode)");
|
|
207
209
|
}
|
|
208
210
|
|
|
211
|
+
if (!authMode && errorCode === "identity_required") {
|
|
212
|
+
return response;
|
|
213
|
+
}
|
|
214
|
+
|
|
209
215
|
if (authMode === "oidc") {
|
|
210
216
|
// Only the first 401 in a burst navigates; concurrent 401s within the
|
|
211
217
|
// window are suppressed so they don't rotate radar_oidc_state. The gate
|
|
@@ -256,6 +262,10 @@ export class ApiError extends Error {
|
|
|
256
262
|
}
|
|
257
263
|
}
|
|
258
264
|
|
|
265
|
+
export function shouldRetryReplacedMember(failureCount: number, error: unknown): boolean {
|
|
266
|
+
return failureCount < 1 && error instanceof ApiError && (error.status === 409 || error.status === 503);
|
|
267
|
+
}
|
|
268
|
+
|
|
259
269
|
export function isForbiddenError(error: unknown): boolean {
|
|
260
270
|
return error instanceof ApiError && error.status === 403;
|
|
261
271
|
}
|
|
@@ -4739,6 +4749,8 @@ export function useRightsizingScan(namespaces: string[], context = "") {
|
|
|
4739
4749
|
if (inaccessible) {
|
|
4740
4750
|
previous.current = null;
|
|
4741
4751
|
queryClient.setQueryData(cache.queryKey, null);
|
|
4752
|
+
} else if (current === null) {
|
|
4753
|
+
previous.current = null;
|
|
4742
4754
|
} else if (current && current.coverage.workloadsEvaluated > 0) {
|
|
4743
4755
|
previous.current = { scope, result: current };
|
|
4744
4756
|
}
|
package/src/api/cnpg-history.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query'
|
|
2
2
|
import type { CNPGFleetMetricsReading, Grant } from '@skyhook-io/k8s-ui'
|
|
3
|
-
import { fetchJSON, useRadarFeature } from './client'
|
|
3
|
+
import { fetchJSON, shouldRetryReplacedMember, useRadarFeature } from './client'
|
|
4
4
|
import { shouldRetryRadarQuery } from './radarFeatures'
|
|
5
5
|
import type { CNPGClusterActivityResponse } from './cnpg'
|
|
6
6
|
|
|
@@ -76,7 +76,7 @@ export function useCNPGClusterHistory(namespace: string, name: string, range: CN
|
|
|
76
76
|
refetchInterval: range === '15m' ? 30_000 : 60_000,
|
|
77
77
|
refetchIntervalInBackground: false,
|
|
78
78
|
staleTime: 10_000,
|
|
79
|
-
retry:
|
|
79
|
+
retry: shouldRetryReplacedMember,
|
|
80
80
|
placeholderData: (prev) => (prev?.range === range ? prev : undefined),
|
|
81
81
|
})
|
|
82
82
|
}
|
|
@@ -101,7 +101,7 @@ export function useCNPGFleetMetrics(namespaces: string[], enabled = true) {
|
|
|
101
101
|
enabled,
|
|
102
102
|
staleTime: 20_000,
|
|
103
103
|
refetchInterval: 60_000,
|
|
104
|
-
retry:
|
|
104
|
+
retry: shouldRetryReplacedMember,
|
|
105
105
|
placeholderData: (prev) => prev,
|
|
106
106
|
})
|
|
107
107
|
}
|
package/src/api/cnpg-storage.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query'
|
|
2
2
|
import type { CNPGDiskReading, CNPGMetricIsolation, Grant } from '@skyhook-io/k8s-ui'
|
|
3
|
-
import { fetchJSON, useRadarFeature } from './client'
|
|
3
|
+
import { fetchJSON, shouldRetryReplacedMember, useRadarFeature } from './client'
|
|
4
4
|
|
|
5
5
|
export type CNPGPVCRole = 'PG_DATA' | 'PG_WAL' | 'PG_TABLESPACE'
|
|
6
6
|
|
|
@@ -110,7 +110,7 @@ export function useCNPGClusterStorage(namespace: string, name: string, enabled =
|
|
|
110
110
|
refetchInterval: 30_000,
|
|
111
111
|
refetchIntervalInBackground: false,
|
|
112
112
|
staleTime: 10_000,
|
|
113
|
-
retry:
|
|
113
|
+
retry: shouldRetryReplacedMember,
|
|
114
114
|
placeholderData: (prev) => prev,
|
|
115
115
|
})
|
|
116
116
|
}
|
|
@@ -132,7 +132,7 @@ export function useCNPGFleetDisk(namespaces: string[], enabled = true) {
|
|
|
132
132
|
enabled,
|
|
133
133
|
staleTime: 20_000,
|
|
134
134
|
refetchInterval: 60_000,
|
|
135
|
-
retry:
|
|
135
|
+
retry: shouldRetryReplacedMember,
|
|
136
136
|
placeholderData: (prev) => prev,
|
|
137
137
|
})
|
|
138
138
|
}
|
package/src/api/diagnose.test.ts
CHANGED
|
@@ -438,3 +438,37 @@ describe("fetchAgents agents normalisation", () => {
|
|
|
438
438
|
expect(r.agents.map((a) => a.name)).toEqual(["claude"]);
|
|
439
439
|
});
|
|
440
440
|
});
|
|
441
|
+
|
|
442
|
+
describe("Diagnose writes name the tab's connection", () => {
|
|
443
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
444
|
+
|
|
445
|
+
it("sends the connection ID when starting a run and adding a turn", async () => {
|
|
446
|
+
const { observeConnectionStatus, resetConnectionBindingForTest, CONNECTION_HEADER } = await import("./connectionBinding");
|
|
447
|
+
resetConnectionBindingForTest();
|
|
448
|
+
observeConnectionStatus({ connectionId: "conn-a" });
|
|
449
|
+
const fetchMock = vi.fn(async () => new Response(JSON.stringify({ id: "run-1" }), { status: 200 }));
|
|
450
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
451
|
+
await createRun({ kind: "Pod", group: "", namespace: "default", name: "web" });
|
|
452
|
+
await addTurn("run-1", { question: "why?" });
|
|
453
|
+
for (const [, init] of fetchMock.mock.calls as unknown as [string, RequestInit][]) {
|
|
454
|
+
expect((init.headers as Record<string, string>)[CONNECTION_HEADER]).toBe("conn-a");
|
|
455
|
+
}
|
|
456
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
457
|
+
resetConnectionBindingForTest();
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
describe("Diagnose names connection refusals in its own words", () => {
|
|
462
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
463
|
+
|
|
464
|
+
it.each([
|
|
465
|
+
["context_changed", 409, "The cluster changed since this view loaded"],
|
|
466
|
+
["cluster_unavailable", 503, "Radar isn't connected to a cluster right now"],
|
|
467
|
+
])("%s", async (code, status, text) => {
|
|
468
|
+
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ error: "Nothing was changed: …", error_code: code }), { status })));
|
|
469
|
+
const err = await createRun({ kind: "Pod", group: "", namespace: "default", name: "web" }).catch((e: unknown) => e);
|
|
470
|
+
expect(err).toBeInstanceOf(DiagnoseError);
|
|
471
|
+
expect((err as DiagnoseError).message).toContain(text);
|
|
472
|
+
expect((err as DiagnoseError).message).not.toContain("Nothing was changed");
|
|
473
|
+
});
|
|
474
|
+
});
|
package/src/api/diagnose.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// on the user's own machine/subscription against Radar's MCP; this just starts
|
|
3
3
|
// the investigation and consumes its SSE event stream.
|
|
4
4
|
import { getApiBase, getAuthHeaders, getCredentialsMode } from "./config";
|
|
5
|
+
import { connectionHeaderValue, connectionHeaders } from "./connectionBinding";
|
|
5
6
|
|
|
6
7
|
export interface AgentInfo {
|
|
7
8
|
name: string;
|
|
@@ -20,8 +21,10 @@ export interface AgentInfo {
|
|
|
20
21
|
/** The backend re-checks the resource after an Apply. Absent means it does not. */
|
|
21
22
|
verification?: boolean;
|
|
22
23
|
/** The backend opens a run from a question, with or without a resource.
|
|
23
|
-
*
|
|
24
|
+
* Also enables resource-pinned questions. */
|
|
24
25
|
questions?: boolean;
|
|
26
|
+
/** The backend accepts an opening question about one selected resource. */
|
|
27
|
+
targetQuestions?: boolean;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export interface AgentsResponse {
|
|
@@ -341,6 +344,13 @@ export interface DiagnoseRefusal {
|
|
|
341
344
|
// The sentence to show is `detail` when a host sends one, else `error`. A
|
|
342
345
|
// host's machine-readable code is `code`, or `error` when that is not the
|
|
343
346
|
// sentence itself.
|
|
347
|
+
const connectionRefusals: Record<string, string> = {
|
|
348
|
+
context_changed:
|
|
349
|
+
"The cluster changed since this view loaded. Check which cluster you're on and ask again.",
|
|
350
|
+
cluster_unavailable:
|
|
351
|
+
"Radar isn't connected to a cluster right now. Ask again once it reconnects.",
|
|
352
|
+
};
|
|
353
|
+
|
|
344
354
|
async function diagnoseError(res: Response): Promise<DiagnoseError> {
|
|
345
355
|
let body: Record<string, unknown> | null = null;
|
|
346
356
|
try {
|
|
@@ -353,7 +363,10 @@ async function diagnoseError(res: Response): Promise<DiagnoseError> {
|
|
|
353
363
|
typeof v === "string" && v.trim() !== "" ? v : undefined;
|
|
354
364
|
const detail = str(body?.detail);
|
|
355
365
|
const error = str(body?.error);
|
|
356
|
-
|
|
366
|
+
// The connection check refuses before Diagnose runs; its general wording is
|
|
367
|
+
// about writes ("Nothing was changed"), which reads oddly for an investigation.
|
|
368
|
+
const refusal = connectionRefusals[str(body?.error_code) ?? ""];
|
|
369
|
+
const message = refusal ?? detail ?? error ?? `request failed (${res.status})`;
|
|
357
370
|
return new DiagnoseError(res.status, message, {
|
|
358
371
|
code: str(body?.code) ?? (detail && error !== detail ? error : undefined),
|
|
359
372
|
reason: str(body?.reason),
|
|
@@ -475,7 +488,7 @@ export async function createRun(
|
|
|
475
488
|
const res = await fetch(RUNS(), {
|
|
476
489
|
method: "POST",
|
|
477
490
|
credentials: getCredentialsMode(),
|
|
478
|
-
headers: { "Content-Type": "application/json", ...getAuthHeaders() },
|
|
491
|
+
headers: { "Content-Type": "application/json", ...getAuthHeaders(), ...connectionHeaders(connectionHeaderValue()) },
|
|
479
492
|
body: JSON.stringify({ ...target, ...opts }),
|
|
480
493
|
});
|
|
481
494
|
if (!res.ok) throw await diagnoseError(res);
|
|
@@ -553,7 +566,7 @@ export async function addTurn(
|
|
|
553
566
|
const res = await fetch(`${RUNS()}/${id}/turns`, {
|
|
554
567
|
method: "POST",
|
|
555
568
|
credentials: getCredentialsMode(),
|
|
556
|
-
headers: { "Content-Type": "application/json", ...getAuthHeaders() },
|
|
569
|
+
headers: { "Content-Type": "application/json", ...getAuthHeaders(), ...connectionHeaders(connectionHeaderValue()) },
|
|
557
570
|
body: JSON.stringify(body),
|
|
558
571
|
});
|
|
559
572
|
if (!res.ok) throw await diagnoseError(res);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { getRadarUpgradeRequirement } from '@skyhook-io/k8s-ui'
|
|
3
|
-
import { ApiError } from './client'
|
|
3
|
+
import { ApiError, shouldRetryReplacedMember } from './client'
|
|
4
4
|
import {
|
|
5
5
|
RADAR_FEATURES,
|
|
6
6
|
RadarFeatureUnsupportedError,
|
|
@@ -187,6 +187,18 @@ describe('shouldRetryRadarQuery', () => {
|
|
|
187
187
|
})
|
|
188
188
|
})
|
|
189
189
|
|
|
190
|
+
describe('shouldRetryReplacedMember', () => {
|
|
191
|
+
it('retries only HTTP 409 and 503, once each', () => {
|
|
192
|
+
for (const status of [409, 503]) {
|
|
193
|
+
expect(shouldRetryReplacedMember(0, new ApiError('x', status))).toBe(true)
|
|
194
|
+
expect(shouldRetryReplacedMember(1, new ApiError('x', status))).toBe(false)
|
|
195
|
+
}
|
|
196
|
+
for (const error of [new ApiError('x', 404), new ApiError('x', 500), new TypeError('Failed to fetch')]) {
|
|
197
|
+
expect(shouldRetryReplacedMember(0, error)).toBe(false)
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
|
|
190
202
|
describe('affirmative mutation support', () => {
|
|
191
203
|
it.each(['argoRollback', 'argoAutoSyncEnable', 'workloadRestartPreconditions'] as const)('%s distinguishes checking, failed and known answers', feature => {
|
|
192
204
|
expect(radarControlBlockedReason(feature, 'unknown', false)).toBe("Checking this cluster's Radar…")
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -55,6 +55,7 @@ export const RADAR_FEATURES = {
|
|
|
55
55
|
drainPlan: { label: 'Drain plans', minimumVersion: 'v1.14.0' },
|
|
56
56
|
applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
|
|
57
57
|
workloadHistory: { label: 'Workload history', flag: 'workloadHistory', flagShippedWithEndpoint: true },
|
|
58
|
+
workloadSource: { label: 'Workload source', flag: 'workloadSource', flagShippedWithEndpoint: true },
|
|
58
59
|
deploymentPause: { label: 'Deployment rollout pause and resume', flag: 'deploymentPause', flagShippedWithEndpoint: true },
|
|
59
60
|
substrateHealthMetrics: { label: 'Agent Substrate charts', flag: 'substrateHealthMetrics', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
60
61
|
cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
|
|
@@ -74,6 +75,7 @@ export const RADAR_FEATURES = {
|
|
|
74
75
|
veleroRuns: { label: 'Velero backup and restore lists', flag: 'veleroRuns', flagShippedWithEndpoint: true },
|
|
75
76
|
veleroDeleteBackup: { label: 'Delete a Velero backup', flag: 'veleroDeleteBackup', flagShippedWithEndpoint: true },
|
|
76
77
|
workloadRestartPreconditions: { label: 'Reviewed workload restarts', flag: 'workloadRestartPreconditions', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
78
|
+
resourceActions: { label: 'Resource action preview and execute', flag: 'resourceActions', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
77
79
|
resourceDeletePreconditions: { label: 'Delete only the object you reviewed', flag: 'resourceDeletePreconditions', flagShippedWithEndpoint: true },
|
|
78
80
|
gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
|
|
79
81
|
serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
|