@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,8 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext, useState, useCallback, useEffect, useRef, ReactNode } from 'react'
|
|
2
2
|
import { useQuery, useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
|
|
3
|
-
import { getApiBase } from '../api/config'
|
|
3
|
+
import { automaticRequestHeaders, getApiBase } from '../api/config'
|
|
4
4
|
import { readErrorBody } from '../api/httpErrors'
|
|
5
5
|
import { apiFetch, type SyncStatusSnapshot, type NodeDrainActivity } from '../api/client'
|
|
6
|
+
import { ClusterConnectedContext } from './clusterConnected'
|
|
6
7
|
|
|
7
8
|
export type ConnectionStateType = 'connected' | 'disconnected' | 'connecting'
|
|
8
9
|
|
|
@@ -13,6 +14,9 @@ export interface ConnectionState {
|
|
|
13
14
|
error?: string
|
|
14
15
|
errorType?: string // config, auth, auth-rejected, auth-plugin-stuck, rbac, network, timeout, tls, unknown
|
|
15
16
|
progressMessage?: string
|
|
17
|
+
// When this context stopped working (RFC 3339). Set by the server while
|
|
18
|
+
// disconnected; older servers never send it.
|
|
19
|
+
disconnectedAt?: string
|
|
16
20
|
// Per-kind readiness while the initial informer sync runs ('connecting'
|
|
17
21
|
// with informers started). Drives the progressive app shell — absent once
|
|
18
22
|
// connected or before informers exist.
|
|
@@ -49,6 +53,15 @@ class ConnectionRetryError extends Error {
|
|
|
49
53
|
const ConnectionContext = createContext<ConnectionContextValue | null>(null)
|
|
50
54
|
const AUTO_RETRY_INITIAL_DELAY_MS = 10000
|
|
51
55
|
const AUTO_RETRY_MAX_DELAY_MS = 60000
|
|
56
|
+
// Failed attempts in an outage before an unattended window slows to
|
|
57
|
+
// AUTO_RETRY_UNATTENDED_DELAY_MS (10s + 20s + 40s + 60s + 60s ≈ 3 minutes).
|
|
58
|
+
const AUTO_RETRY_ATTEMPTS_BEFORE_SLOWDOWN = 5
|
|
59
|
+
const AUTO_RETRY_UNATTENDED_DELAY_MS = 5 * 60_000
|
|
60
|
+
const WAKE_RETRY_DEDUPE_MS = 2000
|
|
61
|
+
// Returning to the window retries at once, but no sooner than this after the
|
|
62
|
+
// previous attempt started: someone alt-tabbing while they fix a VPN would
|
|
63
|
+
// otherwise run a full reconnect on every return.
|
|
64
|
+
const WAKE_RETRY_MIN_GAP_MS = AUTO_RETRY_INITIAL_DELAY_MS
|
|
52
65
|
const CONNECTION_STATUS_FALLBACK_POLL_MS = 30000
|
|
53
66
|
|
|
54
67
|
export function refreshQueriesAfterReconnect(queryClient: QueryClient, previousContext: string, nextContext: string) {
|
|
@@ -97,9 +110,10 @@ async function fetchConnectionStatus(sseGenerationAtStart: number): Promise<Poll
|
|
|
97
110
|
return { ...status, sseGenerationAtStart }
|
|
98
111
|
}
|
|
99
112
|
|
|
100
|
-
async function retryConnection(): Promise<ConnectionState> {
|
|
113
|
+
async function retryConnection(automatic = false): Promise<ConnectionState> {
|
|
101
114
|
const response = await apiFetch(`${getApiBase()}/connection/retry`, {
|
|
102
115
|
method: 'POST',
|
|
116
|
+
headers: automatic ? automaticRequestHeaders() : undefined,
|
|
103
117
|
})
|
|
104
118
|
if (!response.ok) {
|
|
105
119
|
const error = await readErrorBody(response) as { error?: string; errorType?: string }
|
|
@@ -125,6 +139,12 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
125
139
|
const hasConnectedRef = useRef(false)
|
|
126
140
|
const autoRetryInFlightRef = useRef(false)
|
|
127
141
|
const autoRetryDelayRef = useRef(AUTO_RETRY_INITIAL_DELAY_MS)
|
|
142
|
+
// Attempts in the current outage; only a successful connect resets it, so a
|
|
143
|
+
// manual retry's brief 'connecting' doesn't restart the count.
|
|
144
|
+
const autoRetryAttemptsRef = useRef(0)
|
|
145
|
+
const autoRetryContextRef = useRef('')
|
|
146
|
+
const lastWakeRetryAtRef = useRef(0)
|
|
147
|
+
const lastAutoRetryAtRef = useRef(0)
|
|
128
148
|
const manualRetryPendingRef = useRef(false)
|
|
129
149
|
// Fed by the status poll only (SSE frames don't carry the field, and must
|
|
130
150
|
// not clear it): while the server's recovery loop owns the episode, browser
|
|
@@ -155,6 +175,9 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
155
175
|
// Cache refresh shared by every path that lands on 'connected'.
|
|
156
176
|
const lastCacheRefreshAtRef = useRef(0)
|
|
157
177
|
const refreshCachesOnConnect = useCallback(() => {
|
|
178
|
+
// RBAC queries don't refetch an errored answer on mount; a fresh
|
|
179
|
+
// connection is when that answer may have changed.
|
|
180
|
+
queryClient.removeQueries({ queryKey: ['rbac'], predicate: query => query.state.status === 'error' })
|
|
158
181
|
const firstConnect = !hasConnectedRef.current
|
|
159
182
|
hasConnectedRef.current = true
|
|
160
183
|
// Poll and SSE can both observe the same reconnect within moments of each
|
|
@@ -258,6 +281,7 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
258
281
|
error: data.error,
|
|
259
282
|
errorType: data.errorType,
|
|
260
283
|
progressMessage: data.progressMessage,
|
|
284
|
+
disconnectedAt: data.disconnectedAt,
|
|
261
285
|
syncStatus: data.syncStatus,
|
|
262
286
|
})
|
|
263
287
|
if (becameConnected) {
|
|
@@ -267,7 +291,7 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
267
291
|
|
|
268
292
|
// Retry mutation
|
|
269
293
|
const retryMutation = useMutation({
|
|
270
|
-
mutationFn: retryConnection,
|
|
294
|
+
mutationFn: () => retryConnection(),
|
|
271
295
|
onMutate: () => {
|
|
272
296
|
manualRetryPendingRef.current = true
|
|
273
297
|
// Until SSE re-delivers state, a failed retry may report its own error
|
|
@@ -322,6 +346,13 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
322
346
|
}, [retryMutation.isPending])
|
|
323
347
|
|
|
324
348
|
useEffect(() => {
|
|
349
|
+
// An outage belongs to one context: switching to another starts its own
|
|
350
|
+
// count and backoff, and so does connecting.
|
|
351
|
+
if (connection.state === 'connected' || autoRetryContextRef.current !== connection.context) {
|
|
352
|
+
autoRetryAttemptsRef.current = 0
|
|
353
|
+
autoRetryDelayRef.current = AUTO_RETRY_INITIAL_DELAY_MS
|
|
354
|
+
autoRetryContextRef.current = connection.context
|
|
355
|
+
}
|
|
325
356
|
if (connection.state !== 'disconnected' || !shouldAutoRetryConnection(connection.errorType)) {
|
|
326
357
|
autoRetryDelayRef.current = AUTO_RETRY_INITIAL_DELAY_MS
|
|
327
358
|
return
|
|
@@ -329,65 +360,102 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
329
360
|
let stopped = false
|
|
330
361
|
let retryTimeout: number | undefined
|
|
331
362
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (serverOwnsRecoveryRef.current) {
|
|
342
|
-
scheduleRetry()
|
|
343
|
-
return
|
|
344
|
-
}
|
|
363
|
+
// Nobody is looking at a hidden or unfocused window (a desktop window
|
|
364
|
+
// behind others still reports visible), so after a few failures it
|
|
365
|
+
// checks only every few minutes. Coming back retries at once.
|
|
366
|
+
const nextDelay = () => {
|
|
367
|
+
const unattended = document.visibilityState === 'hidden' || !document.hasFocus()
|
|
368
|
+
return unattended && autoRetryAttemptsRef.current >= AUTO_RETRY_ATTEMPTS_BEFORE_SLOWDOWN
|
|
369
|
+
? AUTO_RETRY_UNATTENDED_DELAY_MS
|
|
370
|
+
: autoRetryDelayRef.current
|
|
371
|
+
}
|
|
345
372
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
373
|
+
const attempt = () => {
|
|
374
|
+
if (stopped) return
|
|
375
|
+
if (manualRetryPendingRef.current || autoRetryInFlightRef.current) {
|
|
376
|
+
scheduleRetry()
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
// Checked at fire time (not arm time): the poll may have learned
|
|
380
|
+
// mid-wait that the server's recovery loop owns this episode.
|
|
381
|
+
if (serverOwnsRecoveryRef.current) {
|
|
382
|
+
scheduleRetry()
|
|
383
|
+
return
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
autoRetryInFlightRef.current = true
|
|
387
|
+
autoRetryAttemptsRef.current += 1
|
|
388
|
+
lastAutoRetryAtRef.current = Date.now()
|
|
389
|
+
setIsAutoRetrying(true)
|
|
390
|
+
let recovered = false
|
|
391
|
+
retryConnection(true)
|
|
392
|
+
.then((result) => {
|
|
393
|
+
if (stopped) return
|
|
394
|
+
recovered = true
|
|
395
|
+
autoRetryDelayRef.current = AUTO_RETRY_INITIAL_DELAY_MS
|
|
396
|
+
sseActiveRef.current = false
|
|
397
|
+
const previousContext = connectionRef.current.context
|
|
398
|
+
setConnection(result)
|
|
399
|
+
if (result.state === 'connected') {
|
|
400
|
+
hasConnectedRef.current = true
|
|
401
|
+
lastCacheRefreshAtRef.current = Date.now()
|
|
402
|
+
}
|
|
403
|
+
refreshQueriesAfterReconnect(queryClient, previousContext, result.context)
|
|
404
|
+
})
|
|
405
|
+
.catch((error: Error) => {
|
|
406
|
+
if (stopped) return
|
|
407
|
+
const retryError = error as ConnectionRetryError
|
|
408
|
+
setConnection(prev => {
|
|
409
|
+
if (sseActiveRef.current && prev.state === 'connected') return prev
|
|
410
|
+
return {
|
|
411
|
+
...prev,
|
|
412
|
+
state: 'disconnected',
|
|
413
|
+
error: error.message || prev.error,
|
|
414
|
+
errorType: retryError.errorType || prev.errorType,
|
|
415
|
+
progressMessage: undefined,
|
|
387
416
|
}
|
|
388
417
|
})
|
|
389
|
-
|
|
418
|
+
autoRetryDelayRef.current = Math.min(autoRetryDelayRef.current * 2, AUTO_RETRY_MAX_DELAY_MS)
|
|
419
|
+
// Keep the visible disconnected state until a retry succeeds.
|
|
420
|
+
})
|
|
421
|
+
.finally(() => {
|
|
422
|
+
autoRetryInFlightRef.current = false
|
|
423
|
+
setIsAutoRetrying(false)
|
|
424
|
+
// Mirror the manual-retry onSettled: re-poll so a status update
|
|
425
|
+
// dropped by the mid-retry guard isn't stranded until next tick.
|
|
426
|
+
queryClient.invalidateQueries({ queryKey: ['connection-status'] })
|
|
427
|
+
if (!stopped && !recovered) {
|
|
428
|
+
scheduleRetry()
|
|
429
|
+
}
|
|
430
|
+
})
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const scheduleRetry = () => {
|
|
434
|
+
retryTimeout = window.setTimeout(attempt, nextDelay())
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// Returning to the window or regaining the network retries now, silently.
|
|
438
|
+
// focus and visibilitychange often fire together, so one wake per moment.
|
|
439
|
+
// The network coming back counts even in a background window.
|
|
440
|
+
const wake = (event: Event) => {
|
|
441
|
+
if (stopped) return
|
|
442
|
+
if (event.type !== 'online' && document.visibilityState === 'hidden') return
|
|
443
|
+
const now = Date.now()
|
|
444
|
+
if (now - lastWakeRetryAtRef.current < WAKE_RETRY_DEDUPE_MS) return
|
|
445
|
+
// The network coming back is worth an attempt right away; a focus or
|
|
446
|
+
// visibility change only once the previous attempt is old enough.
|
|
447
|
+
if (event.type !== 'online' && now - lastAutoRetryAtRef.current < WAKE_RETRY_MIN_GAP_MS) return
|
|
448
|
+
lastWakeRetryAtRef.current = now
|
|
449
|
+
if (manualRetryPendingRef.current || autoRetryInFlightRef.current || serverOwnsRecoveryRef.current) return
|
|
450
|
+
if (retryTimeout !== undefined) {
|
|
451
|
+
window.clearTimeout(retryTimeout)
|
|
452
|
+
}
|
|
453
|
+
autoRetryDelayRef.current = AUTO_RETRY_INITIAL_DELAY_MS
|
|
454
|
+
attempt()
|
|
390
455
|
}
|
|
456
|
+
window.addEventListener('focus', wake)
|
|
457
|
+
window.addEventListener('online', wake)
|
|
458
|
+
document.addEventListener('visibilitychange', wake)
|
|
391
459
|
|
|
392
460
|
scheduleRetry()
|
|
393
461
|
|
|
@@ -396,8 +464,11 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
396
464
|
if (retryTimeout !== undefined) {
|
|
397
465
|
window.clearTimeout(retryTimeout)
|
|
398
466
|
}
|
|
467
|
+
window.removeEventListener('focus', wake)
|
|
468
|
+
window.removeEventListener('online', wake)
|
|
469
|
+
document.removeEventListener('visibilitychange', wake)
|
|
399
470
|
}
|
|
400
|
-
}, [connection.errorType, connection.state, queryClient])
|
|
471
|
+
}, [connection.context, connection.errorType, connection.state, queryClient])
|
|
401
472
|
|
|
402
473
|
const retry = useCallback(() => {
|
|
403
474
|
if (retryMutation.isPending || autoRetryInFlightRef.current) return
|
|
@@ -444,7 +515,9 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
444
515
|
|
|
445
516
|
return (
|
|
446
517
|
<ConnectionContext.Provider value={value}>
|
|
447
|
-
{
|
|
518
|
+
<ClusterConnectedContext.Provider value={connection.state === 'connected'}>
|
|
519
|
+
{children}
|
|
520
|
+
</ClusterConnectedContext.Provider>
|
|
448
521
|
</ConnectionContext.Provider>
|
|
449
522
|
)
|
|
450
523
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { ConnectionProvider, useConnection } from './ConnectionContext'
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
|
+
|
|
10
|
+
let root: Root
|
|
11
|
+
let container: HTMLDivElement
|
|
12
|
+
let retries: number
|
|
13
|
+
const seen = vi.fn<(value: ReturnType<typeof useConnection>) => void>()
|
|
14
|
+
const latest = () => seen.mock.lastCall?.[0]
|
|
15
|
+
let focused: boolean
|
|
16
|
+
let pollContext: string
|
|
17
|
+
|
|
18
|
+
function Probe() {
|
|
19
|
+
seen(useConnection())
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function jsonResponse(status: number, body: unknown) {
|
|
24
|
+
return new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function advance(ms: number) {
|
|
28
|
+
await act(async () => {
|
|
29
|
+
await vi.advanceTimersByTimeAsync(ms)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
vi.useFakeTimers()
|
|
35
|
+
retries = 0
|
|
36
|
+
seen.mockClear()
|
|
37
|
+
focused = false
|
|
38
|
+
pollContext = 'prod'
|
|
39
|
+
vi.spyOn(document, 'hasFocus').mockImplementation(() => focused)
|
|
40
|
+
vi.stubGlobal('fetch', vi.fn(async (input: string) => {
|
|
41
|
+
const url = new URL(String(input), 'http://localhost')
|
|
42
|
+
if (url.pathname === '/api/connection/retry') {
|
|
43
|
+
retries += 1
|
|
44
|
+
return jsonResponse(503, { error: 'cluster unreachable', errorType: 'network' })
|
|
45
|
+
}
|
|
46
|
+
if (url.pathname === '/api/connection') {
|
|
47
|
+
return jsonResponse(200, {
|
|
48
|
+
state: 'disconnected',
|
|
49
|
+
context: pollContext,
|
|
50
|
+
error: 'cluster unreachable',
|
|
51
|
+
errorType: 'network',
|
|
52
|
+
disconnectedAt: '2026-10-30T14:02:00Z',
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
return jsonResponse(404, { error: 'not found' })
|
|
56
|
+
}))
|
|
57
|
+
|
|
58
|
+
container = document.createElement('div')
|
|
59
|
+
document.body.appendChild(container)
|
|
60
|
+
root = createRoot(container)
|
|
61
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
62
|
+
await act(async () => {
|
|
63
|
+
root.render(
|
|
64
|
+
<QueryClientProvider client={client}>
|
|
65
|
+
<ConnectionProvider>
|
|
66
|
+
<Probe />
|
|
67
|
+
</ConnectionProvider>
|
|
68
|
+
</QueryClientProvider>,
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
// Let the first status poll land.
|
|
72
|
+
await advance(100)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
act(() => root.unmount())
|
|
77
|
+
container.remove()
|
|
78
|
+
vi.restoreAllMocks()
|
|
79
|
+
vi.unstubAllGlobals()
|
|
80
|
+
vi.useRealTimers()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// Attempts land at 10s, 30s, 70s, 130s and 190s (10s doubling to a 60s cap).
|
|
84
|
+
const FIVE_ATTEMPTS_MS = 190_000
|
|
85
|
+
|
|
86
|
+
describe('ConnectionProvider auto-retry', () => {
|
|
87
|
+
it('carries the outage start from the server', () => {
|
|
88
|
+
expect(latest()?.connection.state).toBe('disconnected')
|
|
89
|
+
expect(latest()?.connection.disconnectedAt).toBe('2026-10-30T14:02:00Z')
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('keeps retrying every minute while someone is looking', async () => {
|
|
93
|
+
focused = true
|
|
94
|
+
await advance(FIVE_ATTEMPTS_MS)
|
|
95
|
+
expect(retries).toBe(5)
|
|
96
|
+
await advance(60_000)
|
|
97
|
+
expect(retries).toBe(6)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('slows to every five minutes when nobody is looking, then retries at once on return', async () => {
|
|
101
|
+
await advance(FIVE_ATTEMPTS_MS)
|
|
102
|
+
expect(retries).toBe(5)
|
|
103
|
+
|
|
104
|
+
await advance(60_000)
|
|
105
|
+
expect(retries).toBe(5)
|
|
106
|
+
await advance(240_000)
|
|
107
|
+
expect(retries).toBe(6)
|
|
108
|
+
await advance(30_000)
|
|
109
|
+
|
|
110
|
+
focused = true
|
|
111
|
+
await act(async () => {
|
|
112
|
+
window.dispatchEvent(new Event('focus'))
|
|
113
|
+
document.dispatchEvent(new Event('visibilitychange'))
|
|
114
|
+
})
|
|
115
|
+
await advance(10)
|
|
116
|
+
// focus and visibilitychange together are one return, so one retry.
|
|
117
|
+
expect(retries).toBe(7)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('alt-tabbing back and forth retries no more than every ten seconds', async () => {
|
|
121
|
+
focused = true
|
|
122
|
+
await advance(15_000)
|
|
123
|
+
expect(retries).toBe(1) // the scheduled attempt at 10s
|
|
124
|
+
// Back to the window every 3s for 30s, as when switching to a terminal
|
|
125
|
+
// to fix the VPN and back.
|
|
126
|
+
for (let i = 0; i < 10; i++) {
|
|
127
|
+
await act(async () => {
|
|
128
|
+
window.dispatchEvent(new Event('blur'))
|
|
129
|
+
window.dispatchEvent(new Event('focus'))
|
|
130
|
+
document.dispatchEvent(new Event('visibilitychange'))
|
|
131
|
+
})
|
|
132
|
+
await advance(3_000)
|
|
133
|
+
}
|
|
134
|
+
// 30s of returns: at most one attempt per ten seconds, scheduled ones included.
|
|
135
|
+
expect(retries).toBeLessThanOrEqual(4)
|
|
136
|
+
expect(retries).toBeGreaterThanOrEqual(3)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('retries at once when the network comes back', async () => {
|
|
140
|
+
focused = true
|
|
141
|
+
await advance(15_000)
|
|
142
|
+
const before = retries
|
|
143
|
+
await act(async () => {
|
|
144
|
+
window.dispatchEvent(new Event('online'))
|
|
145
|
+
})
|
|
146
|
+
await advance(10)
|
|
147
|
+
expect(retries).toBe(before + 1)
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
describe('ConnectionProvider auto-retry across contexts and background windows', () => {
|
|
152
|
+
it('retries at once when the network comes back, even in a hidden window', async () => {
|
|
153
|
+
await advance(FIVE_ATTEMPTS_MS)
|
|
154
|
+
const before = retries
|
|
155
|
+
const visibility = vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('hidden')
|
|
156
|
+
await act(async () => {
|
|
157
|
+
window.dispatchEvent(new Event('online'))
|
|
158
|
+
})
|
|
159
|
+
await advance(10)
|
|
160
|
+
expect(retries).toBe(before + 1)
|
|
161
|
+
visibility.mockRestore()
|
|
162
|
+
})
|
|
163
|
+
it('starts a fresh count and backoff for another context', async () => {
|
|
164
|
+
await advance(FIVE_ATTEMPTS_MS)
|
|
165
|
+
expect(retries).toBe(5)
|
|
166
|
+
// The next status poll reports a different context that is also down.
|
|
167
|
+
pollContext = 'staging'
|
|
168
|
+
await advance(30_000)
|
|
169
|
+
await advance(100)
|
|
170
|
+
expect(latest()?.connection.context).toBe('staging')
|
|
171
|
+
const before = retries
|
|
172
|
+
// A fresh outage retries after the initial 10s, not the unattended 5 minutes.
|
|
173
|
+
await advance(10_500)
|
|
174
|
+
expect(retries).toBe(before + 1)
|
|
175
|
+
})
|
|
176
|
+
})
|
|
@@ -9,8 +9,19 @@ export interface ParsedContextInfo {
|
|
|
9
9
|
clusterName: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// A switch Radar refused before leaving the current cluster, because the new
|
|
13
|
+
// one didn't answer. The app shows the connection error screen for it while
|
|
14
|
+
// staying connected to the current cluster underneath.
|
|
15
|
+
export interface FailedSwitch {
|
|
16
|
+
context: string
|
|
17
|
+
error: string
|
|
18
|
+
errorType: string
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
interface ContextSwitchState {
|
|
13
22
|
isSwitching: boolean
|
|
23
|
+
failedSwitch: FailedSwitch | null
|
|
24
|
+
setFailedSwitch: (failed: FailedSwitch | null) => void
|
|
14
25
|
targetContext: ParsedContextInfo | null
|
|
15
26
|
progressMessage: string | null
|
|
16
27
|
startSwitch: (context: ParsedContextInfo) => void
|
|
@@ -29,8 +40,10 @@ export function ContextSwitchProvider({ children }: { children: ReactNode }) {
|
|
|
29
40
|
const [isSwitching, setIsSwitching] = useState(false)
|
|
30
41
|
const [targetContext, setTargetContext] = useState<ParsedContextInfo | null>(null)
|
|
31
42
|
const [progressMessage, setProgressMessage] = useState<string | null>(null)
|
|
43
|
+
const [failedSwitch, setFailedSwitch] = useState<FailedSwitch | null>(null)
|
|
32
44
|
|
|
33
45
|
const startSwitch = useCallback((context: ParsedContextInfo) => {
|
|
46
|
+
setFailedSwitch(null)
|
|
34
47
|
setIsSwitching(true)
|
|
35
48
|
setTargetContext(context)
|
|
36
49
|
setProgressMessage(null)
|
|
@@ -57,7 +70,7 @@ export function ContextSwitchProvider({ children }: { children: ReactNode }) {
|
|
|
57
70
|
}, [])
|
|
58
71
|
|
|
59
72
|
return (
|
|
60
|
-
<ContextSwitchContext.Provider value={{ isSwitching, targetContext, progressMessage, startSwitch, updateProgress, endSwitch, setOpenAfterSwitch, takeOpenAfterSwitch }}>
|
|
73
|
+
<ContextSwitchContext.Provider value={{ isSwitching, failedSwitch, setFailedSwitch, targetContext, progressMessage, startSwitch, updateProgress, endSwitch, setOpenAfterSwitch, takeOpenAfterSwitch }}>
|
|
61
74
|
{children}
|
|
62
75
|
</ContextSwitchContext.Provider>
|
|
63
76
|
)
|
|
@@ -39,6 +39,9 @@ export type RenderDiagnoseAction = (ctx: {
|
|
|
39
39
|
/** Coarse health of the resource (from its status badge), so the entry point can
|
|
40
40
|
* adapt: an urgent "Investigate" on a problem vs. a quiet "ask AI" when fine/unknown. */
|
|
41
41
|
health?: "problem" | "healthy" | "unknown";
|
|
42
|
+
/** The object's metadata.creationTimestamp, when loaded. An investigation
|
|
43
|
+
* that started before it was of an earlier object with the same name. */
|
|
44
|
+
createdAt?: string;
|
|
42
45
|
}) => ReactNode;
|
|
43
46
|
|
|
44
47
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
// Whether the cluster is connected right now, for data hooks that poll it.
|
|
4
|
+
// Kept apart from ConnectionContext so api hooks can read it without a
|
|
5
|
+
// circular import. Defaults to true outside the provider (tests, hosts).
|
|
6
|
+
export const ClusterConnectedContext = createContext(true)
|
|
7
|
+
|
|
8
|
+
export function useClusterConnected(): boolean {
|
|
9
|
+
return useContext(ClusterConnectedContext)
|
|
10
|
+
}
|
|
@@ -44,6 +44,8 @@ const restrictedCapabilities: Capabilities = {
|
|
|
44
44
|
},
|
|
45
45
|
mcpEnabled: false,
|
|
46
46
|
mcpExecTools: false,
|
|
47
|
+
mcpHttpTools: false,
|
|
48
|
+
mcpHelmTools: false,
|
|
47
49
|
deployment: { mode: 'local' },
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -159,6 +161,9 @@ export function useNamespacedCapabilities(namespace: string | undefined) {
|
|
|
159
161
|
console.warn('Failed to fetch namespace capabilities, using global:', namespace, error)
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
// A failed refetch keeps the last successful namespace answer; with none,
|
|
165
|
+
// the global value is not an answer for this namespace.
|
|
166
|
+
const namespaceUnknown = Boolean(namespace && !nsCaps && (isPending || error))
|
|
162
167
|
return useMemo(() => ({
|
|
163
168
|
canExec: nsCaps?.exec ?? globalCaps.exec,
|
|
164
169
|
canViewLogs: nsCaps?.logs ?? globalCaps.logs,
|
|
@@ -166,8 +171,7 @@ export function useNamespacedCapabilities(namespace: string | undefined) {
|
|
|
166
171
|
canHelmWrite: nsCaps?.helmWrite ?? globalCaps.helmWrite,
|
|
167
172
|
workloadWrites: nsCaps?.workloadWrites ?? globalCaps.workloadWrites,
|
|
168
173
|
workloadWritesPending: Boolean(namespace && isPending),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}), [globalCaps.exec, globalCaps.logs, globalCaps.portForward, globalCaps.helmWrite, globalCaps.workloadWrites, error, isPending, namespace, nsCaps])
|
|
174
|
+
helmWriteUnknown: namespaceUnknown,
|
|
175
|
+
logsUnknown: namespaceUnknown,
|
|
176
|
+
}), [globalCaps.exec, globalCaps.logs, globalCaps.portForward, globalCaps.helmWrite, globalCaps.workloadWrites, isPending, namespace, nsCaps, namespaceUnknown])
|
|
173
177
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface ElementSize {
|
|
4
|
+
width: number
|
|
5
|
+
height: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Tracks an element's rendered size. Until the first measurement (and where
|
|
9
|
+
// ResizeObserver is missing, as in jsdom) it reports `initial`.
|
|
10
|
+
export function useElementSize<T extends Element>(initial: ElementSize) {
|
|
11
|
+
const ref = useRef<T>(null)
|
|
12
|
+
const [size, setSize] = useState(initial)
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const el = ref.current
|
|
16
|
+
if (!el || typeof ResizeObserver === 'undefined') return
|
|
17
|
+
const update = () => {
|
|
18
|
+
const { width, height } = el.getBoundingClientRect()
|
|
19
|
+
if (width > 0 && height > 0) {
|
|
20
|
+
setSize(prev => (prev.width === width && prev.height === height ? prev : { width, height }))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
update()
|
|
24
|
+
const observer = new ResizeObserver(update)
|
|
25
|
+
observer.observe(el)
|
|
26
|
+
return () => observer.disconnect()
|
|
27
|
+
}, [])
|
|
28
|
+
|
|
29
|
+
return [ref, size] as const
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { describeGitOpsOwnerSource } from './useResolvedGitOpsOwner'
|
|
3
|
+
|
|
4
|
+
const owner = { tool: 'fluxcd', kind: 'kustomizations', namespace: 'flux-system', name: 'apps' } as const
|
|
5
|
+
const nameKey = 'kustomize.toolkit.fluxcd.io/name'
|
|
6
|
+
const nsKey = 'kustomize.toolkit.fluxcd.io/namespace'
|
|
7
|
+
|
|
8
|
+
describe('GitOps owner evidence', () => {
|
|
9
|
+
it('shows only the paired labels that identify the resolved manager', () => {
|
|
10
|
+
expect(describeGitOpsOwnerSource(owner, { metadata: { labels: { [nameKey]: 'apps', [nsKey]: 'flux-system' } } })).toBe(`${nameKey}=apps, ${nsKey}=flux-system`)
|
|
11
|
+
})
|
|
12
|
+
it.each([
|
|
13
|
+
{ [nameKey]: 'flux-system', [nsKey]: 'flux-system' },
|
|
14
|
+
{ [nameKey]: 'apps', [nsKey]: 'other' },
|
|
15
|
+
{ [nameKey]: 'apps' },
|
|
16
|
+
])('does not cite stale or incomplete origin labels: %j', labels => {
|
|
17
|
+
expect(describeGitOpsOwnerSource(owner, { metadata: { labels } })).toBeNull()
|
|
18
|
+
})
|
|
19
|
+
it('does not cite an Argo annotation for a Flux manager', () => {
|
|
20
|
+
expect(describeGitOpsOwnerSource(owner, { metadata: { annotations: { 'argocd.argoproj.io/tracking-id': 'old:apps/Deployment:prod/web' } } })).toBeNull()
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -214,7 +214,7 @@ function isNativeHelmManager(ref: ResourceRef): boolean {
|
|
|
214
214
|
return ref.kind === 'HelmRelease' && ref.group !== 'helm.toolkit.fluxcd.io'
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any): string | null {
|
|
217
|
+
export function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any): string | null {
|
|
218
218
|
if (!owner || !resource) return null
|
|
219
219
|
const labels = resource.metadata?.labels ?? {}
|
|
220
220
|
const annotations = resource.metadata?.annotations ?? {}
|
|
@@ -223,9 +223,12 @@ function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any):
|
|
|
223
223
|
const nameKey = owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/name' : 'kustomize.toolkit.fluxcd.io/name'
|
|
224
224
|
const nsKey =
|
|
225
225
|
owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/namespace' : 'kustomize.toolkit.fluxcd.io/namespace'
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
// Cite the origin labels only when they name the manager shown: labels a
|
|
227
|
+
// controller copied from an ancestor's metadata name a different one.
|
|
228
|
+
if (labels[nameKey] === owner.name && labels[nsKey] === owner.namespace) {
|
|
229
|
+
return `${nameKey}=${labels[nameKey]}, ${nsKey}=${labels[nsKey]}`
|
|
228
230
|
}
|
|
231
|
+
return null
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
const trackingID = annotations['argocd.argoproj.io/tracking-id']
|
|
@@ -48,6 +48,7 @@ describe('resource host composition', () => {
|
|
|
48
48
|
|
|
49
49
|
it('catches summary and tab conflicts even if a contribution omitted its declaration', () => {
|
|
50
50
|
expect(() => composeDetailSlots(['one', 'two'].map(id => ({ id, slots: { renderSummary: () => null } })))).toThrow('summary ownership conflict')
|
|
51
|
+
expect(() => composeDetailSlots(['one', 'two'].map(id => ({ id, slots: { renderStatusBadge: () => null } })))).toThrow('status badge ownership conflict')
|
|
51
52
|
const tab = { id: 'runs', label: 'Runs', render: () => null }
|
|
52
53
|
expect(composeDetailSlots([], [tab, tab]).extraTabs).toEqual([tab, tab])
|
|
53
54
|
expect(() => composeDetailSlots([{ id: 'execution', slots: { extraTabs: [tab] } }], [tab])).toThrow('tab ownership conflict: runs')
|