@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,325 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SubstrateAPITier,
|
|
3
|
+
SubstrateLocalConnection,
|
|
4
|
+
SubstrateManagedConnectionView,
|
|
5
|
+
SubstrateActorDetail,
|
|
6
|
+
SubstrateActorRow,
|
|
7
|
+
SubstrateActors,
|
|
8
|
+
SubstrateAttention,
|
|
9
|
+
SubstrateStateCounts,
|
|
10
|
+
SubstrateStatus,
|
|
11
|
+
SubstrateWorkspace,
|
|
12
|
+
} from '../../api/substrateWorkspace'
|
|
13
|
+
|
|
14
|
+
// Shaped exactly as /api/substrate/* serve them (pkg/substrate,
|
|
15
|
+
// internal/server/substrate_workspace_handlers.go): absent fields are
|
|
16
|
+
// values Substrate or Radar did not read.
|
|
17
|
+
|
|
18
|
+
export const minutesAgo = (m: number) => new Date(Date.now() - m * 60_000).toISOString()
|
|
19
|
+
|
|
20
|
+
export const connectedTier: SubstrateAPITier = {
|
|
21
|
+
state: 'connected',
|
|
22
|
+
identity: { mode: 'shared', principal: 'system:serviceaccount:ate-system:ate-client' },
|
|
23
|
+
readAt: minutesAgo(0.1),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const notConfiguredTier: SubstrateAPITier = {
|
|
27
|
+
state: 'notConfigured',
|
|
28
|
+
code: 'notConfigured',
|
|
29
|
+
reason: 'Choose who Radar reads Substrate’s API as.',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const sharedTier: SubstrateAPITier = {
|
|
33
|
+
state: 'disabled',
|
|
34
|
+
code: 'sharedRadar',
|
|
35
|
+
reason: 'This Radar is shared without sign-in, so it can’t tell who is asking and doesn’t read Substrate’s API.',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** An in-cluster Radar or Radar Hub whose operator turned Substrate's API off. */
|
|
39
|
+
export const apiDisabledTier: SubstrateAPITier = {
|
|
40
|
+
state: 'disabled',
|
|
41
|
+
code: 'apiDisabled',
|
|
42
|
+
reason: 'The operator turned off reading Substrate’s API on this Radar.',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A signed-in person whose Kubernetes access can't create ate-client's token. */
|
|
46
|
+
export const mintDeniedTier: SubstrateAPITier = {
|
|
47
|
+
state: 'failed',
|
|
48
|
+
code: 'mintDenied',
|
|
49
|
+
reason: 'Radar could not create ate-system/ate-client’s token with your Kubernetes access.',
|
|
50
|
+
identity: { mode: 'sharedAsCaller', principal: 'system:serviceaccount:ate-system:ate-client' },
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A signed-in person (in-cluster or Radar Hub): the shared client identity, minted with their Kubernetes access. */
|
|
54
|
+
export const ownerTier: SubstrateAPITier = {
|
|
55
|
+
...connectedTier,
|
|
56
|
+
endpoint: 'api.ate-system.svc:443',
|
|
57
|
+
identity: { mode: 'sharedAsCaller', principal: 'system:serviceaccount:ate-system:ate-client' },
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function counts(byState: Partial<SubstrateStateCounts['byState']>): SubstrateStateCounts {
|
|
61
|
+
const full = { running: 0, suspended: 0, resuming: 0, suspending: 0, reverting: 0, crashed: 0, deleting: 0, unknown: 0, ...byState }
|
|
62
|
+
return { total: Object.values(full).reduce((a, b) => a + b, 0), byState: full }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function status(overrides: Partial<SubstrateStatus> = {}): SubstrateStatus {
|
|
66
|
+
return {
|
|
67
|
+
installed: true,
|
|
68
|
+
apiService: { namespace: 'ate-system', name: 'api', port: 443, found: true },
|
|
69
|
+
apiTier: connectedTier,
|
|
70
|
+
coverage: { pools: { state: 'full' } },
|
|
71
|
+
canConfigure: true,
|
|
72
|
+
...overrides,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const crashedRow: SubstrateAttention = {
|
|
77
|
+
id: 'crashedActors',
|
|
78
|
+
rule: 'crashedActors',
|
|
79
|
+
severity: 'critical',
|
|
80
|
+
title: '14 actors are crashed',
|
|
81
|
+
reading: "Latest: research/lit-review-0193. Substrate's message: container agent: OOMKilled (limit 2Gi)",
|
|
82
|
+
nextStep: "Fix the cause Substrate's crash message names, then revert each actor to its newest stored generation.",
|
|
83
|
+
command: 'kubectl ate revert actor <name> -a <atespace>',
|
|
84
|
+
subject: { kind: 'Actors', filter: { state: 'crashed' } },
|
|
85
|
+
count: 14,
|
|
86
|
+
since: minutesAgo(4),
|
|
87
|
+
groups: [
|
|
88
|
+
{ subject: { kind: 'ActorTemplate', atespace: 'research', name: 'langgraph-research' }, count: 11 },
|
|
89
|
+
{ subject: { kind: 'ActorTemplate', atespace: 'code-review', name: 'claude-code-gvisor' }, count: 3 },
|
|
90
|
+
],
|
|
91
|
+
messages: [
|
|
92
|
+
{ text: 'container agent: OOMKilled (limit 2Gi)', count: 11 },
|
|
93
|
+
{ text: 'exit 1: git clone: authentication failed', count: 3 },
|
|
94
|
+
],
|
|
95
|
+
sample: [{ atespace: 'research', name: 'lit-review-0193' }],
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const poolShortRow: SubstrateAttention = {
|
|
99
|
+
id: 'poolShort:agent-ns/agent-pool',
|
|
100
|
+
rule: 'poolShort',
|
|
101
|
+
severity: 'warning',
|
|
102
|
+
title: 'agent-ns / agent-pool is short of workers',
|
|
103
|
+
reading: '5 of 6 desired workers are active. New and resuming actors may wait or fail to start.',
|
|
104
|
+
nextStep: "Open the pool: compare its worker Pods with Substrate's worker states to see which side is missing.",
|
|
105
|
+
subject: { kind: 'WorkerPool', namespace: 'agent-ns', name: 'agent-pool' },
|
|
106
|
+
count: 1,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const goldenRow: SubstrateAttention = {
|
|
110
|
+
id: 'goldenSnapshotFailed:sandbox-dev/mcp-browser',
|
|
111
|
+
rule: 'goldenSnapshotFailed',
|
|
112
|
+
severity: 'warning',
|
|
113
|
+
title: 'sandbox-dev/mcp-browser has no golden snapshot, so new actors not seeded from a tag start from a cold boot',
|
|
114
|
+
reading: "Substrate's message: warm-up: container browser exited 137. Substrate does not retry a failed build.",
|
|
115
|
+
nextStep: 'Templates are immutable, so fix the cause and create the template again: delete and recreate it, or create it under a new name. Substrate builds a golden snapshot for each new template.',
|
|
116
|
+
subject: { kind: 'ActorTemplate', atespace: 'sandbox-dev', name: 'mcp-browser' },
|
|
117
|
+
count: 1,
|
|
118
|
+
since: minutesAgo(25),
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const pool = {
|
|
122
|
+
namespace: 'agent-ns',
|
|
123
|
+
name: 'agent-pool',
|
|
124
|
+
kubernetes: { namespace: 'agent-ns', name: 'agent-pool', desired: 6, reportedReady: 6, sandboxClasses: ['gvisor'], health: 'degraded', healthReason: '5 of 6 workers active' },
|
|
125
|
+
sandboxClasses: ['gvisor'],
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** A connected workspace: three pools, 1,284 actors, five rows needing attention. */
|
|
129
|
+
export function workspace(overrides: Partial<SubstrateWorkspace> = {}): SubstrateWorkspace {
|
|
130
|
+
return {
|
|
131
|
+
apiTier: connectedTier,
|
|
132
|
+
coverage: {
|
|
133
|
+
actors: { state: 'full', count: 1284 },
|
|
134
|
+
templates: { state: 'full', count: 6 },
|
|
135
|
+
workers: { state: 'full', count: 20 },
|
|
136
|
+
atespaces: { state: 'full', count: 4 },
|
|
137
|
+
pools: { state: 'full' },
|
|
138
|
+
},
|
|
139
|
+
summary: {
|
|
140
|
+
pools: { total: 3, short: 1, full: 1, noRoom: 0 },
|
|
141
|
+
workers: { total: 20, active: 18, draining: 1, unavailable: 1 },
|
|
142
|
+
slots: { used: 212, total: 236 },
|
|
143
|
+
freeSlots: [
|
|
144
|
+
{ pool: { namespace: 'batch', name: 'batch-pool' }, free: 21 },
|
|
145
|
+
{ pool: { namespace: 'agent-ns', name: 'agent-pool' }, free: 3 },
|
|
146
|
+
],
|
|
147
|
+
actors: { total: 1284, crashed: 14, attentionCount: 14 },
|
|
148
|
+
templates: { total: 6, goldenFailed: 1, attentionCount: 1, noMatchingPool: 0 },
|
|
149
|
+
},
|
|
150
|
+
actorStates: counts({ running: 212, suspended: 1041, resuming: 6, suspending: 9, reverting: 2, crashed: 14 }),
|
|
151
|
+
needsAttention: [crashedRow, poolShortRow, goldenRow],
|
|
152
|
+
checks: [
|
|
153
|
+
{ rule: 'crashedActors', label: 'Crashed actors', ran: true },
|
|
154
|
+
{ rule: 'poolShort', label: 'Pools short of workers', ran: true },
|
|
155
|
+
{ rule: 'goldenSnapshotFailed', label: 'Failed golden snapshots', ran: true },
|
|
156
|
+
],
|
|
157
|
+
notAssessed: ['API operation errors (resume, suspend and tag calls)', 'Request routing and egress'],
|
|
158
|
+
service: { read: false, why: 'Prometheus is not connected', poolsUnknown: 3, nodesOverdue: 0, nodesUnknown: 0 },
|
|
159
|
+
pools: [
|
|
160
|
+
{
|
|
161
|
+
...pool,
|
|
162
|
+
placement: { workers: { total: 6, active: 5, draining: 0, unavailable: 1 }, slots: { used: 37, total: 40 }, cpuMillicores: { used: 9000, total: 12000 }, memoryBytes: { used: 1, total: 2 }, complete: true },
|
|
163
|
+
actors: 37,
|
|
164
|
+
capacity: 'short',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
namespace: 'agent-ns',
|
|
168
|
+
name: 'microvm-pool',
|
|
169
|
+
kubernetes: { namespace: 'agent-ns', name: 'microvm-pool', desired: 4, reportedReady: 4, health: 'healthy', healthReason: '' },
|
|
170
|
+
placement: { workers: { total: 4, active: 4, draining: 0, unavailable: 0 }, slots: { used: 16, total: 16 }, cpuMillicores: { used: 1, total: 1 }, memoryBytes: { used: 1, total: 1 }, complete: true },
|
|
171
|
+
actors: 16,
|
|
172
|
+
sandboxClasses: ['microvm'],
|
|
173
|
+
capacity: 'full',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
namespace: 'batch',
|
|
177
|
+
name: 'batch-pool',
|
|
178
|
+
kubernetes: { namespace: 'batch', name: 'batch-pool', desired: 10, reportedReady: 9, health: 'healthy', healthReason: '' },
|
|
179
|
+
placement: { workers: { total: 10, active: 9, draining: 1, unavailable: 0 }, slots: { used: 159, total: 180 }, cpuMillicores: { used: 1, total: 2 }, memoryBytes: { used: 1, total: 2 }, complete: true },
|
|
180
|
+
actors: 159,
|
|
181
|
+
sandboxClasses: ['gvisor'],
|
|
182
|
+
capacity: 'free',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
atespaces: [
|
|
186
|
+
{ name: 'support-bots', actorsRead: 'full', actors: counts({ running: 60, suspended: 550, crashed: 1 }), templatesRead: 'full', templates: 1 },
|
|
187
|
+
{ name: 'research', actorsRead: 'full', actors: counts({ running: 40, suspended: 121, crashed: 11 }), templatesRead: 'full', templates: 2 },
|
|
188
|
+
{ name: 'restricted', actorsRead: 'denied', templatesRead: 'denied' },
|
|
189
|
+
],
|
|
190
|
+
...overrides,
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** The same cluster with Substrate's API not connected: Kubernetes' pools only. */
|
|
195
|
+
export function notConnectedWorkspace(tier: SubstrateAPITier = notConfiguredTier): SubstrateWorkspace {
|
|
196
|
+
return {
|
|
197
|
+
apiTier: tier,
|
|
198
|
+
coverage: { pools: { state: 'full' } },
|
|
199
|
+
summary: { pools: { total: 1, short: 0, full: 0, noRoom: 0 } },
|
|
200
|
+
needsAttention: [],
|
|
201
|
+
checks: [
|
|
202
|
+
{ rule: 'poolShort', label: 'Pools short of workers', ran: true },
|
|
203
|
+
{ rule: 'crashedActors', label: 'Crashed actors', ran: false, why: 'actors were not read' },
|
|
204
|
+
],
|
|
205
|
+
notAssessed: ['Request routing and egress'],
|
|
206
|
+
service: { read: false, why: 'Prometheus is not connected', poolsUnknown: 1, nodesOverdue: 0, nodesUnknown: 0 },
|
|
207
|
+
pools: [{ ...pool, capacity: undefined }],
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function actorRow(overrides: Partial<SubstrateActorRow> = {}): SubstrateActorRow {
|
|
212
|
+
return {
|
|
213
|
+
atespace: 'research',
|
|
214
|
+
name: 'lit-review-0193',
|
|
215
|
+
state: 'crashed',
|
|
216
|
+
reason: 'container agent: OOMKilled (limit 2Gi)',
|
|
217
|
+
template: { atespace: 'research', name: 'langgraph-research' },
|
|
218
|
+
node: 'ip-10-0-4-57',
|
|
219
|
+
newestSnapshot: { generation: 14, fidelity: 'memory', owner: 'actor', durable: 'completed', sandboxClass: 'gvisor' },
|
|
220
|
+
resumeGeneration: 14,
|
|
221
|
+
resumesWith: 'memory',
|
|
222
|
+
createTime: minutesAgo(2 * 24 * 60),
|
|
223
|
+
updateTime: minutesAgo(4),
|
|
224
|
+
...overrides,
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function actors(overrides: Partial<SubstrateActors> = {}): SubstrateActors {
|
|
229
|
+
const rows = overrides.rows ?? [
|
|
230
|
+
actorRow(),
|
|
231
|
+
actorRow({ name: 'ticket-41207', atespace: 'support-bots', state: 'suspended', reason: 'Upload pending for 12m', newestSnapshot: { generation: 7, fidelity: 'memory', durable: 'pending', locality: 'ip-10-0-4-57' }, resumeGeneration: 7 }),
|
|
232
|
+
actorRow({ name: 'pr-8790-reviewer', atespace: 'code-review', state: 'running', reason: undefined, newestSnapshot: undefined, resumeGeneration: undefined, resumesWith: 'cold', worker: { worker: 'w-1', namespace: 'batch', pool: 'batch-pool', pod: 'batch-pool-5d2b-r8t' }, node: 'ip-10-0-6-11' }),
|
|
233
|
+
]
|
|
234
|
+
return {
|
|
235
|
+
apiTier: connectedTier,
|
|
236
|
+
coverage: { state: 'full', count: 1284 },
|
|
237
|
+
workerCoverage: { state: 'full', count: 20 },
|
|
238
|
+
sources: ['snapshot'],
|
|
239
|
+
total: 1284,
|
|
240
|
+
counts: counts({ running: 212, suspended: 1041, resuming: 6, suspending: 9, reverting: 2, crashed: 14 }),
|
|
241
|
+
rows,
|
|
242
|
+
limit: 50,
|
|
243
|
+
offset: 0,
|
|
244
|
+
...overrides,
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function actorDetail(overrides: Partial<SubstrateActorDetail> = {}): SubstrateActorDetail {
|
|
249
|
+
const row = actorRow()
|
|
250
|
+
return {
|
|
251
|
+
apiTier: connectedTier,
|
|
252
|
+
actor: {
|
|
253
|
+
atespace: 'research',
|
|
254
|
+
name: 'lit-review-0193',
|
|
255
|
+
uid: 'a-1',
|
|
256
|
+
template: { atespace: 'research', name: 'langgraph-research' },
|
|
257
|
+
state: 'crashed',
|
|
258
|
+
assignedNode: 'ip-10-0-4-57',
|
|
259
|
+
crash: { message: 'container agent: OOMKilled (limit 2Gi)', time: minutesAgo(4) },
|
|
260
|
+
snapshots: [
|
|
261
|
+
{ generation: 14, fidelity: 'memory', owner: 'actor', durable: 'completed', sandboxClass: 'gvisor' },
|
|
262
|
+
{ generation: 13, fidelity: 'memory', owner: 'actor', durable: 'completed', sandboxClass: 'gvisor' },
|
|
263
|
+
],
|
|
264
|
+
createTime: minutesAgo(2 * 24 * 60),
|
|
265
|
+
updateTime: minutesAgo(4),
|
|
266
|
+
},
|
|
267
|
+
row,
|
|
268
|
+
template: {
|
|
269
|
+
atespace: 'research',
|
|
270
|
+
name: 'langgraph-research',
|
|
271
|
+
golden: { state: 'ready', tag: { atespace: 'research', name: 'golden' }, time: minutesAgo(600) },
|
|
272
|
+
actors: counts({ suspended: 150, running: 10, crashed: 11 }),
|
|
273
|
+
matchingPools: [{ namespace: 'agent-ns', name: 'agent-pool' }],
|
|
274
|
+
matchingPoolsComplete: true,
|
|
275
|
+
cpuMillicores: 2000,
|
|
276
|
+
memoryBytes: 2 * 1024 ** 3,
|
|
277
|
+
preferredFidelity: 'memory',
|
|
278
|
+
containers: ['agent', 'sidecar'],
|
|
279
|
+
},
|
|
280
|
+
egress: { state: 'set', rules: 2, destinations: ['api.openai.com', '*.arxiv.org'] },
|
|
281
|
+
related: [
|
|
282
|
+
{ kind: 'ActorTemplate', atespace: 'research', name: 'langgraph-research' },
|
|
283
|
+
{ kind: 'Node', name: 'ip-10-0-4-57' },
|
|
284
|
+
],
|
|
285
|
+
// On an actor's page the row's command names the actor.
|
|
286
|
+
attention: [{ ...crashedRow, command: 'kubectl ate revert actor lit-review-0193 -a research' }],
|
|
287
|
+
coverage: { actors: { state: 'full' }, templates: { state: 'full' }, workers: { state: 'full' }, pools: { state: 'full' } },
|
|
288
|
+
matchingPools: [{ namespace: 'agent-ns', name: 'agent-pool' }],
|
|
289
|
+
matchingPoolsComplete: true,
|
|
290
|
+
recovery: { generation: 14, fidelity: 'memory', resumesWith: 'memory', discarded: [] },
|
|
291
|
+
...overrides,
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** GET /connection on a local private Radar, for a context with nothing saved. */
|
|
296
|
+
export function connection(overrides: Partial<SubstrateLocalConnection> = {}): SubstrateLocalConnection {
|
|
297
|
+
return {
|
|
298
|
+
view: 'local',
|
|
299
|
+
target: { binding: 'b', context: 'kind-demo', fingerprint: 'f', clientGeneration: 1, operationGeneration: 1 },
|
|
300
|
+
revision: 'r1',
|
|
301
|
+
saved: false,
|
|
302
|
+
settings: null,
|
|
303
|
+
sharedPrincipal: 'system:serviceaccount:ate-system:ate-client',
|
|
304
|
+
access: { state: 'notConfigured', code: 'notConfigured' },
|
|
305
|
+
...overrides,
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** GET /connection on an in-cluster Radar or Radar Hub. */
|
|
310
|
+
export function managedConnection(overrides: Partial<SubstrateManagedConnectionView> = {}): SubstrateManagedConnectionView {
|
|
311
|
+
return {
|
|
312
|
+
view: 'managed',
|
|
313
|
+
sharedPrincipal: 'system:serviceaccount:ate-system:ate-client',
|
|
314
|
+
access: ownerTier,
|
|
315
|
+
managed: {
|
|
316
|
+
enabled: true,
|
|
317
|
+
readsAs: 'eachUser',
|
|
318
|
+
endpoint: 'api.ate-system.svc:443',
|
|
319
|
+
serverName: 'api.ate-system.svc',
|
|
320
|
+
trust: 'clusterTrustBundle',
|
|
321
|
+
helm: { api: 'substrate.api.enabled', endpoint: 'substrate.api.endpoint', serverName: 'substrate.api.serverName', ca: 'substrate.api.caConfigMap', atespaces: 'substrate.api.atespaces' },
|
|
322
|
+
},
|
|
323
|
+
...overrides,
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { Bot } from 'lucide-react'
|
|
3
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import type { APIResource } from '../../types'
|
|
5
|
+
import { useRadarFeature } from '../../api/client'
|
|
6
|
+
import { useSubstrateWorkspace } from '../../api/substrateWorkspace'
|
|
7
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
8
|
+
import { AGENTS_SIDEBAR_CATEGORY } from '../workspace/sidebar'
|
|
9
|
+
import { substrateAttentionCount, substrateScreenCounts } from './attention'
|
|
10
|
+
import { SUBSTRATE_GROUP, SUBSTRATE_POOLS_PATH, SUBSTRATE_SCREENS, SUBSTRATE_WORKERPOOL_KIND, type SubstrateScreen } from './routes'
|
|
11
|
+
|
|
12
|
+
/** Substrate's heading among the Agents row's destinations, when another runtime shares the row. */
|
|
13
|
+
export const SUBSTRATE_SIDEBAR_SECTION = 'Substrate'
|
|
14
|
+
|
|
15
|
+
/** How often the sidebar's badge alone refreshes the workspace read. */
|
|
16
|
+
export const SIDEBAR_POLL_MS = 60_000
|
|
17
|
+
|
|
18
|
+
export function substrateDiscovered(apiResources: APIResource[] | undefined): boolean {
|
|
19
|
+
return !!apiResources?.some((r) => r.group === SUBSTRATE_GROUP)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Agent Substrate in the sidebar's Integrations, as its part of the Agents
|
|
24
|
+
* row: what needs attention across it, and the Overview, Actors, Templates,
|
|
25
|
+
* Workers and Radar's WorkerPool table, each with what needs attention there.
|
|
26
|
+
* SandboxConfig and CSIDriverConfig stay under Other kinds. Undefined when
|
|
27
|
+
* Substrate is not discovered, or the connected Radar is known to predate the
|
|
28
|
+
* views. The namespace filter does not apply.
|
|
29
|
+
*/
|
|
30
|
+
export function useSubstrateSidebarWorkspace({
|
|
31
|
+
apiResources,
|
|
32
|
+
active,
|
|
33
|
+
}: {
|
|
34
|
+
apiResources: APIResource[] | undefined
|
|
35
|
+
/** The screen on show, highlighted; an object's page highlights its screen or kind instead. */
|
|
36
|
+
active?: SubstrateScreen
|
|
37
|
+
}): Record<string, SidebarCategoryWorkspace> | undefined {
|
|
38
|
+
const navigate = useWorkspaceNavigate()
|
|
39
|
+
const { support } = useRadarFeature('substrateWorkspace')
|
|
40
|
+
const available = substrateDiscovered(apiResources) && support !== 'unsupported'
|
|
41
|
+
// Slow: a Substrate screen polls the same query faster while it is open,
|
|
42
|
+
// and the query refetches at the fastest interval any observer asks for.
|
|
43
|
+
const { data } = useSubstrateWorkspace(available, { pollMs: SIDEBAR_POLL_MS })
|
|
44
|
+
const counts = useMemo(() => (data ? { total: substrateAttentionCount(data), screens: substrateScreenCounts(data) } : undefined), [data])
|
|
45
|
+
return useMemo(() => {
|
|
46
|
+
if (!available) return undefined
|
|
47
|
+
const screen = (id: Exclude<SubstrateScreen, 'overview'>) => {
|
|
48
|
+
const c = counts?.screens[id]
|
|
49
|
+
return {
|
|
50
|
+
id,
|
|
51
|
+
label: SUBSTRATE_SCREENS[id].label,
|
|
52
|
+
section: SUBSTRATE_SIDEBAR_SECTION,
|
|
53
|
+
active: active === id,
|
|
54
|
+
count: c?.count,
|
|
55
|
+
countLowerBound: c?.lowerBound,
|
|
56
|
+
countTitle: c?.title,
|
|
57
|
+
onSelect: () => navigate(SUBSTRATE_SCREENS[id].path),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const pools = counts?.screens.pools
|
|
61
|
+
return {
|
|
62
|
+
[AGENTS_SIDEBAR_CATEGORY]: {
|
|
63
|
+
tools: 'Agent Substrate',
|
|
64
|
+
icon: Bot,
|
|
65
|
+
count: counts?.total.count,
|
|
66
|
+
countLowerBound: counts?.total.lowerBound,
|
|
67
|
+
countTitle: counts?.total.title,
|
|
68
|
+
destinations: [
|
|
69
|
+
{ id: 'substrate-overview', label: SUBSTRATE_SCREENS.overview.label, section: SUBSTRATE_SIDEBAR_SECTION, active: active === 'overview', onSelect: () => navigate(SUBSTRATE_SCREENS.overview.path) },
|
|
70
|
+
screen('actors'),
|
|
71
|
+
screen('templates'),
|
|
72
|
+
screen('workers'),
|
|
73
|
+
{
|
|
74
|
+
id: 'pools',
|
|
75
|
+
label: 'Pools',
|
|
76
|
+
section: SUBSTRATE_SIDEBAR_SECTION,
|
|
77
|
+
kind: SUBSTRATE_WORKERPOOL_KIND,
|
|
78
|
+
count: pools?.count,
|
|
79
|
+
countLowerBound: pools?.lowerBound,
|
|
80
|
+
countTitle: pools?.title,
|
|
81
|
+
onSelect: () => navigate(SUBSTRATE_POOLS_PATH),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
}, [available, active, navigate, counts])
|
|
87
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WorkspaceRoute } from '../../integrations/workspaceRoute'
|
|
2
|
+
import { SUBSTRATE_NAMESPACE_FILTER_TOOLTIP, SUBSTRATE_PATH, SUBSTRATE_SCREENS, parseSubstrateRoute } from './routes'
|
|
3
|
+
|
|
4
|
+
export const substrateWorkspaceRoute: WorkspaceRoute = {
|
|
5
|
+
id: 'substrate',
|
|
6
|
+
path: SUBSTRATE_PATH,
|
|
7
|
+
label: 'Agent Substrate',
|
|
8
|
+
navView: 'resources',
|
|
9
|
+
namespaceScope: 'cluster',
|
|
10
|
+
namespaceFilterTooltip: SUBSTRATE_NAMESPACE_FILTER_TOOLTIP,
|
|
11
|
+
pageTitle(pathname) {
|
|
12
|
+
const route = parseSubstrateRoute(pathname)
|
|
13
|
+
return route.actor?.name ?? route.template?.name ?? route.pool?.name ?? SUBSTRATE_SCREENS[route.screen].title
|
|
14
|
+
},
|
|
15
|
+
contextSwitchSearch(pathname, search) {
|
|
16
|
+
// An object's page keeps its context pin, so a same-named actor in another cluster never opens.
|
|
17
|
+
const next = new URLSearchParams()
|
|
18
|
+
const context = search.get('ctx')
|
|
19
|
+
const route = parseSubstrateRoute(pathname)
|
|
20
|
+
if (context && (route.actor || route.template || route.pool)) next.set('ctx', context)
|
|
21
|
+
return next
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -74,6 +74,15 @@ describe('TrafficConnectionsTable', () => {
|
|
|
74
74
|
act(() => root.render(<TrafficConnectionsTable flows={[{ ...tcp, connections: 2 }]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
75
75
|
expect(container.querySelector('[role="row"]')!.textContent).toContain('2.03 KB')
|
|
76
76
|
})
|
|
77
|
+
|
|
78
|
+
it('shows unmeasured count and orders by bytes when hasVolumeCounts is false', () => {
|
|
79
|
+
const busy = { ...tcp, destination: { ...tcp.destination, name: 'busy-db' }, bytesSent: 50000, bytesRecv: 50000 }
|
|
80
|
+
act(() => root.render(<TrafficConnectionsTable flows={[tcp, busy]} isRateBased={false} hasVolumeCounts={false} selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
81
|
+
const rows = Array.from(container.querySelectorAll('[role="row"]'))
|
|
82
|
+
expect(rows[0].textContent).toContain('busy-db')
|
|
83
|
+
expect(rows[0].textContent).toContain('—97.7 KB')
|
|
84
|
+
expect(rows[1].textContent).toContain('—3 KB')
|
|
85
|
+
})
|
|
77
86
|
})
|
|
78
87
|
|
|
79
88
|
describe('TrafficConnectionsTable ports taken from a Service', () => {
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
interface TrafficConnectionsTableProps {
|
|
16
16
|
flows: AggregatedFlow[]
|
|
17
17
|
isRateBased: boolean
|
|
18
|
+
/** False when the source exports only byte volume without connection counts (Caretta). */
|
|
19
|
+
hasVolumeCounts?: boolean
|
|
18
20
|
selection: TrafficGraphSelection | null
|
|
19
21
|
onSelect: (selection: TrafficGraphSelection | null) => void
|
|
20
22
|
onFocus: (focus: TrafficFocus) => void
|
|
@@ -57,7 +59,7 @@ function selectedRows(rows: GraphFlow[], selection: TrafficGraphSelection | null
|
|
|
57
59
|
* the problems are comes first. Selecting a row loads its records into the
|
|
58
60
|
* flow list, as selecting an edge does; a name narrows the view to it.
|
|
59
61
|
*/
|
|
60
|
-
export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelect, onFocus, focusedId }: TrafficConnectionsTableProps) {
|
|
62
|
+
export function TrafficConnectionsTable({ flows, isRateBased, hasVolumeCounts = true, selection, onSelect, onFocus, focusedId }: TrafficConnectionsTableProps) {
|
|
61
63
|
const rows = useMemo(() => connectionRows(flows), [flows])
|
|
62
64
|
const selected = useMemo(() => selectedRows(rows, selection), [rows, selection])
|
|
63
65
|
const showStatus = useMemo(() => flows.some(hasStatusData), [flows])
|
|
@@ -137,7 +139,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
|
|
|
137
139
|
{isExternalKind(flow.destination.kind) && <span className="ml-1 text-theme-text-tertiary">ext</span>}
|
|
138
140
|
</span>
|
|
139
141
|
<span className="text-right tabular-nums text-theme-text-secondary">
|
|
140
|
-
{isRateBased && !flow.connections ? '—' : isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
|
|
142
|
+
{(isRateBased || !hasVolumeCounts) && !flow.connections ? '—' : isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
|
|
141
143
|
</span>
|
|
142
144
|
{showData && (
|
|
143
145
|
<span className="text-right tabular-nums text-theme-text-secondary">
|
|
@@ -77,6 +77,8 @@ interface TrafficFilterSidebarProps {
|
|
|
77
77
|
/** The active source measures rates rather than counting events, which changes
|
|
78
78
|
* both the unit and the useful scale of the volume filter. */
|
|
79
79
|
isRateBased?: boolean
|
|
80
|
+
/** Set when the active source exports only byte volume with no counts (Caretta). */
|
|
81
|
+
hideVolumeFilter?: boolean
|
|
80
82
|
l7Protocol: string // 'all' | 'HTTP' | 'DNS' | 'TCP'
|
|
81
83
|
setL7Protocol: (v: string) => void
|
|
82
84
|
l7Methods: Set<string>
|
|
@@ -181,6 +183,7 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
|
|
|
181
183
|
hasDNSQueries,
|
|
182
184
|
availableHTTPMethods = [],
|
|
183
185
|
isRateBased,
|
|
186
|
+
hideVolumeFilter,
|
|
184
187
|
l7Protocol,
|
|
185
188
|
setL7Protocol,
|
|
186
189
|
l7Methods,
|
|
@@ -228,20 +231,22 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
|
|
|
228
231
|
</select>
|
|
229
232
|
</Tooltip>
|
|
230
233
|
</div>
|
|
231
|
-
|
|
232
|
-
<
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
234
|
+
{!hideVolumeFilter && (
|
|
235
|
+
<div className="flex items-center gap-2">
|
|
236
|
+
<Filter className="w-3.5 h-3.5 text-theme-text-tertiary" />
|
|
237
|
+
<Tooltip content="Hide low-traffic flows to reduce noise" wrapperClassName="!flex flex-1">
|
|
238
|
+
<select
|
|
239
|
+
value={minConnections}
|
|
240
|
+
onChange={(e) => setMinConnections(Number(e.target.value))}
|
|
241
|
+
className="flex-1 bg-theme-elevated text-theme-text-primary text-xs rounded px-2 py-1.5 border border-theme-border focus:outline-none focus:ring-1 focus:ring-blue-500"
|
|
242
|
+
>
|
|
243
|
+
{volumeThresholds(isRateBased).map(({ value, label }) => (
|
|
244
|
+
<option key={value} value={value}>{label}</option>
|
|
245
|
+
))}
|
|
246
|
+
</select>
|
|
247
|
+
</Tooltip>
|
|
248
|
+
</div>
|
|
249
|
+
)}
|
|
245
250
|
</div>
|
|
246
251
|
|
|
247
252
|
{/* Filtering */}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import type { TrafficFlow, TrafficPolicyRef } from '../../types'
|
|
7
|
+
import { TrafficFlowList } from './TrafficFlowList'
|
|
8
|
+
|
|
9
|
+
vi.mock('react-virtuoso', () => ({
|
|
10
|
+
Virtuoso: ({ data, itemContent }: { data: TrafficFlow[]; itemContent: (index: number, flow: TrafficFlow) => ReactNode }) =>
|
|
11
|
+
<div>{data.map((flow, index) => <div key={index}>{itemContent(index, flow)}</div>)}</div>,
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
15
|
+
let container: HTMLDivElement
|
|
16
|
+
let root: Root
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
container = document.createElement('div')
|
|
20
|
+
document.body.appendChild(container)
|
|
21
|
+
root = createRoot(container)
|
|
22
|
+
})
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
act(() => root.unmount())
|
|
25
|
+
container.remove()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// A Calico drop between two workloads, as the Calico source reports it.
|
|
29
|
+
function calicoDrop(deniedBy: TrafficPolicyRef[]): TrafficFlow {
|
|
30
|
+
return {
|
|
31
|
+
source: { name: 'client', namespace: 'demo', kind: 'Workload', workload: 'client', workloadKind: 'Deployment' },
|
|
32
|
+
destination: { name: 'web', namespace: 'demo', kind: 'Workload', workload: 'web', workloadKind: 'Deployment' },
|
|
33
|
+
protocol: 'tcp', port: 80, trafficDirection: 'egress', verdict: 'dropped',
|
|
34
|
+
bytesSent: 60, bytesRecv: 0, connections: 1, lastSeen: '',
|
|
35
|
+
policyVerdict: { deniedBy },
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function expandedText(flow: TrafficFlow): string {
|
|
40
|
+
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
41
|
+
act(() => root.render(
|
|
42
|
+
<QueryClientProvider client={queryClient}>
|
|
43
|
+
<TrafficFlowList flows={[flow]} responsesCallerOriented={false} />
|
|
44
|
+
</QueryClientProvider>,
|
|
45
|
+
))
|
|
46
|
+
const row = Array.from(container.querySelectorAll('button')).find(b => b.textContent?.includes('client'))
|
|
47
|
+
if (!row) throw new Error('flow row not rendered')
|
|
48
|
+
act(() => row.click())
|
|
49
|
+
return container.textContent ?? ''
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('TrafficFlowList policy attribution', () => {
|
|
53
|
+
it('names a Calico NetworkPolicy apart from a Kubernetes one', () => {
|
|
54
|
+
const text = expandedText(calicoDrop([{ group: 'projectcalico.org', kind: 'NetworkPolicy', namespace: 'demo', name: 'lock-web' }]))
|
|
55
|
+
expect(text).toContain('Blocked by Calico NetworkPolicy demo/lock-web')
|
|
56
|
+
expect(text).not.toContain('default deny')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("says a tier's default deny dropped it when no rule matched", () => {
|
|
60
|
+
const text = expandedText(calicoDrop([{ group: 'projectcalico.org', kind: 'GlobalNetworkPolicy', name: 'only-dns', tierDefault: true }]))
|
|
61
|
+
expect(text).toContain("Blocked by GlobalNetworkPolicy only-dns (no rule matched; its tier's default deny)")
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState, useMemo } from 'react'
|
|
2
2
|
import { Virtuoso } from 'react-virtuoso'
|
|
3
|
-
import type { TrafficFlow, TrafficEndpoint } from '../../types'
|
|
3
|
+
import type { TrafficFlow, TrafficEndpoint, TrafficPolicyRef } from '../../types'
|
|
4
4
|
import { clsx } from 'clsx'
|
|
5
5
|
import { dedupeHTTPPairs } from './trafficFilters'
|
|
6
6
|
import { ChevronDown, ChevronUp, ShieldCheck } from 'lucide-react'
|
|
@@ -410,8 +410,12 @@ function endpointNote(ep: TrafficEndpoint): string {
|
|
|
410
410
|
return ep.ip ? 'not identified' : ''
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
/** Kind and name as the reader would look the policy up. Calico's own
|
|
414
|
+
* NetworkPolicy shares its kind with the Kubernetes one, so it is named. */
|
|
415
|
+
function policyLabel(p: TrafficPolicyRef): string {
|
|
416
|
+
const kind = p.group === 'projectcalico.org' && p.kind === 'NetworkPolicy' ? 'Calico NetworkPolicy' : p.kind
|
|
417
|
+
const name = p.namespace ? `${p.namespace}/${p.name}` : p.name
|
|
418
|
+
return `${kind} ${name}${p.tierDefault ? " (no rule matched; its tier's default deny)" : ''}`
|
|
415
419
|
}
|
|
416
420
|
|
|
417
421
|
function PolicyCorrelation({ flow }: { flow: TrafficFlow }) {
|
|
@@ -475,12 +479,12 @@ function PolicyCorrelation({ flow }: { flow: TrafficFlow }) {
|
|
|
475
479
|
// allow on a dropped flow — at another layer (L3 allowed, then dropped at
|
|
476
480
|
// L7) or at the other end — and that is not why the packet was dropped.
|
|
477
481
|
const attribution = hubbleDenied.length > 0
|
|
478
|
-
? { text: `Blocked by ${hubbleDenied.map(
|
|
482
|
+
? { text: `Blocked by ${hubbleDenied.map(policyLabel).join(', ')}`, tone: 'unhealthy' as StatusTone }
|
|
479
483
|
: withheld > 0
|
|
480
484
|
? { text: `Blocked by ${withheld === 1 ? 'a policy' : `${withheld} policies`} you don't have permission to read`, tone: 'unhealthy' as StatusTone }
|
|
481
485
|
: null
|
|
482
486
|
const alsoAllowed = hubbleAllowed.length > 0
|
|
483
|
-
? `The plugin also recorded ${hubbleAllowed.map(
|
|
487
|
+
? `The plugin also recorded ${hubbleAllowed.map(policyLabel).join(', ')} allowing this flow at another layer or at the other end. That is not the reason for the drop.`
|
|
484
488
|
: ''
|
|
485
489
|
|
|
486
490
|
if (!canQuery && !attribution) {
|