@skyhook-io/radar-app 1.22.2 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +49 -13
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -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 +151 -27
- package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
- 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/poll.ts +78 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +16 -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 +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +128 -32
- 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/AgentSetupNotice.tsx +5 -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/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
- package/src/components/helm/HelmView.tsx +4 -3
- package/src/components/helm/ObservedHelmNotice.tsx +39 -17
- package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- 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/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- 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/issues/uncheckedSources.test.ts +8 -0
- package/src/components/issues/uncheckedSources.ts +3 -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/nudges/activeNudges.test.ts +39 -0
- package/src/components/nudges/activeNudges.ts +76 -0
- package/src/components/poll/OssPoll.tsx +871 -0
- package/src/components/poll/mount.test.ts +12 -0
- package/src/components/poll/pollCloud.test.ts +23 -0
- package/src/components/poll/pollCloud.ts +6 -0
- package/src/components/poll/pollDefinition.ts +93 -0
- package/src/components/poll/pollFlow.test.ts +140 -0
- package/src/components/poll/pollFlow.ts +137 -0
- package/src/components/poll/pollSender.test.ts +137 -0
- package/src/components/poll/pollSender.ts +76 -0
- package/src/components/poll/pollStorage.test.ts +53 -0
- package/src/components/poll/pollStorage.ts +77 -0
- package/src/components/poll/round.json +350 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +2 -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/ImageFilesystemModal.test.tsx +21 -1
- package/src/components/resources/ImageFilesystemModal.tsx +42 -3
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +24 -11
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- 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/ui/UpdateNotification.tsx +2 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
- 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/whats-new/WhatsNew.tsx +2 -0
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- 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/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -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
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query'
|
|
2
|
+
import type { HealthLevel } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { fetchJSON, useRadarFeature } from './client'
|
|
4
|
+
import { getApiBase } from './config'
|
|
5
|
+
import { shouldRetryRadarQuery } from './radarFeatures'
|
|
6
|
+
|
|
7
|
+
// Wire types of GET /api/agentsandbox/workspace: internal/server
|
|
8
|
+
// AgentSandboxWorkspaceResponse and pkg/agentsandbox Summary.
|
|
9
|
+
|
|
10
|
+
export type AgentSandboxCoverageState = 'full' | 'partial' | 'denied' | 'uncached' | 'notInstalled' | 'syncing' | 'error'
|
|
11
|
+
|
|
12
|
+
export interface AgentSandboxKindCoverage {
|
|
13
|
+
state: AgentSandboxCoverageState
|
|
14
|
+
/** Named only when the caller named the namespaces. */
|
|
15
|
+
deniedNamespaces?: string[]
|
|
16
|
+
uncachedNamespaces?: string[]
|
|
17
|
+
/** For partial coverage: the namespaces that were read. */
|
|
18
|
+
allowedNamespaces?: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type AgentSandboxWorkspaceKey = 'sandboxes' | 'claims' | 'warmPools' | 'templates'
|
|
22
|
+
|
|
23
|
+
export interface AgentSandboxRef {
|
|
24
|
+
kind: string
|
|
25
|
+
group: string
|
|
26
|
+
namespace?: string
|
|
27
|
+
name: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What Radar can say about an object a row names: absent only where its kind was read in full in that namespace. */
|
|
31
|
+
export type AgentSandboxPresence = 'present' | 'absent' | 'unread'
|
|
32
|
+
|
|
33
|
+
export interface AgentSandboxRelation {
|
|
34
|
+
role: 'warmPool' | 'template' | 'sandbox' | 'owner'
|
|
35
|
+
ref: AgentSandboxRef
|
|
36
|
+
presence: AgentSandboxPresence
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type AgentSandboxCategory = 'controller' | 'sandbox' | 'claim' | 'warmPool'
|
|
40
|
+
|
|
41
|
+
/** Which rule raised a row; branch on this, never on the title. */
|
|
42
|
+
export type AgentSandboxRule =
|
|
43
|
+
| 'controllerNotRunning'
|
|
44
|
+
| 'failed'
|
|
45
|
+
| 'reconcilerError'
|
|
46
|
+
| 'suspensionBlocked'
|
|
47
|
+
/**
|
|
48
|
+
* In progress for longer than 30 minutes (IncidentAfter). Whether Issues list
|
|
49
|
+
* it is the row's `issue`: a claim forwarding its Sandbox's progress is not
|
|
50
|
+
* listed, since Issues report that on the Sandbox.
|
|
51
|
+
*/
|
|
52
|
+
| 'stalled'
|
|
53
|
+
/** In progress past 5 minutes: an advisory, never an Issue. */
|
|
54
|
+
| 'slow'
|
|
55
|
+
| 'cannotBind'
|
|
56
|
+
| 'templateMissing'
|
|
57
|
+
| 'reserveBelowTarget'
|
|
58
|
+
|
|
59
|
+
export interface AgentSandboxAttention {
|
|
60
|
+
id: string
|
|
61
|
+
category: AgentSandboxCategory
|
|
62
|
+
rule: AgentSandboxRule
|
|
63
|
+
/**
|
|
64
|
+
* The controller's own reason where it reported one (PodFailed,
|
|
65
|
+
* Unschedulable, WarmPoolNotFound); an AgentSandbox-prefixed reason where
|
|
66
|
+
* Radar found it (AgentSandboxWarmPoolNotFound, AgentSandboxControllerNotReady).
|
|
67
|
+
*/
|
|
68
|
+
reason?: string
|
|
69
|
+
/** The prominence ladder GitOps, Velero, CNPG and Substrate rows use. */
|
|
70
|
+
severity: 'critical' | 'alert' | 'warning'
|
|
71
|
+
/** Carries no elapsed time; `since` does. */
|
|
72
|
+
title: string
|
|
73
|
+
reading?: string
|
|
74
|
+
/** What limits or contradicts the row in Radar's own reads; never folded away. */
|
|
75
|
+
caveat?: string
|
|
76
|
+
/** The controller's or scheduler's own words, folded under the reading. */
|
|
77
|
+
rawDetail?: string
|
|
78
|
+
rawDetailLabel?: string
|
|
79
|
+
/** `scheduler`: rawDetail can be put plainly with summarizeSchedulerMessage. */
|
|
80
|
+
rawDetailSource?: 'scheduler' | 'controller'
|
|
81
|
+
nextStep: string
|
|
82
|
+
/** The one shell command nextStep names, verbatim and in parentheses there: a client may show it as a copyable chip. */
|
|
83
|
+
command?: string
|
|
84
|
+
subject: AgentSandboxRef
|
|
85
|
+
related?: { lead: string; refs: AgentSandboxRef[] }
|
|
86
|
+
relations?: AgentSandboxRelation[]
|
|
87
|
+
/**
|
|
88
|
+
* When the state began: the latest transition among the conditions that
|
|
89
|
+
* report it, so no earlier than this. Absent where no condition records one
|
|
90
|
+
* (a refused suspension, a pool's reserve, Radar's own missing-object joins).
|
|
91
|
+
*/
|
|
92
|
+
since?: string
|
|
93
|
+
/** Radar's Issues list the subject for the same state: the authoritative parity bit, which no rule implies. */
|
|
94
|
+
issue: boolean
|
|
95
|
+
/**
|
|
96
|
+
* On a warm pool's reserve row when no sandbox in it is ready: its unbound
|
|
97
|
+
* claims still in progress, waiting while none is ready. Absent when
|
|
98
|
+
* none of the namespace's claims were read.
|
|
99
|
+
*/
|
|
100
|
+
waitingClaims?: AgentSandboxCount
|
|
101
|
+
/** On an unbound claim's row: the warm pool it names, read, with no sandbox ready. */
|
|
102
|
+
emptyPool?: AgentSandboxRef
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type AgentSandboxControllerState = 'running' | 'notReady' | 'scaledToZero' | 'notFound' | 'unread' | 'notInstalled'
|
|
106
|
+
|
|
107
|
+
export interface AgentSandboxController {
|
|
108
|
+
state: AgentSandboxControllerState
|
|
109
|
+
namespace: string
|
|
110
|
+
name: string
|
|
111
|
+
/** Set only when the Deployment was read. */
|
|
112
|
+
ready?: number
|
|
113
|
+
desired?: number
|
|
114
|
+
/**
|
|
115
|
+
* Why it was not read, when state is unread: a pkg/readreason code
|
|
116
|
+
* (user_forbidden, outside_namespace_pin, radar_namespace_not_collected,
|
|
117
|
+
* radar_kind_not_collected, kind_sync_pending, kind_sync_timed_out,
|
|
118
|
+
* read_error); readActionFor gives its action.
|
|
119
|
+
*/
|
|
120
|
+
code?: string
|
|
121
|
+
/** When the Deployment's Available condition last turned False. */
|
|
122
|
+
since?: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Lower bound: read in part, so every count is at least this and says nothing about the rest. */
|
|
126
|
+
export interface AgentSandboxSandboxCounts {
|
|
127
|
+
total: number
|
|
128
|
+
lowerBound: boolean
|
|
129
|
+
running: number
|
|
130
|
+
/** In progress, other than unschedulable. */
|
|
131
|
+
starting: number
|
|
132
|
+
/** In progress, and the scheduler can't place its Pod (PodScheduled=False with the scheduler's reason). */
|
|
133
|
+
unschedulable: number
|
|
134
|
+
/** Confirmed suspended, or suspending. */
|
|
135
|
+
suspended: number
|
|
136
|
+
/** The controller refuses the suspension (PodNotOwned); its Pod may still be running. */
|
|
137
|
+
suspensionBlocked: number
|
|
138
|
+
expired: number
|
|
139
|
+
finished: number
|
|
140
|
+
failed: number
|
|
141
|
+
terminating: number
|
|
142
|
+
unknown: number
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface AgentSandboxClaimCounts {
|
|
146
|
+
total: number
|
|
147
|
+
lowerBound: boolean
|
|
148
|
+
bound: number
|
|
149
|
+
waiting: number
|
|
150
|
+
expired: number
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface AgentSandboxWarmPoolCounts {
|
|
154
|
+
total: number
|
|
155
|
+
lowerBound: boolean
|
|
156
|
+
ready: number
|
|
157
|
+
readyLowerBound?: boolean
|
|
158
|
+
/** Only pools that set spec.replicas. */
|
|
159
|
+
desired: number
|
|
160
|
+
desiredLowerBound?: boolean
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A kind is absent when nothing of it was read. */
|
|
164
|
+
export interface AgentSandboxCounts {
|
|
165
|
+
sandboxes?: AgentSandboxSandboxCounts
|
|
166
|
+
claims?: AgentSandboxClaimCounts
|
|
167
|
+
warmPools?: AgentSandboxWarmPoolCounts
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** `count` is null when the read was partial and found nothing. */
|
|
171
|
+
export interface AgentSandboxCount {
|
|
172
|
+
count: number | null
|
|
173
|
+
lowerBound: boolean
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface AgentSandboxSidebar {
|
|
177
|
+
total: AgentSandboxCount
|
|
178
|
+
sandboxes: AgentSandboxCount
|
|
179
|
+
claims: AgentSandboxCount
|
|
180
|
+
warmPools: AgentSandboxCount
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface AgentSandboxWarmPoolRow {
|
|
184
|
+
namespace: string
|
|
185
|
+
name: string
|
|
186
|
+
state: { text: string; level: HealthLevel }
|
|
187
|
+
/** Absent until the pool reports status. */
|
|
188
|
+
ready?: number
|
|
189
|
+
/** Absent when the pool sets no spec.replicas. */
|
|
190
|
+
desired?: number
|
|
191
|
+
template?: string
|
|
192
|
+
templatePresence?: AgentSandboxPresence
|
|
193
|
+
/** Absent when the namespace's claims were not read. */
|
|
194
|
+
claims?: { total: number; bound: number }
|
|
195
|
+
created?: string
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface AgentSandboxExpiredEntry {
|
|
199
|
+
ref: AgentSandboxRef
|
|
200
|
+
/** The configured shutdown time. */
|
|
201
|
+
at: string
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface AgentSandboxExpired {
|
|
205
|
+
/**
|
|
206
|
+
* Within the last 7 days, newest first, capped. An expiry with no shutdown
|
|
207
|
+
* time recorded can't be placed in the week and is left out; the status
|
|
208
|
+
* line's expired count still includes it.
|
|
209
|
+
*/
|
|
210
|
+
recent: AgentSandboxExpiredEntry[]
|
|
211
|
+
recentTotal: number
|
|
212
|
+
lowerBound: boolean
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface AgentSandboxWorkspaceResponse {
|
|
216
|
+
context: string
|
|
217
|
+
installed: boolean
|
|
218
|
+
/** The namespaces asked for, after Radar's --namespace-scope clamp; empty for all the caller may read. */
|
|
219
|
+
namespaces: string[]
|
|
220
|
+
forcedNamespace?: string
|
|
221
|
+
coverage: Record<AgentSandboxWorkspaceKey, AgentSandboxKindCoverage>
|
|
222
|
+
controller: AgentSandboxController
|
|
223
|
+
counts: AgentSandboxCounts
|
|
224
|
+
/** One list ordered by severity, then rule, then newest first; never grouped by kind. */
|
|
225
|
+
attention: AgentSandboxAttention[]
|
|
226
|
+
attentionTotal: number
|
|
227
|
+
/** Namespace/name keys in each Needs attention segment, independent of the findings cap. */
|
|
228
|
+
attentionObjects?: { [K in Exclude<AgentSandboxWorkspaceKey, 'templates'>]: string[] }
|
|
229
|
+
/** Every kind and the controller were read in full: no rows means nothing needs attention. */
|
|
230
|
+
attentionComplete: boolean
|
|
231
|
+
sidebar: AgentSandboxSidebar
|
|
232
|
+
warmPools: AgentSandboxWarmPoolRow[]
|
|
233
|
+
warmPoolsTotal: number
|
|
234
|
+
expired: AgentSandboxExpired
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// /api/agentsandbox/workspace?namespaces=
|
|
238
|
+
//
|
|
239
|
+
// The Overview, Needs attention and the sidebar's badges, computed on the
|
|
240
|
+
// server from what the caller can read. The namespace filter applies. The API
|
|
241
|
+
// base is in the key because Radar Hub points one query client at many
|
|
242
|
+
// clusters.
|
|
243
|
+
export function useAgentSandboxWorkspace(namespaces: string[], options?: { enabled?: boolean }) {
|
|
244
|
+
const { guard, gatedKey } = useRadarFeature('agentSandboxWorkspace')
|
|
245
|
+
const base = getApiBase()
|
|
246
|
+
const ns = [...namespaces].sort().join(',')
|
|
247
|
+
return useQuery<AgentSandboxWorkspaceResponse>({
|
|
248
|
+
queryKey: ['agent-sandbox', 'workspace', base, ns, ...gatedKey],
|
|
249
|
+
queryFn: ({ signal }) =>
|
|
250
|
+
guard(() => fetchJSON<AgentSandboxWorkspaceResponse>(`/agentsandbox/workspace${ns ? `?namespaces=${encodeURIComponent(ns)}` : ''}`, signal)),
|
|
251
|
+
enabled: options?.enabled ?? true,
|
|
252
|
+
staleTime: 10_000,
|
|
253
|
+
refetchInterval: 30_000,
|
|
254
|
+
// Keep the previous answer while refetching, but never another cluster's
|
|
255
|
+
// or another namespace filter's.
|
|
256
|
+
placeholderData: (prev, prevQuery) => (prevQuery?.queryKey[2] === base && prevQuery?.queryKey[3] === ns ? prev : undefined),
|
|
257
|
+
retry: shouldRetryRadarQuery,
|
|
258
|
+
})
|
|
259
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { expect, it, vi } from 'vitest'
|
|
6
|
+
import { useAutoPromConnect, type PrometheusStatus } from './client'
|
|
7
|
+
|
|
8
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
9
|
+
|
|
10
|
+
function Probe() {
|
|
11
|
+
useAutoPromConnect()
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
it('sends a discovery that an OpenObserve check canceled once the check ends without charts', async () => {
|
|
16
|
+
let connects = 0
|
|
17
|
+
vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input) => {
|
|
18
|
+
const url = String(input)
|
|
19
|
+
if (url.includes('/cluster-info')) return new Response(JSON.stringify({ context: 'ctx' }))
|
|
20
|
+
if (url.includes('/prometheus/connect')) {
|
|
21
|
+
connects++
|
|
22
|
+
return new Response(JSON.stringify({ available: false, connected: false }))
|
|
23
|
+
}
|
|
24
|
+
return new Response(JSON.stringify(client.getQueryData(['prometheus-status'])))
|
|
25
|
+
}))
|
|
26
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, refetchInterval: false } } })
|
|
27
|
+
const notConnected: PrometheusStatus = { available: false, connected: false, openobserve: 'local' }
|
|
28
|
+
client.setQueryData(['prometheus-status'], notConnected)
|
|
29
|
+
const root = createRoot(document.createElement('div'))
|
|
30
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>))
|
|
31
|
+
await act(async () => { await new Promise((r) => setTimeout(r, 50)) })
|
|
32
|
+
|
|
33
|
+
// The check starts before the delayed first probe is sent, then ends without charts.
|
|
34
|
+
await act(async () => client.setQueryData(['prometheus-status'], { ...notConnected, source: { kind: 'openobserve', via: 'local', pending: true } }))
|
|
35
|
+
await act(async () => { await new Promise((r) => setTimeout(r, 700)) })
|
|
36
|
+
expect(connects).toBe(0)
|
|
37
|
+
await act(async () => client.setQueryData(['prometheus-status'], { ...notConnected, source: { kind: 'openobserve', via: 'local', error: 'unreachable' } }))
|
|
38
|
+
await act(async () => { await new Promise((r) => setTimeout(r, 700)) })
|
|
39
|
+
expect(connects).toBe(1)
|
|
40
|
+
|
|
41
|
+
act(() => root.unmount())
|
|
42
|
+
vi.unstubAllGlobals()
|
|
43
|
+
})
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { expect, it, vi } from 'vitest'
|
|
6
|
+
import { useMetricsRelayCheck, type PrometheusStatus } from './client'
|
|
7
|
+
|
|
8
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
9
|
+
|
|
10
|
+
function Settings({ open }: { open: boolean }) {
|
|
11
|
+
useMetricsRelayCheck(open)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const relay: PrometheusStatus = { available: true, connected: true, source: { kind: 'openobserve', via: 'local', matchedBy: 'id' } }
|
|
16
|
+
const down: PrometheusStatus = { available: false, connected: false, source: { kind: 'openobserve', via: 'local', matchedBy: 'id', unavailable: true, error: 'OpenObserve unavailable: connection refused' } }
|
|
17
|
+
|
|
18
|
+
async function settle() {
|
|
19
|
+
await act(async () => { await new Promise((r) => setTimeout(r, 20)) })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
it('checks the relay once each time Settings opens and keeps the answer', async () => {
|
|
23
|
+
const checks: string[] = []
|
|
24
|
+
let server = relay
|
|
25
|
+
vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input) => {
|
|
26
|
+
const url = String(input)
|
|
27
|
+
if (url.includes('check=true')) {
|
|
28
|
+
checks.push(url)
|
|
29
|
+
server = down
|
|
30
|
+
return new Response(JSON.stringify(down))
|
|
31
|
+
}
|
|
32
|
+
return new Response(JSON.stringify(server))
|
|
33
|
+
}))
|
|
34
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, refetchInterval: false } } })
|
|
35
|
+
client.setQueryData(['prometheus-status'], relay)
|
|
36
|
+
const root = createRoot(document.createElement('div'))
|
|
37
|
+
const render = (open: boolean) => act(async () => root.render(<QueryClientProvider client={client}><Settings open={open} /></QueryClientProvider>))
|
|
38
|
+
|
|
39
|
+
await render(false)
|
|
40
|
+
await settle()
|
|
41
|
+
expect(checks).toHaveLength(0)
|
|
42
|
+
|
|
43
|
+
await render(true)
|
|
44
|
+
await settle()
|
|
45
|
+
await render(true)
|
|
46
|
+
await settle()
|
|
47
|
+
expect(checks).toHaveLength(1)
|
|
48
|
+
expect(client.getQueryData<PrometheusStatus>(['prometheus-status'])?.source?.unavailable).toBe(true)
|
|
49
|
+
|
|
50
|
+
await render(false)
|
|
51
|
+
await render(true)
|
|
52
|
+
await settle()
|
|
53
|
+
expect(checks).toHaveLength(2)
|
|
54
|
+
act(() => root.unmount())
|
|
55
|
+
vi.unstubAllGlobals()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('never checks when metrics do not come through a relay', async () => {
|
|
59
|
+
const fetchMock = vi.fn<typeof fetch>(async () => new Response(JSON.stringify({ available: false, connected: false })))
|
|
60
|
+
vi.stubGlobal('fetch', fetchMock)
|
|
61
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, refetchInterval: false } } })
|
|
62
|
+
client.setQueryData(['prometheus-status'], { available: false, connected: false })
|
|
63
|
+
const root = createRoot(document.createElement('div'))
|
|
64
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Settings open /></QueryClientProvider>))
|
|
65
|
+
await settle()
|
|
66
|
+
expect(fetchMock.mock.calls.some(([u]) => String(u).includes('check=true'))).toBe(false)
|
|
67
|
+
act(() => root.unmount())
|
|
68
|
+
vi.unstubAllGlobals()
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
function deferred() {
|
|
72
|
+
let resolve!: () => void
|
|
73
|
+
const promise = new Promise<void>((r) => { resolve = r })
|
|
74
|
+
return { promise, resolve }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The check only changes what Radar knows; the status shown is read after it,
|
|
78
|
+
// so a newer status (here, saved settings that dropped OpenObserve) is never
|
|
79
|
+
// replaced by the check's older reply.
|
|
80
|
+
it('reads the status after the check instead of keeping its reply', async () => {
|
|
81
|
+
const answer = deferred()
|
|
82
|
+
const saved: PrometheusStatus = { available: false, connected: false }
|
|
83
|
+
let server = relay
|
|
84
|
+
vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input) => {
|
|
85
|
+
if (String(input).includes('check=true')) {
|
|
86
|
+
await answer.promise
|
|
87
|
+
return new Response(JSON.stringify(down))
|
|
88
|
+
}
|
|
89
|
+
return new Response(JSON.stringify(server))
|
|
90
|
+
}))
|
|
91
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, refetchInterval: false } } })
|
|
92
|
+
client.setQueryData(['prometheus-status'], relay)
|
|
93
|
+
const root = createRoot(document.createElement('div'))
|
|
94
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Settings open /></QueryClientProvider>))
|
|
95
|
+
await settle()
|
|
96
|
+
|
|
97
|
+
server = saved
|
|
98
|
+
client.setQueryData(['prometheus-status'], saved)
|
|
99
|
+
answer.resolve()
|
|
100
|
+
await settle()
|
|
101
|
+
expect(client.getQueryData(['prometheus-status'])).toEqual(saved)
|
|
102
|
+
act(() => root.unmount())
|
|
103
|
+
vi.unstubAllGlobals()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('closing Settings stops its check, and reopening starts a new one', async () => {
|
|
107
|
+
const signals: AbortSignal[] = []
|
|
108
|
+
vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input, init) => {
|
|
109
|
+
if (String(input).includes('check=true')) {
|
|
110
|
+
const signal = init?.signal as AbortSignal
|
|
111
|
+
signals.push(signal)
|
|
112
|
+
if (signals.length === 1) {
|
|
113
|
+
await new Promise((_, reject) => signal.addEventListener('abort', () => reject(new DOMException('aborted', 'AbortError'))))
|
|
114
|
+
}
|
|
115
|
+
return new Response(JSON.stringify(down))
|
|
116
|
+
}
|
|
117
|
+
return new Response(JSON.stringify(relay))
|
|
118
|
+
}))
|
|
119
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, refetchInterval: false } } })
|
|
120
|
+
client.setQueryData(['prometheus-status'], relay)
|
|
121
|
+
const root = createRoot(document.createElement('div'))
|
|
122
|
+
const render = (open: boolean) => act(async () => root.render(<QueryClientProvider client={client}><Settings open={open} /></QueryClientProvider>))
|
|
123
|
+
|
|
124
|
+
await render(true)
|
|
125
|
+
await settle()
|
|
126
|
+
await render(false)
|
|
127
|
+
await settle()
|
|
128
|
+
expect(signals[0]?.aborted).toBe(true)
|
|
129
|
+
await render(true)
|
|
130
|
+
await settle()
|
|
131
|
+
expect(signals).toHaveLength(2)
|
|
132
|
+
act(() => root.unmount())
|
|
133
|
+
vi.unstubAllGlobals()
|
|
134
|
+
})
|