@skyhook-io/radar-app 1.19.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +37 -9
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useId, useState } from 'react'
|
|
2
|
-
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
1
|
+
import { useEffect, useId, useRef, useState } from 'react'
|
|
2
|
+
import { useIsMutating, useMutation, useQueryClient } from '@tanstack/react-query'
|
|
3
3
|
import { Bell, Check, Cloud, Globe, History, Sparkles, Users, X } from 'lucide-react'
|
|
4
4
|
import { Collapse, CollapseChevron } from '@skyhook-io/k8s-ui/components/ui/Collapse'
|
|
5
5
|
import { DialogPortal } from '@skyhook-io/k8s-ui/components/ui/DialogPortal'
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type CloudConnectSelf,
|
|
23
23
|
type CloudInstallConnectedRadar,
|
|
24
24
|
type CloudInstallBlocked,
|
|
25
|
+
type CloudInstallStage,
|
|
25
26
|
type CloudInstallStatus,
|
|
26
27
|
prepareCloudInstall,
|
|
27
28
|
useCapabilities,
|
|
@@ -76,6 +77,7 @@ const ABOUT_URL = 'https://radarhq.io/about'
|
|
|
76
77
|
const BENCHMARK_URL = 'https://radarhq.io/benchmark'
|
|
77
78
|
const PRICING_URL = 'https://radarhq.io/pricing'
|
|
78
79
|
const SEEN_KEY = 'radar.cloudFunnel.seen'
|
|
80
|
+
const PREPARE_MUTATION_KEY = ['cloud-install-prepare']
|
|
79
81
|
|
|
80
82
|
// localStorage access can throw (SecurityError) where storage is denied —
|
|
81
83
|
// sandboxed embeds, some privacy modes. This button mounts in the top bar
|
|
@@ -104,6 +106,17 @@ export function CloudFunnelButton() {
|
|
|
104
106
|
const [inFlowView, setInFlowView] = useState(false)
|
|
105
107
|
const [selfManaged, setSelfManaged] = useState(false)
|
|
106
108
|
const [blocked, setBlocked] = useState<CloudInstallBlocked | null>(null)
|
|
109
|
+
// The server flow this attempt was seen preparing, and the furthest check it
|
|
110
|
+
// reached. A blocked preparation clears the flow before its request answers,
|
|
111
|
+
// so a poll in between reads idle; the synthesized view resumes at this
|
|
112
|
+
// step rather than the first. Only this flow can stand in for a prepare
|
|
113
|
+
// answer that was lost: a status from before the click, or another flow
|
|
114
|
+
// fetched late, says nothing about this attempt.
|
|
115
|
+
const [seenPreparing, setSeenPreparing] = useState<{ flowId: string; step?: CloudInstallStage } | null>(null)
|
|
116
|
+
// Identifies the latest Connect attempt. The status poll can show a plan
|
|
117
|
+
// before its prepare request answers, so the person may move on and start
|
|
118
|
+
// again; a late answer from an earlier attempt must not act on the new one.
|
|
119
|
+
const attemptRef = useRef(0)
|
|
107
120
|
// Set once an in-app attempt has ended without connecting, naming what
|
|
108
121
|
// happened (a flow failure kind, a blocked plan, a canceled plan, or the
|
|
109
122
|
// prepare call itself failing) and whether it is worth trying again. It
|
|
@@ -157,7 +170,8 @@ export function CloudFunnelButton() {
|
|
|
157
170
|
|
|
158
171
|
// The flow is server-owned: polling here both drives the live progress view
|
|
159
172
|
// and re-attaches to an ongoing flow after a reload or modal close.
|
|
160
|
-
const
|
|
173
|
+
const preparing = useIsMutating({ mutationKey: PREPARE_MUTATION_KEY }) > 0
|
|
174
|
+
const flowStatus = useCloudInstallStatus(lane === 'driver', preparing)
|
|
161
175
|
const flow = flowStatus.data
|
|
162
176
|
const flowLive = cloudInstallActive(flow?.state) || flow?.state === 'connected' || flow?.state === 'failed'
|
|
163
177
|
|
|
@@ -167,13 +181,17 @@ export function CloudFunnelButton() {
|
|
|
167
181
|
flowStatus.invalidate()
|
|
168
182
|
}
|
|
169
183
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
// The variable is the attempt id, read back in the callbacks.
|
|
185
|
+
const prepare = useMutation<CloudInstallStatus, Error, number>({
|
|
186
|
+
mutationKey: PREPARE_MUTATION_KEY,
|
|
187
|
+
mutationFn: () => prepareCloudInstall(),
|
|
188
|
+
onSuccess: (st, attempt) => {
|
|
189
|
+
if (attempt !== attemptRef.current) return
|
|
173
190
|
if (st.state === 'blocked' && st.blocked) setBlocked(st.blocked)
|
|
174
191
|
else applyStatus(st)
|
|
175
192
|
},
|
|
176
|
-
onError: (err) => {
|
|
193
|
+
onError: (err, attempt) => {
|
|
194
|
+
if (attempt !== attemptRef.current) return
|
|
177
195
|
// A single-flight 409 is not a failure: its body IS the live flow (one
|
|
178
196
|
// started in another tab, or before this tab's status cache refreshed).
|
|
179
197
|
// Attach to it rather than showing an error over a running install.
|
|
@@ -182,6 +200,20 @@ export function CloudFunnelButton() {
|
|
|
182
200
|
applyStatus(live)
|
|
183
201
|
return
|
|
184
202
|
}
|
|
203
|
+
// The status poll may already have seen this attempt's preparation
|
|
204
|
+
// finish (and the flow move on from there): only this request's answer
|
|
205
|
+
// was lost. Stay on what the server reports rather than calling a
|
|
206
|
+
// finished inspection a failure.
|
|
207
|
+
const polled = queryClient.getQueryData<CloudInstallStatus>(['cloud-install-status'])
|
|
208
|
+
if (
|
|
209
|
+
polled?.flowId &&
|
|
210
|
+
polled.flowId === seenPreparing?.flowId &&
|
|
211
|
+
polled.state !== 'idle' &&
|
|
212
|
+
polled.state !== 'preparing'
|
|
213
|
+
) {
|
|
214
|
+
flowStatus.invalidate()
|
|
215
|
+
return
|
|
216
|
+
}
|
|
185
217
|
// Anything else failed before a flow existed. Return to the pitch rather
|
|
186
218
|
// than leaving the flow view armed, where a later status change would
|
|
187
219
|
// pull the user into a screen they did not ask for.
|
|
@@ -205,8 +237,10 @@ export function CloudFunnelButton() {
|
|
|
205
237
|
const startConnect = () => {
|
|
206
238
|
setBlocked(null)
|
|
207
239
|
setHandoff(null)
|
|
240
|
+
setSeenPreparing(null)
|
|
208
241
|
setInFlowView(true)
|
|
209
|
-
|
|
242
|
+
attemptRef.current += 1
|
|
243
|
+
prepare.mutate(attemptRef.current)
|
|
210
244
|
}
|
|
211
245
|
|
|
212
246
|
// A flow that ended without connecting returns to a pitch whose CTA must
|
|
@@ -242,6 +276,13 @@ export function CloudFunnelButton() {
|
|
|
242
276
|
return { outcome: 'install_plan_canceled', retryable: false }
|
|
243
277
|
}
|
|
244
278
|
|
|
279
|
+
const observed = prepare.isPending && flow?.state === 'preparing' ? flow : undefined
|
|
280
|
+
if (observed?.flowId) {
|
|
281
|
+
const sameFlow = observed.flowId === seenPreparing?.flowId
|
|
282
|
+
const step = observed.prepareStep ?? (sameFlow ? seenPreparing?.step : undefined)
|
|
283
|
+
if (!sameFlow || step !== seenPreparing?.step) setSeenPreparing({ flowId: observed.flowId, step })
|
|
284
|
+
}
|
|
285
|
+
|
|
245
286
|
useEffect(() => {
|
|
246
287
|
window.addEventListener(OPEN_EVENT, openModal)
|
|
247
288
|
return () => window.removeEventListener(OPEN_EVENT, openModal)
|
|
@@ -280,7 +321,7 @@ export function CloudFunnelButton() {
|
|
|
280
321
|
// explanation back to the pitch.
|
|
281
322
|
const flowForView: CloudInstallStatus | undefined =
|
|
282
323
|
prepare.isPending && !flowLive
|
|
283
|
-
? { state: 'preparing' }
|
|
324
|
+
? { state: 'preparing', prepareStep: seenPreparing?.step }
|
|
284
325
|
: (flow ?? (blocked ? { state: 'blocked', blocked } : undefined))
|
|
285
326
|
|
|
286
327
|
return (
|
|
@@ -191,3 +191,37 @@ describe('ConnectionErrorView kubeconfig guidance', () => {
|
|
|
191
191
|
expect(markup).not.toContain('Switch context')
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
|
+
|
|
195
|
+
describe('ConnectionErrorView after a refused switch', () => {
|
|
196
|
+
const connection = { state: 'disconnected' as const, context: 'staging-eu', errorType: 'auth', error: 'safe error' }
|
|
197
|
+
|
|
198
|
+
it('offers a way back to the cluster the person was using', () => {
|
|
199
|
+
const markup = renderToStaticMarkup(
|
|
200
|
+
<ConnectionErrorView connection={connection} onRetry={() => {}} isRetrying={false} back={{ label: 'kind-radar-ph-video', onBack: () => {} }} variant="switch" />,
|
|
201
|
+
)
|
|
202
|
+
expect(markup).toContain('Back to kind-radar-ph-video')
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('does not promise background re-checks for a cluster it never connected to', () => {
|
|
206
|
+
const switchMarkup = renderToStaticMarkup(
|
|
207
|
+
<ConnectionErrorView connection={connection} onRetry={() => {}} isRetrying={false} variant="switch" />,
|
|
208
|
+
)
|
|
209
|
+
const connectionMarkup = renderToStaticMarkup(
|
|
210
|
+
<ConnectionErrorView connection={connection} onRetry={() => {}} isRetrying={false} />,
|
|
211
|
+
)
|
|
212
|
+
expect(connectionMarkup).toContain('re-checks in the background')
|
|
213
|
+
expect(switchMarkup).not.toContain('re-checks in the background')
|
|
214
|
+
expect(switchMarkup).not.toContain('Back to')
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
describe('ConnectionErrorView after a refused switch with a stuck credential plugin', () => {
|
|
219
|
+
it('does not say Radar keeps checking a cluster it never connected to', () => {
|
|
220
|
+
const connection = { state: 'disconnected' as const, context: 'prod', errorType: 'auth-plugin-stuck', error: 'safe error' }
|
|
221
|
+
const switchMarkup = renderToStaticMarkup(<ConnectionErrorView connection={connection} onRetry={() => {}} isRetrying={false} variant="switch" />)
|
|
222
|
+
const connectionMarkup = renderToStaticMarkup(<ConnectionErrorView connection={connection} onRetry={() => {}} isRetrying={false} />)
|
|
223
|
+
expect(connectionMarkup).toContain('keep checking in the background')
|
|
224
|
+
expect(switchMarkup).not.toContain('keep checking in the background')
|
|
225
|
+
expect(switchMarkup).toContain('use Retry Connection')
|
|
226
|
+
})
|
|
227
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerOff, RefreshCw, Loader2, Copy, Check, TerminalSquare } from 'lucide-react'
|
|
1
|
+
import { ServerOff, RefreshCw, Loader2, Copy, Check, TerminalSquare, ArrowLeft } from 'lucide-react'
|
|
2
2
|
import { useEffect, useState } from 'react'
|
|
3
3
|
import type { ConnectionState } from '../context/ConnectionContext'
|
|
4
4
|
import { ContextSwitcher } from './ContextSwitcher'
|
|
@@ -11,11 +11,18 @@ import { Collapse, CollapseChevron } from '@skyhook-io/k8s-ui/components/ui/Coll
|
|
|
11
11
|
import { allShellSafe, awsProfileFlag } from '../utils/shell-safe'
|
|
12
12
|
import { apiUrl } from '../api/config'
|
|
13
13
|
import { useCapabilitiesContext } from '../contexts/CapabilitiesContext'
|
|
14
|
+
import { outageSinceLabel } from './outageSince'
|
|
14
15
|
|
|
15
16
|
interface ConnectionErrorViewProps {
|
|
16
17
|
connection: ConnectionState
|
|
17
18
|
onRetry: () => void
|
|
18
19
|
isRetrying: boolean
|
|
20
|
+
// A one-click way back to the cluster the person was using.
|
|
21
|
+
back?: { label: string; onBack: () => void; disabled?: boolean }
|
|
22
|
+
// 'switch': a switch Radar refused before leaving the current cluster.
|
|
23
|
+
// Nothing re-checks that cluster in the background, so the note saying so
|
|
24
|
+
// is left out.
|
|
25
|
+
variant?: 'connection' | 'switch'
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
interface CommandHint {
|
|
@@ -167,13 +174,15 @@ export function getAuthRejectedHints(context: string, awsProfile?: string): Auth
|
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
176
|
|
|
170
|
-
function getAuthPluginStuckHints(): AuthHints {
|
|
177
|
+
function getAuthPluginStuckHints(backgroundRecovery = true): AuthHints {
|
|
171
178
|
return {
|
|
172
179
|
title: 'Credential Plugin Stopped Responding',
|
|
173
180
|
hints: [
|
|
174
181
|
'The credential command configured by this kubeconfig did not return before the deadline.',
|
|
175
182
|
'Check that your cloud-provider CLI and its identity-provider or network dependencies are responsive.',
|
|
176
|
-
|
|
183
|
+
backgroundRecovery
|
|
184
|
+
? 'Radar will keep checking in the background and reconnect when the credential command recovers.'
|
|
185
|
+
: 'Once the credential command responds, use Retry Connection.',
|
|
177
186
|
],
|
|
178
187
|
}
|
|
179
188
|
}
|
|
@@ -334,7 +343,7 @@ export function CopyableCommand({ command, onRunInTerminal }: { command: string;
|
|
|
334
343
|
)
|
|
335
344
|
}
|
|
336
345
|
|
|
337
|
-
export function selectConnectionHints(errorType: string | undefined, context: string, originalContext?: string, awsProfile?: string): AuthHints | null {
|
|
346
|
+
export function selectConnectionHints(errorType: string | undefined, context: string, originalContext?: string, awsProfile?: string, backgroundRecovery = true): AuthHints | null {
|
|
338
347
|
const parsedContext = originalContext || context
|
|
339
348
|
switch (errorType) {
|
|
340
349
|
case 'auth':
|
|
@@ -342,7 +351,7 @@ export function selectConnectionHints(errorType: string | undefined, context: st
|
|
|
342
351
|
case 'auth-rejected':
|
|
343
352
|
return getAuthRejectedHints(parsedContext, awsProfile)
|
|
344
353
|
case 'auth-plugin-stuck':
|
|
345
|
-
return getAuthPluginStuckHints()
|
|
354
|
+
return getAuthPluginStuckHints(backgroundRecovery)
|
|
346
355
|
case 'timeout':
|
|
347
356
|
return getTimeoutHints(parsedContext, awsProfile)
|
|
348
357
|
default:
|
|
@@ -350,7 +359,7 @@ export function selectConnectionHints(errorType: string | undefined, context: st
|
|
|
350
359
|
}
|
|
351
360
|
}
|
|
352
361
|
|
|
353
|
-
export function ConnectionErrorView({ connection, onRetry, isRetrying }: ConnectionErrorViewProps) {
|
|
362
|
+
export function ConnectionErrorView({ connection, onRetry, isRetrying, back, variant = 'connection' }: ConnectionErrorViewProps) {
|
|
354
363
|
// For auth errors, generate context-aware hints with a specific re-auth command
|
|
355
364
|
const isAuth = connection.errorType === 'auth'
|
|
356
365
|
const isAuthRejected = connection.errorType === 'auth-rejected'
|
|
@@ -360,7 +369,8 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying }: Connect
|
|
|
360
369
|
const matchedContext = contexts?.find((context) => context.name === connection.context)
|
|
361
370
|
const originalContext = matchedContext?.originalName
|
|
362
371
|
const awsProfile = contextsLoading ? undefined : matchedContext?.awsProfile
|
|
363
|
-
const
|
|
372
|
+
const since = outageSinceLabel(connection.disconnectedAt)
|
|
373
|
+
const commandInfo = selectConnectionHints(connection.errorType, connection.context || '', originalContext, awsProfile, variant === 'connection')
|
|
364
374
|
const errorInfo = commandInfo || errorHints[connection.errorType || 'unknown'] || errorHints.unknown
|
|
365
375
|
const openLocalTerminal = useOpenLocalTerminal()
|
|
366
376
|
const { data: authMe } = useAuthMe()
|
|
@@ -378,7 +388,9 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying }: Connect
|
|
|
378
388
|
|
|
379
389
|
const handleAuthInTerminal = () => {
|
|
380
390
|
if (!commandInfo?.authCommand) return
|
|
381
|
-
|
|
391
|
+
// The follow-up retry reconnects the current context, so it only belongs on
|
|
392
|
+
// the screen for a lost connection, not on one for a refused switch.
|
|
393
|
+
const cmd = authMe?.authEnabled === false && variant === 'connection'
|
|
382
394
|
? `${commandInfo.authCommand.command} && ${retryCmd}`
|
|
383
395
|
: commandInfo.authCommand.command
|
|
384
396
|
openLocalTerminal({
|
|
@@ -410,6 +422,7 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying }: Connect
|
|
|
410
422
|
) : (
|
|
411
423
|
<span className="inline-code">(none)</span>
|
|
412
424
|
)}
|
|
425
|
+
{since && <span>· since {since}</span>}
|
|
413
426
|
</p>
|
|
414
427
|
|
|
415
428
|
{connection.clusterName && (
|
|
@@ -475,11 +488,11 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying }: Connect
|
|
|
475
488
|
)}
|
|
476
489
|
</div>
|
|
477
490
|
|
|
478
|
-
<div className="flex items-center gap-
|
|
491
|
+
<div className="flex flex-wrap items-center justify-center gap-3">
|
|
479
492
|
<button
|
|
480
493
|
onClick={onRetry}
|
|
481
494
|
disabled={isRetrying}
|
|
482
|
-
className="inline-flex items-center gap-2 px-4 py-2 btn-brand rounded-lg"
|
|
495
|
+
className="inline-flex items-center gap-2 px-4 py-2 btn-brand rounded-lg whitespace-nowrap"
|
|
483
496
|
>
|
|
484
497
|
{isRetrying ? (
|
|
485
498
|
<>
|
|
@@ -494,10 +507,21 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying }: Connect
|
|
|
494
507
|
)}
|
|
495
508
|
</button>
|
|
496
509
|
|
|
510
|
+
{back && (
|
|
511
|
+
<button
|
|
512
|
+
onClick={back.onBack}
|
|
513
|
+
disabled={back.disabled}
|
|
514
|
+
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg border border-theme-border bg-theme-surface text-theme-text-primary hover:bg-theme-hover disabled:opacity-50 whitespace-nowrap"
|
|
515
|
+
>
|
|
516
|
+
<ArrowLeft className="w-4 h-4" />
|
|
517
|
+
Back to {back.label}
|
|
518
|
+
</button>
|
|
519
|
+
)}
|
|
520
|
+
|
|
497
521
|
{connection.context && <ContextSwitcher triggerName="Switch context" />}
|
|
498
522
|
</div>
|
|
499
523
|
|
|
500
|
-
{isAuthError && (
|
|
524
|
+
{isAuthError && variant === 'connection' && (
|
|
501
525
|
<p className="mt-4 text-xs text-theme-text-tertiary">
|
|
502
526
|
{isAuthRejected
|
|
503
527
|
? 'Radar re-checks in the background — access changes are picked up automatically. Use Retry Connection to check immediately.'
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { useContexts, useClusterInfo, useCapabilities } from '../api/client'
|
|
7
7
|
import type { ContextInfo } from '../types'
|
|
8
8
|
import { useContextSwitchFlow } from './useContextSwitchFlow'
|
|
9
|
+
import { useContextSwitch } from '../context/ContextSwitchContext'
|
|
9
10
|
import { parseContextForSwitcher, visibleContextQualifier, type ParsedContextName } from '../utils/context-name'
|
|
10
11
|
|
|
11
12
|
interface ContextSwitcherProps {
|
|
@@ -29,6 +30,7 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
|
|
|
29
30
|
const { data: clusterInfo } = useClusterInfo()
|
|
30
31
|
const { data: capabilities } = useCapabilities()
|
|
31
32
|
const switchFlow = useContextSwitchFlow()
|
|
33
|
+
const { failedSwitch } = useContextSwitch()
|
|
32
34
|
|
|
33
35
|
// Parse contexts and decide whether to render group headers (multi-account only).
|
|
34
36
|
// hasMultipleSources gates the kubeconfig-source chip — only useful when 2+
|
|
@@ -134,10 +136,11 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
|
|
|
134
136
|
loading={switchFlow.isPending}
|
|
135
137
|
disabled={contextsLoading || !capabilities || capabilities.configManagement === 'operator'}
|
|
136
138
|
searchable={items.length > 1}
|
|
139
|
+
currentSelectable={!!failedSwitch}
|
|
137
140
|
showGroupHeaders={hasMultipleAccounts}
|
|
138
141
|
errorSlot={
|
|
139
|
-
switchFlow.
|
|
140
|
-
<span className="text-xs text-red-400">{switchFlow.
|
|
142
|
+
switchFlow.errorText ? (
|
|
143
|
+
<span className="text-xs text-red-400">{switchFlow.errorText}</span>
|
|
141
144
|
) : undefined
|
|
142
145
|
}
|
|
143
146
|
/>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import type { ContextInfo } from '../types'
|
|
4
|
+
|
|
5
|
+
const requestSwitch = vi.fn()
|
|
6
|
+
const contexts: ContextInfo[] = [
|
|
7
|
+
{ name: 'kind-radar-ph-video', cluster: 'kind-radar-ph-video', user: 'u', namespace: '', isCurrent: false } as ContextInfo,
|
|
8
|
+
{ name: 'gke_acme_europe-west1_staging-eu', cluster: 'staging-eu', user: 'u', namespace: '', isCurrent: true } as ContextInfo,
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
vi.mock('../api/client', () => ({ useContexts: () => ({ data: contexts }) }))
|
|
12
|
+
vi.mock('./useContextSwitchFlow', () => ({ useContextSwitchFlow: () => ({ requestSwitch, isPending: false, confirmDialog: null }) }))
|
|
13
|
+
vi.mock('../context/ContextSwitchContext', () => ({ useContextSwitch: () => ({ failedSwitch: null, setFailedSwitch: vi.fn() }) }))
|
|
14
|
+
vi.mock('./ConnectionErrorView', () => ({
|
|
15
|
+
ConnectionErrorView: ({ back }: { back?: { label: string } }) => <div>{back ? `back:${back.label}` : 'no back'}</div>,
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
const { DisconnectedView } = await import('./SwitchAwareConnectionError')
|
|
19
|
+
|
|
20
|
+
const down = { state: 'disconnected' as const, context: 'gke_acme_europe-west1_staging-eu', errorType: 'timeout' }
|
|
21
|
+
|
|
22
|
+
describe('DisconnectedView', () => {
|
|
23
|
+
it('offers the last connected cluster after a switch that left it', () => {
|
|
24
|
+
const markup = renderToStaticMarkup(
|
|
25
|
+
<DisconnectedView connection={down} onRetry={() => {}} isRetrying={false} lastConnectedContext="kind-radar-ph-video" />,
|
|
26
|
+
)
|
|
27
|
+
expect(markup).toContain('back:kind-radar-ph-video')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('offers nothing when the cluster that is down is the one that last worked', () => {
|
|
31
|
+
const markup = renderToStaticMarkup(
|
|
32
|
+
<DisconnectedView connection={down} onRetry={() => {}} isRetrying={false} lastConnectedContext="gke_acme_europe-west1_staging-eu" />,
|
|
33
|
+
)
|
|
34
|
+
expect(markup).toContain('no back')
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('offers nothing before anything has connected', () => {
|
|
38
|
+
const markup = renderToStaticMarkup(
|
|
39
|
+
<DisconnectedView connection={down} onRetry={() => {}} isRetrying={false} lastConnectedContext={null} />,
|
|
40
|
+
)
|
|
41
|
+
expect(markup).toContain('no back')
|
|
42
|
+
})
|
|
43
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { useContexts } from '../api/client'
|
|
3
|
+
import type { ConnectionState } from '../context/ConnectionContext'
|
|
4
|
+
import { useContextSwitch } from '../context/ContextSwitchContext'
|
|
5
|
+
import type { ContextInfo } from '../types'
|
|
6
|
+
import { parseContextForSwitcher } from '../utils/context-name'
|
|
7
|
+
import { ConnectionErrorView } from './ConnectionErrorView'
|
|
8
|
+
import { useContextSwitchFlow } from './useContextSwitchFlow'
|
|
9
|
+
|
|
10
|
+
function clusterLabel(contexts: ContextInfo[] | undefined, name: string): string {
|
|
11
|
+
const match = contexts?.find(context => context.name === name)
|
|
12
|
+
return match ? parseContextForSwitcher(match).clusterName : name
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// A switch Radar refused before leaving the current cluster: the connection
|
|
16
|
+
// error screen for the cluster that didn't answer, with its fix steps. The
|
|
17
|
+
// current cluster is still connected underneath, so Back only closes this.
|
|
18
|
+
export function FailedSwitchView({ currentContext }: { currentContext: string }) {
|
|
19
|
+
const { failedSwitch, setFailedSwitch } = useContextSwitch()
|
|
20
|
+
const { data: contexts } = useContexts()
|
|
21
|
+
const { requestSwitch, isPending, confirmDialog } = useContextSwitchFlow()
|
|
22
|
+
// Retry checks for open sessions before the switch itself is pending; Back
|
|
23
|
+
// stays disabled through that, so it can't close the screen and then switch.
|
|
24
|
+
const [starting, setStarting] = useState(false)
|
|
25
|
+
if (!failedSwitch) return null
|
|
26
|
+
const target = contexts?.find(context => context.name === failedSwitch.context)
|
|
27
|
+
const busy = starting || isPending
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<ConnectionErrorView
|
|
32
|
+
connection={{
|
|
33
|
+
state: 'disconnected',
|
|
34
|
+
context: failedSwitch.context,
|
|
35
|
+
error: failedSwitch.error,
|
|
36
|
+
errorType: failedSwitch.errorType,
|
|
37
|
+
}}
|
|
38
|
+
onRetry={() => {
|
|
39
|
+
if (!target || busy) return
|
|
40
|
+
setStarting(true)
|
|
41
|
+
void requestSwitch(target).finally(() => setStarting(false))
|
|
42
|
+
}}
|
|
43
|
+
isRetrying={busy}
|
|
44
|
+
back={{ label: clusterLabel(contexts, currentContext), onBack: () => setFailedSwitch(null), disabled: busy }}
|
|
45
|
+
variant="switch"
|
|
46
|
+
/>
|
|
47
|
+
{confirmDialog}
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Disconnected after leaving a cluster that worked (an older Radar server, or
|
|
53
|
+
// a new cluster that answered and then failed to load): Back switches to the
|
|
54
|
+
// last cluster that was connected.
|
|
55
|
+
export function DisconnectedView({
|
|
56
|
+
connection,
|
|
57
|
+
onRetry,
|
|
58
|
+
isRetrying,
|
|
59
|
+
lastConnectedContext,
|
|
60
|
+
}: {
|
|
61
|
+
connection: ConnectionState
|
|
62
|
+
onRetry: () => void
|
|
63
|
+
isRetrying: boolean
|
|
64
|
+
lastConnectedContext: string | null
|
|
65
|
+
}) {
|
|
66
|
+
const { data: contexts } = useContexts()
|
|
67
|
+
const { requestSwitch, isPending, confirmDialog } = useContextSwitchFlow()
|
|
68
|
+
const previous = lastConnectedContext && lastConnectedContext !== connection.context
|
|
69
|
+
? contexts?.find(context => context.name === lastConnectedContext)
|
|
70
|
+
: undefined
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<ConnectionErrorView
|
|
75
|
+
connection={connection}
|
|
76
|
+
onRetry={onRetry}
|
|
77
|
+
isRetrying={isRetrying}
|
|
78
|
+
back={previous
|
|
79
|
+
? { label: parseContextForSwitcher(previous).clusterName, onBack: () => void requestSwitch(previous), disabled: isPending }
|
|
80
|
+
: undefined}
|
|
81
|
+
/>
|
|
82
|
+
{confirmDialog}
|
|
83
|
+
</>
|
|
84
|
+
)
|
|
85
|
+
}
|