@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
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// GET /api/agentsandbox/workspace?namespaces=radar-agents-live as a Radar
|
|
2
|
+
// built from this branch answered it against the live test cluster (a real
|
|
3
|
+
// agent-sandbox controller v1.0.11): nine Sandboxes, two claims, one template,
|
|
4
|
+
// one warm pool short of ready. Times are relative to now.
|
|
5
|
+
import type { AgentSandboxAttention, AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
|
|
6
|
+
|
|
7
|
+
const NS = 'radar-agents-live'
|
|
8
|
+
const hoursAgo = (h: number) => new Date(Date.now() - h * 3_600_000).toISOString()
|
|
9
|
+
export const minutesAgo = (m: number) => new Date(Date.now() - m * 60_000).toISOString()
|
|
10
|
+
|
|
11
|
+
const sandbox = (name: string) => ({ kind: 'Sandbox', group: 'agents.x-k8s.io', namespace: NS, name })
|
|
12
|
+
const claim = (name: string) => ({ kind: 'SandboxClaim', group: 'extensions.agents.x-k8s.io', namespace: NS, name })
|
|
13
|
+
const pool = (name: string) => ({ kind: 'SandboxWarmPool', group: 'extensions.agents.x-k8s.io', namespace: NS, name })
|
|
14
|
+
const pod = (name: string) => ({ kind: 'Pod', group: '', namespace: NS, name })
|
|
15
|
+
const FOREIGN_OWNERS = `kubectl get pod foreign -n ${NS} -o jsonpath='{.metadata.ownerReferences}'`
|
|
16
|
+
|
|
17
|
+
export function liveAttention(): AgentSandboxAttention[] {
|
|
18
|
+
// In the server's order: severity, then rule, then newest first.
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
id: `sandbox:${NS}/failed`, category: 'sandbox', rule: 'failed', reason: 'PodFailed', severity: 'critical',
|
|
22
|
+
title: 'Pod failed', nextStep: 'Read the Pod’s logs to see why it exited',
|
|
23
|
+
subject: sandbox('failed'), related: { lead: 'Its Pod:', refs: [pod('failed')] }, issue: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: `sandbox:${NS}/bad-image`, category: 'sandbox', rule: 'failed', reason: 'ErrImagePull', severity: 'critical',
|
|
27
|
+
title: 'Image can’t be pulled',
|
|
28
|
+
rawDetail: 'Pod exists with phase: Pending; container "agent" is waiting: ErrImagePull', rawDetailLabel: 'Controller’s message', rawDetailSource: 'controller',
|
|
29
|
+
nextStep: 'Check the image name and the registry credentials (imagePullSecrets) in the Sandbox’s Pod template',
|
|
30
|
+
subject: sandbox('bad-image'), related: { lead: 'Its Pod:', refs: [pod('bad-image')] }, issue: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: `sandbox:${NS}/foreign`, category: 'sandbox', rule: 'suspensionBlocked', reason: 'PodNotOwned', severity: 'warning',
|
|
34
|
+
title: 'Suspension blocked',
|
|
35
|
+
reading: 'The controller refuses to delete a Pod this Sandbox doesn’t own, so the suspension waits.',
|
|
36
|
+
rawDetail: 'Refused to delete pod because it is not owned by this sandbox', rawDetailLabel: 'Controller’s message', rawDetailSource: 'controller',
|
|
37
|
+
nextStep: `Check who owns Pod foreign (${FOREIGN_OWNERS}) before removing it, or recreate the Sandbox under another name`,
|
|
38
|
+
command: FOREIGN_OWNERS,
|
|
39
|
+
subject: sandbox('foreign'), related: { lead: 'The Pod it won’t delete:', refs: [pod('foreign')] }, issue: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: `warmPool:${NS}/warm`, category: 'warmPool', rule: 'reserveBelowTarget', reason: 'Warming', severity: 'alert',
|
|
43
|
+
title: 'Warm reserve below target: 0/2 ready',
|
|
44
|
+
reading: 'Its 2 sandboxes can’t be scheduled. No sandbox is ready in reserve, so a new claim takes one still starting or starts its own from the template (a slower, cold start).',
|
|
45
|
+
rawDetail: '0/4 nodes are available: 4 Too many pods. no new claims to deallocate, preemption: 0/4 nodes are available: 4 No preemption victims found for incoming pod.',
|
|
46
|
+
rawDetailLabel: 'Scheduler’s message', rawDetailSource: 'scheduler',
|
|
47
|
+
nextStep: 'Add nodes, raise the nodes’ max-pods limit, or remove Pods you no longer need',
|
|
48
|
+
subject: pool('warm'), related: { lead: 'Not ready:', refs: [sandbox('warm-nd2zw'), sandbox('warm-4xmkm')] },
|
|
49
|
+
relations: [{ role: 'template', ref: { kind: 'SandboxTemplate', group: 'extensions.agents.x-k8s.io', namespace: NS, name: 'tmpl' }, presence: 'present' }],
|
|
50
|
+
waitingClaims: { count: 0, lowerBound: false },
|
|
51
|
+
issue: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: `claim:${NS}/claim-missing-pool`, category: 'claim', rule: 'cannotBind', reason: 'WarmPoolNotFound', severity: 'warning',
|
|
55
|
+
title: 'Warm pool not found',
|
|
56
|
+
rawDetail: 'SandboxWarmPool "no-such-pool" not found', rawDetailLabel: 'Controller’s message', rawDetailSource: 'controller',
|
|
57
|
+
nextStep: 'Create SandboxWarmPool no-such-pool in radar-agents-live, or point the claim at an existing pool',
|
|
58
|
+
subject: claim('claim-missing-pool'),
|
|
59
|
+
relations: [{ role: 'warmPool', ref: pool('no-such-pool'), presence: 'absent' }],
|
|
60
|
+
issue: true,
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function liveWorkspace(overrides: Partial<AgentSandboxWorkspaceResponse> = {}): AgentSandboxWorkspaceResponse {
|
|
66
|
+
return {
|
|
67
|
+
context: 'radar-test-management',
|
|
68
|
+
installed: true,
|
|
69
|
+
namespaces: [NS],
|
|
70
|
+
coverage: { claims: { state: 'full' }, sandboxes: { state: 'full' }, templates: { state: 'full' }, warmPools: { state: 'full' } },
|
|
71
|
+
controller: { state: 'running', namespace: 'agent-sandbox-system', name: 'agent-sandbox-controller', ready: 1, desired: 1 },
|
|
72
|
+
counts: {
|
|
73
|
+
sandboxes: { total: 9, lowerBound: false, running: 0, starting: 0, unschedulable: 2, suspended: 1, suspensionBlocked: 1, expired: 2, finished: 1, failed: 2, terminating: 0, unknown: 0 },
|
|
74
|
+
claims: { total: 2, lowerBound: false, bound: 0, waiting: 1, expired: 1 },
|
|
75
|
+
warmPools: { total: 1, lowerBound: false, ready: 0, desired: 2 },
|
|
76
|
+
},
|
|
77
|
+
attention: liveAttention(),
|
|
78
|
+
attentionTotal: 5,
|
|
79
|
+
attentionObjects: {
|
|
80
|
+
sandboxes: ['bad-image', 'failed', 'foreign', 'warm-4xmkm', 'warm-nd2zw'].map((name) => `${NS}/${name}`),
|
|
81
|
+
claims: [`${NS}/claim-missing-pool`],
|
|
82
|
+
warmPools: [`${NS}/warm`],
|
|
83
|
+
},
|
|
84
|
+
attentionComplete: true,
|
|
85
|
+
sidebar: {
|
|
86
|
+
total: { count: 7, lowerBound: false },
|
|
87
|
+
sandboxes: { count: 5, lowerBound: false },
|
|
88
|
+
claims: { count: 1, lowerBound: false },
|
|
89
|
+
warmPools: { count: 1, lowerBound: false },
|
|
90
|
+
},
|
|
91
|
+
warmPools: [
|
|
92
|
+
{ namespace: NS, name: 'warm', state: { text: 'Warming', level: 'degraded' }, ready: 0, desired: 2, template: 'tmpl', templatePresence: 'present', claims: { total: 1, bound: 0 }, created: hoursAgo(42) },
|
|
93
|
+
],
|
|
94
|
+
warmPoolsTotal: 1,
|
|
95
|
+
expired: {
|
|
96
|
+
recent: [
|
|
97
|
+
{ ref: sandbox('running'), at: hoursAgo(39) },
|
|
98
|
+
{ ref: claim('claim-ok'), at: hoursAgo(39) },
|
|
99
|
+
{ ref: sandbox('expired'), at: hoursAgo(43) },
|
|
100
|
+
],
|
|
101
|
+
recentTotal: 3,
|
|
102
|
+
lowerBound: false,
|
|
103
|
+
},
|
|
104
|
+
...overrides,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Nothing installed in scope beyond the CRDs: every kind read in full and empty. */
|
|
109
|
+
export function emptyWorkspace(overrides: Partial<AgentSandboxWorkspaceResponse> = {}): AgentSandboxWorkspaceResponse {
|
|
110
|
+
return liveWorkspace({
|
|
111
|
+
counts: {
|
|
112
|
+
sandboxes: { total: 0, lowerBound: false, running: 0, starting: 0, unschedulable: 0, suspended: 0, suspensionBlocked: 0, expired: 0, finished: 0, failed: 0, terminating: 0, unknown: 0 },
|
|
113
|
+
claims: { total: 0, lowerBound: false, bound: 0, waiting: 0, expired: 0 },
|
|
114
|
+
warmPools: { total: 0, lowerBound: false, ready: 0, desired: 0 },
|
|
115
|
+
},
|
|
116
|
+
attention: [],
|
|
117
|
+
attentionTotal: 0,
|
|
118
|
+
attentionObjects: { sandboxes: [], claims: [], warmPools: [] },
|
|
119
|
+
sidebar: { total: { count: 0, lowerBound: false }, sandboxes: { count: 0, lowerBound: false }, claims: { count: 0, lowerBound: false }, warmPools: { count: 0, lowerBound: false } },
|
|
120
|
+
warmPools: [],
|
|
121
|
+
warmPoolsTotal: 0,
|
|
122
|
+
expired: { recent: [], recentTotal: 0, lowerBound: false },
|
|
123
|
+
...overrides,
|
|
124
|
+
})
|
|
125
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { Boxes } from 'lucide-react'
|
|
3
|
+
import type { UseQueryResult } from '@tanstack/react-query'
|
|
4
|
+
import { PaneLoader, RadarUpgradeAction, getRadarUpgradeRequirement, radarUpgradeDetail, radarUpgradeHeadline, type StatusTone, type WorkspaceProblem } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { formatDuration, summarizeSchedulerMessage } from '@skyhook-io/k8s-ui/components/resources/resource-utils'
|
|
6
|
+
import { gapReasonText } from '@skyhook-io/k8s-ui/utils/read-actions'
|
|
7
|
+
import type {
|
|
8
|
+
AgentSandboxAttention,
|
|
9
|
+
AgentSandboxController,
|
|
10
|
+
AgentSandboxCount,
|
|
11
|
+
AgentSandboxRelation,
|
|
12
|
+
AgentSandboxWorkspaceKey,
|
|
13
|
+
AgentSandboxWorkspaceResponse,
|
|
14
|
+
} from '../../api/agentSandbox'
|
|
15
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
16
|
+
import { INCOMPLETE_COVERAGE_STATES, coverageLabel } from '../workspace/coverage'
|
|
17
|
+
import { Notice, RefreshFailedNotice, ScreenEmptyState } from '../workspace/layout'
|
|
18
|
+
import { KIND_LABEL, KIND_LIST_PERMISSION } from './shared'
|
|
19
|
+
|
|
20
|
+
// Presentation of GET /api/agentsandbox/workspace. The server decides every
|
|
21
|
+
// reading, row and count; this file only words them.
|
|
22
|
+
|
|
23
|
+
/** A row's severity as the health tone the problem components color by. */
|
|
24
|
+
export function severityTone(s: AgentSandboxAttention['severity']): 'unhealthy' | 'alert' | 'degraded' {
|
|
25
|
+
return s === 'critical' ? 'unhealthy' : s === 'alert' ? 'alert' : 'degraded'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Why the controller Deployment was not read, from its pkg/readreason code.
|
|
29
|
+
const CONTROLLER_UNREAD: Record<string, string> = {
|
|
30
|
+
user_forbidden: 'no access',
|
|
31
|
+
outside_namespace_pin: 'outside Radar’s namespace scope',
|
|
32
|
+
radar_namespace_not_collected: 'not collected by Radar',
|
|
33
|
+
radar_kind_not_collected: 'not collected by Radar',
|
|
34
|
+
kind_sync_pending: 'still loading',
|
|
35
|
+
kind_sync_timed_out: 'loading is overdue',
|
|
36
|
+
read_error: 'couldn’t be read',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Radar's Issues raise an in-progress state after this (pkg/agentsandbox IncidentAfter). */
|
|
40
|
+
export const ISSUE_AFTER_MINUTES = 30
|
|
41
|
+
|
|
42
|
+
const sentenceCase = (t: string) => (t ? `${t[0].toUpperCase()}${t.slice(1)}` : t)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* How long a row's state has lasted, beside its title, from the server's
|
|
46
|
+
* `since`. For most rules `since` is the latest condition transition Radar
|
|
47
|
+
* can see, and a condition keeps its transition time when only its reason
|
|
48
|
+
* changes, so the state began no earlier: the age is a ceiling, shown "up to 1d 2h".
|
|
49
|
+
* The controller's row is a real status flip, so its age is exact. Nothing
|
|
50
|
+
* without `since`; creation time would claim more than Radar knows.
|
|
51
|
+
*/
|
|
52
|
+
export function attentionAge(a: AgentSandboxAttention, now = Date.now()): { text: string; tip: string } | undefined {
|
|
53
|
+
const at = a.since ? Date.parse(a.since) : NaN
|
|
54
|
+
if (!Number.isFinite(at) || now <= at) return undefined
|
|
55
|
+
if (a.rule === 'controllerNotRunning') {
|
|
56
|
+
const d = formatDuration(now - at)
|
|
57
|
+
return { text: d, tip: `Not running for ${d}, since its Available condition turned False.` }
|
|
58
|
+
}
|
|
59
|
+
const d = ceilingDuration(now - at)
|
|
60
|
+
return {
|
|
61
|
+
text: `up to ${d}`,
|
|
62
|
+
tip: `Began up to ${d} ago. Radar sees when the condition last changed; Kubernetes keeps that time when only the reason changes, so this state may have begun later.`,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const MINUTE = 60_000
|
|
67
|
+
const HOUR = 60 * MINUTE
|
|
68
|
+
const DAY = 24 * HOUR
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A duration rounded up, never down, since it is shown as an upper bound:
|
|
72
|
+
* 90 minutes is "1h 30m", 61m 10s is "1h 2m", a day and an hour and a bit is "1d 2h".
|
|
73
|
+
*/
|
|
74
|
+
export function ceilingDuration(ms: number): string {
|
|
75
|
+
const up = (unit: number) => Math.ceil(ms / unit) * unit
|
|
76
|
+
if (ms < MINUTE) return formatDuration(up(1000))
|
|
77
|
+
if (ms < HOUR) return formatDuration(up(MINUTE))
|
|
78
|
+
const rounded = ms < DAY ? up(MINUTE) : up(HOUR)
|
|
79
|
+
return formatDuration(rounded, true).replace(/ 0[hm]$/, '')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A row's title: the server's, which carries no elapsed time. */
|
|
83
|
+
export function attentionTitle(a: AgentSandboxAttention): string {
|
|
84
|
+
return a.title
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The reading in plain words: the server's reading, the scheduler's verdict
|
|
89
|
+
* put plainly when it is the source, and for a slow state that it is an
|
|
90
|
+
* advisory Radar's Issues don't raise yet.
|
|
91
|
+
*/
|
|
92
|
+
export function attentionDetail(a: AgentSandboxAttention): string | undefined {
|
|
93
|
+
const parts: string[] = []
|
|
94
|
+
if (a.reading) parts.push(a.reading)
|
|
95
|
+
if (a.rawDetailSource === 'scheduler' && a.rawDetail) {
|
|
96
|
+
const plain = summarizeSchedulerMessage(a.rawDetail, { plain: true })
|
|
97
|
+
if (plain) parts.push(`Scheduler: ${plain}.`)
|
|
98
|
+
}
|
|
99
|
+
if (a.rule === 'slow') parts.push(`Radar’s Issues raise it after ${ISSUE_AFTER_MINUTES} minutes.`)
|
|
100
|
+
return parts.length ? parts.join(' ') : undefined
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The row as a WorkspaceProblem, for a drawer's callout and "See in Issues".
|
|
105
|
+
* A callout has no place of its own for the caveat, so it leads the detail.
|
|
106
|
+
*/
|
|
107
|
+
export function attentionProblem(a: AgentSandboxAttention): WorkspaceProblem {
|
|
108
|
+
const detail = [a.caveat, attentionDetail(a)].filter(Boolean).join(' ')
|
|
109
|
+
return {
|
|
110
|
+
id: a.id,
|
|
111
|
+
category: a.category,
|
|
112
|
+
title: attentionTitle(a),
|
|
113
|
+
detail: detail || undefined,
|
|
114
|
+
rawDetail: a.rawDetail,
|
|
115
|
+
rawDetailLabel: a.rawDetailLabel,
|
|
116
|
+
nextStep: a.nextStep,
|
|
117
|
+
subject: { kind: a.subject.kind, group: a.subject.group, namespace: a.subject.namespace ?? '', name: a.subject.name },
|
|
118
|
+
related: a.related ? { lead: a.related.lead, refs: a.related.refs.map((r) => ({ ...r, namespace: r.namespace ?? '' })) } : undefined,
|
|
119
|
+
...(a.issue ? { source: 'issue' as const } : { source: 'reading' as const }),
|
|
120
|
+
tone: severityTone(a.severity),
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const ROLE_LABEL: Record<AgentSandboxRelation['role'], string> = { warmPool: 'Warm pool', template: 'Template', sandbox: 'Sandbox', owner: 'Owner' }
|
|
125
|
+
|
|
126
|
+
export function relationLabel(r: AgentSandboxRelation): string {
|
|
127
|
+
if (r.role === 'owner') return r.ref.kind === 'SandboxWarmPool' ? 'Warm pool' : r.ref.kind === 'SandboxClaim' ? 'Claim' : r.ref.kind
|
|
128
|
+
return ROLE_LABEL[r.role]
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** What a relation's presence says: absent only where its kind was read in full there. */
|
|
132
|
+
export const PRESENCE_TEXT: Record<AgentSandboxRelation['presence'], string | undefined> = { present: undefined, absent: 'not found', unread: 'not read' }
|
|
133
|
+
|
|
134
|
+
// The controller's since is its Available=False transition, a real status
|
|
135
|
+
// flip, so its age is exact.
|
|
136
|
+
const withHeld = (text: string, since: string | undefined, now = Date.now()) => {
|
|
137
|
+
const at = since ? Date.parse(since) : NaN
|
|
138
|
+
return Number.isFinite(at) && now > at ? `${text} for ${formatDuration(now - at)}` : text
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function controllerValue(c: AgentSandboxController): { value: string; tone: StatusTone; unknown: boolean } {
|
|
142
|
+
switch (c.state) {
|
|
143
|
+
case 'running':
|
|
144
|
+
return { value: c.ready !== undefined && c.desired !== undefined ? `Running (${c.ready}/${c.desired} ready)` : 'Running', tone: 'healthy', unknown: false }
|
|
145
|
+
case 'notReady':
|
|
146
|
+
return { value: withHeld('Not ready', c.since), tone: 'unhealthy', unknown: false }
|
|
147
|
+
case 'scaledToZero':
|
|
148
|
+
return { value: withHeld('Scaled to zero', c.since), tone: 'unhealthy', unknown: false }
|
|
149
|
+
case 'notInstalled':
|
|
150
|
+
return { value: 'Not installed', tone: 'neutral', unknown: false }
|
|
151
|
+
case 'notFound':
|
|
152
|
+
return { value: `Unknown — not found as ${c.namespace}/${c.name}`, tone: 'unknown', unknown: true }
|
|
153
|
+
}
|
|
154
|
+
if (c.code === 'user_forbidden') {
|
|
155
|
+
return { value: `Unknown — no access (missing get deployments in namespace ${c.namespace})`, tone: 'unknown', unknown: true }
|
|
156
|
+
}
|
|
157
|
+
const why = c.code ? CONTROLLER_UNREAD[c.code] ?? gapReasonText(c.code) : 'not read'
|
|
158
|
+
return { value: `Unknown — ${why}`, tone: 'unknown', unknown: true }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** "Unknown — no access (missing ...)" for a kind the summary left out; "Not installed" for one whose CRD isn't served. */
|
|
162
|
+
export function leftOutText(data: AgentSandboxWorkspaceResponse, key: AgentSandboxWorkspaceKey): string {
|
|
163
|
+
const cov = data.coverage[key]
|
|
164
|
+
if (cov?.state === 'notInstalled') return 'Not installed'
|
|
165
|
+
if (cov?.state === 'denied') return `Unknown — no access (missing ${KIND_LIST_PERMISSION[key]})`
|
|
166
|
+
return `Unknown — ${coverageLabel(cov)}`
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** A badge from the server's count: "≥N" for a lower bound, the unknown dash for a lower-bound zero. */
|
|
170
|
+
export function sidebarCount(c: AgentSandboxCount, noun: [string, string]): { count: number | null; lowerBound: boolean; title: string } {
|
|
171
|
+
if (c.count === null) {
|
|
172
|
+
return { count: null, lowerBound: true, title: `Unknown: Radar couldn’t read every ${noun[0]}, so nothing found doesn’t mean nothing needs attention.` }
|
|
173
|
+
}
|
|
174
|
+
const partial = c.lowerBound ? ' Some couldn’t be read, so there may be more.' : ''
|
|
175
|
+
const unit = c.count === 1 ? `${noun[0]} needs attention` : `${noun[1]} need attention`
|
|
176
|
+
return {
|
|
177
|
+
count: c.count,
|
|
178
|
+
lowerBound: c.lowerBound,
|
|
179
|
+
title: `${c.lowerBound ? 'At least ' : ''}${c.count} ${unit}.${partial}`,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Says which kinds the summary read only in part, and why. */
|
|
184
|
+
export function WorkspaceCoverageNotice({ data }: { data: AgentSandboxWorkspaceResponse }) {
|
|
185
|
+
const gaps = (['sandboxes', 'claims', 'warmPools', 'templates'] as const).flatMap((k) => {
|
|
186
|
+
const cov = data.coverage[k]
|
|
187
|
+
if (!cov || !INCOMPLETE_COVERAGE_STATES.has(cov.state)) return []
|
|
188
|
+
const detail = cov.state === 'denied' ? `no access — missing ${KIND_LIST_PERMISSION[k]}` : coverageLabel(cov)
|
|
189
|
+
return [`${KIND_LABEL[k]} (${detail})`]
|
|
190
|
+
})
|
|
191
|
+
const controller = controllerValue(data.controller)
|
|
192
|
+
if (controller.unknown) gaps.push(`the controller Deployment (${controller.value.replace(/^Unknown — /, '')})`)
|
|
193
|
+
if (gaps.length === 0 && !data.forcedNamespace) return null
|
|
194
|
+
return (
|
|
195
|
+
<Notice>
|
|
196
|
+
{data.forcedNamespace && <>Radar is limited to namespace {data.forcedNamespace}. </>}
|
|
197
|
+
{gaps.length > 0 && <>Radar couldn’t read all of Agent Sandbox here: {gaps.join('; ')}. What it couldn’t read shows as unknown, and the counts that rest on it as lower bounds.</>}
|
|
198
|
+
</Notice>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
type WorkspaceQuery = Pick<UseQueryResult<AgentSandboxWorkspaceResponse>, 'data' | 'error' | 'isLoading' | 'isFetching' | 'refetch' | 'isRefetchError' | 'dataUpdatedAt'>
|
|
203
|
+
|
|
204
|
+
/** Loading, needs-newer-Radar, error and not-installed states of the Overview, as Velero's gate. */
|
|
205
|
+
export function AgentSandboxWorkspaceGate({
|
|
206
|
+
query,
|
|
207
|
+
discoveryPending,
|
|
208
|
+
discovered,
|
|
209
|
+
children,
|
|
210
|
+
}: {
|
|
211
|
+
query: WorkspaceQuery
|
|
212
|
+
discoveryPending: boolean
|
|
213
|
+
discovered: boolean
|
|
214
|
+
children: (data: AgentSandboxWorkspaceResponse) => ReactNode
|
|
215
|
+
}) {
|
|
216
|
+
const { connection } = useConnection()
|
|
217
|
+
const data = query.data
|
|
218
|
+
const notInstalled = <ScreenEmptyState icon={Boxes} title="Agent Sandbox is not installed" detail={`No agents.x-k8s.io resources are served in ${connection.context || 'this cluster'}.`} />
|
|
219
|
+
if (!data && (query.isLoading || discoveryPending)) return <PaneLoader label="Loading Agent Sandbox…" className="flex-1" />
|
|
220
|
+
if (!data && !discovered) return notInstalled
|
|
221
|
+
if (!data) {
|
|
222
|
+
const upgrade = getRadarUpgradeRequirement(query.error)
|
|
223
|
+
if (upgrade) {
|
|
224
|
+
return (
|
|
225
|
+
<ScreenEmptyState
|
|
226
|
+
icon={Boxes}
|
|
227
|
+
title={radarUpgradeHeadline('The Agent Sandbox overview')}
|
|
228
|
+
detail={radarUpgradeDetail(upgrade)}
|
|
229
|
+
action={
|
|
230
|
+
<div className="mt-3 text-sm">
|
|
231
|
+
<RadarUpgradeAction requirement={upgrade} />
|
|
232
|
+
<p className="mt-2 text-theme-text-tertiary">The Sandboxes, Claims and Warm pools lists work on this Radar.</p>
|
|
233
|
+
</div>
|
|
234
|
+
}
|
|
235
|
+
/>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
return (
|
|
239
|
+
<ScreenEmptyState
|
|
240
|
+
icon={Boxes}
|
|
241
|
+
title="Agent Sandbox data unavailable"
|
|
242
|
+
detail={query.error instanceof Error ? sentenceCase(query.error.message) : 'Radar could not load the Agent Sandbox overview.'}
|
|
243
|
+
action={
|
|
244
|
+
<button type="button" onClick={() => void query.refetch()} disabled={query.isFetching} className="btn-secondary mt-3 px-3 py-1.5 text-sm">
|
|
245
|
+
{query.isFetching ? 'Retrying…' : 'Retry'}
|
|
246
|
+
</button>
|
|
247
|
+
}
|
|
248
|
+
/>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
if (!data.installed) return notInstalled
|
|
252
|
+
return (
|
|
253
|
+
<>
|
|
254
|
+
<RefreshFailedNotice queries={[query]} className="px-5 pt-3 xl:px-7" />
|
|
255
|
+
{children(data)}
|
|
256
|
+
</>
|
|
257
|
+
)
|
|
258
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WorkspaceRoute } from '../../integrations/workspaceRoute'
|
|
2
|
+
import { AGENT_SANDBOX_OVERVIEW } from './routes'
|
|
3
|
+
|
|
4
|
+
export const agentSandboxWorkspaceRoute: WorkspaceRoute = {
|
|
5
|
+
id: 'agent-sandbox',
|
|
6
|
+
path: AGENT_SANDBOX_OVERVIEW.path,
|
|
7
|
+
label: 'Agent Sandbox',
|
|
8
|
+
navView: 'resources',
|
|
9
|
+
// Sandboxes, claims and warm pools are namespaced app objects: the filter applies.
|
|
10
|
+
namespaceScope: 'view',
|
|
11
|
+
pageTitle() {
|
|
12
|
+
return AGENT_SANDBOX_OVERVIEW.title
|
|
13
|
+
},
|
|
14
|
+
// The Overview follows the active cluster; there is no per-object page to pin.
|
|
15
|
+
contextSwitchSearch() {
|
|
16
|
+
return new URLSearchParams()
|
|
17
|
+
},
|
|
18
|
+
}
|