@skyhook-io/radar-app 1.22.2 → 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 +35 -10
- 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 +122 -24
- 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 +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 +127 -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/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/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/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/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 +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,462 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
|
+
import { toneFillClass } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
6
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
7
|
+
import type { SubstratePool, SubstrateWorkerRow, SubstrateWorkers } from '../../api/substrateWorkspace'
|
|
8
|
+
import { ApiError } from '../../api/client'
|
|
9
|
+
import { SubstrateWorkerPodContext, SubstrateWorkerPodScope } from './SubstrateWorkerPodContext'
|
|
10
|
+
import { PLACEMENT_CARD_LIMIT, Placement, PoolSpecStatus, SubstratePoolSummary, workerSlots } from './SubstratePoolSummary'
|
|
11
|
+
import { actorAttentionText } from './SubstrateActorOverview'
|
|
12
|
+
import { actorDetail, connectedTier, minutesAgo, workspace } from './substrate.fixtures'
|
|
13
|
+
|
|
14
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-demo' } }) }))
|
|
15
|
+
|
|
16
|
+
const text = (html: string) => html.replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&').replace(/<\/?span[^>]*>/g, '')
|
|
17
|
+
|
|
18
|
+
const state = vi.hoisted(() => ({ pool: undefined as SubstratePool | undefined, workers: undefined as SubstrateWorkers | undefined, workerError: null as Error | null, poolError: null as Error | null, poolLoading: false }))
|
|
19
|
+
vi.mock('../../api/substrateWorkspace', async (original) => ({
|
|
20
|
+
...(await original<typeof import('../../api/substrateWorkspace')>()),
|
|
21
|
+
useSubstratePool: () => ({ data: state.pool, isLoading: state.poolLoading, error: state.poolError }),
|
|
22
|
+
useSubstrateWorkers: () => ({ data: state.workers, isLoading: false, error: state.workerError, isRefetchError: !!state.workers && !!state.workerError, dataUpdatedAt: Date.now() }),
|
|
23
|
+
}))
|
|
24
|
+
vi.mock('../../api/client', async (original) => ({
|
|
25
|
+
...(await original<typeof import('../../api/client')>()),
|
|
26
|
+
usePrometheusStatus: () => ({ data: { connected: false } }),
|
|
27
|
+
}))
|
|
28
|
+
vi.mock('../../api/substrateHealth', async (original) => ({
|
|
29
|
+
...(await original<typeof import('../../api/substrateHealth')>()),
|
|
30
|
+
useSubstrateHealth: () => ({ support: 'supported' }),
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
function worker(i: number, overrides: Partial<SubstrateWorkerRow> = {}): SubstrateWorkerRow {
|
|
34
|
+
return {
|
|
35
|
+
name: `w-${i}`,
|
|
36
|
+
namespace: 'agents',
|
|
37
|
+
pool: 'agent-pool',
|
|
38
|
+
pod: `agent-pool-worker-${i}`,
|
|
39
|
+
node: 'ip-10-0-16-162.ec2.internal',
|
|
40
|
+
state: 'active',
|
|
41
|
+
capacity: { cpuMillicores: 16000, memoryBytes: 64 * 1024 ** 3, actors: 4 },
|
|
42
|
+
allocated: { cpuMillicores: 4000, memoryBytes: 8 * 1024 ** 3, actors: 2 },
|
|
43
|
+
registeredEpoch: 1,
|
|
44
|
+
observedEpoch: 1,
|
|
45
|
+
hasFreeSlot: true,
|
|
46
|
+
heldForSeconds: 3600,
|
|
47
|
+
podReady: true,
|
|
48
|
+
actors: [
|
|
49
|
+
{ atespace: 'research', name: 'lit-review-0193', state: 'running', template: { atespace: 'research', name: 'lg' } },
|
|
50
|
+
{ atespace: 'research', name: 'lit-review-0194', state: 'resuming', template: { atespace: 'research', name: 'lg' } },
|
|
51
|
+
],
|
|
52
|
+
...overrides,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function pool(workers: SubstrateWorkerRow[], desired = workers.length): SubstratePool {
|
|
57
|
+
return {
|
|
58
|
+
apiTier: connectedTier,
|
|
59
|
+
pool: { namespace: 'agents', name: 'agent-pool', kubernetes: { namespace: 'agents', name: 'agent-pool', desired, reportedReady: workers.length, health: 'healthy', healthReason: '' } },
|
|
60
|
+
workers,
|
|
61
|
+
templates: [{ atespace: 'research', name: 'lg' }],
|
|
62
|
+
coverage: { workers: { state: 'full' }, actors: { state: 'full' }, templates: { state: 'full' }, pools: { state: 'full' } },
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const raw = (data: SubstratePool) => renderToStaticMarkup(<MemoryRouter><Placement data={data} onOpenActor={() => {}} onOpenPod={() => {}} /></MemoryRouter>)
|
|
67
|
+
const render = (data: SubstratePool) => text(renderToStaticMarkup(<MemoryRouter><Placement data={data} onOpenActor={() => {}} onOpenPod={() => {}} /></MemoryRouter>))
|
|
68
|
+
|
|
69
|
+
describe('WorkerPool placement', () => {
|
|
70
|
+
it('draws one card per worker with a cell per actor, and counts the free slots in words, not cells', () => {
|
|
71
|
+
const html = render(pool([worker(0)]))
|
|
72
|
+
expect(html).toContain('agent-pool-worker-0')
|
|
73
|
+
expect(html).toContain('lit-review-0193')
|
|
74
|
+
// Free slots have no position, so they are a count: no cell repeats "free".
|
|
75
|
+
expect(html).not.toContain('border-dashed')
|
|
76
|
+
expect(html).not.toMatch(/>free</)
|
|
77
|
+
expect(html).toContain('2 of 4 actor slots used · 2 free')
|
|
78
|
+
// What the figures are, from Substrate's fields: what its actors request of the capacity it reports, not usage.
|
|
79
|
+
expect(html).toContain('4 of 16 CPU · 8Gi of 64Gi reserved')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
it('says a worker that takes no new actors has unused slots, not free ones, and when its Pod is Ready', () => {
|
|
83
|
+
const html = render(pool([worker(0, { state: 'unavailable' })]))
|
|
84
|
+
expect(html).toContain('2 of 4 actor slots used · 2 unused · takes no new actors')
|
|
85
|
+
expect(html).not.toContain('2 free')
|
|
86
|
+
expect(html).toContain('Its Pod is Ready, so the worker, not Kubernetes, is refusing work.')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('keeps an unknown capacity unknown, never zero free', () => {
|
|
90
|
+
const html = render(pool([worker(0, { capacity: undefined })]))
|
|
91
|
+
expect(html).toContain('2 actors · slot capacity unknown')
|
|
92
|
+
expect(html).not.toContain('0 free')
|
|
93
|
+
expect(html).not.toContain('0 slots')
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('lets each card end at its content, in row order', () => {
|
|
97
|
+
expect(raw(pool([worker(0), worker(1)]))).toMatch(/class="grid items-start gap-3/)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('hides the placement and legend when no workers have registered', () => {
|
|
101
|
+
expect(render(pool([], 3))).toBe('')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('shows observed workers only when Substrate’s inventory is partial', () => {
|
|
105
|
+
const data = { ...pool([worker(0)], 3), coverage: { ...pool([]).coverage, workers: { state: 'partial' as const, code: 'capExceeded' as const } } }
|
|
106
|
+
const html = render(data)
|
|
107
|
+
expect(html).toContain('agent-pool-worker-0')
|
|
108
|
+
expect(html).toContain('Observed workers only')
|
|
109
|
+
expect(html).not.toContain('not registered')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('becomes one row per worker with a slot bar past the card limit', () => {
|
|
113
|
+
const many = Array.from({ length: PLACEMENT_CARD_LIMIT + 1 }, (_, i) => worker(i))
|
|
114
|
+
const html = render(pool(many))
|
|
115
|
+
expect(html).toContain('role="img" aria-label="2 of 4 slots used"')
|
|
116
|
+
expect(html).not.toContain('lit-review-0193')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('says 0 slots for a worker that reports no actor capacity', () => {
|
|
120
|
+
const html = render(pool([worker(0, { capacity: { cpuMillicores: 1, memoryBytes: 1, actors: 0 }, allocated: { cpuMillicores: 0, memoryBytes: 0, actors: 0 }, actors: [] })]))
|
|
121
|
+
expect(html).toContain('0 slots: the worker reports no actor capacity')
|
|
122
|
+
expect(workerSlots({ capacity: undefined, allocated: undefined, actors: undefined }).total).toBeUndefined()
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('says which actor holds a slot is unknown when actors were not read', () => {
|
|
126
|
+
const html = render(pool([worker(0, { actors: undefined })]))
|
|
127
|
+
expect(html).toContain('Actors were not read')
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
describe('WorkerPool Overview', () => {
|
|
132
|
+
function overview(data: SubstratePool, ready = data.pool.kubernetes?.reportedReady, framed = true) {
|
|
133
|
+
state.pool = data
|
|
134
|
+
const resource = { spec: { replicas: data.pool.kubernetes?.desired }, status: { readyReplicas: ready } }
|
|
135
|
+
return text(renderToStaticMarkup(<MemoryRouter><SubstratePoolSummary namespace="agents" name="agent-pool" resource={resource} context={framed ? 'expanded' : 'drawer'} /></MemoryRouter>))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
it('keeps registrations, requested workers and observed Pod readiness separate above the placement grid', () => {
|
|
139
|
+
const data = pool([worker(0), worker(1, { state: 'unavailable' })], 5)
|
|
140
|
+
data.pool.kubernetes!.pods = { created: 0, ready: 0, terminating: 0 }
|
|
141
|
+
data.pool.placement = { workers: { total: 2, active: 1, draining: 0, unavailable: 1 }, slots: { used: 2, total: 4 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: true }
|
|
142
|
+
const html = overview(data, 2)
|
|
143
|
+
expect(html).toContain('5 desired by spec')
|
|
144
|
+
expect(html).toContain('2 ready reported by controller')
|
|
145
|
+
expect(html).toContain('Pods observed by Radar: 0 present, 0 ready')
|
|
146
|
+
expect(html).toContain('Counts differ from the controller’s status')
|
|
147
|
+
expect(html.replace(/<[^>]+>/g, '')).toContain('2 registered · 1 accepting actors')
|
|
148
|
+
expect(html.indexOf('At a glance')).toBeLessThan(html.indexOf('agent-pool-worker-0'))
|
|
149
|
+
expect(html).toContain('Prometheus is not connected')
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('renders a partial registration count as a lower bound and an unread count as unknown', () => {
|
|
153
|
+
const data = pool([worker(0)], 3)
|
|
154
|
+
data.coverage.workers = { state: 'partial', deniedAtespaces: ['restricted'] }
|
|
155
|
+
data.pool.placement = { workers: { total: 1, active: 1, draining: 0, unavailable: 0 }, slots: { used: 2, total: 4 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: false }
|
|
156
|
+
const partial = overview(data).replace(/<[^>]+>/g, '')
|
|
157
|
+
expect(partial).toContain('≥1 registered · ≥1 accepting actors')
|
|
158
|
+
data.pool.placement.workers = { total: 1, active: 0, draining: 1, unavailable: 0 }
|
|
159
|
+
data.pool.placement.slots = { used: 0, total: 0 }
|
|
160
|
+
const zeroObserved = overview(data).replace(/<[^>]+>/g, '')
|
|
161
|
+
expect(zeroObserved).toContain('≥1 registered · accepting actors unknown')
|
|
162
|
+
expect(zeroObserved).toContain('Placement capacityUnknown')
|
|
163
|
+
expect(zeroObserved).not.toMatch(/≥\s*0/)
|
|
164
|
+
const denied = pool([], 3)
|
|
165
|
+
denied.coverage.workers = { state: 'denied', code: 'denied' }
|
|
166
|
+
const unread = overview(denied, 3).replace(/<[^>]+>/g, '')
|
|
167
|
+
expect(unread).toContain('RegistrationUnknown')
|
|
168
|
+
expect(unread).toContain('Substrate denied permission to list workers')
|
|
169
|
+
expect(unread).toContain('3 ready reported by controller')
|
|
170
|
+
expect(unread).not.toContain('0 registered')
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('leads with the distinct provisioning cause and has flat drawer sections', () => {
|
|
174
|
+
const data = pool([], 3)
|
|
175
|
+
data.pool.kubernetes!.health = 'unhealthy'
|
|
176
|
+
data.pool.kubernetes!.healthReason = 'SandboxConfigNotFound'
|
|
177
|
+
data.attention = { id: 'broken', rule: 'poolShort', severity: 'critical', title: 'Missing config', reading: 'SandboxConfig gvisor-v2 is missing.', nextStep: 'Restore the SandboxConfig.', subject: { kind: 'WorkerPool', namespace: 'agents', name: 'agent-pool' }, count: 3 }
|
|
178
|
+
const html = overview(data, 0, false)
|
|
179
|
+
expect(html).toContain('Sandbox configuration missing')
|
|
180
|
+
expect(html).toContain('SandboxConfig gvisor-v2 is missing.')
|
|
181
|
+
expect(html).toContain('Restore the SandboxConfig.')
|
|
182
|
+
expect(html).toContain('Open pool')
|
|
183
|
+
expect(html).not.toContain('aria-label="Legend"')
|
|
184
|
+
expect(html).not.toContain('shadow-theme-sm')
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
describe('Needs attention on an actor’s page', () => {
|
|
189
|
+
it('says a stuck transition about this actor, not the longest one', () => {
|
|
190
|
+
const d = actorDetail({ actor: { ...actorDetail().actor, state: 'resuming', crash: undefined, updateTime: minutesAgo(54) } })
|
|
191
|
+
const t = actorAttentionText({ id: 's', rule: 'stuckTransition', severity: 'warning', title: '5 actors have been resuming for more than 5m', reading: 'The longest, code-review / pr-8818-reviewer, …', nextStep: 'x', subject: { kind: 'Actors' }, count: 5 }, d)
|
|
192
|
+
expect(t.title).toBe('Resuming for at least 54m, longer than a transition should take')
|
|
193
|
+
expect(t.message).toBe('4 other actors are in the same state.')
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
describe('Workers by pool', () => {
|
|
198
|
+
it('shows zero reservations for idle workers and keeps unreported capacity unknown', async () => {
|
|
199
|
+
const { workerColumns } = await import('./SubstrateWorkers')
|
|
200
|
+
const cols = workerColumns(() => {}, true).slice(2, 5)
|
|
201
|
+
const readings = (row: SubstrateWorkerRow) => cols.map((c) =>
|
|
202
|
+
new DOMParser().parseFromString(renderToStaticMarkup(<>{c.cell(row)}</>), 'text/html').body.textContent,
|
|
203
|
+
)
|
|
204
|
+
expect(readings(worker(0, { allocated: undefined }))).toEqual(['0 of 4', '0 of 16', '0 of 64Gi'])
|
|
205
|
+
expect(readings(worker(0, { allocated: undefined, capacity: undefined }))).toEqual(['unknown', 'unknown', 'unknown'])
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
it('sorts the worst state first, then full workers, then by name', async () => {
|
|
209
|
+
const { sortWorkers } = await import('./SubstrateWorkers')
|
|
210
|
+
const order = sortWorkers([
|
|
211
|
+
worker(3),
|
|
212
|
+
worker(1, { state: 'unavailable' }),
|
|
213
|
+
worker(2, { hasFreeSlot: false }),
|
|
214
|
+
worker(0, { state: 'draining' }),
|
|
215
|
+
]).map((w) => w.pod)
|
|
216
|
+
expect(order).toEqual(['agent-pool-worker-1', 'agent-pool-worker-0', 'agent-pool-worker-2', 'agent-pool-worker-3'])
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('groups under a pool header with its slots and reading, and marks a full worker', async () => {
|
|
220
|
+
const { WorkersTable } = await import('./SubstrateWorkers')
|
|
221
|
+
const pools = [{ namespace: 'agents', name: 'agent-pool', placement: { workers: { total: 2, active: 2, draining: 0, unavailable: 0 }, slots: { used: 6, total: 8 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: true }, capacity: 'free' as const }]
|
|
222
|
+
const html = text(renderToStaticMarkup(
|
|
223
|
+
<MemoryRouter>
|
|
224
|
+
<WorkersTable data={{ workers: [worker(0, { hasFreeSlot: false }), worker(1)], coverage: { workers: { state: 'full' } } }} pools={pools} onOpenSubject={() => {}} grouped />
|
|
225
|
+
</MemoryRouter>,
|
|
226
|
+
))
|
|
227
|
+
expect(html).toContain('6 of 8 actor slots used on active workers')
|
|
228
|
+
// Registered, active and desired are each named, from the pool's totals.
|
|
229
|
+
expect(html).toContain('2 workers registered, 2 active')
|
|
230
|
+
// Narrow (as rendered here), CPU and memory sit under the slots, still labelled.
|
|
231
|
+
expect(html).toContain('4 of 16 CPU · 8Gi of 64Gi reserved')
|
|
232
|
+
expect(html).toContain('Free actor slots')
|
|
233
|
+
expect(html).toContain('of 4Full')
|
|
234
|
+
// Slots are utilization: a full worker in a pool with room, and the pool's free slots, are neutral facts.
|
|
235
|
+
const { Badge } = await import('@skyhook-io/k8s-ui')
|
|
236
|
+
const getSeverityColorClass = (severity: 'neutral' | 'success') => /class="([^"]*)"/.exec(renderToStaticMarkup(<Badge severity={severity} size="sm">x</Badge>))![1]
|
|
237
|
+
const rawHtml = renderToStaticMarkup(
|
|
238
|
+
<MemoryRouter>
|
|
239
|
+
<WorkersTable data={{ workers: [worker(0, { hasFreeSlot: false }), worker(1)], coverage: { workers: { state: 'full' } } }} pools={pools} onOpenSubject={() => {}} grouped />
|
|
240
|
+
</MemoryRouter>,
|
|
241
|
+
)
|
|
242
|
+
const badgeClass = (label: string) => { const i = rawHtml.indexOf(`>${label}</span>`); return rawHtml.slice(rawHtml.lastIndexOf('class="', i), i) }
|
|
243
|
+
expect(badgeClass('Full')).toContain(getSeverityColorClass('neutral'))
|
|
244
|
+
expect(badgeClass('Free actor slots')).toContain(getSeverityColorClass('neutral'))
|
|
245
|
+
expect(badgeClass('Free actor slots')).not.toContain(getSeverityColorClass('success'))
|
|
246
|
+
expect(html).toContain('aria-label="Show assigned actors for agent-pool-worker-0"')
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it('names registered of desired workers on the pool header, and keeps a lost count out of the state chip', async () => {
|
|
250
|
+
const { WorkersTable, poolWorkersText } = await import('./SubstrateWorkers')
|
|
251
|
+
const row = { placement: { workers: { total: 4, active: 2, draining: 1, unavailable: 1 }, slots: { used: 6, total: 8 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: true }, kubernetes: { namespace: 'agents', name: 'agent-pool', desired: 5, reportedReady: 3, health: 'degraded', healthReason: '' } }
|
|
252
|
+
expect(poolWorkersText(row, [])).toBe('4 of 5 desired workers registered, 2 active')
|
|
253
|
+
expect(poolWorkersText({ ...row, placement: { ...row.placement, complete: false } }, [])).toBe('at least 4 of 5 desired workers registered, at least 2 active')
|
|
254
|
+
const reconciling = worker(0, { workerState: { kind: 'reconciling', assigned: 13, lost: 3, reading: 'Restarted.' } })
|
|
255
|
+
const html = text(renderToStaticMarkup(<MemoryRouter><WorkersTable data={{ workers: [reconciling], coverage: { workers: { state: 'full' } } }} onOpenSubject={() => {}} /></MemoryRouter>))
|
|
256
|
+
expect(html).toContain('3 actors lost · Pod ready')
|
|
257
|
+
// The chip is one short line; the count rides beside it, never inside it.
|
|
258
|
+
expect(html).toContain('Active · reconciling')
|
|
259
|
+
expect(html).not.toContain('(3 actors lost)')
|
|
260
|
+
const raw = renderToStaticMarkup(<MemoryRouter><WorkersTable data={{ workers: [reconciling], coverage: { workers: { state: 'full' } } }} onOpenSubject={() => {}} /></MemoryRouter>)
|
|
261
|
+
expect(raw).toMatch(/class="[^"]*whitespace-nowrap[^"]*">Active · reconciling</)
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it('labels wide CPU and memory as reserved, and keeps a node’s hostname whole, never broken inside it', async () => {
|
|
265
|
+
const { workerColumns } = await import('./SubstrateWorkers')
|
|
266
|
+
const cols = workerColumns(() => {}, true)
|
|
267
|
+
const headers = text(renderToStaticMarkup(<MemoryRouter>{cols.map((c, i) => <div key={i}>{c.header}</div>)}</MemoryRouter>))
|
|
268
|
+
expect(headers).toContain('CPU reserved')
|
|
269
|
+
expect(headers).toContain('Memory reserved')
|
|
270
|
+
const node = cols.find((c) => c.header === 'Node')!
|
|
271
|
+
const html = renderToStaticMarkup(<MemoryRouter>{node.cell(worker(0))}</MemoryRouter>)
|
|
272
|
+
expect(html).toMatch(/class="block truncate whitespace-nowrap font-mono text-\[12px\]">ip-10-0-16-162\.ec2\.internal</)
|
|
273
|
+
expect(html).not.toContain('overflow-wrap:anywhere')
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it('marks a running actor on an unavailable worker apart from healthy running', () => {
|
|
277
|
+
const impact = { kind: 'unavailable' as const, reading: 'Substrate marks its worker unavailable although the worker Pod is Ready.', podState: 'ready' as const, nextStep: 'x', command: 'y' }
|
|
278
|
+
const w = worker(0, { state: 'unavailable', actors: [{ atespace: 'research', name: 'ticket-41001', state: 'running', template: { atespace: 'research', name: 'lg' }, workerImpact: impact }] })
|
|
279
|
+
const html = render(pool([w]))
|
|
280
|
+
expect(html).toContain('ticket-41001, Running · worker unavailable')
|
|
281
|
+
expect(html).toContain('its worker is unavailable')
|
|
282
|
+
expect(raw(pool([w]))).toMatch(/bg-orange-500"><\/span><span[^>]*>ticket-41001/)
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('colours a lost sandbox, an unavailable worker and a transition apart, as the legend does', () => {
|
|
286
|
+
const lost = { kind: 'restarted' as const, reading: 'lost', nextStep: 'x', command: 'y' }
|
|
287
|
+
const w = worker(0, { actors: [
|
|
288
|
+
{ atespace: 'r', name: 'lost-one', state: 'running', template: { atespace: 'r', name: 'lg' }, workerImpact: lost },
|
|
289
|
+
{ atespace: 'r', name: 'moving-one', state: 'resuming', template: { atespace: 'r', name: 'lg' } },
|
|
290
|
+
] })
|
|
291
|
+
const html = render(pool([w]))
|
|
292
|
+
expect(raw(pool([w]))).toMatch(/bg-rose-500"><\/span><span class="[^"]*">lost-one<\/span><svg[^>]*lucide-unlink/)
|
|
293
|
+
expect(raw(pool([w]))).not.toContain('line-through')
|
|
294
|
+
expect(raw(pool([w]))).toMatch(/bg-sky-500"><\/span><span[^>]*>moving-one/)
|
|
295
|
+
expect(html).toContain('sandbox lost: its worker restarted under it')
|
|
296
|
+
expect(html).toContain('resuming, suspending or reverting')
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
const dom = (node: React.ReactNode, path = '/substrate') => new DOMParser().parseFromString(
|
|
301
|
+
renderToStaticMarkup(<MemoryRouter initialEntries={[path]}>{node}</MemoryRouter>), 'text/html',
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
it('reads requested SandboxConfigs on Spec and the two independent status refs on Overview', () => {
|
|
305
|
+
const resource = {
|
|
306
|
+
spec: { sandboxClasses: [{ name: 'gvisor', configRef: { name: 'gvisor-v2' } }] },
|
|
307
|
+
status: { sandboxClasses: [{ name: 'gvisor', configRef: { name: 'gvisor-v1' }, pendingConfigRef: { name: 'gvisor-next' }, conditions: [{ type: 'Resolved', status: 'False' }] }] },
|
|
308
|
+
}
|
|
309
|
+
const spec = dom(<PoolSpecStatus resource={resource} onNavigate={() => {}} />)
|
|
310
|
+
expect(spec.body.textContent).toContain('status.sandboxClasses[].conditions')
|
|
311
|
+
expect([...spec.querySelectorAll('button')].some((b) => b.textContent === 'gvisor-v2')).toBe(true)
|
|
312
|
+
expect(spec.body.textContent).not.toContain('gvisor-v1')
|
|
313
|
+
state.pool = pool([])
|
|
314
|
+
const summary = (poolResource: typeof resource) => dom(<SubstratePoolSummary namespace="agents" name="agent-pool" context="expanded" resource={poolResource} onNavigate={() => {}} />)
|
|
315
|
+
expect([...summary(resource).querySelectorAll('button')].map((b) => b.textContent)).toEqual(expect.arrayContaining(['gvisor-v1', 'gvisor-next']))
|
|
316
|
+
const unresolved = structuredClone(resource)
|
|
317
|
+
unresolved.status.sandboxClasses = []
|
|
318
|
+
expect(summary(unresolved).body.textContent).toContain('Requested: gvisor-v2 (unresolved)')
|
|
319
|
+
})
|
|
320
|
+
|
|
321
|
+
it('shows the controller’s SandboxConfig evidence and recovery when the pool still has ready workers', () => {
|
|
322
|
+
const data = pool([worker(0)])
|
|
323
|
+
data.pool.kubernetes = { ...data.pool.kubernetes!, health: 'degraded', healthReason: 'SandboxConfigNotFound', healthDetail: 'SandboxConfig "gvisor-v2" not found.' }
|
|
324
|
+
data.attention = {
|
|
325
|
+
id: 'poolShort:agents/agent-pool', rule: 'poolShort', severity: 'warning', title: 'Sandbox configuration missing',
|
|
326
|
+
reading: data.pool.kubernetes.healthDetail!, nextStep: 'Restore the missing SandboxConfig or select an existing configuration for this sandbox class.',
|
|
327
|
+
subject: { kind: 'WorkerPool', name: 'agent-pool' }, count: 1,
|
|
328
|
+
}
|
|
329
|
+
state.pool = data
|
|
330
|
+
try {
|
|
331
|
+
const summary = dom(<SubstratePoolSummary namespace="agents" name="agent-pool" context="expanded" resource={{ status: { readyReplicas: 1 } }} />)
|
|
332
|
+
expect(summary.body.textContent).toContain('SandboxConfig "gvisor-v2" not found.')
|
|
333
|
+
expect(summary.body.textContent).toContain(data.attention.nextStep)
|
|
334
|
+
expect(summary.body.textContent).toContain('WorkerPool controller status')
|
|
335
|
+
expect(summary.body.textContent).not.toContain('Compare controller readiness with Substrate registrations below.')
|
|
336
|
+
} finally {
|
|
337
|
+
state.pool = undefined
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
it('keeps unread worker dimensions unknown and names the failed read before blaming Pod permissions', () => {
|
|
342
|
+
const summary = () => dom(<SubstratePoolSummary namespace="agents" name="agent-pool" context="expanded" resource={{}} />)
|
|
343
|
+
try {
|
|
344
|
+
state.pool = undefined
|
|
345
|
+
state.poolLoading = true
|
|
346
|
+
expect(summary().body.textContent).toContain('Reading Pod counts…')
|
|
347
|
+
state.poolLoading = false
|
|
348
|
+
state.poolError = new ApiError('this read requires get on workerpools.ate.dev in namespace agents', 403, { error_code: 'denied' })
|
|
349
|
+
expect(summary().body.textContent).toContain('requires get on workerpools.ate.dev in namespace agents')
|
|
350
|
+
expect(summary().body.textContent).not.toContain('list on pods')
|
|
351
|
+
expect(summary().body.textContent).not.toContain('couldn’t read the pool from Substrate’s API')
|
|
352
|
+
state.pool = pool([worker(0)])
|
|
353
|
+
state.poolError = new ApiError('Token request forbidden.', 403, { error_code: 'mintDenied' })
|
|
354
|
+
const mint = summary()
|
|
355
|
+
expect(mint.body.textContent).toContain('create on serviceaccounts/token for ate-client in ate-system')
|
|
356
|
+
expect(mint.body.textContent).not.toContain('agent-pool-worker-0')
|
|
357
|
+
const denied = pool([])
|
|
358
|
+
denied.podRead = 'denied'
|
|
359
|
+
denied.coverage.workers = { state: 'denied', code: 'denied' }
|
|
360
|
+
denied.attention = { id: 'broken', rule: 'poolShort', severity: 'critical', title: 'Unresolved', reading: 'Unresolved', nextStep: 'Review conditions', subject: { kind: 'WorkerPool', name: 'agent-pool' }, count: 1 }
|
|
361
|
+
state.pool = denied
|
|
362
|
+
state.poolError = null
|
|
363
|
+
const doc = summary()
|
|
364
|
+
expect(doc.body.textContent).toContain('Requires list on pods in agents')
|
|
365
|
+
for (const dimension of ['Registration', 'Placement capacity']) {
|
|
366
|
+
const value = [...doc.querySelectorAll('dt')].find((e) => e.textContent === dimension)?.nextElementSibling
|
|
367
|
+
expect(value?.textContent).toContain('Unknown')
|
|
368
|
+
expect(value?.textContent).toContain('Substrate denied permission to list workers')
|
|
369
|
+
expect(value?.querySelector(`.${toneFillClass('unknown')}`)).not.toBeNull()
|
|
370
|
+
}
|
|
371
|
+
} finally {
|
|
372
|
+
state.poolError = null
|
|
373
|
+
state.poolLoading = false
|
|
374
|
+
}
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
it('shows a worker Pod handoff with no invented count and names the role or Kubernetes permission for refusal', () => {
|
|
378
|
+
const context = (framed?: boolean) => dom(<SubstrateWorkerPodContext namespace="agents" pool="agent-pool" pod="agent-pool-worker-0" resource={{}} framed={framed} />)
|
|
379
|
+
try {
|
|
380
|
+
state.workers = { apiTier: connectedTier, workers: [worker(0, { actors: [] })], coverage: { workers: { state: 'full' }, actors: { state: 'partial' } } }
|
|
381
|
+
const doc = context()
|
|
382
|
+
expect(doc.body.textContent).toContain('View assigned actors')
|
|
383
|
+
expect(doc.body.textContent).not.toContain('≥0')
|
|
384
|
+
expect(doc.querySelector('section')?.classList.contains('border-t-subtle')).toBe(true)
|
|
385
|
+
expect(context(true).querySelector('section')?.classList.contains('rounded-xl')).toBe(true)
|
|
386
|
+
state.workers = undefined
|
|
387
|
+
state.workerError = new ApiError('denied mint', 403, { error_code: 'mintDenied' })
|
|
388
|
+
expect(context().body.textContent).toContain('create on serviceaccounts/token for ate-client in ate-system')
|
|
389
|
+
state.workerError = new ApiError('denied read', 403, { error_code: 'denied' })
|
|
390
|
+
expect(context().body.textContent).toContain('viewer role')
|
|
391
|
+
} finally {
|
|
392
|
+
state.workerError = null
|
|
393
|
+
state.workers = undefined
|
|
394
|
+
}
|
|
395
|
+
for (const tab of ['logs', 'metrics'] as const) {
|
|
396
|
+
const doc = dom(<SubstrateWorkerPodScope namespace="agents" pool="agent-pool" pod="agent-pool-worker-0" tab={tab} />)
|
|
397
|
+
expect(doc.body.textContent).toContain(`These ${tab} cover the shared worker Pod`)
|
|
398
|
+
expect(doc.querySelector('button')?.textContent).toContain('View assigned actors')
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
it('filters Workers attention by the shared severity and links to pools with no registrations', async () => {
|
|
403
|
+
const { SubstrateWorkersScreen, poolWorkersText } = await import('./SubstrateWorkers')
|
|
404
|
+
try {
|
|
405
|
+
state.workers = {
|
|
406
|
+
apiTier: connectedTier,
|
|
407
|
+
workers: [worker(0, { attentionSeverity: 'warning', actors: [] }), worker(1, { attentionSeverity: 'info', state: 'draining' })],
|
|
408
|
+
coverage: { workers: { state: 'full' }, actors: { state: 'partial', deniedAtespaces: ['restricted'] } },
|
|
409
|
+
}
|
|
410
|
+
state.workerError = new Error('timed out')
|
|
411
|
+
const doc = dom(<SubstrateWorkersScreen workspace={workspace()} onOpenSubject={() => {}} />, '/substrate/workers?state=attention')
|
|
412
|
+
const content = doc.body.textContent ?? ''
|
|
413
|
+
const toolbar = content.indexOf('Needs attention≥1')
|
|
414
|
+
for (const notice of ['Last refresh failed: timed out', 'Substrate denied atespace restricted']) {
|
|
415
|
+
expect(content).toContain(notice)
|
|
416
|
+
expect(content.indexOf(notice)).toBeLessThan(toolbar)
|
|
417
|
+
}
|
|
418
|
+
expect(doc.body.textContent).toContain('Needs attention≥1')
|
|
419
|
+
expect(doc.querySelector('button[aria-label="Show assigned actors for agent-pool-worker-0"]')?.textContent).toBe('View assigned actors')
|
|
420
|
+
expect(doc.querySelector('button[aria-label="Show assigned actors for agent-pool-worker-1"]')).toBeNull()
|
|
421
|
+
expect(doc.body.textContent).toContain('Pools with no registered workers')
|
|
422
|
+
expect([...doc.querySelectorAll('button')].some((b) => b.textContent === 'agent-ns/microvm-pool →')).toBe(true)
|
|
423
|
+
const row = workspace().pools[0]
|
|
424
|
+
row.placement!.workers.active = 0
|
|
425
|
+
row.placement!.complete = false
|
|
426
|
+
expect(poolWorkersText(row, [])).toContain('active worker count unknown')
|
|
427
|
+
} finally {
|
|
428
|
+
state.workers = undefined
|
|
429
|
+
state.workerError = null
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
it('keeps the placement qualification below the value and uses a degraded provisioning tone', () => {
|
|
434
|
+
const data = pool([worker(0), worker(1, { state: 'unavailable' })], 5)
|
|
435
|
+
data.pool.kubernetes!.health = 'degraded'
|
|
436
|
+
data.pool.actors = 9
|
|
437
|
+
data.pool.placement = { workers: { total: 2, active: 1, draining: 0, unavailable: 1 }, slots: { used: 2, total: 4 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: true }
|
|
438
|
+
state.pool = data
|
|
439
|
+
const doc = dom(<SubstratePoolSummary namespace="agents" name="agent-pool" context="expanded" resource={{}} />)
|
|
440
|
+
const field = (label: string) => [...doc.querySelectorAll('dt')].find((node) => node.textContent === label)?.nextElementSibling
|
|
441
|
+
expect(field('Provisioning')?.querySelector(`.${toneFillClass('degraded')}`)).not.toBeNull()
|
|
442
|
+
const placement = field('Placement capacity')
|
|
443
|
+
expect(placement?.querySelector('button')?.parentElement?.textContent).toContain('2 of 4 used')
|
|
444
|
+
expect(placement?.querySelector('button')?.parentElement?.textContent).not.toContain('+7')
|
|
445
|
+
expect(placement?.textContent).toContain('+7 on non-active workers')
|
|
446
|
+
expect(field('Template matches')?.querySelector('button')?.textContent).toBe('All templates →')
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
describe('kagent sessions on a worker', () => {
|
|
450
|
+
it('shows a session by its short id with its Agent, the whole name on hover', () => {
|
|
451
|
+
const html = render(pool([worker(0, { actors: [
|
|
452
|
+
{ atespace: 'kagent', name: 'session-01a1faa2-b3e3-7dd3-ae2d-3114122d4291', state: 'running', template: { atespace: 'kagent', name: 'k8s-helper-aa5e9426eb2e' },
|
|
453
|
+
kagent: { sessionId: '01a1faa2-b3e3-7dd3-ae2d-3114122d4291', kind: 'agentSession', agent: { namespace: 'kagent', name: 'k8s-helper' }, revision: 'aa5e9426eb2e', newSessions: true } },
|
|
454
|
+
{ atespace: 'kagent', name: 'session-9b2d6c1e-4f3a-4e8b-9c7d-1a2b3c4d5e6f', state: 'running', template: { atespace: 'kagent', name: 'sandbox-3f2c1b0a9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b' },
|
|
455
|
+
kagent: { sessionId: '9b2d6c1e-4f3a-4e8b-9c7d-1a2b3c4d5e6f', kind: 'sandbox' } },
|
|
456
|
+
] })]))
|
|
457
|
+
expect(html).toContain('session …122d4291')
|
|
458
|
+
expect(html).toContain('Agent k8s-helper')
|
|
459
|
+
expect(html).toContain('session …3c4d5e6f')
|
|
460
|
+
expect(html).toContain('kagent sandbox')
|
|
461
|
+
})
|
|
462
|
+
})
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react'
|
|
2
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
3
|
+
import { Bot, Server } from 'lucide-react'
|
|
4
|
+
import { PaneLoader, type WorkloadExtraTab } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { substrateErrorCode, useSubstratePool, type SubstratePoolRef, type SubstrateSubject } from '../../api/substrateWorkspace'
|
|
6
|
+
import type { SelectedResource } from '../../types'
|
|
7
|
+
import { refToSelectedResource } from '../../utils/navigation'
|
|
8
|
+
import { WorkloadView } from '../workload/WorkloadView'
|
|
9
|
+
import { Notice, RefreshFailedNotice } from '../workspace/layout'
|
|
10
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
11
|
+
import { SUBSTRATE_GROUP, SUBSTRATE_PATH, SUBSTRATE_POOLS_PATH, substratePoolPath } from './routes'
|
|
12
|
+
import { WorkersTable } from './SubstrateWorkers'
|
|
13
|
+
import { useOpenActor } from './SubstratePoolSummary'
|
|
14
|
+
import { definitiveFailure, poolReadFailure, tierReading } from './readings'
|
|
15
|
+
import { NotInContext, useContextPin } from './contextPin'
|
|
16
|
+
|
|
17
|
+
function PoolWorkers({ pool, onOpenResource }: { pool: SubstratePoolRef; onOpenResource: (resource: SelectedResource) => void }) {
|
|
18
|
+
const query = useSubstratePool(pool)
|
|
19
|
+
const navigate = useWorkspaceNavigate()
|
|
20
|
+
const pin = useContextPin()
|
|
21
|
+
const code = substrateErrorCode(query.error)
|
|
22
|
+
const data = definitiveFailure(code) || code === 'incomplete' ? undefined : query.data
|
|
23
|
+
const openActor = useOpenActor()
|
|
24
|
+
const open = (s: SubstrateSubject) => {
|
|
25
|
+
if (s.kind === 'Pod' || s.kind === 'Worker') onOpenResource(refToSelectedResource({ kind: 'Pod', group: '', namespace: s.namespace ?? '', name: s.name ?? '' }))
|
|
26
|
+
if (s.kind === 'Actor' && s.atespace && s.name) openActor({ atespace: s.atespace, name: s.name })
|
|
27
|
+
}
|
|
28
|
+
if (query.isLoading) return <PaneLoader label="Loading workers…" />
|
|
29
|
+
if (!data) return <div className="p-4"><Notice>{poolReadFailure(query.error, pool.namespace)}</Notice></div>
|
|
30
|
+
if (data.apiTier.state !== 'connected') return <div className="p-4"><Notice>{tierReading(data.apiTier).detail}</Notice></div>
|
|
31
|
+
return (
|
|
32
|
+
<div className="h-full space-y-3 overflow-y-auto p-4">
|
|
33
|
+
<RefreshFailedNotice queries={[query]} />
|
|
34
|
+
<WorkersTable data={{ workers: data.workers, coverage: data.coverage }} onOpenSubject={open}
|
|
35
|
+
emptyMessage={<div className="space-y-1">
|
|
36
|
+
<div className="font-medium text-theme-text-primary">No workers registered{data.pool.kubernetes?.desired !== undefined ? ` · ${data.pool.kubernetes.desired} desired` : ''}</div>
|
|
37
|
+
{data.attention && <button type="button" className="text-accent-text hover:underline" onClick={() => navigate(substratePoolPath(pool, pin.pinned || pin.active || undefined))}>
|
|
38
|
+
{data.pool.kubernetes?.healthReason === 'SandboxConfigNotFound' ? 'See the missing sandbox configuration' : data.pool.kubernetes?.healthReason === 'Provisioning stalled' ? 'See why provisioning stalled' : 'See the capacity finding'} →
|
|
39
|
+
</button>}
|
|
40
|
+
</div>}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A WorkerPool's page: Radar's detail view of the Kubernetes object, framed
|
|
48
|
+
* by Agent Substrate, with its workers from Substrate's API. `ctx` pins the
|
|
49
|
+
* context, as on an actor's page.
|
|
50
|
+
*/
|
|
51
|
+
export function SubstratePoolPage({ pool, onOpenResource }: { pool: SubstratePoolRef; onOpenResource: (resource: SelectedResource) => void }) {
|
|
52
|
+
const navigate = useWorkspaceNavigate()
|
|
53
|
+
const pin = useContextPin()
|
|
54
|
+
const queryClient = useQueryClient()
|
|
55
|
+
const refresh = useCallback(() => queryClient.refetchQueries({ type: 'active', queryKey: ['substrate'] }), [queryClient])
|
|
56
|
+
|
|
57
|
+
const extraTabs = useMemo<WorkloadExtraTab[]>(
|
|
58
|
+
() => [{ id: 'workers', label: 'Workers', after: 'overview', icon: <Server className="h-4 w-4" />, render: () => <PoolWorkers pool={pool} onOpenResource={onOpenResource} /> }],
|
|
59
|
+
[pool, onOpenResource],
|
|
60
|
+
)
|
|
61
|
+
const titlePrefix = (
|
|
62
|
+
<nav aria-label="Location" className="flex shrink-0 items-center gap-1.5 text-sm text-theme-text-tertiary">
|
|
63
|
+
<Bot className="h-3.5 w-3.5" />
|
|
64
|
+
<button type="button" onClick={() => navigate(SUBSTRATE_PATH)} className="hover:text-theme-text-primary hover:underline">Agent Substrate</button>
|
|
65
|
+
<span>/</span>
|
|
66
|
+
<button type="button" onClick={() => navigate(SUBSTRATE_POOLS_PATH)} className="hover:text-theme-text-primary hover:underline">Pools</button>
|
|
67
|
+
<span>/</span>
|
|
68
|
+
</nav>
|
|
69
|
+
)
|
|
70
|
+
// Before the Kubernetes view mounts: its reads and its controls would act on the other cluster's namesake.
|
|
71
|
+
if (pin.mismatch) {
|
|
72
|
+
return <NotInContext name={pool.name} what={`WorkerPool ${pool.namespace} / ${pool.name}`} pinnedContext={pin.pinned!} activeContext={pin.active} />
|
|
73
|
+
}
|
|
74
|
+
return (
|
|
75
|
+
<div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">
|
|
76
|
+
<WorkloadView
|
|
77
|
+
key={`${pool.namespace}/${pool.name}`}
|
|
78
|
+
kind="workerpools"
|
|
79
|
+
namespace={pool.namespace}
|
|
80
|
+
name={pool.name}
|
|
81
|
+
group={SUBSTRATE_GROUP}
|
|
82
|
+
expanded
|
|
83
|
+
onBack={() => navigate(SUBSTRATE_POOLS_PATH)}
|
|
84
|
+
hideBackButton
|
|
85
|
+
titlePrefix={titlePrefix}
|
|
86
|
+
inlineBadges
|
|
87
|
+
hideKindBadge
|
|
88
|
+
truncateName
|
|
89
|
+
onNavigateToResource={onOpenResource}
|
|
90
|
+
onRefresh={refresh}
|
|
91
|
+
extraTabs={extraTabs}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|