@skyhook-io/radar-app 1.22.1 → 1.23.0
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 +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
1
|
+
import { useState, useEffect, useCallback, useMemo, useRef } from 'react'
|
|
2
2
|
import type { Topology, K8sEvent, ViewMode } from '../types'
|
|
3
3
|
import type { ConnectionState } from '../context/ConnectionContext'
|
|
4
4
|
import { getApiBase, getCredentialsMode } from '../api/config'
|
|
5
5
|
|
|
6
|
+
/** What a screen needs from a topology cycle without drawing the graph. */
|
|
7
|
+
export type TopologyStatus = Pick<Topology, 'requiresNamespaceFilter' | 'crdDiscoveryStatus'>
|
|
8
|
+
|
|
6
9
|
interface UseEventSourceReturn {
|
|
10
|
+
/** Set only while the stream asks for topology frames. */
|
|
7
11
|
topology: Topology | null
|
|
12
|
+
/** From topology_status frames, or from topology frames (an older Radar sends those to every tab). */
|
|
13
|
+
topologyStatus: TopologyStatus | null
|
|
8
14
|
events: K8sEvent[]
|
|
9
15
|
connected: boolean
|
|
10
16
|
connecting: boolean
|
|
@@ -16,7 +22,8 @@ interface UseEventSourceOptions {
|
|
|
16
22
|
onContextSwitchComplete?: () => void
|
|
17
23
|
onContextSwitchProgress?: (message: string) => void
|
|
18
24
|
onContextChanged?: (context: string) => void
|
|
19
|
-
|
|
25
|
+
/** handover: the stream was replaced for new parameters, so nothing was missed. */
|
|
26
|
+
onConnectionStateChange?: (status: ConnectionState, opts?: { handover: boolean }) => void
|
|
20
27
|
onDeferredReady?: () => void
|
|
21
28
|
onK8sEvent?: (event: K8sEvent) => void
|
|
22
29
|
}
|
|
@@ -32,6 +39,22 @@ function getTopologyThrottleMs(nodeCount: number): number {
|
|
|
32
39
|
}
|
|
33
40
|
const INITIAL_RECONNECT_DELAY_MS = 3000
|
|
34
41
|
const MAX_RECONNECT_DELAY_MS = 30000 // Cap at 30 seconds
|
|
42
|
+
// After a handover the previous stream keeps delivering change events until
|
|
43
|
+
// the new one is reading its own (its first status or graph frame, written
|
|
44
|
+
// after any initial build) and at least this long, since a change it queued
|
|
45
|
+
// before the new stream subscribed can still be in flight behind a large frame.
|
|
46
|
+
// Changes sent to both arrive twice meanwhile; applying one is idempotent.
|
|
47
|
+
const HANDOVER_DRAIN_MS = 3000
|
|
48
|
+
// A drain still waiting this long ends as a reconnect: refetch everything.
|
|
49
|
+
const HANDOVER_DRAIN_LIMIT_MS = 30000
|
|
50
|
+
|
|
51
|
+
interface Drain {
|
|
52
|
+
source: EventSource
|
|
53
|
+
successor: EventSource
|
|
54
|
+
elapsed: boolean
|
|
55
|
+
successorReading: boolean
|
|
56
|
+
timers: number[]
|
|
57
|
+
}
|
|
35
58
|
|
|
36
59
|
export function useEventSource(
|
|
37
60
|
namespaces: string[],
|
|
@@ -41,12 +64,23 @@ export function useEventSource(
|
|
|
41
64
|
forceNamespaceFilter?: string[],
|
|
42
65
|
/** When true, evaluates NetworkPolicies and annotates edges with allow/block/unprotected */
|
|
43
66
|
showPolicyEffect?: boolean,
|
|
67
|
+
/** When true, the stream carries topology frames; only the Topology screen draws them. */
|
|
68
|
+
wantsTopology = false,
|
|
44
69
|
): UseEventSourceReturn {
|
|
45
70
|
const [topology, setTopology] = useState<Topology | null>(null)
|
|
71
|
+
const [topologyStatus, setTopologyStatus] = useState<TopologyStatus | null>(null)
|
|
46
72
|
const [events, setEvents] = useState<K8sEvent[]>([])
|
|
47
73
|
const [connected, setConnected] = useState(false)
|
|
48
74
|
const [connecting, setConnecting] = useState(true)
|
|
49
75
|
const eventSourceRef = useRef<EventSource | null>(null)
|
|
76
|
+
// A stream opened for new parameters, delivering nothing until its first
|
|
77
|
+
// frame replaces eventSourceRef's stream (see handover).
|
|
78
|
+
const pendingSourceRef = useRef<EventSource | null>(null)
|
|
79
|
+
// The stream whose opening connection_state has been delivered, so the
|
|
80
|
+
// receiver has reconciled anything missed before it. Only that one can be
|
|
81
|
+
// handed over from without missing anything.
|
|
82
|
+
const liveSourceRef = useRef<EventSource | null>(null)
|
|
83
|
+
const drainRef = useRef<Drain | null>(null)
|
|
50
84
|
const reconnectTimeoutRef = useRef<number | null>(null)
|
|
51
85
|
const waitingForTopologyAfterSwitch = useRef(false)
|
|
52
86
|
const reconnectDelayRef = useRef(INITIAL_RECONNECT_DELAY_MS) // Exponential backoff
|
|
@@ -64,6 +98,26 @@ export function useEventSource(
|
|
|
64
98
|
// Small/medium clusters get all-namespace data and filter on the frontend.
|
|
65
99
|
const sseNamespaceFilter = forceNamespaceFilter?.join(',') || ''
|
|
66
100
|
|
|
101
|
+
const streamParams = useMemo(() => {
|
|
102
|
+
const params = new URLSearchParams()
|
|
103
|
+
if (sseNamespaceFilter) {
|
|
104
|
+
params.set('namespaces', sseNamespaceFilter)
|
|
105
|
+
}
|
|
106
|
+
// view and policyEffect only shape topology frames.
|
|
107
|
+
if (wantsTopology) {
|
|
108
|
+
params.set('topology', '1')
|
|
109
|
+
if (viewMode && viewMode !== 'resources') {
|
|
110
|
+
params.set('view', viewMode)
|
|
111
|
+
}
|
|
112
|
+
if (showPolicyEffect) {
|
|
113
|
+
params.set('policyEffect', 'true')
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return params.toString()
|
|
117
|
+
}, [sseNamespaceFilter, viewMode, showPolicyEffect, wantsTopology])
|
|
118
|
+
const streamParamsRef = useRef(streamParams)
|
|
119
|
+
streamParamsRef.current = streamParams
|
|
120
|
+
|
|
67
121
|
// Use ref to avoid stale closures while not triggering reconnection on callback changes
|
|
68
122
|
const optionsRef = useRef(options)
|
|
69
123
|
optionsRef.current = options
|
|
@@ -79,49 +133,159 @@ export function useEventSource(
|
|
|
79
133
|
pendingTopologyRef.current = null
|
|
80
134
|
waitingForTopologyAfterSwitch.current = true
|
|
81
135
|
setTopology(null)
|
|
136
|
+
setTopologyStatus(null)
|
|
82
137
|
setEvents([])
|
|
83
138
|
optionsRef.current?.onContextChanged?.(context)
|
|
84
139
|
return true
|
|
85
140
|
}, [])
|
|
86
141
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
142
|
+
const applyStatus = useCallback((next: TopologyStatus) => {
|
|
143
|
+
const status: TopologyStatus = { requiresNamespaceFilter: Boolean(next.requiresNamespaceFilter), crdDiscoveryStatus: next.crdDiscoveryStatus }
|
|
144
|
+
setTopologyStatus(prev => (prev && prev.requiresNamespaceFilter === status.requiresNamespaceFilter && prev.crdDiscoveryStatus === status.crdDiscoveryStatus ? prev : status))
|
|
145
|
+
}, [])
|
|
146
|
+
|
|
147
|
+
// The first topology cycle after context_changed means the new cluster is
|
|
148
|
+
// ready. A tab that doesn't draw the graph sees it as topology_status.
|
|
149
|
+
const finishSwitchWait = useCallback(() => {
|
|
150
|
+
if (!waitingForTopologyAfterSwitch.current) return false
|
|
151
|
+
waitingForTopologyAfterSwitch.current = false
|
|
152
|
+
optionsRef.current?.onContextSwitchComplete?.()
|
|
153
|
+
return true
|
|
154
|
+
}, [])
|
|
155
|
+
|
|
156
|
+
// Also restarts the throttle clock, so a new stream's first graph shows at once.
|
|
157
|
+
const clearPendingTopology = useCallback(() => {
|
|
158
|
+
if (throttleTimeoutRef.current !== null) window.clearTimeout(throttleTimeoutRef.current)
|
|
159
|
+
throttleTimeoutRef.current = null
|
|
160
|
+
pendingTopologyRef.current = null
|
|
161
|
+
lastTopologyUpdateRef.current = 0
|
|
162
|
+
}, [])
|
|
163
|
+
|
|
164
|
+
// open(false) is a hard reconnect: on mount, after an error, a manual
|
|
165
|
+
// reconnect, or a context change, where frames already queued on the old
|
|
166
|
+
// stream must not arrive. open(true) hands over to new parameters: the old
|
|
167
|
+
// stream keeps delivering until the new one's first frame, which the server
|
|
168
|
+
// writes after subscribing it, so no change event falls between the two.
|
|
169
|
+
// The last connection_state delivered, to report a reconnect after all when
|
|
170
|
+
// a drain can't finish.
|
|
171
|
+
const lastConnectionStateRef = useRef<ConnectionState | null>(null)
|
|
172
|
+
const stopDrain = useCallback(() => {
|
|
173
|
+
const drain = drainRef.current
|
|
174
|
+
if (!drain) return
|
|
175
|
+
drain.timers.forEach(clearTimeout)
|
|
176
|
+
drain.source.close()
|
|
177
|
+
drainRef.current = null
|
|
178
|
+
}, [])
|
|
179
|
+
// The previous stream stopped before it could hand over everything it had.
|
|
180
|
+
const cutDrain = useCallback(() => {
|
|
181
|
+
if (!drainRef.current) return
|
|
182
|
+
stopDrain()
|
|
183
|
+
const state = lastConnectionStateRef.current
|
|
184
|
+
if (state) optionsRef.current?.onConnectionStateChange?.(state, { handover: false })
|
|
185
|
+
}, [stopDrain])
|
|
186
|
+
const finishDrainIfDone = useCallback(() => {
|
|
187
|
+
const drain = drainRef.current
|
|
188
|
+
if (drain?.elapsed && drain.successorReading) stopDrain()
|
|
189
|
+
}, [stopDrain])
|
|
190
|
+
|
|
191
|
+
const open = useCallback((handover: boolean) => {
|
|
95
192
|
if (reconnectTimeoutRef.current) {
|
|
96
193
|
clearTimeout(reconnectTimeoutRef.current)
|
|
194
|
+
reconnectTimeoutRef.current = null
|
|
97
195
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
196
|
+
pendingSourceRef.current?.close()
|
|
197
|
+
pendingSourceRef.current = null
|
|
198
|
+
const replacing = handover && eventSourceRef.current !== null && liveSourceRef.current === eventSourceRef.current
|
|
199
|
+
if (!replacing) {
|
|
200
|
+
stopDrain()
|
|
201
|
+
setConnecting(true)
|
|
202
|
+
eventSourceRef.current?.close()
|
|
203
|
+
eventSourceRef.current = null
|
|
204
|
+
// Clear stale topology so consumers show loading state instead of old data
|
|
205
|
+
setTopology(null)
|
|
206
|
+
clearPendingTopology()
|
|
109
207
|
}
|
|
110
|
-
|
|
208
|
+
|
|
209
|
+
const params = streamParamsRef.current
|
|
210
|
+
const wantsGraph = new URLSearchParams(params).get('topology') === '1'
|
|
211
|
+
const url = `${getApiBase()}/events/stream${params ? `?${params}` : ''}`
|
|
111
212
|
|
|
112
213
|
// Mirror the fetch credentials mode: 'include' sets withCredentials so
|
|
113
214
|
// cookies flow cross-origin (embedded in Radar Hub); 'omit' turns them
|
|
114
215
|
// off (pure-bearer auth). Default same-origin standalone behaves as
|
|
115
216
|
// before.
|
|
116
217
|
const es = new EventSource(url, { withCredentials: getCredentialsMode() === 'include' })
|
|
117
|
-
|
|
118
|
-
|
|
218
|
+
if (replacing) {
|
|
219
|
+
pendingSourceRef.current = es
|
|
220
|
+
} else {
|
|
221
|
+
eventSourceRef.current = es
|
|
222
|
+
}
|
|
223
|
+
let connectionStateSeen = false
|
|
224
|
+
// Set at promotion: whether the old stream was still delivering, so
|
|
225
|
+
// nothing fell between the two.
|
|
226
|
+
let handedOver = false
|
|
227
|
+
|
|
228
|
+
const current = () => {
|
|
229
|
+
if (pendingSourceRef.current === es) {
|
|
230
|
+
const previous = eventSourceRef.current
|
|
231
|
+
// A drain still running means the previous handover hasn't settled.
|
|
232
|
+
handedOver = previous !== null && liveSourceRef.current === previous && drainRef.current === null
|
|
233
|
+
eventSourceRef.current = es
|
|
234
|
+
pendingSourceRef.current = null
|
|
235
|
+
stopDrain()
|
|
236
|
+
if (previous && handedOver) {
|
|
237
|
+
const drain: Drain = { source: previous, successor: es, elapsed: false, successorReading: false, timers: [] }
|
|
238
|
+
drain.timers.push(
|
|
239
|
+
window.setTimeout(() => {
|
|
240
|
+
drain.elapsed = true
|
|
241
|
+
finishDrainIfDone()
|
|
242
|
+
}, HANDOVER_DRAIN_MS),
|
|
243
|
+
window.setTimeout(cutDrain, HANDOVER_DRAIN_LIMIT_MS),
|
|
244
|
+
)
|
|
245
|
+
drainRef.current = drain
|
|
246
|
+
} else {
|
|
247
|
+
previous?.close()
|
|
248
|
+
}
|
|
249
|
+
setTopology(null)
|
|
250
|
+
clearPendingTopology()
|
|
251
|
+
setConnected(true)
|
|
252
|
+
setConnecting(false)
|
|
253
|
+
reconnectDelayRef.current = INITIAL_RECONNECT_DELAY_MS
|
|
254
|
+
}
|
|
255
|
+
return eventSourceRef.current === es
|
|
256
|
+
}
|
|
119
257
|
const listen = (type: string, handle: (event: MessageEvent) => void) => {
|
|
120
258
|
es.addEventListener(type, (event: MessageEvent) => {
|
|
121
|
-
if (
|
|
259
|
+
if (current()) handle(event)
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
const draining = () => drainRef.current?.source === es
|
|
263
|
+
const reading = () => {
|
|
264
|
+
const drain = drainRef.current
|
|
265
|
+
if (drain?.successor !== es) return
|
|
266
|
+
drain.successorReading = true
|
|
267
|
+
finishDrainIfDone()
|
|
268
|
+
}
|
|
269
|
+
// Change events, cluster switches and deferred readiness still count from a
|
|
270
|
+
// draining stream; its graph, status and connection state are superseded.
|
|
271
|
+
const listenWhileDraining = (type: string, handle: (event: MessageEvent) => void) => {
|
|
272
|
+
es.addEventListener(type, (event: MessageEvent) => {
|
|
273
|
+
if (current() || draining()) handle(event)
|
|
122
274
|
})
|
|
123
275
|
}
|
|
124
276
|
|
|
277
|
+
const retryLater = () => {
|
|
278
|
+
setConnected(false)
|
|
279
|
+
setConnecting(false)
|
|
280
|
+
const delay = reconnectDelayRef.current
|
|
281
|
+
reconnectTimeoutRef.current = window.setTimeout(() => {
|
|
282
|
+
console.log(`SSE reconnecting after ${delay}ms...`)
|
|
283
|
+
open(false)
|
|
284
|
+
}, delay)
|
|
285
|
+
// Increase delay for next attempt (exponential backoff with cap)
|
|
286
|
+
reconnectDelayRef.current = Math.min(delay * 1.5, MAX_RECONNECT_DELAY_MS)
|
|
287
|
+
}
|
|
288
|
+
|
|
125
289
|
es.onopen = () => {
|
|
126
290
|
if (eventSourceRef.current !== es) return
|
|
127
291
|
console.log('SSE connected')
|
|
@@ -132,26 +296,50 @@ export function useEventSource(
|
|
|
132
296
|
}
|
|
133
297
|
|
|
134
298
|
es.onerror = (error) => {
|
|
299
|
+
if (draining()) {
|
|
300
|
+
cutDrain()
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
if (pendingSourceRef.current === es) {
|
|
304
|
+
// The new parameters' stream failed before delivering anything (for
|
|
305
|
+
// example the server's client cap). Fall back to a hard reconnect.
|
|
306
|
+
console.error('SSE error before handover:', error)
|
|
307
|
+
es.close()
|
|
308
|
+
pendingSourceRef.current = null
|
|
309
|
+
eventSourceRef.current?.close()
|
|
310
|
+
eventSourceRef.current = null
|
|
311
|
+
stopDrain()
|
|
312
|
+
setTopology(null)
|
|
313
|
+
clearPendingTopology()
|
|
314
|
+
retryLater()
|
|
315
|
+
return
|
|
316
|
+
}
|
|
135
317
|
if (eventSourceRef.current !== es) return
|
|
136
318
|
console.error('SSE error:', error)
|
|
137
|
-
setConnected(false)
|
|
138
|
-
setConnecting(false)
|
|
139
319
|
es.close()
|
|
140
|
-
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
320
|
+
stopDrain()
|
|
321
|
+
// A stream that failed is not one a later parameter change can hand over from.
|
|
322
|
+
eventSourceRef.current = null
|
|
323
|
+
if (pendingSourceRef.current) {
|
|
324
|
+
// A handover is under way: its stream takes over on its first frame,
|
|
325
|
+
// or retries if it fails too.
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
retryLater()
|
|
149
329
|
}
|
|
150
330
|
|
|
151
331
|
// Handle topology updates with dynamic throttling based on cluster size
|
|
152
332
|
listen('topology', (event) => {
|
|
153
333
|
try {
|
|
334
|
+
reading()
|
|
154
335
|
const data = JSON.parse(event.data) as Topology
|
|
336
|
+
applyStatus(data)
|
|
337
|
+
// An older Radar sends the graph to every tab. One that didn't ask
|
|
338
|
+
// reads only its status, and its arrival as the switch's end.
|
|
339
|
+
if (!wantsGraph) {
|
|
340
|
+
finishSwitchWait()
|
|
341
|
+
return
|
|
342
|
+
}
|
|
155
343
|
const now = Date.now()
|
|
156
344
|
const timeSinceLastUpdate = now - lastTopologyUpdateRef.current
|
|
157
345
|
|
|
@@ -161,10 +349,9 @@ export function useEventSource(
|
|
|
161
349
|
|
|
162
350
|
// If waiting for topology after context switch, update immediately
|
|
163
351
|
if (waitingForTopologyAfterSwitch.current) {
|
|
164
|
-
waitingForTopologyAfterSwitch.current = false
|
|
165
352
|
lastTopologyUpdateRef.current = now
|
|
166
353
|
setTopology(data)
|
|
167
|
-
|
|
354
|
+
finishSwitchWait()
|
|
168
355
|
return
|
|
169
356
|
}
|
|
170
357
|
|
|
@@ -196,8 +383,18 @@ export function useEventSource(
|
|
|
196
383
|
}
|
|
197
384
|
})
|
|
198
385
|
|
|
386
|
+
listen('topology_status', (event) => {
|
|
387
|
+
try {
|
|
388
|
+
reading()
|
|
389
|
+
applyStatus(JSON.parse(event.data) as TopologyStatus)
|
|
390
|
+
finishSwitchWait()
|
|
391
|
+
} catch (e) {
|
|
392
|
+
console.error('Failed to parse topology_status:', e)
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
|
|
199
396
|
// Handle K8s events
|
|
200
|
-
|
|
397
|
+
listenWhileDraining('k8s_event', (event) => {
|
|
201
398
|
try {
|
|
202
399
|
const data = JSON.parse(event.data) as K8sEvent
|
|
203
400
|
data.timestamp = Date.now()
|
|
@@ -224,48 +421,65 @@ export function useEventSource(
|
|
|
224
421
|
})
|
|
225
422
|
|
|
226
423
|
// Handle context changed event - clear state while new data loads
|
|
227
|
-
|
|
424
|
+
listenWhileDraining('context_changed', (event) => {
|
|
228
425
|
try {
|
|
229
426
|
const data = JSON.parse(event.data) as { context: string; switchId?: string }
|
|
230
427
|
console.log('Context changed to:', data.context)
|
|
231
|
-
|
|
428
|
+
// A stream opened for new parameters, or one that took over while this
|
|
429
|
+
// one drains, may already hold the previous cluster's frames, which
|
|
430
|
+
// would end the switch early.
|
|
431
|
+
const replacing = pendingSourceRef.current !== null || draining()
|
|
432
|
+
if (applyContextChange(data.context, data.switchId)) {
|
|
433
|
+
if (replacing) open(false)
|
|
434
|
+
else stopDrain()
|
|
435
|
+
}
|
|
232
436
|
} catch (e) {
|
|
233
437
|
console.error('Failed to parse context_changed event:', e)
|
|
234
438
|
}
|
|
235
439
|
})
|
|
236
440
|
|
|
237
441
|
// Handle deferred informer sync completion — refetch dashboard data
|
|
238
|
-
|
|
442
|
+
listenWhileDraining('deferred_ready', () => {
|
|
239
443
|
optionsRef.current?.onDeferredReady?.()
|
|
240
444
|
})
|
|
241
445
|
|
|
242
446
|
// Handle connection state events (for graceful startup)
|
|
243
447
|
listen('connection_state', (event) => {
|
|
244
448
|
try {
|
|
449
|
+
// Every stream opens with the current state. After a handover nothing
|
|
450
|
+
// was missed, which the receiver needs to know so it doesn't refetch
|
|
451
|
+
// every query as it would after a reconnect.
|
|
452
|
+
const handover = handedOver && !connectionStateSeen
|
|
453
|
+
connectionStateSeen = true
|
|
245
454
|
const data = JSON.parse(event.data) as ConnectionState
|
|
246
|
-
|
|
455
|
+
lastConnectionStateRef.current = data
|
|
456
|
+
optionsRef.current?.onConnectionStateChange?.(data, { handover })
|
|
457
|
+
liveSourceRef.current = es
|
|
247
458
|
} catch (e) {
|
|
248
459
|
console.error('Failed to parse connection_state event:', e)
|
|
249
460
|
}
|
|
250
461
|
})
|
|
251
|
-
}, [
|
|
462
|
+
}, [applyContextChange, applyStatus, finishSwitchWait, clearPendingTopology, stopDrain, cutDrain, finishDrainIfDone])
|
|
252
463
|
|
|
253
464
|
// A poll can beat context_changed on the stream. Only a fresh subscription
|
|
254
465
|
// has a known boundary in that case: queued frames carry no cluster ID.
|
|
255
466
|
const applyPolledContextChange = useCallback((context: string, switchId?: string) => {
|
|
256
|
-
if (applyContextChange(context, switchId))
|
|
257
|
-
}, [applyContextChange,
|
|
467
|
+
if (applyContextChange(context, switchId)) open(false)
|
|
468
|
+
}, [applyContextChange, open])
|
|
258
469
|
|
|
259
470
|
// Reconnect function for manual reconnection
|
|
260
471
|
const reconnect = useCallback(() => {
|
|
261
|
-
|
|
262
|
-
}, [
|
|
472
|
+
open(false)
|
|
473
|
+
}, [open])
|
|
263
474
|
|
|
264
|
-
// Connect on mount
|
|
475
|
+
// Connect on mount; close everything on unmount
|
|
265
476
|
useEffect(() => {
|
|
266
|
-
|
|
477
|
+
open(false)
|
|
267
478
|
|
|
268
479
|
return () => {
|
|
480
|
+
stopDrain()
|
|
481
|
+
pendingSourceRef.current?.close()
|
|
482
|
+
pendingSourceRef.current = null
|
|
269
483
|
if (eventSourceRef.current) {
|
|
270
484
|
eventSourceRef.current.close()
|
|
271
485
|
eventSourceRef.current = null
|
|
@@ -277,7 +491,19 @@ export function useEventSource(
|
|
|
277
491
|
clearTimeout(throttleTimeoutRef.current)
|
|
278
492
|
}
|
|
279
493
|
}
|
|
280
|
-
}, [
|
|
494
|
+
}, [open, stopDrain])
|
|
495
|
+
|
|
496
|
+
// New parameters hand the stream over without a gap, unless the namespaces
|
|
497
|
+
// change: the old stream never carried changes outside its own, so the new
|
|
498
|
+
// scope's data needs the full refresh a reconnect brings.
|
|
499
|
+
const openedParamsRef = useRef(streamParams)
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
const previous = openedParamsRef.current
|
|
502
|
+
if (previous === streamParams) return
|
|
503
|
+
openedParamsRef.current = streamParams
|
|
504
|
+
const sameScope = new URLSearchParams(previous).get('namespaces') === new URLSearchParams(streamParams).get('namespaces')
|
|
505
|
+
open(sameScope)
|
|
506
|
+
}, [streamParams, open])
|
|
281
507
|
|
|
282
508
|
// Clear events when namespaces change
|
|
283
509
|
useEffect(() => {
|
|
@@ -286,6 +512,7 @@ export function useEventSource(
|
|
|
286
512
|
|
|
287
513
|
return {
|
|
288
514
|
topology,
|
|
515
|
+
topologyStatus,
|
|
289
516
|
events,
|
|
290
517
|
connected,
|
|
291
518
|
connecting,
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { SelectedResource } from '../types'
|
|
|
6
6
|
import { kindToPluralWithGroup } from '../utils/navigation'
|
|
7
7
|
|
|
8
8
|
export type HostResource = Pick<SelectedResource, 'kind' | 'group' | 'namespace' | 'name'>
|
|
9
|
-
export type DetailSlots = Pick<ComponentProps<typeof WorkloadView>, 'renderSummary' | 'renderHeaderActions' | 'extraTabs' | 'renderStatusBadge'>
|
|
9
|
+
export type DetailSlots = Pick<ComponentProps<typeof WorkloadView>, 'renderSummary' | 'renderHeaderActions' | 'extraTabs' | 'renderStatusBadge' | 'breadcrumb'>
|
|
10
10
|
export type HostFeatures = Partial<Record<RadarFeature, RadarFeatureSupport>>
|
|
11
11
|
export type KindListMode = 'table' | 'wait' | 'view'
|
|
12
12
|
export interface HostKind { name: string; kind: string; group: string }
|
|
@@ -21,6 +21,7 @@ type ExclusiveDetailSlot = 'summary' | 'destination' | 'logs'
|
|
|
21
21
|
export interface ResourceHost {
|
|
22
22
|
id: string
|
|
23
23
|
feature?: RadarFeature
|
|
24
|
+
waitForFeature?: boolean
|
|
24
25
|
diagnoseAction?: (render: RenderDiagnoseAction | undefined) => RenderDiagnoseAction | undefined
|
|
25
26
|
kindLists?: readonly {
|
|
26
27
|
kind: HostKind
|
|
@@ -51,15 +52,19 @@ export function hostSupport(host: ResourceHost, features: HostFeatures): RadarFe
|
|
|
51
52
|
|
|
52
53
|
function resourceKey(name: string, group: string): string { return `${group}\u0000${name}` }
|
|
53
54
|
|
|
54
|
-
export function hostsForResource(hosts: readonly ResourceHost[], resource: HostResource): ResourceHost[] {
|
|
55
|
+
export function hostsForResource(hosts: readonly ResourceHost[], resource: HostResource, features?: HostFeatures): ResourceHost[] {
|
|
55
56
|
// An unresolved group must not select a colliding CRD, or be treated as core.
|
|
56
57
|
if (resource.group === undefined) return []
|
|
57
58
|
const plural = kindToPluralWithGroup(resource.kind, resource.group)
|
|
58
|
-
return hosts.filter(host =>
|
|
59
|
+
return hosts.filter(host => {
|
|
60
|
+
const support = features ? hostSupport(host, features) : 'supported'
|
|
61
|
+
return (support === 'supported' || support === 'unknown' && !host.waitForFeature) &&
|
|
62
|
+
host.resources?.some(kind => kind.name === plural && kind.group === resource.group)
|
|
63
|
+
})
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
export function resourceHostForSlot(hosts: readonly ResourceHost[], resource: HostResource, slot: ExclusiveDetailSlot): ResourceHost | undefined {
|
|
62
|
-
return hostsForResource(hosts, resource).find(host => host.detailOwnership?.includes(slot))
|
|
66
|
+
export function resourceHostForSlot(hosts: readonly ResourceHost[], resource: HostResource, slot: ExclusiveDetailSlot, features?: HostFeatures): ResourceHost | undefined {
|
|
67
|
+
return hostsForResource(hosts, resource, features).find(host => host.detailOwnership?.includes(slot))
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
export function composeResourceHosts(hosts: readonly ResourceHost[]): RendererOverrides {
|
|
@@ -88,6 +93,7 @@ export function composeDetailSlots(contributions: readonly { id: string; slots:
|
|
|
88
93
|
const summaries = contributions.filter(host => host.slots?.renderSummary)
|
|
89
94
|
if (summaries.length > 1) throw new Error(`Resource host summary ownership conflict: ${summaries.map(host => host.id).join(', ')}`)
|
|
90
95
|
const summary = summaries[0]?.slots?.renderSummary
|
|
96
|
+
const breadcrumb = summaries[0]?.slots?.breadcrumb
|
|
91
97
|
const badges = contributions.filter(host => host.slots?.renderStatusBadge)
|
|
92
98
|
if (badges.length > 1) throw new Error(`Resource host status badge ownership conflict: ${badges.map(host => host.id).join(', ')}`)
|
|
93
99
|
const badge = badges[0]?.slots?.renderStatusBadge
|
|
@@ -99,7 +105,7 @@ export function composeDetailSlots(contributions: readonly { id: string; slots:
|
|
|
99
105
|
tabIds.add(tab.id)
|
|
100
106
|
}
|
|
101
107
|
return {
|
|
102
|
-
...(summary ? { renderSummary: summary } : {}),
|
|
108
|
+
...(summary ? { renderSummary: summary, ...(breadcrumb ? { breadcrumb } : {}) } : {}),
|
|
103
109
|
...(badge ? { renderStatusBadge: badge } : {}),
|
|
104
110
|
...(actions.length ? { renderHeaderActions: (props: Parameters<NonNullable<DetailSlots['renderHeaderActions']>>[0]) => actions.map(host => createElement(Fragment, { key: host.id }, host.slots!.renderHeaderActions!(props))) } : {}),
|
|
105
111
|
...(tabs.length ? { extraTabs: tabs } : {}),
|
|
@@ -55,7 +55,7 @@ describe('application resource hosts', () => {
|
|
|
55
55
|
'RolloutRenderer', 'KyvernoPolicyCoverage', 'KyvernoPolicyQueued', 'CNPGObjectStoreRenderer',
|
|
56
56
|
'VeleroBSLRenderer', 'VeleroBackupRenderer', 'VeleroRestoreRenderer', 'CNPGClusterRenderer',
|
|
57
57
|
'CNPGDatabaseRenderer', 'CNPGPublicationRenderer', 'CNPGSubscriptionRenderer', 'CNPGImageCatalogRenderer',
|
|
58
|
-
'FluxHelmReleaseRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'MutatingAdmissionPolicyRenderer', 'MutatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer', 'UpgradePlanRenderer', 'SealedSecretRenderer', 'K3sHelmChartRenderer', 'TraefikIngressRouteRenderer', 'TraefikMiddlewareRenderer',
|
|
58
|
+
'FluxHelmReleaseRenderer', 'KagentAgentRenderer', 'OpenTelemetryCollectorRenderer', 'ValidatingAdmissionPolicyRenderer', 'ValidatingAdmissionPolicyBindingRenderer', 'MutatingAdmissionPolicyRenderer', 'MutatingAdmissionPolicyBindingRenderer', 'SecretProviderClassRenderer', 'UpgradePlanRenderer', 'SealedSecretRenderer', 'K3sHelmChartRenderer', 'TraefikIngressRouteRenderer', 'TraefikMiddlewareRenderer',
|
|
59
59
|
].sort())
|
|
60
60
|
const inherited = [{ id: 'local', label: 'Local', render: () => null }]
|
|
61
61
|
expect(resourceDetailSlots({ kind: 'Pod', group: '', namespace: 'db', name: 'pg-1' }, inherited).extraTabs).toEqual(inherited)
|
|
@@ -63,6 +63,20 @@ describe('application resource hosts', () => {
|
|
|
63
63
|
expect(resourceDetailRedirect({ ...cluster, group: '' }, new URLSearchParams('tab=events'))).toBeNull()
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
+
it('keeps WorkerPool paths on generic detail when the Radar lacks Substrate workspace routes', () => {
|
|
67
|
+
const pool = { kind: 'WorkerPool', group: 'ate.dev', namespace: 'agents', name: 'pool' }
|
|
68
|
+
const search = new URLSearchParams('apiGroup=ate.dev')
|
|
69
|
+
const older = { substrateWorkspace: 'unsupported' } as const
|
|
70
|
+
const current = { substrateWorkspace: 'supported' } as const
|
|
71
|
+
|
|
72
|
+
expect(resourceExpandedPath(pool, undefined, undefined, older)).toBeNull()
|
|
73
|
+
expect(resourceDetailRedirect(pool, search, older)).toBeNull()
|
|
74
|
+
expect(resourceDetailSlots(pool, undefined, older)).toEqual({})
|
|
75
|
+
expect(resourceExpandedPath(pool, undefined, undefined, current)).toBe('/substrate/workerpools/agents/pool')
|
|
76
|
+
expect(resourceDetailRedirect(pool, search, current)).toBe('/substrate/workerpools/agents/pool')
|
|
77
|
+
expect(resourceDetailSlots(pool, undefined, current).renderSummary).toBeDefined()
|
|
78
|
+
})
|
|
79
|
+
|
|
66
80
|
it('owns the LocalQueue header badge and nothing for other Kueue kinds', () => {
|
|
67
81
|
expect(resourceDetailSlots({ kind: 'LocalQueue', group: 'kueue.x-k8s.io', namespace: 'team', name: 'q' }).renderStatusBadge).toBeTypeOf('function')
|
|
68
82
|
expect(resourceDetailSlots({ kind: 'ClusterQueue', group: 'kueue.x-k8s.io', namespace: '', name: 'q' }).renderStatusBadge).toBeUndefined()
|
|
@@ -169,3 +183,15 @@ it('registers one CRD renderer and one Schema tab for the exact group', () => {
|
|
|
169
183
|
expect(resourceDetailSlots({ ...resource, kind: 'CustomResourceDefinition' }).extraTabs).toHaveLength(1)
|
|
170
184
|
expect(resourceHosts.filter(host => host.renderers?.CustomResourceDefinitionRenderer).map(host => host.id)).toEqual(['crd'])
|
|
171
185
|
})
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
it('gates kagent destinations and composed summaries while keeping the generic renderer', () => {
|
|
189
|
+
const agent = { kind: 'Agent', group: 'api.kagent.dev', namespace: 'agents', name: 'helper' }
|
|
190
|
+
for (const kagentWorkspace of ['unknown', 'unsupported'] as const) {
|
|
191
|
+
expect(resourceExpandedPath(agent, 'test', undefined, { kagentWorkspace })).toBeNull()
|
|
192
|
+
expect(resourceDetailRedirect(agent, new URLSearchParams(), { kagentWorkspace })).toBeNull()
|
|
193
|
+
expect(resourceDetailSlots(agent, [], { kagentWorkspace }).renderSummary).toBeUndefined()
|
|
194
|
+
}
|
|
195
|
+
expect(resourceExpandedPath(agent, 'test', undefined, { kagentWorkspace: 'supported' })).toBe('/kagent/agents/agents/helper?ctx=test')
|
|
196
|
+
expect(resourceExpandedPath({ ...agent, group: 'agent.k8s.elastic.co' }, 'test', undefined, { kagentWorkspace: 'supported' })).toBeNull()
|
|
197
|
+
})
|
|
@@ -7,6 +7,9 @@ import { apiVersionToGroup } from '../utils/navigation'
|
|
|
7
7
|
import type { SelectedResource } from '../types'
|
|
8
8
|
import { cnpgResourceHost } from '../components/cnpg/host'
|
|
9
9
|
import { veleroResourceHost } from '../components/velero/host'
|
|
10
|
+
import { substrateResourceHost } from '../components/substrate/host'
|
|
11
|
+
import { agentSandboxResourceHost } from '../components/agentsandbox/host'
|
|
12
|
+
import { kagentResourceHost } from '../components/kagent/host'
|
|
10
13
|
import { crdResourceHost } from '../components/resources/crd/host'
|
|
11
14
|
import {
|
|
12
15
|
composeDetailSlots, composeResourceHosts, hostsForResource, hostSupport, resourceHostForSlot,
|
|
@@ -77,6 +80,9 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
77
80
|
{ id: 'kyverno', renderers: { KyvernoPolicyCoverage, KyvernoPolicyQueued } },
|
|
78
81
|
veleroResourceHost,
|
|
79
82
|
{ id: 'longhorn', renderers: { LonghornVolumeRenderer } },
|
|
83
|
+
substrateResourceHost,
|
|
84
|
+
agentSandboxResourceHost,
|
|
85
|
+
kagentResourceHost,
|
|
80
86
|
{ id: 'flux', renderers: { FluxHelmReleaseRenderer } },
|
|
81
87
|
{ id: 'secrets-store-csi', renderers: { SecretProviderClassRenderer } },
|
|
82
88
|
{ id: 'admission-policy', renderers: { ValidatingAdmissionPolicyRenderer, ValidatingAdmissionPolicyBindingRenderer, MutatingAdmissionPolicyRenderer, MutatingAdmissionPolicyBindingRenderer } },
|
|
@@ -86,12 +92,12 @@ export const resourceHosts: readonly ResourceHost[] = [
|
|
|
86
92
|
|
|
87
93
|
export const resourceRendererOverrides = composeResourceHosts(resourceHosts)
|
|
88
94
|
|
|
89
|
-
export function resourceExpandedPath(resource: HostResource, context?: string, tab?: 'yaml'): string | null {
|
|
90
|
-
return resourceHostForSlot(resourceHosts, resource, 'destination')?.expandedPath?.(resource, context, tab) ?? null
|
|
95
|
+
export function resourceExpandedPath(resource: HostResource, context?: string, tab?: 'yaml', features?: HostFeatures): string | null {
|
|
96
|
+
return resourceHostForSlot(resourceHosts, resource, 'destination', features)?.expandedPath?.(resource, context, tab) ?? null
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
export function resourceDetailRedirect(resource: HostResource, search: URLSearchParams): string | null {
|
|
94
|
-
return resourceHostForSlot(resourceHosts, resource, 'destination')?.detailRedirect?.(resource, search) ?? null
|
|
99
|
+
export function resourceDetailRedirect(resource: HostResource, search: URLSearchParams, features?: HostFeatures): string | null {
|
|
100
|
+
return resourceHostForSlot(resourceHosts, resource, 'destination', features)?.detailRedirect?.(resource, search) ?? null
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
export function resourceIssueDetail(resource: HostResource, props: { issue: { kind?: string; reason?: string }; resource: any }) {
|
|
@@ -102,8 +108,8 @@ export function resourceIssueDetail(resource: HostResource, props: { issue: { ki
|
|
|
102
108
|
return null
|
|
103
109
|
}
|
|
104
110
|
|
|
105
|
-
export function resourceDetailSlots(resource: HostResource, inheritedTabs?: WorkloadExtraTab[]): DetailSlots {
|
|
106
|
-
const slots = hostsForResource(resourceHosts, resource)
|
|
111
|
+
export function resourceDetailSlots(resource: HostResource, inheritedTabs?: WorkloadExtraTab[], features?: HostFeatures): DetailSlots {
|
|
112
|
+
const slots = hostsForResource(resourceHosts, resource, features)
|
|
107
113
|
.map(host => ({ id: host.id, slots: host.detailSlots?.(resource) }))
|
|
108
114
|
return composeDetailSlots(slots, inheritedTabs)
|
|
109
115
|
}
|
|
@@ -128,7 +134,9 @@ export function useResourceHostFeatures(): HostFeatures {
|
|
|
128
134
|
// Hook order is fixed here; selected adapters mount components that own their data hooks.
|
|
129
135
|
const { support: cnpgWorkspace } = useRadarFeature('cnpgWorkspace')
|
|
130
136
|
const { support: veleroWorkspace } = useRadarFeature('veleroWorkspace')
|
|
131
|
-
|
|
137
|
+
const { support: substrateWorkspace } = useRadarFeature('substrateWorkspace')
|
|
138
|
+
const { support: kagentWorkspace } = useRadarFeature('kagentWorkspace')
|
|
139
|
+
return useMemo(() => ({ cnpgWorkspace, veleroWorkspace, substrateWorkspace, kagentWorkspace }), [cnpgWorkspace, veleroWorkspace, substrateWorkspace, kagentWorkspace])
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
|