@skyhook-io/radar-app 1.21.7 → 1.22.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/README.md +1 -1
- package/package.json +2 -2
- package/src/App.tsx +26 -3
- package/src/api/client.ts +16 -3
- package/src/api/radarFeatures.ts +4 -0
- package/src/api/traefik.ts +33 -0
- package/src/api/traffic.ts +1 -0
- package/src/components/CloudFunnelButton.test.tsx +39 -1
- package/src/components/CloudFunnelButton.tsx +10 -3
- package/src/components/NamespaceSwitcher.tsx +6 -2
- package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
- package/src/components/applications/ApplicationsView.tsx +71 -142
- package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
- package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
- package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
- package/src/components/cnpg/CNPGOverview.tsx +62 -4
- package/src/components/home/HomeView.tsx +9 -1
- package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
- package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
- package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
- package/src/components/issues/IssuesPane.render.test.tsx +78 -2
- package/src/components/issues/IssuesPane.tsx +38 -6
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
- package/src/components/settings/FormSaveActions.tsx +6 -2
- package/src/components/settings/MetricsBackendSwitch.tsx +13 -15
- package/src/components/settings/OpenObserveSetup.test.tsx +68 -27
- package/src/components/settings/OpenObserveSetup.tsx +93 -123
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
- package/src/components/traffic/TrafficFlowList.tsx +5 -5
- package/src/components/traffic/TrafficGraph.test.tsx +11 -0
- package/src/components/traffic/TrafficGraph.tsx +31 -19
- package/src/components/traffic/TrafficView.tsx +17 -6
- package/src/components/traffic/traffic-export.test.ts +8 -0
- package/src/components/traffic/traffic-export.ts +7 -4
- package/src/components/traffic/trafficFilters.test.ts +51 -1
- package/src/components/traffic/trafficFilters.ts +39 -11
- package/src/components/ui/command-items-crd.test.tsx +23 -8
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.tsx +8 -6
- package/src/components/workspace/WorkspaceConditions.tsx +56 -0
- package/src/components/workspace/layout.test.tsx +20 -0
- package/src/components/workspace/layout.tsx +1 -1
- package/src/contexts/CapabilitiesContext.tsx +2 -0
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +3 -0
- package/src/utils/page-links.ts +15 -1
|
@@ -75,3 +75,17 @@ describe('TrafficFilterSidebar verdict filter', () => {
|
|
|
75
75
|
expect(container.textContent).not.toContain('Verdict')
|
|
76
76
|
})
|
|
77
77
|
})
|
|
78
|
+
|
|
79
|
+
describe('TrafficFilterSidebar overlay toggle', () => {
|
|
80
|
+
it('is offered only when the source marked flows as likely overlay, off by default', () => {
|
|
81
|
+
act(() => root.render(<TrafficFilterSidebar {...props({ setHideOverlay: vi.fn() })} />))
|
|
82
|
+
expect(container.textContent).not.toContain('Hide node-to-node overlay')
|
|
83
|
+
|
|
84
|
+
const setHideOverlay = vi.fn()
|
|
85
|
+
act(() => root.render(<TrafficFilterSidebar {...props({ hasOverlayFlows: true, hideOverlay: false, setHideOverlay })} />))
|
|
86
|
+
expect(container.textContent).toContain('Hide node-to-node overlay')
|
|
87
|
+
const toggle = Array.from(container.querySelectorAll('button')).find(b => b.textContent?.includes('Hide node-to-node overlay'))!
|
|
88
|
+
act(() => toggle.click())
|
|
89
|
+
expect(setHideOverlay).toHaveBeenCalledWith(true)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Puzzle,
|
|
13
13
|
Boxes,
|
|
14
14
|
ShieldAlert,
|
|
15
|
+
Server,
|
|
15
16
|
} from 'lucide-react'
|
|
16
17
|
import { clsx } from 'clsx'
|
|
17
18
|
import { SEVERITY_BADGE } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
@@ -35,6 +36,10 @@ interface TrafficFilterSidebarProps {
|
|
|
35
36
|
setHideSystem: (v: boolean) => void
|
|
36
37
|
hideExternal: boolean
|
|
37
38
|
setHideExternal: (v: boolean) => void
|
|
39
|
+
/** Offered only when the source marked some flows as likely overlay. */
|
|
40
|
+
hasOverlayFlows?: boolean
|
|
41
|
+
hideOverlay?: boolean
|
|
42
|
+
setHideOverlay?: (v: boolean) => void
|
|
38
43
|
minConnections: number
|
|
39
44
|
setMinConnections: (v: number) => void
|
|
40
45
|
|
|
@@ -151,6 +156,9 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
|
|
|
151
156
|
setHideSystem,
|
|
152
157
|
hideExternal,
|
|
153
158
|
setHideExternal,
|
|
159
|
+
hasOverlayFlows,
|
|
160
|
+
hideOverlay,
|
|
161
|
+
setHideOverlay,
|
|
154
162
|
minConnections,
|
|
155
163
|
setMinConnections,
|
|
156
164
|
showNamespaceGroups,
|
|
@@ -257,6 +265,15 @@ export const TrafficFilterSidebar = memo(function TrafficFilterSidebar({
|
|
|
257
265
|
onToggle={() => setHideExternal(!hideExternal)}
|
|
258
266
|
icon={Globe}
|
|
259
267
|
/>
|
|
268
|
+
{hasOverlayFlows && setHideOverlay && (
|
|
269
|
+
<ToggleOption
|
|
270
|
+
label="Hide node-to-node overlay"
|
|
271
|
+
description="UDP between two nodes is likely CNI overlay (VXLAN, Geneve) carrying pod traffic already on the map. Unless Beyla reports the port, a guess: WireGuard or DNS between nodes look the same."
|
|
272
|
+
enabled={!!hideOverlay}
|
|
273
|
+
onToggle={() => setHideOverlay(!hideOverlay)}
|
|
274
|
+
icon={Server}
|
|
275
|
+
/>
|
|
276
|
+
)}
|
|
260
277
|
</div>
|
|
261
278
|
|
|
262
279
|
{/* Cluster Addons 3-way toggle */}
|
|
@@ -8,7 +8,7 @@ import { SEVERITY_BADGE, SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-co
|
|
|
8
8
|
import { pluralize, StatusDot } from '@skyhook-io/k8s-ui'
|
|
9
9
|
import type { StatusTone } from '@skyhook-io/k8s-ui'
|
|
10
10
|
import { useFlowSearch } from './TrafficFlowListContext'
|
|
11
|
-
import { isPolicyDropReason, protocolLabel } from './trafficFilters'
|
|
11
|
+
import { isPolicyDropReason, portLabel, protocolLabel } from './trafficFilters'
|
|
12
12
|
import { useQuery } from '@tanstack/react-query'
|
|
13
13
|
import { fetchJSON } from '../../api/client'
|
|
14
14
|
import { Tooltip } from '../ui/Tooltip'
|
|
@@ -208,7 +208,7 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
|
|
|
208
208
|
</>
|
|
209
209
|
)}
|
|
210
210
|
{!isHTTP && !isDNS && (
|
|
211
|
-
<span className="text-theme-text-tertiary uppercase">{flow.port
|
|
211
|
+
<span className="text-theme-text-tertiary"><span className="uppercase">{flow.protocol}</span>{portLabel(flow.port, flow.portSource) && `:${portLabel(flow.port, flow.portSource)}`}</span>
|
|
212
212
|
)}
|
|
213
213
|
</div>
|
|
214
214
|
|
|
@@ -255,10 +255,10 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
|
|
|
255
255
|
<span className="text-theme-text-primary">{protocolLabel(flow.l7Protocol, flow.protocol)}</span>
|
|
256
256
|
{flow.httpProtocol && <span className="text-theme-text-tertiary"> ({flow.httpProtocol})</span>}
|
|
257
257
|
</div>
|
|
258
|
-
{flow.port
|
|
258
|
+
{portLabel(flow.port, flow.portSource) && (
|
|
259
259
|
<div>
|
|
260
260
|
<span className="text-theme-text-tertiary">Port: </span>
|
|
261
|
-
<span className="text-theme-text-primary">{flow.port}</span>
|
|
261
|
+
<span className="text-theme-text-primary">{portLabel(flow.port, flow.portSource)}</span>
|
|
262
262
|
</div>
|
|
263
263
|
)}
|
|
264
264
|
{flow.trafficDirection && (
|
|
@@ -440,7 +440,7 @@ function PolicyCorrelation({ flow }: { flow: TrafficFlow }) {
|
|
|
440
440
|
if (src?.name) params.set('sourcePodName', src.name)
|
|
441
441
|
if (src?.kind) params.set('sourceKind', src.kind)
|
|
442
442
|
if (src?.ip) params.set('sourceIP', src.ip)
|
|
443
|
-
if (flow.port) params.set('port', String(flow.port))
|
|
443
|
+
if (flow.port && !flow.portSource) params.set('port', String(flow.port))
|
|
444
444
|
if (flow.protocol) params.set('protocol', flow.protocol)
|
|
445
445
|
return fetchJSON(`/network-policies/evaluate?${params}`)
|
|
446
446
|
},
|
|
@@ -297,3 +297,14 @@ describe('TrafficNode title', () => {
|
|
|
297
297
|
expect(container.querySelector(`[title="${label}"]`)!.closest('[aria-hidden="true"]')).not.toBeNull()
|
|
298
298
|
})
|
|
299
299
|
})
|
|
300
|
+
|
|
301
|
+
it('draws likely-overlay traffic between two nodes as its own edge', async () => {
|
|
302
|
+
const nodeA = { name: 'node-a', namespace: '', kind: 'External' }
|
|
303
|
+
const nodeB = { name: 'node-b', namespace: '', kind: 'External' }
|
|
304
|
+
const tcp: AggregatedFlow = { source: nodeA, destination: nodeB, protocol: 'tcp', port: 0, connections: 0, bytesSent: 10, bytesRecv: 0, flowCount: 1, lastSeen: '' }
|
|
305
|
+
const overlay: AggregatedFlow = { ...tcp, protocol: 'udp', bytesSent: 1000, likelyOverlay: true }
|
|
306
|
+
await act(async () => root.render(<TrafficGraph flows={[tcp, overlay]} trafficSource="beyla" onLayoutUnavailable={vi.fn()} windowSeconds={60} />))
|
|
307
|
+
const ids = [...container.querySelectorAll('[data-edge]')].map(e => e.getAttribute('data-edge'))
|
|
308
|
+
expect(ids).toContain('node-a->node-b:0')
|
|
309
|
+
expect(ids).toContain('node-a->node-b:0:overlay')
|
|
310
|
+
})
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@xyflow/react'
|
|
17
17
|
import '@xyflow/react/dist/style.css'
|
|
18
18
|
import type { ELK } from 'elkjs/lib/elk.bundled.js'
|
|
19
|
-
import type { AggregatedFlow } from '../../types'
|
|
19
|
+
import type { AggregatedFlow, TrafficPortSource } from '../../types'
|
|
20
20
|
import { clsx } from 'clsx'
|
|
21
21
|
import { X, ArrowRight, Globe, Server, Activity, Puzzle, Crosshair } from 'lucide-react'
|
|
22
22
|
import { GraphExportButton, MiddleEllipsis, PaneLoader } from '@skyhook-io/k8s-ui'
|
|
@@ -26,7 +26,7 @@ import { getNamespaceColor } from '../../utils/traffic-colors'
|
|
|
26
26
|
import { Tooltip } from '../ui/Tooltip'
|
|
27
27
|
import { TrafficData } from './TrafficData'
|
|
28
28
|
import { describeTrafficNode } from './traffic-export'
|
|
29
|
-
import { dataByProtocol, protocolsOf, throughputLabel, totalDataByProtocol, protocolName, isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, formatConnections, formatVolume, MAX_VISIBLE_PORTS, displayVolume, latencyWeightOf, edgesOnPort, protocolLabel, type TrafficFocus } from './trafficFilters'
|
|
29
|
+
import { dataByProtocol, protocolsOf, throughputLabel, totalDataByProtocol, protocolName, isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, formatConnections, formatVolume, MAX_VISIBLE_PORTS, displayVolume, latencyWeightOf, edgesOnPort, protocolLabel, portLabel, type TrafficFocus } from './trafficFilters'
|
|
30
30
|
|
|
31
31
|
// ELK is 1.5 MB; load it with the first traffic layout, not with the app.
|
|
32
32
|
let elkPromise: Promise<ELK> | null = null
|
|
@@ -64,8 +64,9 @@ export interface TrafficGraphSelection {
|
|
|
64
64
|
sourceId?: string
|
|
65
65
|
destId?: string
|
|
66
66
|
port?: number
|
|
67
|
-
// The graph draws traffic of unknown direction as its own edge.
|
|
67
|
+
// The graph draws traffic of unknown direction, and likely overlay, as its own edge.
|
|
68
68
|
directionUnknown?: boolean
|
|
69
|
+
likelyOverlay?: boolean
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
interface TrafficGraphProps {
|
|
@@ -157,6 +158,8 @@ function StatusDistributionBar({ counts }: { counts: Record<string, number> }) {
|
|
|
157
158
|
interface PortInfo {
|
|
158
159
|
port: number
|
|
159
160
|
connections: number
|
|
161
|
+
/** Set when no edge observed this port: taken from a Service, or, on port 0, several Service ports. */
|
|
162
|
+
portSource?: TrafficPortSource
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
interface TrafficNodeData extends Record<string, unknown> {
|
|
@@ -301,15 +304,15 @@ export function TrafficNode({ data }: { data: TrafficNodeData }) {
|
|
|
301
304
|
</div>
|
|
302
305
|
)}
|
|
303
306
|
{/* Ports section */}
|
|
304
|
-
{data.ports && data.ports.filter(p => p.port !==
|
|
307
|
+
{data.ports && data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length > 0 && (
|
|
305
308
|
<div className="mt-1.5 space-y-0.5">
|
|
306
|
-
{data.ports.filter(p => p.port !==
|
|
309
|
+
{data.ports.filter(p => portLabel(p.port, p.portSource) !== null).slice(0, MAX_VISIBLE_PORTS).map((portInfo) => (
|
|
307
310
|
<div key={portInfo.port} className="flex items-center justify-between gap-1 text-xs">
|
|
308
311
|
<span className={clsx(
|
|
309
312
|
'font-mono',
|
|
310
313
|
(hasNamespaceColor || isAddonNode) ? 'text-cyan-300' : 'text-blue-600 dark:text-blue-300'
|
|
311
314
|
)}>
|
|
312
|
-
:{portInfo.port}
|
|
315
|
+
:{portLabel(portInfo.port, portInfo.portSource)}
|
|
313
316
|
</span>
|
|
314
317
|
{/* A port serving traffic with no HTTP has no request rate to show, and
|
|
315
318
|
"0" beside the port reads as an idle port rather than an unmeasured
|
|
@@ -328,18 +331,18 @@ export function TrafficNode({ data }: { data: TrafficNodeData }) {
|
|
|
328
331
|
)}
|
|
329
332
|
</div>
|
|
330
333
|
))}
|
|
331
|
-
{data.ports.filter(p => p.port !==
|
|
334
|
+
{data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length > MAX_VISIBLE_PORTS && (
|
|
332
335
|
<div className={clsx(
|
|
333
336
|
'text-xs',
|
|
334
337
|
(hasNamespaceColor || isAddonNode) ? 'text-white/50' : 'text-theme-text-tertiary'
|
|
335
338
|
)}>
|
|
336
|
-
+{data.ports.filter(p => p.port !==
|
|
339
|
+
+{data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length - MAX_VISIBLE_PORTS} more
|
|
337
340
|
</div>
|
|
338
341
|
)}
|
|
339
342
|
</div>
|
|
340
343
|
)}
|
|
341
344
|
{/* Total connections (only if no ports shown, or all ports are 0) */}
|
|
342
|
-
{(!data.ports || data.ports.filter(p => p.port !==
|
|
345
|
+
{(!data.ports || data.ports.filter(p => portLabel(p.port, p.portSource) !== null).length === 0) && data.totalConnections != null && data.totalConnections > 0 && (
|
|
343
346
|
<div className="mt-1">
|
|
344
347
|
<span className={clsx(
|
|
345
348
|
'text-xs truncate',
|
|
@@ -754,8 +757,8 @@ function DetailsPanel({
|
|
|
754
757
|
) : (
|
|
755
758
|
<ArrowRight className="h-3 w-3 text-theme-text-tertiary shrink-0" />
|
|
756
759
|
)}
|
|
757
|
-
{flow.port
|
|
758
|
-
<span className="text-blue-400 font-mono">:{flow.port}</span>
|
|
760
|
+
{portLabel(flow.port, flow.portSource) && (
|
|
761
|
+
<span className="text-blue-400 font-mono">:{portLabel(flow.port, flow.portSource)}</span>
|
|
759
762
|
)}
|
|
760
763
|
</div>
|
|
761
764
|
<div className="flex items-center gap-2 text-[10px]">
|
|
@@ -806,8 +809,8 @@ function DetailsPanel({
|
|
|
806
809
|
<span className="text-theme-text-primary truncate flex-1">
|
|
807
810
|
{flow.destination.name}
|
|
808
811
|
</span>
|
|
809
|
-
{flow.port
|
|
810
|
-
<span className="text-blue-400 font-mono">:{flow.port}</span>
|
|
812
|
+
{portLabel(flow.port, flow.portSource) && (
|
|
813
|
+
<span className="text-blue-400 font-mono">:{portLabel(flow.port, flow.portSource)}</span>
|
|
811
814
|
)}
|
|
812
815
|
</div>
|
|
813
816
|
<div className="flex items-center gap-2 text-[10px]">
|
|
@@ -858,10 +861,10 @@ function DetailsPanel({
|
|
|
858
861
|
</div>
|
|
859
862
|
|
|
860
863
|
<div className="grid grid-cols-2 gap-2 text-xs">
|
|
861
|
-
{edgeData.port
|
|
864
|
+
{portLabel(edgeData.port, edgeData.flow?.portSource) && (
|
|
862
865
|
<div className="p-2 rounded bg-theme-elevated">
|
|
863
866
|
<div className="text-theme-text-tertiary">Port</div>
|
|
864
|
-
<div className="text-theme-text-primary font-medium">{edgeData.port}</div>
|
|
867
|
+
<div className="text-theme-text-primary font-medium">{portLabel(edgeData.port, edgeData.flow?.portSource)}</div>
|
|
865
868
|
</div>
|
|
866
869
|
)}
|
|
867
870
|
<div className="p-2 rounded bg-theme-elevated">
|
|
@@ -1151,7 +1154,8 @@ function isFocusable(id: string, data: TrafficNodeData | undefined): boolean {
|
|
|
1151
1154
|
// one would silently replace the other. Only unoriented edges are suffixed, so
|
|
1152
1155
|
// every id a source that always orients its flows produces is unchanged.
|
|
1153
1156
|
function trafficEdgeId(sourceId: string, destId: string, flow: AggregatedFlow): string {
|
|
1154
|
-
|
|
1157
|
+
// The server keeps likely-overlay traffic apart from the rest between the same nodes.
|
|
1158
|
+
return `${sourceId}->${destId}:${flow.port}${flow.directionUnknown ? ':unoriented' : ''}${flow.likelyOverlay ? ':overlay' : ''}`
|
|
1155
1159
|
}
|
|
1156
1160
|
|
|
1157
1161
|
export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups = false, serviceCategories, addonMode = 'show', trafficSource = '', selection: viewSelection, onSelectionChange, onFocus, focusedId, onLayoutUnavailable, windowSeconds, onDownloadBlob }: TrafficGraphProps) {
|
|
@@ -1194,6 +1198,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
|
|
|
1194
1198
|
|
|
1195
1199
|
// Track primary port for each node (most common destination port)
|
|
1196
1200
|
const nodePorts = new Map<string, Map<number, number>>() // nodeId -> port -> connection count
|
|
1201
|
+
const observedPorts = new Set<string>() // `${nodeId}|${port}` seen on an edge that observed it
|
|
1202
|
+
const multiplePorts = new Set<string>() // nodes an edge reached on several possible Service ports
|
|
1197
1203
|
|
|
1198
1204
|
// Count connections per node
|
|
1199
1205
|
flows.forEach((flow) => {
|
|
@@ -1218,6 +1224,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
|
|
|
1218
1224
|
if (!nodePorts.has(destId)) nodePorts.set(destId, new Map())
|
|
1219
1225
|
const portCounts = nodePorts.get(destId)!
|
|
1220
1226
|
portCounts.set(flow.port, (portCounts.get(flow.port) || 0) + volume)
|
|
1227
|
+
if (!flow.portSource) observedPorts.add(`${destId}|${flow.port}`)
|
|
1228
|
+
if (flow.portSource === 'serviceMultiple') multiplePorts.add(destId)
|
|
1221
1229
|
if (flow.connections >= hotPathThreshold && hotPathThreshold > 0) hotNodes.add(destId)
|
|
1222
1230
|
}
|
|
1223
1231
|
})
|
|
@@ -1228,7 +1236,10 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
|
|
|
1228
1236
|
if (!ports || ports.size === 0) return []
|
|
1229
1237
|
const portList: PortInfo[] = []
|
|
1230
1238
|
ports.forEach((connections, port) => {
|
|
1231
|
-
|
|
1239
|
+
const portSource: TrafficPortSource | undefined = port === 0
|
|
1240
|
+
? (multiplePorts.has(nodeId) ? 'serviceMultiple' : undefined)
|
|
1241
|
+
: (observedPorts.has(`${nodeId}|${port}`) ? undefined : 'service')
|
|
1242
|
+
portList.push({ port, connections, ...(portSource && { portSource }) })
|
|
1232
1243
|
})
|
|
1233
1244
|
// Sort by connection count descending
|
|
1234
1245
|
return portList.sort((a, b) => b.connections - a.connections)
|
|
@@ -1739,7 +1750,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
|
|
|
1739
1750
|
}
|
|
1740
1751
|
const between = layoutedEdges.filter(e =>
|
|
1741
1752
|
e.source === viewSelection.sourceId && e.target === viewSelection.destId &&
|
|
1742
|
-
!!flowByEdgeId.get(e.id)?.directionUnknown === !!viewSelection.directionUnknown
|
|
1753
|
+
!!flowByEdgeId.get(e.id)?.directionUnknown === !!viewSelection.directionUnknown &&
|
|
1754
|
+
!!flowByEdgeId.get(e.id)?.likelyOverlay === !!viewSelection.likelyOverlay)
|
|
1743
1755
|
const [edge] = edgesOnPort(between, e => flowByEdgeId.get(e.id), viewSelection.port)
|
|
1744
1756
|
setSelection(edge ? edgeSelection(edge, flowByEdgeId.get(edge.id)) : null)
|
|
1745
1757
|
}, [viewSelection, layoutedNodes, layoutedEdges, flowByEdgeId])
|
|
@@ -1768,7 +1780,7 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
|
|
|
1768
1780
|
const onEdgeClick: EdgeMouseHandler<Edge> = useCallback((_event, edge) => {
|
|
1769
1781
|
const flow = flowByEdgeId.get(edge.id)
|
|
1770
1782
|
setSelection(edgeSelection(edge, flow))
|
|
1771
|
-
onSelectionChange?.({ type: 'edge', sourceId: edge.source, destId: edge.target, port: flow?.port, directionUnknown: !!flow?.directionUnknown })
|
|
1783
|
+
onSelectionChange?.({ type: 'edge', sourceId: edge.source, destId: edge.target, port: flow?.port, directionUnknown: !!flow?.directionUnknown, ...(flow?.likelyOverlay && { likelyOverlay: true }) })
|
|
1772
1784
|
}, [flowByEdgeId, onSelectionChange])
|
|
1773
1785
|
|
|
1774
1786
|
const onPaneClick = useCallback(() => {
|
|
@@ -20,7 +20,7 @@ import { useDesktopBlobDownload } from '../../hooks/useDesktopDownload'
|
|
|
20
20
|
import { Tooltip } from '../ui/Tooltip'
|
|
21
21
|
import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
22
22
|
import { DURATION_DOCK } from '@skyhook-io/k8s-ui/utils/animation'
|
|
23
|
-
import { matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, type VolumeUnit, isExternalKind, groupAddonFlows, mergeFlowVolume, coverageLabel, type GraphFlow, endpointPair, graphEndpoint, graphEndpointId, mergeRawPairs,
|
|
23
|
+
import { matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, type VolumeUnit, isExternalKind, groupAddonFlows, mergeFlowVolume, coverageLabel, type GraphFlow, endpointPair, graphEndpoint, graphEndpointId, mergeRawPairs, mergeEdgePortInto, selectedEdgeMatcher, selectionRawPairs, selectionMatch, graphSize, GRAPH_DRAW_BUDGET, GRAPH_DRAW_CEILING, parseFocus, focusParam, focusId, focusNeighborhood, touchesFocus, endpointSummaries, namespaceSummaries, verdictChoices, type TrafficFocus, warningRetries, warningBannerTitle, emptyWarningHeadline, rateWindowSeconds } from './trafficFilters'
|
|
24
24
|
|
|
25
25
|
// Where a warning about which cluster the traffic belongs to points: how the map
|
|
26
26
|
// keeps to this cluster in a shared metrics store, and how to set its label.
|
|
@@ -397,6 +397,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
397
397
|
const [timeRange, setTimeRange] = useState<string>('5m')
|
|
398
398
|
const [hideSystem, setHideSystem] = useState(true)
|
|
399
399
|
const [hideExternal, setHideExternal] = useState(false)
|
|
400
|
+
// Off by default: the classification is a guess, and real traffic matches it.
|
|
401
|
+
const [hideOverlay, setHideOverlay] = useState(false)
|
|
400
402
|
const [minConnections, setMinConnections] = useState(0)
|
|
401
403
|
// The unit the threshold above was picked under. Stored because the number alone
|
|
402
404
|
// is ambiguous: 100 is a valid step in both scales and means something different
|
|
@@ -609,6 +611,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
609
611
|
const activeDnsPattern = l7Capabilities.hasDNSQueries ? dnsPattern : ''
|
|
610
612
|
const activeMinConnections = effectiveThreshold(minConnections, minConnectionsUnit, volumeUnit(isRateBased))
|
|
611
613
|
|
|
614
|
+
const hasOverlayFlows = useMemo(() => !!flowsData?.aggregated?.some(f => f.likelyOverlay), [flowsData?.aggregated])
|
|
615
|
+
|
|
612
616
|
const filteredFlows = useMemo<AggregatedFlow[]>(() => {
|
|
613
617
|
if (!flowsData?.aggregated) return []
|
|
614
618
|
|
|
@@ -638,6 +642,8 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
638
642
|
return false
|
|
639
643
|
}
|
|
640
644
|
|
|
645
|
+
if (hideOverlay && flow.likelyOverlay) return false
|
|
646
|
+
|
|
641
647
|
// If hiding external, skip flows with external endpoints
|
|
642
648
|
if (hideExternal) {
|
|
643
649
|
if (isExternal(flow.source.kind) || isExternal(flow.destination.kind)) {
|
|
@@ -687,7 +693,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
687
693
|
|
|
688
694
|
return true
|
|
689
695
|
})
|
|
690
|
-
}, [flowsData?.aggregated, hideSystem, hideExternal, activeMinConnections, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern])
|
|
696
|
+
}, [flowsData?.aggregated, hideSystem, hideExternal, hideOverlay, activeMinConnections, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern])
|
|
691
697
|
|
|
692
698
|
// The graph's filters, applied to individual records for the list view
|
|
693
699
|
const rawFlowPasses = useCallback((flow: TrafficFlow) => {
|
|
@@ -706,6 +712,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
706
712
|
if (isAlwaysFiltered(flow.source.name) || isAlwaysFiltered(flow.destination.name)) return false
|
|
707
713
|
|
|
708
714
|
if (hideExternal && (isExternal(flow.source.kind) || isExternal(flow.destination.kind))) return false
|
|
715
|
+
if (hideOverlay && flow.likelyOverlay) return false
|
|
709
716
|
|
|
710
717
|
if (addonMode === 'hide') {
|
|
711
718
|
if (isClusterAddon(sourceName, flow.source.namespace) || isClusterAddon(destName, flow.destination.namespace)) return false
|
|
@@ -734,7 +741,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
734
741
|
}
|
|
735
742
|
|
|
736
743
|
return true
|
|
737
|
-
}, [hideSystem, hideExternal, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern, drawnEndpoint])
|
|
744
|
+
}, [hideSystem, hideExternal, hideOverlay, hiddenNamespaces, addonMode, l7Protocol, activeMethods, activeStatusRanges, activeVerdicts, activeDnsPattern, drawnEndpoint])
|
|
738
745
|
|
|
739
746
|
const filteredRawFlows = useMemo(
|
|
740
747
|
() => (flowsData?.flows ?? []).filter(rawFlowPasses),
|
|
@@ -845,13 +852,13 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
845
852
|
// Traffic whose direction is known is kept apart from traffic whose direction
|
|
846
853
|
// is not, the same way the backend aggregation keys it: merging them would
|
|
847
854
|
// give one edge a single arrowhead answer that is wrong for half its bytes.
|
|
848
|
-
const key = `${sourceKey}->${destKey}|${flow.directionUnknown ? 'u' : 'o'}`
|
|
855
|
+
const key = `${sourceKey}->${destKey}|${flow.directionUnknown ? 'u' : 'o'}${flow.likelyOverlay ? '|v' : ''}`
|
|
849
856
|
|
|
850
857
|
const existing = aggregatedMap.get(key)
|
|
851
858
|
if (existing) {
|
|
852
859
|
mergeFlowVolume(existing, flow)
|
|
853
860
|
mergeRawPairs(existing, flow)
|
|
854
|
-
|
|
861
|
+
mergeEdgePortInto(existing, flow)
|
|
855
862
|
// Everything merged here shares the key's direction-known state, so the
|
|
856
863
|
// flag is already correct on the entry that was created first.
|
|
857
864
|
} else {
|
|
@@ -898,6 +905,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
898
905
|
if (existing) {
|
|
899
906
|
mergeFlowVolume(existing, flow)
|
|
900
907
|
mergeRawPairs(existing, flow)
|
|
908
|
+
mergeEdgePortInto(existing, flow)
|
|
901
909
|
} else {
|
|
902
910
|
// Create new "Internet" → destination flow
|
|
903
911
|
internetFlowsMap.set(destKey, {
|
|
@@ -948,7 +956,7 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
948
956
|
// Everything that makes it a different view. A refresh doesn't, so a view
|
|
949
957
|
// that was drawn keeps being drawn as its size drifts past the budget.
|
|
950
958
|
const viewKey = JSON.stringify([
|
|
951
|
-
sourcesData?.active ?? '', namespaces, timeRange, focusKey ?? '', groupByWorkload, hideSystem, hideExternal, activeMinConnections,
|
|
959
|
+
sourcesData?.active ?? '', namespaces, timeRange, focusKey ?? '', groupByWorkload, hideSystem, hideExternal, hideOverlay, activeMinConnections,
|
|
952
960
|
[...hiddenNamespaces].sort(), addonMode, aggregateExternal, detectServices, collapseInternet,
|
|
953
961
|
l7Protocol, [...activeMethods].sort(), [...activeStatusRanges].sort(), [...activeVerdicts].sort(), activeDnsPattern,
|
|
954
962
|
])
|
|
@@ -1295,6 +1303,9 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1295
1303
|
setHideSystem={setHideSystem}
|
|
1296
1304
|
hideExternal={hideExternal}
|
|
1297
1305
|
setHideExternal={setHideExternal}
|
|
1306
|
+
hasOverlayFlows={hasOverlayFlows}
|
|
1307
|
+
hideOverlay={hideOverlay}
|
|
1308
|
+
setHideOverlay={setHideOverlay}
|
|
1298
1309
|
minConnections={activeMinConnections}
|
|
1299
1310
|
setMinConnections={chooseMinConnections}
|
|
1300
1311
|
showNamespaceGroups={showNamespaceGroups}
|
|
@@ -49,3 +49,11 @@ describe('describeTrafficNode', () => {
|
|
|
49
49
|
expect(describeTrafficNode({ id: 'addon-internet', type: 'traffic', data: { kind: 'AddonInternet', label: 'Internet' } })?.shape).toBe('internet')
|
|
50
50
|
})
|
|
51
51
|
})
|
|
52
|
+
|
|
53
|
+
describe('describeTrafficNode ports taken from a Service', () => {
|
|
54
|
+
it('marks them as on the card', () => {
|
|
55
|
+
const ports = [{ port: 5432, connections: 3, portSource: 'service' }, { port: 0, connections: 1, portSource: 'serviceMultiple' }, { port: 80, connections: 2 }]
|
|
56
|
+
const node = describeTrafficNode({ id: 'shop/db', type: 'traffic', data: { kind: 'Pod', label: 'db', ports } })
|
|
57
|
+
expect(node?.rows?.map(r => r.text)).toEqual([':5432 (from Service)', ':multiple (from Service)', ':80'])
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CircleQuestionMark, Database, Globe, Puzzle, Server } from 'lucide-react'
|
|
2
2
|
import { getTopologyIcon } from '@skyhook-io/k8s-ui'
|
|
3
3
|
import type { GraphBoxRow, GraphNodeMapper } from '@skyhook-io/k8s-ui/utils/graph-model'
|
|
4
|
-
import { formatVolume, isExternalKind, MAX_VISIBLE_PORTS } from './trafficFilters'
|
|
4
|
+
import { formatVolume, isExternalKind, MAX_VISIBLE_PORTS, portLabel } from './trafficFilters'
|
|
5
|
+
import type { TrafficPortSource } from '../../types'
|
|
5
6
|
|
|
6
7
|
// Hex values of the Tailwind 500 shades the traffic nodes use for these categories.
|
|
7
8
|
const CATEGORY_COLORS: Record<string, string> = {
|
|
@@ -37,11 +38,13 @@ function trafficRows(data: Record<string, unknown>, hot: boolean): GraphBoxRow[]
|
|
|
37
38
|
if (typeof p !== 'object' || p === null || !('port' in p)) return []
|
|
38
39
|
const port = num(p.port)
|
|
39
40
|
const connections = ('connections' in p ? num(p.connections) : undefined) ?? 0
|
|
40
|
-
|
|
41
|
+
const source = 'portSource' in p && (p.portSource === 'service' || p.portSource === 'serviceMultiple') ? p.portSource as TrafficPortSource : undefined
|
|
42
|
+
const label = portLabel(port ?? 0, source)
|
|
43
|
+
return label ? [{ label, connections }] : []
|
|
41
44
|
})
|
|
42
45
|
if (ports.length > 0) {
|
|
43
|
-
const rows: GraphBoxRow[] = ports.slice(0, MAX_VISIBLE_PORTS).map(({
|
|
44
|
-
text: `:${
|
|
46
|
+
const rows: GraphBoxRow[] = ports.slice(0, MAX_VISIBLE_PORTS).map(({ label, connections }) => ({
|
|
47
|
+
text: `:${label}`,
|
|
45
48
|
code: true,
|
|
46
49
|
hot,
|
|
47
50
|
// No figure for a port with no measured traffic, as on the card.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import type { AggregatedFlow, TrafficFlow } from '../../types'
|
|
3
|
-
import { dataByProtocol, protocolsOf, totalDataByProtocol, rateWindowSeconds, throughputLabel, protocolName, matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, isExternalKind, isPolicyDropReason, requestRateOf, errorRateOf, formatRate, displayVolume, groupAddonFlows, mergeFlowVolume, dedupeHTTPPairs, coverageLabel, latencyWeightOf, endpointPair, selectionRawPairs, mergeRawPairs, graphEndpoint, graphSize, parseFocus, focusParam, focusId, touchesFocus, focusNeighborhood, endpointSummaries, searchEndpoints, namespaceSummaries, namespaceOverBudget, hasStatusData, connectionRows, selectionMatch, edgeCarriesPort, edgesOnPort, mergedEdgePort, selectedEdgeMatcher, verdictChoices, warningRetries, warningBannerTitle, emptyWarningHeadline, protocolLabel, type GraphFlow } from './trafficFilters'
|
|
3
|
+
import { dataByProtocol, protocolsOf, totalDataByProtocol, rateWindowSeconds, throughputLabel, protocolName, matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, isExternalKind, isPolicyDropReason, requestRateOf, errorRateOf, formatRate, displayVolume, groupAddonFlows, mergeFlowVolume, dedupeHTTPPairs, coverageLabel, latencyWeightOf, endpointPair, selectionRawPairs, mergeRawPairs, graphEndpoint, graphSize, parseFocus, focusParam, focusId, touchesFocus, focusNeighborhood, endpointSummaries, searchEndpoints, namespaceSummaries, namespaceOverBudget, hasStatusData, connectionRows, selectionMatch, edgeCarriesPort, edgesOnPort, mergedEdgePort, mergeEdgePortInto, portLabel, selectedEdgeMatcher, verdictChoices, warningRetries, warningBannerTitle, emptyWarningHeadline, protocolLabel, type GraphFlow } from './trafficFilters'
|
|
4
4
|
|
|
5
5
|
describe('matchesStatusRanges', () => {
|
|
6
6
|
it('does not filter when nothing is selected', () => {
|
|
@@ -885,3 +885,53 @@ describe('throughputLabel', () => {
|
|
|
885
885
|
expect(throughputLabel({ ...base, bytesByProtocol: { tcp: { bytesSent: 0, bytesRecv: 0 } } }, 60)).toBe('')
|
|
886
886
|
})
|
|
887
887
|
})
|
|
888
|
+
|
|
889
|
+
describe('portLabel', () => {
|
|
890
|
+
it('marks a port taken from a Service', () => {
|
|
891
|
+
expect(portLabel(5432, 'service')).toBe('5432 (from Service)')
|
|
892
|
+
expect(portLabel(0, 'serviceMultiple')).toBe('multiple (from Service)')
|
|
893
|
+
expect(portLabel(80)).toBe('80')
|
|
894
|
+
expect(portLabel(0)).toBeNull()
|
|
895
|
+
})
|
|
896
|
+
})
|
|
897
|
+
|
|
898
|
+
describe('mergeEdgePortInto', () => {
|
|
899
|
+
const merge = (a: { port: number; portSource?: 'service' | 'serviceMultiple' }, b: typeof a) => {
|
|
900
|
+
const into = { ...a }
|
|
901
|
+
mergeEdgePortInto(into, b)
|
|
902
|
+
return into
|
|
903
|
+
}
|
|
904
|
+
it('keeps the marking of the port it shows', () => {
|
|
905
|
+
expect(merge({ port: 0 }, { port: 5432, portSource: 'service' })).toEqual({ port: 5432, portSource: 'service' })
|
|
906
|
+
expect(merge({ port: 9000, portSource: 'service' }, { port: 80 })).toEqual({ port: 80, portSource: undefined })
|
|
907
|
+
expect(merge({ port: 80 }, { port: 9000, portSource: 'service' })).toEqual({ port: 80 })
|
|
908
|
+
})
|
|
909
|
+
it('lets an observed port outrank the same number from a Service', () => {
|
|
910
|
+
expect(merge({ port: 80, portSource: 'service' }, { port: 80 })).toEqual({ port: 80, portSource: undefined })
|
|
911
|
+
})
|
|
912
|
+
it('keeps "multiple" when no part has a port', () => {
|
|
913
|
+
expect(merge({ port: 0 }, { port: 0, portSource: 'serviceMultiple' })).toEqual({ port: 0, portSource: 'serviceMultiple' })
|
|
914
|
+
expect(merge({ port: 0, portSource: 'serviceMultiple' }, { port: 0 })).toEqual({ port: 0, portSource: 'serviceMultiple' })
|
|
915
|
+
})
|
|
916
|
+
})
|
|
917
|
+
|
|
918
|
+
describe('likely-overlay edges in a selection', () => {
|
|
919
|
+
const tcp: AggregatedFlow = {
|
|
920
|
+
source: { namespace: '', name: 'node-a', kind: 'Pod' }, destination: { namespace: '', name: 'node-b', kind: 'Pod' },
|
|
921
|
+
protocol: 'tcp', port: 0, flowCount: 1, bytesSent: 0, bytesRecv: 0, connections: 0, lastSeen: '',
|
|
922
|
+
}
|
|
923
|
+
const overlay: AggregatedFlow = { ...tcp, protocol: 'udp', likelyOverlay: true }
|
|
924
|
+
const flows: GraphFlow[] = [tcp, overlay].map(f => ({ ...f, rawPairs: [endpointPair(f)] }))
|
|
925
|
+
|
|
926
|
+
it('selects the edge the user clicked, not the other traffic between the two nodes', () => {
|
|
927
|
+
expect(selectionRawPairs(flows, { type: 'edge', sourceId: 'node-a', destId: 'node-b', port: 0 })).toEqual([endpointPair(tcp)])
|
|
928
|
+
expect(selectionRawPairs(flows, { type: 'edge', sourceId: 'node-a', destId: 'node-b', port: 0, likelyOverlay: true })).toEqual([endpointPair(overlay)])
|
|
929
|
+
})
|
|
930
|
+
|
|
931
|
+
it('keeps overlay records off the other edge', () => {
|
|
932
|
+
const on = selectedEdgeMatcher([endpointPair(tcp)], true, e => e)
|
|
933
|
+
const record = (f: AggregatedFlow) => ({ ...f, lastSeen: '2025-01-01T00:00:00Z' }) as unknown as TrafficFlow
|
|
934
|
+
expect(on(record(tcp))).toBe(true)
|
|
935
|
+
expect(on(record(overlay))).toBe(false)
|
|
936
|
+
})
|
|
937
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatBytes } from '@skyhook-io/k8s-ui/utils/format'
|
|
2
|
-
import type { AggregatedFlow, TrafficFlow, TrafficWarningKind } from '../../types'
|
|
2
|
+
import type { AggregatedFlow, TrafficFlow, TrafficPortSource, TrafficWarningKind } from '../../types'
|
|
3
3
|
import type { TrafficEndpointPair, TrafficEndpointRef, TrafficMatch } from '../../api/traffic'
|
|
4
4
|
import type { TrafficGraphSelection } from './TrafficGraph'
|
|
5
5
|
|
|
@@ -415,6 +415,33 @@ export function mergedEdgePort(a: number, b: number): number {
|
|
|
415
415
|
return Math.min(a, b)
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
+
/**
|
|
419
|
+
* The port as text, or null when there is none to show. A port taken from the
|
|
420
|
+
* destination's Services is declared, not observed, so it always says so.
|
|
421
|
+
*/
|
|
422
|
+
export function portLabel(port: number, portSource?: TrafficPortSource): string | null {
|
|
423
|
+
if (portSource === 'serviceMultiple') return 'multiple (from Service)'
|
|
424
|
+
if (port <= 0) return null
|
|
425
|
+
return portSource === 'service' ? `${port} (from Service)` : String(port)
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** mergedEdgePort, keeping the shown port's marking with it. An observed port
|
|
429
|
+
* outranks the same number taken from a Service. */
|
|
430
|
+
export function mergeEdgePortInto(
|
|
431
|
+
into: { port: number; portSource?: TrafficPortSource },
|
|
432
|
+
from: { port: number; portSource?: TrafficPortSource },
|
|
433
|
+
): void {
|
|
434
|
+
const port = mergedEdgePort(into.port, from.port)
|
|
435
|
+
if (port === 0) {
|
|
436
|
+
if (from.portSource) into.portSource = from.portSource
|
|
437
|
+
} else if (port !== into.port) {
|
|
438
|
+
into.portSource = from.portSource
|
|
439
|
+
} else if (port === from.port && !from.portSource) {
|
|
440
|
+
into.portSource = undefined
|
|
441
|
+
}
|
|
442
|
+
into.port = port
|
|
443
|
+
}
|
|
444
|
+
|
|
418
445
|
/**
|
|
419
446
|
* Whether an edge carries a port: its own, or one of the edges merged into it.
|
|
420
447
|
* A merged edge shows one of its ports, so a selection made on another must
|
|
@@ -452,6 +479,7 @@ export function endpointPair(flow: AggregatedFlow): TrafficEndpointPair {
|
|
|
452
479
|
destination: ref(flow.destination),
|
|
453
480
|
port: flow.port,
|
|
454
481
|
...(flow.directionUnknown && { directionUnknown: true }),
|
|
482
|
+
...(flow.likelyOverlay && { likelyOverlay: true }),
|
|
455
483
|
}
|
|
456
484
|
}
|
|
457
485
|
|
|
@@ -475,11 +503,11 @@ export function groupAddonFlows(flows: GraphFlow[], isAddon: (name: string, name
|
|
|
475
503
|
connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
|
|
476
504
|
source: { name: 'addon-internet', namespace: '', kind: 'AddonInternet' },
|
|
477
505
|
destination: { name: 'addon-group-target', namespace: '', kind: 'AddonGroupTarget' },
|
|
478
|
-
protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
|
|
506
|
+
protocol: flow.protocol, port: flow.port, portSource: flow.portSource, l7Protocol: flow.l7Protocol,
|
|
479
507
|
rawPairs: [],
|
|
480
508
|
}
|
|
481
509
|
}
|
|
482
|
-
|
|
510
|
+
mergeEdgePortInto(internet, flow)
|
|
483
511
|
if (internet.protocol !== flow.protocol) internet.protocol = 'mixed'
|
|
484
512
|
if (internet.l7Protocol !== flow.l7Protocol) internet.l7Protocol = 'mixed'
|
|
485
513
|
mergeFlowVolume(internet, flow)
|
|
@@ -492,11 +520,11 @@ export function groupAddonFlows(flows: GraphFlow[], isAddon: (name: string, name
|
|
|
492
520
|
connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
|
|
493
521
|
source: { name: 'addon-group-source', namespace: '', kind: 'AddonGroupSource' },
|
|
494
522
|
destination: { name: 'kubernetes', namespace: 'default', kind: 'Service' },
|
|
495
|
-
protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
|
|
523
|
+
protocol: flow.protocol, port: flow.port, portSource: flow.portSource, l7Protocol: flow.l7Protocol,
|
|
496
524
|
rawPairs: [],
|
|
497
525
|
}
|
|
498
526
|
}
|
|
499
|
-
|
|
527
|
+
mergeEdgePortInto(kubernetes, flow)
|
|
500
528
|
if (kubernetes.protocol !== flow.protocol) kubernetes.protocol = 'mixed'
|
|
501
529
|
if (kubernetes.l7Protocol !== flow.l7Protocol) kubernetes.l7Protocol = 'mixed'
|
|
502
530
|
mergeFlowVolume(kubernetes, flow)
|
|
@@ -532,8 +560,8 @@ export function graphEndpointId(e: { namespace?: string; name: string }): string
|
|
|
532
560
|
return e.namespace ? `${e.namespace}/${e.name}` : e.name
|
|
533
561
|
}
|
|
534
562
|
|
|
535
|
-
export function pairKey(source: { namespace?: string; name: string }, destination: { namespace?: string; name: string }, port: number, directionUnknown?: boolean): string {
|
|
536
|
-
return `${graphEndpointId(source)}->${graphEndpointId(destination)}:${port}${directionUnknown ? ':u' : ''}`
|
|
563
|
+
export function pairKey(source: { namespace?: string; name: string }, destination: { namespace?: string; name: string }, port: number, directionUnknown?: boolean, likelyOverlay?: boolean): string {
|
|
564
|
+
return `${graphEndpointId(source)}->${graphEndpointId(destination)}:${port}${directionUnknown ? ':u' : ''}${likelyOverlay ? ':v' : ''}`
|
|
537
565
|
}
|
|
538
566
|
|
|
539
567
|
/**
|
|
@@ -550,12 +578,12 @@ export function selectedEdgeMatcher(
|
|
|
550
578
|
drawn: (e: TrafficFlow['source']) => { namespace?: string; name: string },
|
|
551
579
|
): (f: TrafficFlow) => boolean {
|
|
552
580
|
if (!pairs) return () => true
|
|
553
|
-
const keys = new Set(pairs.map(p => pairKey(p.source, p.destination, p.port, p.directionUnknown)))
|
|
581
|
+
const keys = new Set(pairs.map(p => pairKey(p.source, p.destination, p.port, p.directionUnknown, p.likelyOverlay)))
|
|
554
582
|
const callers = responsesCallerOriented ? null : new Set(pairs.map(p => `${graphEndpointId(p.source)}->${graphEndpointId(p.destination)}`))
|
|
555
583
|
return f => {
|
|
556
584
|
const src = drawn(f.source)
|
|
557
585
|
const dst = drawn(f.destination)
|
|
558
|
-
if (keys.has(pairKey(src, dst, f.port, f.directionUnknown))) return true
|
|
586
|
+
if (keys.has(pairKey(src, dst, f.port, f.directionUnknown, f.likelyOverlay))) return true
|
|
559
587
|
// The response travels callee to caller: reversed, it is the edge's.
|
|
560
588
|
return !!callers && f.l7Protocol === 'HTTP' && f.l7Type === 'RESPONSE' &&
|
|
561
589
|
callers.has(`${graphEndpointId(dst)}->${graphEndpointId(src)}`)
|
|
@@ -584,14 +612,14 @@ export function selectionRawPairs(
|
|
|
584
612
|
return selection.type === 'node'
|
|
585
613
|
? sourceId === selection.nodeId || destId === selection.nodeId
|
|
586
614
|
: sourceId === selection.sourceId && destId === selection.destId &&
|
|
587
|
-
!!flow.directionUnknown === !!selection.directionUnknown
|
|
615
|
+
!!flow.directionUnknown === !!selection.directionUnknown && !!flow.likelyOverlay === !!selection.likelyOverlay
|
|
588
616
|
})
|
|
589
617
|
// An edge stands for its port; an edge merged from several ports shows one
|
|
590
618
|
// of them and carries the rest (edgesOnPort).
|
|
591
619
|
const selected = selection.type === 'node' ? touching : edgesOnPort(touching, f => f, selection.port)
|
|
592
620
|
for (const flow of selected) {
|
|
593
621
|
for (const pair of flow.rawPairs ?? []) {
|
|
594
|
-
pairs.set(pairKey(pair.source, pair.destination, pair.port, pair.directionUnknown), pair)
|
|
622
|
+
pairs.set(pairKey(pair.source, pair.destination, pair.port, pair.directionUnknown, pair.likelyOverlay), pair)
|
|
595
623
|
}
|
|
596
624
|
}
|
|
597
625
|
if (pairs.size === 0) return null
|