@skyhook-io/radar-app 1.20.1 → 1.21.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 +10 -9
- package/src/App.tsx +65 -16
- package/src/api/client.audit-gating.test.tsx +105 -5
- package/src/api/client.auditBadgesSync.test.tsx +118 -0
- package/src/api/client.capabilitiesPoll.test.ts +61 -0
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +347 -16
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +10 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +201 -0
- package/src/api/vulnerabilities.ts +255 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
- package/src/components/audit/ChecksViewTabs.tsx +11 -1
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +907 -0
- package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
- package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
- package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
- package/src/components/cnpg/CNPGView.tsx +43 -117
- package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
- package/src/components/cnpg/host.tsx +2 -2
- package/src/components/cnpg/routes.ts +3 -1
- package/src/components/cnpg/shared.tsx +5 -53
- package/src/components/cnpg/useCNPGNavigate.ts +1 -21
- package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
- package/src/components/community.tsx +42 -0
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationMetrics.test.ts +20 -0
- package/src/components/diagnose/investigationMetrics.ts +2 -1
- package/src/components/dock/BottomDock.tsx +1 -0
- package/src/components/dock/LogsTab.tsx +3 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +2 -10
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
- package/src/components/helm/HelmView.tsx +25 -19
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +69 -11
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +25 -11
- package/src/components/home/HelmSummary.tsx +15 -15
- package/src/components/home/HomeAgentBlock.tsx +3 -0
- package/src/components/home/HomeView.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +19 -12
- package/src/components/home/MCPSetupDialog.tsx +4 -2
- package/src/components/home/mcpToolCatalog.ts +17 -4
- package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
- package/src/components/home/useVulnerabilitiesRow.ts +50 -0
- package/src/components/logs/LogsViewer.tsx +3 -1
- package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
- package/src/components/logs/MultiPodLogsTab.tsx +9 -5
- package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
- package/src/components/nav/PrimaryNavRail.tsx +174 -29
- package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
- package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
- package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
- package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
- package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
- package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
- package/src/components/timeline/TimelineView.tsx +3 -1
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
- package/src/components/traffic/TrafficData.test.tsx +37 -0
- package/src/components/traffic/TrafficData.tsx +27 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -7
- package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
- package/src/components/traffic/TrafficGraph.test.tsx +269 -0
- package/src/components/traffic/TrafficGraph.tsx +135 -64
- package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
- package/src/components/traffic/TrafficView.tsx +72 -155
- package/src/components/traffic/trafficFilters.test.ts +189 -1
- package/src/components/traffic/trafficFilters.ts +169 -1
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +54 -3
- package/src/components/ui/UpdateNotification.tsx +60 -19
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
- package/src/components/velero/VeleroBackupNow.tsx +143 -0
- package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
- package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
- package/src/components/velero/VeleroDetailPage.tsx +148 -0
- package/src/components/velero/VeleroKindLists.test.tsx +48 -0
- package/src/components/velero/VeleroKindLists.tsx +43 -0
- package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
- package/src/components/velero/VeleroLocations.test.tsx +86 -0
- package/src/components/velero/VeleroLocations.tsx +240 -0
- package/src/components/velero/VeleroOverview.test.tsx +311 -0
- package/src/components/velero/VeleroOverview.tsx +485 -0
- package/src/components/velero/VeleroPages.test.tsx +516 -0
- package/src/components/velero/VeleroPages.tsx +1056 -0
- package/src/components/velero/VeleroRunLists.tsx +309 -0
- package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
- package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
- package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
- package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
- package/src/components/velero/VeleroSchedules.tsx +255 -0
- package/src/components/velero/VeleroView.tsx +59 -0
- package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
- package/src/components/velero/attention.test.ts +178 -0
- package/src/components/velero/attention.ts +281 -0
- package/src/components/velero/backupDelete.test.tsx +91 -0
- package/src/components/velero/backupDelete.tsx +182 -0
- package/src/components/velero/coverage.test.ts +87 -0
- package/src/components/velero/coverage.ts +150 -0
- package/src/components/velero/host.tsx +86 -0
- package/src/components/velero/routes.ts +78 -0
- package/src/components/velero/runs.tsx +121 -0
- package/src/components/velero/shared.test.ts +84 -0
- package/src/components/velero/shared.tsx +423 -0
- package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
- package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
- package/src/components/velero/velero.fixtures.ts +61 -0
- package/src/components/velero/workspaceRoute.ts +21 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +114 -37
- package/src/components/workspace/DrawerTrailBack.tsx +32 -0
- package/src/components/workspace/WorkspaceFrame.tsx +71 -0
- package/src/components/workspace/coverage.ts +61 -0
- package/src/components/workspace/layout.test.tsx +29 -1
- package/src/components/workspace/layout.tsx +15 -5
- package/src/components/workspace/sidebar.ts +9 -0
- package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
- package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/desktop/AboutDialog.test.ts +12 -0
- package/src/desktop/AboutDialog.tsx +151 -0
- package/src/desktop/WindowsTitleBar.tsx +359 -0
- package/src/desktop/titleBar.test.ts +61 -0
- package/src/desktop/titleBar.ts +45 -0
- package/src/index.css +19 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +15 -3
- package/src/integrations/resourceHosts.tsx +26 -6
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.test.ts +11 -0
- package/src/integrations/workspaceRoutes.ts +3 -1
- package/src/integrations/workspaceScreens.tsx +2 -0
- package/src/main.tsx +8 -0
- package/src/utils/desktop-zoom.test.ts +53 -0
- package/src/utils/desktop-zoom.ts +30 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
useRightsizingScan,
|
|
20
20
|
type RightsizingRow,
|
|
21
21
|
} from '../../api/client'
|
|
22
|
-
import { RIGHTSIZING_DOCS_URL } from '../resource/RightsizingStrip'
|
|
22
|
+
import { podLevelOverUseNote, RIGHTSIZING_DOCS_URL } from '../resource/RightsizingStrip'
|
|
23
23
|
import { buildWorkloadPath } from '../../utils/navigation'
|
|
24
24
|
import { CostViewTabs } from '../cost/CostViewTabs'
|
|
25
25
|
import {
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
} from './presentation'
|
|
38
38
|
import { useNavCustomization } from '../../context/NavCustomization'
|
|
39
39
|
import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings'
|
|
40
|
+
import { clsx } from 'clsx'
|
|
40
41
|
|
|
41
42
|
export const RIGHTSIZING_SCAN_DESCRIPTION =
|
|
42
43
|
'Find CPU and memory requests to increase, reduce, or review. Radar never changes them.'
|
|
@@ -396,7 +397,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
|
|
|
396
397
|
/>
|
|
397
398
|
) : (
|
|
398
399
|
<div>
|
|
399
|
-
<div className="grid grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] gap-3 border-b border-theme-border px-
|
|
400
|
+
<div className="grid grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] gap-3 border-b border-theme-border px-3.5 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
|
|
400
401
|
<span>Workload / container</span>
|
|
401
402
|
<span>CPU request</span>
|
|
402
403
|
<span>Memory request</span>
|
|
@@ -796,7 +797,7 @@ function ScanResultRow({
|
|
|
796
797
|
type="button"
|
|
797
798
|
onClick={onToggle}
|
|
798
799
|
aria-expanded={open}
|
|
799
|
-
className=
|
|
800
|
+
className={clsx('grid w-full grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] items-center gap-3 text-left hover:bg-theme-hover/50', 'px-3.5 py-2.5' /* TABLE_DENSITY.cellClass in k8s-ui */)}
|
|
800
801
|
>
|
|
801
802
|
<div className="min-w-0">
|
|
802
803
|
<div className="flex items-center gap-2">
|
|
@@ -962,6 +963,13 @@ function EvidenceNote({ row }: { row: RightsizingRow }) {
|
|
|
962
963
|
}
|
|
963
964
|
|
|
964
965
|
function primaryEvidenceNote(row: RightsizingRow) {
|
|
966
|
+
if (row.fit === 'pod_level_request' && !row.queryError)
|
|
967
|
+
return (
|
|
968
|
+
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
969
|
+
{podLevelOverUseNote(row) ??
|
|
970
|
+
"This pod sets a pod-level request in spec.resources, which the scheduler reserves instead of container requests. Radar shows this container's usage but doesn't size the pod-level request."}
|
|
971
|
+
</p>
|
|
972
|
+
)
|
|
965
973
|
if (row.hpaManaged)
|
|
966
974
|
return (
|
|
967
975
|
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
@@ -987,6 +995,14 @@ function primaryEvidenceNote(row: RightsizingRow) {
|
|
|
987
995
|
Radar could not verify restart history before suggesting a lower memory request.
|
|
988
996
|
</p>
|
|
989
997
|
)
|
|
998
|
+
if (row.recommendationReason === 'requests_exceed_pod_limit')
|
|
999
|
+
return (
|
|
1000
|
+
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
1001
|
+
Together with the other containers' requests and suggested increases, the calculated
|
|
1002
|
+
request would take the pod above its pod-level limit. Decide how to split the limit, or
|
|
1003
|
+
raise it.
|
|
1004
|
+
</p>
|
|
1005
|
+
)
|
|
990
1006
|
if (row.limitConflict)
|
|
991
1007
|
return (
|
|
992
1008
|
<p className="mt-1 text-xs text-theme-text-tertiary">
|
|
@@ -343,3 +343,14 @@ it('ranks known safety risks and increases above savings, while routine reviews
|
|
|
343
343
|
expect(names.slice(6, 9)).toEqual(['bursty', 'hpa', 'idle'])
|
|
344
344
|
expect(names.slice(9)).toEqual(['failed-risk', 'steady'])
|
|
345
345
|
})
|
|
346
|
+
|
|
347
|
+
describe('pod-level requests', () => {
|
|
348
|
+
it('puts a container under a pod-level request in review, with no impact', () => {
|
|
349
|
+
const rows = [
|
|
350
|
+
metric({ fit: 'pod_level_request', resource: 'cpu', podLevelRequest: '200m' }),
|
|
351
|
+
metric({ fit: 'pod_level_request', resource: 'memory', podLevelRequest: '128Mi' }),
|
|
352
|
+
]
|
|
353
|
+
expect(classifyRows(rows, 2)).toBe('review')
|
|
354
|
+
expect(calculateImpact(rows, 2)).toMatchObject({ cpuChange: 0, memoryChange: 0 })
|
|
355
|
+
})
|
|
356
|
+
})
|
|
@@ -62,7 +62,9 @@ function needsManualReview(row: RightsizingRow): boolean {
|
|
|
62
62
|
needsSafetyReview(row) ||
|
|
63
63
|
(isReduction(row) && row.bursty === true) ||
|
|
64
64
|
row.recommendationReason === 'hpa_evidence_unavailable' ||
|
|
65
|
-
row.recommendationReason === 'oom_evidence_unavailable'
|
|
65
|
+
row.recommendationReason === 'oom_evidence_unavailable' ||
|
|
66
|
+
// Mirrors ManualReviewReasons: Radar does not size a pod-level request.
|
|
67
|
+
row.fit === 'pod_level_request'
|
|
66
68
|
)
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -102,3 +102,49 @@ describe('rightsizing request presentation', () => {
|
|
|
102
102
|
)
|
|
103
103
|
})
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
describe('pod-level request presentation', () => {
|
|
107
|
+
it('shows the pod-level value and asks for review instead of a per-container change', () => {
|
|
108
|
+
const result = getResourceRequestPresentation(
|
|
109
|
+
metric({
|
|
110
|
+
fit: 'pod_level_request',
|
|
111
|
+
podLevelRequest: '200m',
|
|
112
|
+
recommendationReason: 'pod_level_request',
|
|
113
|
+
}),
|
|
114
|
+
)
|
|
115
|
+
expect(result.primary).toContain('200m')
|
|
116
|
+
expect(result.tone).toBe('review')
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
describe('pod-level limit conflict presentation', () => {
|
|
121
|
+
it('points at the pod limit rather than the container limit', () => {
|
|
122
|
+
const podLimit = getResourceRequestPresentation(
|
|
123
|
+
metric({
|
|
124
|
+
fit: 'under_requested',
|
|
125
|
+
limitConflict: true,
|
|
126
|
+
recommendationReason: 'requests_exceed_pod_limit',
|
|
127
|
+
}),
|
|
128
|
+
)
|
|
129
|
+
const containerLimit = getResourceRequestPresentation(
|
|
130
|
+
metric({
|
|
131
|
+
fit: 'under_requested',
|
|
132
|
+
limitConflict: true,
|
|
133
|
+
recommendationReason: 'recommended_request_exceeds_limit',
|
|
134
|
+
}),
|
|
135
|
+
)
|
|
136
|
+
expect(podLimit.tone).toBe('review')
|
|
137
|
+
expect(podLimit.secondary).not.toBe(containerLimit.secondary)
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
describe('pod-level request without usage evidence', () => {
|
|
142
|
+
it('still shows the pod-level request instead of Unset', () => {
|
|
143
|
+
for (const row of [
|
|
144
|
+
metric({ fit: 'insufficient_history', podLevelRequest: '128Mi' }),
|
|
145
|
+
metric({ fit: 'insufficient_history', podLevelRequest: '128Mi', queryError: 'usage query failed' }),
|
|
146
|
+
]) {
|
|
147
|
+
expect(getResourceRequestPresentation(row).primary).toContain('128Mi')
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
})
|
|
@@ -23,12 +23,24 @@ export function getResourceRequestPresentation(
|
|
|
23
23
|
if (!row) return { primary: '—', secondary: 'No result returned', signals: [], tone: 'neutral' }
|
|
24
24
|
|
|
25
25
|
const current = row.currentRequest && row.currentRequestValue !== 0 ? row.currentRequest : 'Unset'
|
|
26
|
-
|
|
26
|
+
// A pod-level request is what the pod reserves, whether or not usage evidence arrived.
|
|
27
|
+
const currentOnly = row.podLevelRequest
|
|
28
|
+
? `${row.podLevelRequest} for the pod`
|
|
29
|
+
: current === 'Unset'
|
|
30
|
+
? current
|
|
31
|
+
: `${current} current`
|
|
27
32
|
const signals = resourceSignals(row)
|
|
28
33
|
const reason = row.recommendationReason
|
|
29
34
|
|
|
30
35
|
if (row.queryError)
|
|
31
36
|
return { primary: currentOnly, secondary: 'Metrics query failed', signals, tone: 'neutral' }
|
|
37
|
+
if (row.fit === 'pod_level_request')
|
|
38
|
+
return {
|
|
39
|
+
primary: currentOnly,
|
|
40
|
+
secondary: 'Review the pod-level request',
|
|
41
|
+
signals,
|
|
42
|
+
tone: 'review',
|
|
43
|
+
}
|
|
32
44
|
if (row.fit === 'insufficient_history')
|
|
33
45
|
return { primary: currentOnly, secondary: 'Not enough history', signals, tone: 'neutral' }
|
|
34
46
|
if (scaledToZero)
|
|
@@ -63,7 +75,10 @@ export function getResourceRequestPresentation(
|
|
|
63
75
|
if (row.limitConflict)
|
|
64
76
|
return {
|
|
65
77
|
primary: comparison,
|
|
66
|
-
secondary:
|
|
78
|
+
secondary:
|
|
79
|
+
reason === 'requests_exceed_pod_limit'
|
|
80
|
+
? 'Review against the pod limit'
|
|
81
|
+
: 'Raise the limit before changing',
|
|
67
82
|
signals,
|
|
68
83
|
tone: 'review',
|
|
69
84
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import { LargeClusterNamespacePicker } from './LargeClusterNamespacePicker'
|
|
6
|
+
|
|
7
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
8
|
+
let root: Root
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
const element = document.createElement('div')
|
|
12
|
+
document.body.appendChild(element)
|
|
13
|
+
root = createRoot(element)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
afterEach(async () => {
|
|
17
|
+
await act(async () => root.unmount())
|
|
18
|
+
document.body.replaceChildren()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('LargeClusterNamespacePicker', () => {
|
|
22
|
+
it("says the namespace list couldn't be read instead of loading forever", async () => {
|
|
23
|
+
await act(async () => root.render(<LargeClusterNamespacePicker namespaces={undefined} error="Radar couldn't list namespaces; retry shortly" onSelect={() => {}} />))
|
|
24
|
+
expect(document.body.textContent).toContain("Radar couldn't list namespaces; retry shortly")
|
|
25
|
+
expect(document.body.textContent).not.toContain('Loading namespaces')
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -2,8 +2,10 @@ import { useState, useRef, useEffect, useMemo, type ReactNode } from 'react'
|
|
|
2
2
|
import { Search } from 'lucide-react'
|
|
3
3
|
import { Input } from '@skyhook-io/k8s-ui'
|
|
4
4
|
|
|
5
|
-
export function LargeClusterNamespacePicker({ namespaces, onSelect, ranked = false, renderMeta }: {
|
|
5
|
+
export function LargeClusterNamespacePicker({ namespaces, error, onSelect, ranked = false, renderMeta }: {
|
|
6
6
|
namespaces: { name: string }[] | undefined
|
|
7
|
+
/** Why the namespace list couldn't be read, when it couldn't. */
|
|
8
|
+
error?: string | null
|
|
7
9
|
onSelect: (ns: string) => void
|
|
8
10
|
/** Keep the given order (already ranked) instead of sorting by name. */
|
|
9
11
|
ranked?: boolean
|
|
@@ -42,7 +44,11 @@ export function LargeClusterNamespacePicker({ namespaces, onSelect, ranked = fal
|
|
|
42
44
|
/>
|
|
43
45
|
</div>
|
|
44
46
|
<div className="max-h-[240px] overflow-y-auto rounded-lg border border-theme-border bg-theme-base">
|
|
45
|
-
{!namespaces ? (
|
|
47
|
+
{!namespaces && error ? (
|
|
48
|
+
<div role="alert" className="px-3 py-6 text-center text-sm text-theme-text-secondary">
|
|
49
|
+
{error}
|
|
50
|
+
</div>
|
|
51
|
+
) : !namespaces ? (
|
|
46
52
|
<div className="px-3 py-6 text-center text-sm text-theme-text-tertiary">
|
|
47
53
|
Loading namespaces…
|
|
48
54
|
</div>
|
|
@@ -277,6 +277,7 @@ interface TimelineViewProps {
|
|
|
277
277
|
initialTimeRange?: TimeRange
|
|
278
278
|
requiresNamespaceFilter?: boolean
|
|
279
279
|
availableNamespaces?: { name: string }[]
|
|
280
|
+
availableNamespacesError?: string
|
|
280
281
|
onNamespaceSelect?: (ns: string) => void
|
|
281
282
|
onOpenDiagnostics?: () => void
|
|
282
283
|
}
|
|
@@ -297,7 +298,7 @@ export function resolveApplicationTimelineScope(searchParams: URLSearchParams, n
|
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
300
|
|
|
300
|
-
export function TimelineView({ namespaces, onResourceClick, initialViewMode, initialFilter, initialTimeRange, requiresNamespaceFilter, availableNamespaces, onNamespaceSelect, onOpenDiagnostics }: TimelineViewProps) {
|
|
301
|
+
export function TimelineView({ namespaces, onResourceClick, initialViewMode, initialFilter, initialTimeRange, requiresNamespaceFilter, availableNamespaces, availableNamespacesError, onNamespaceSelect, onOpenDiagnostics }: TimelineViewProps) {
|
|
301
302
|
// URL is the source of truth for every control below (deep-linkable +
|
|
302
303
|
// back/forward-restorable). Read on mount, written on user change.
|
|
303
304
|
const [searchParams, setSearchParams] = useSearchParams()
|
|
@@ -951,6 +952,7 @@ export function TimelineView({ namespaces, onResourceClick, initialViewMode, ini
|
|
|
951
952
|
<div className="relative">
|
|
952
953
|
<LargeClusterNamespacePicker
|
|
953
954
|
namespaces={availableNamespaces}
|
|
955
|
+
error={availableNamespacesError}
|
|
954
956
|
onSelect={(ns) => onNamespaceSelect?.(ns)}
|
|
955
957
|
/>
|
|
956
958
|
</div>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import type { AggregatedFlow } from '../../types'
|
|
6
|
+
import { TrafficConnectionsTable } from './TrafficConnectionsTable'
|
|
7
|
+
|
|
8
|
+
vi.mock('react-virtuoso', () => ({
|
|
9
|
+
Virtuoso: ({ data, itemContent }: { data: AggregatedFlow[]; itemContent: (index: number, flow: AggregatedFlow) => ReactNode }) =>
|
|
10
|
+
<div>{data.map((flow, index) => <div key={index}>{itemContent(index, flow)}</div>)}</div>,
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
14
|
+
let container: HTMLDivElement
|
|
15
|
+
let root: Root
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
container = document.createElement('div')
|
|
19
|
+
document.body.appendChild(container)
|
|
20
|
+
root = createRoot(container)
|
|
21
|
+
})
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
act(() => root.unmount())
|
|
24
|
+
container.remove()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const tcp: AggregatedFlow = {
|
|
28
|
+
source: { name: 'client', namespace: 'shop', kind: 'Pod' },
|
|
29
|
+
destination: { name: 'db', namespace: 'data', kind: 'Pod' },
|
|
30
|
+
protocol: 'tcp', port: 5432, connections: 0, bytesSent: 1024, bytesRecv: 2048, flowCount: 1, lastSeen: '',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('TrafficConnectionsTable', () => {
|
|
34
|
+
it('shows unmeasured request rate and Data for a TCP-only map, and keeps row selection', () => {
|
|
35
|
+
const onSelect = vi.fn()
|
|
36
|
+
const props = { flows: [tcp], isRateBased: true, selection: null, onSelect, onFocus: vi.fn() }
|
|
37
|
+
act(() => root.render(<TrafficConnectionsTable {...props} />))
|
|
38
|
+
const row = container.querySelector<HTMLElement>('[role="row"]')!
|
|
39
|
+
expect(container.textContent).toContain('Req/sData')
|
|
40
|
+
expect(row.textContent).toContain('—3 KB')
|
|
41
|
+
expect(container.textContent).not.toContain('5xx')
|
|
42
|
+
act(() => row.click())
|
|
43
|
+
expect(onSelect).toHaveBeenCalledWith({ type: 'edge', sourceId: 'shop/client', destId: 'data/db', port: 5432, directionUnknown: false })
|
|
44
|
+
act(() => root.render(<TrafficConnectionsTable {...props} selection={onSelect.mock.calls[0][0]} />))
|
|
45
|
+
expect(container.querySelector('[role="row"]')!.getAttribute('aria-selected')).toBe('true')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('shows HTTP rate beside bytes-only TCP in a mixed map', () => {
|
|
49
|
+
const http = { ...tcp, destination: { ...tcp.destination, name: 'web' }, port: 80, protocol: 'http', connections: 1, requestRate: 0.25, requestCount: 1 }
|
|
50
|
+
act(() => root.render(<TrafficConnectionsTable flows={[tcp, http]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
51
|
+
const rows = Array.from(container.querySelectorAll('[role="row"]'))
|
|
52
|
+
expect(rows.find(row => row.textContent?.includes('web'))!.textContent).toContain('0.253 KB')
|
|
53
|
+
expect(rows.find(row => row.textContent?.includes('db'))!.textContent).toContain('—3 KB')
|
|
54
|
+
expect(container.textContent).toContain('5xx')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('hides Data when no row has byte figures, and marks a missing row in a mixed view', () => {
|
|
58
|
+
const noBytes = { ...tcp, destination: { ...tcp.destination, name: 'unmeasured' }, bytesSent: 0, bytesRecv: 0 }
|
|
59
|
+
const props = { isRateBased: true, selection: null, onSelect: vi.fn(), onFocus: vi.fn() }
|
|
60
|
+
act(() => root.render(<TrafficConnectionsTable {...props} flows={[noBytes]} />))
|
|
61
|
+
expect(container.textContent).not.toContain('Data')
|
|
62
|
+
expect(container.textContent).not.toContain('0 B')
|
|
63
|
+
act(() => root.render(<TrafficConnectionsTable {...props} flows={[tcp, noBytes]} />))
|
|
64
|
+
const row = Array.from(container.querySelectorAll('[role="row"]')).find(r => r.textContent?.includes('unmeasured'))!
|
|
65
|
+
expect(container.textContent).toContain('Data')
|
|
66
|
+
expect(row.textContent).toContain('——')
|
|
67
|
+
expect(row.textContent).not.toContain('0 B')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('preserves connection counts for count-based sources and older TCP rates', () => {
|
|
71
|
+
act(() => root.render(<TrafficConnectionsTable flows={[tcp]} isRateBased={false} selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
72
|
+
expect(container.textContent).toContain('ConnsData')
|
|
73
|
+
expect(container.querySelector('[role="row"]')!.textContent).toContain('03 KB')
|
|
74
|
+
act(() => root.render(<TrafficConnectionsTable flows={[{ ...tcp, connections: 2 }]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
75
|
+
expect(container.querySelector('[role="row"]')!.textContent).toContain('2.03 KB')
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe('TrafficConnectionsTable protocol data', () => {
|
|
80
|
+
it('renders compact protocol figures without their mixed sum', () => {
|
|
81
|
+
const mixed = { ...tcp, bytesSent: 38668, bytesRecv: 652404, bytesByProtocol: {
|
|
82
|
+
http: { bytesSent: 5969, bytesRecv: 260965 }, tcp: { bytesSent: 32699, bytesRecv: 391439 },
|
|
83
|
+
} }
|
|
84
|
+
act(() => root.render(<TrafficConnectionsTable flows={[mixed, tcp]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
|
|
85
|
+
const lines = Array.from(container.querySelector('[role="row"]')!.querySelectorAll('div.whitespace-nowrap')).map(line => line.textContent)
|
|
86
|
+
expect(lines).toEqual(['HTTP 260.7 KB', 'TCP 414.2 KB'])
|
|
87
|
+
const gridClasses = Array.from(container.querySelectorAll('[role="row"]')).map(row => row.className.split(' ').find(c => c.startsWith('grid-cols-')))
|
|
88
|
+
expect(new Set(gridClasses).size).toBe(1)
|
|
89
|
+
// One figure per line keeps the Data column narrow, so the endpoint columns keep their room.
|
|
90
|
+
expect(gridClasses[0]).toContain('_5rem_6.5rem_')
|
|
91
|
+
expect(container.firstElementChild!.firstElementChild!.className).toContain(gridClasses[0]!)
|
|
92
|
+
expect(container.textContent).not.toMatch(/674\.9 KB|691,?072/)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
@@ -3,11 +3,12 @@ import { Virtuoso } from 'react-virtuoso'
|
|
|
3
3
|
import { clsx } from 'clsx'
|
|
4
4
|
import { ArrowRight, Crosshair, Minus } from 'lucide-react'
|
|
5
5
|
import type { AggregatedFlow } from '../../types'
|
|
6
|
+
import { TrafficData } from './TrafficData'
|
|
6
7
|
import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
|
|
7
8
|
import { Tooltip } from '../ui/Tooltip'
|
|
8
9
|
import type { TrafficGraphSelection } from './TrafficGraph'
|
|
9
10
|
import {
|
|
10
|
-
connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
|
|
11
|
+
dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
|
|
11
12
|
type GraphFlow, type TrafficFocus,
|
|
12
13
|
} from './trafficFilters'
|
|
13
14
|
|
|
@@ -21,10 +22,16 @@ interface TrafficConnectionsTableProps {
|
|
|
21
22
|
focusedId?: string
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const GRID = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.
|
|
25
|
+
const GRID = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_5rem_4.5rem_4.5rem] items-center gap-x-3'
|
|
25
26
|
// Without HTTP status anywhere in view (plain TCP) a 5xx column would read as
|
|
26
27
|
// "no errors" rather than "not measured".
|
|
27
|
-
const GRID_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.
|
|
28
|
+
const GRID_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_5rem_4.5rem] items-center gap-x-3'
|
|
29
|
+
|
|
30
|
+
const GRID_PROTOCOL_DATA = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_6.5rem_4.5rem_4.5rem] items-center gap-x-3'
|
|
31
|
+
const GRID_PROTOCOL_DATA_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_6.5rem_4.5rem] items-center gap-x-3'
|
|
32
|
+
|
|
33
|
+
const GRID_NO_DATA = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem_4.5rem] items-center gap-x-3'
|
|
34
|
+
const GRID_NO_DATA_OR_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem] items-center gap-x-3'
|
|
28
35
|
|
|
29
36
|
function rowSelection(flow: AggregatedFlow): TrafficGraphSelection {
|
|
30
37
|
return {
|
|
@@ -53,7 +60,10 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
|
|
|
53
60
|
const rows = useMemo(() => connectionRows(flows), [flows])
|
|
54
61
|
const selected = useMemo(() => selectedRows(rows, selection), [rows, selection])
|
|
55
62
|
const showStatus = useMemo(() => flows.some(hasStatusData), [flows])
|
|
56
|
-
const
|
|
63
|
+
const showData = useMemo(() => flows.some(f => f.bytesSent > 0 || f.bytesRecv > 0), [flows])
|
|
64
|
+
const splitData = useMemo(() => flows.some(f => dataByProtocol(f).length > 1), [flows])
|
|
65
|
+
const dataGrid = splitData ? (showStatus ? GRID_PROTOCOL_DATA : GRID_PROTOCOL_DATA_NO_STATUS) : (showStatus ? GRID : GRID_NO_STATUS)
|
|
66
|
+
const grid = showData ? dataGrid : (showStatus ? GRID_NO_DATA : GRID_NO_DATA_OR_STATUS)
|
|
57
67
|
|
|
58
68
|
const endpoint = (e: AggregatedFlow['source']) => {
|
|
59
69
|
const id = graphEndpointId(e)
|
|
@@ -89,6 +99,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
|
|
|
89
99
|
<span>Destination</span>
|
|
90
100
|
<span>Port</span>
|
|
91
101
|
<span className="text-right">{isRateBased ? 'Req/s' : 'Conns'}</span>
|
|
102
|
+
{showData && <span className="text-right">Data</span>}
|
|
92
103
|
{showStatus && <span className="text-right">5xx</span>}
|
|
93
104
|
<span className="text-right">Dropped</span>
|
|
94
105
|
</div>
|
|
@@ -125,8 +136,13 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
|
|
|
125
136
|
{isExternalKind(flow.destination.kind) && <span className="ml-1 text-theme-text-tertiary">ext</span>}
|
|
126
137
|
</span>
|
|
127
138
|
<span className="text-right tabular-nums text-theme-text-secondary">
|
|
128
|
-
{isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
|
|
139
|
+
{isRateBased && !flow.connections ? '—' : isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
|
|
129
140
|
</span>
|
|
141
|
+
{showData && (
|
|
142
|
+
<span className="text-right tabular-nums text-theme-text-secondary">
|
|
143
|
+
<TrafficData entries={dataByProtocol(flow)} compact stacked />
|
|
144
|
+
</span>
|
|
145
|
+
)}
|
|
130
146
|
{showStatus && (
|
|
131
147
|
<span className={clsx('text-right tabular-nums', errors > 0 ? clsx(SEVERITY_TEXT.error, 'font-medium') : 'text-theme-text-tertiary')}>
|
|
132
148
|
{errors > 0 ? (isRateBased ? formatRate(errors) : errors.toLocaleString()) : hasStatusData(flow) ? '0' : '—'}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { TrafficData } from './TrafficData'
|
|
5
|
+
import { dataByProtocol } from './trafficFilters'
|
|
6
|
+
|
|
7
|
+
describe('TrafficData', () => {
|
|
8
|
+
it('keeps single-protocol and released aggregate figures unlabeled', () => {
|
|
9
|
+
for (const bytesByProtocol of [undefined, { http: { bytesSent: 100, bytesRecv: 200 } }]) {
|
|
10
|
+
expect(renderToStaticMarkup(<TrafficData entries={dataByProtocol({ bytesSent: 100, bytesRecv: 200, bytesByProtocol })} directional explainOverlap />)).toBe('300 B')
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('keeps unmeasured data absent even with zero-byte buckets', () => {
|
|
15
|
+
expect(renderToStaticMarkup(<TrafficData entries={[{ protocol: 'tcp', sent: 0, recv: 0 }]} />)).toBe('—')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
for (const protocols of [['http', 'tcp'], ['grpc', 'tcp'], ['tcp', 'udp'], ['http', 'grpc']]) {
|
|
19
|
+
it(`explains overlapping measurement types only for ${protocols.join('+')}`, () => {
|
|
20
|
+
const entries = protocols.map(protocol => ({ protocol, sent: 100, recv: 200 }))
|
|
21
|
+
const html = renderToStaticMarkup(<TrafficData entries={entries} directional explainOverlap />)
|
|
22
|
+
expect(html).toContain('100 B sent · 200 B received')
|
|
23
|
+
expect(html).not.toContain('600 B')
|
|
24
|
+
if (protocols.includes('tcp') && protocols.some(p => p === 'http' || p === 'grpc')) {
|
|
25
|
+
expect(html).toContain(`${protocols[0] === 'grpc' ? 'gRPC' : 'HTTP'} body bytes and TCP connection bytes can describe the same calls; shown separately.`)
|
|
26
|
+
} else expect(html).not.toContain('body bytes')
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
it('shows no unmeasured protocol as 0 B beside a measured one', () => {
|
|
33
|
+
// e.g. Istio's HTTP byte queries failed while ztunnel's TCP bytes came through
|
|
34
|
+
const bytesByProtocol = { http: { bytesSent: 0, bytesRecv: 0 }, tcp: { bytesSent: 100, bytesRecv: 200 } }
|
|
35
|
+
const html = renderToStaticMarkup(<TrafficData entries={dataByProtocol({ bytesSent: 100, bytesRecv: 200, bytesByProtocol })} directional explainOverlap />)
|
|
36
|
+
expect(html).toBe('300 B')
|
|
37
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { formatBytes } from '@skyhook-io/k8s-ui/utils/format'
|
|
2
|
+
import { isPayloadProtocol, protocolName, type ProtocolData } from './trafficFilters'
|
|
3
|
+
|
|
4
|
+
export function TrafficData({ entries, compact = false, stacked = false, directional = false, explainOverlap = false }: {
|
|
5
|
+
entries: ProtocolData[]
|
|
6
|
+
compact?: boolean
|
|
7
|
+
/** One figure per line, for narrow columns. */
|
|
8
|
+
stacked?: boolean
|
|
9
|
+
directional?: boolean
|
|
10
|
+
explainOverlap?: boolean
|
|
11
|
+
}) {
|
|
12
|
+
if (!entries.some(e => e.sent > 0 || e.recv > 0)) return <>—</>
|
|
13
|
+
if (entries.length === 1) return <>{formatBytes(entries[0].sent + entries[0].recv)}</>
|
|
14
|
+
const payloads = entries.filter(e => e.protocol !== null && isPayloadProtocol(e.protocol))
|
|
15
|
+
const caption = explainOverlap && entries.some(e => e.protocol?.toLowerCase() === 'tcp') && payloads.length > 0
|
|
16
|
+
? `${payloads.map(e => protocolName(e.protocol!)).join('/')} body bytes and TCP connection bytes can describe the same calls; shown separately.`
|
|
17
|
+
: null
|
|
18
|
+
const figures = entries.map(e => `${protocolName(e.protocol ?? '')} ${directional
|
|
19
|
+
? `${formatBytes(e.sent)} sent · ${formatBytes(e.recv)} received`
|
|
20
|
+
: formatBytes(e.sent + e.recv)}`)
|
|
21
|
+
if (compact && !stacked) return <>{figures.join(' · ')}</>
|
|
22
|
+
if (compact) return <>{figures.map((figure, index) => <div key={entries[index].protocol} className="whitespace-nowrap">{figure}</div>)}</>
|
|
23
|
+
return <>
|
|
24
|
+
{figures.map((figure, index) => <div key={entries[index].protocol}>{figure}</div>)}
|
|
25
|
+
{caption && <div className="mt-1 text-theme-text-tertiary font-normal">{caption}</div>}
|
|
26
|
+
</>
|
|
27
|
+
}
|
|
@@ -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 } from './trafficFilters'
|
|
11
|
+
import { isPolicyDropReason, 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.protocol}
|
|
211
|
+
<span className="text-theme-text-tertiary uppercase">{flow.port ? `${flow.protocol}:${flow.port}` : flow.protocol}</span>
|
|
212
212
|
)}
|
|
213
213
|
</div>
|
|
214
214
|
|
|
@@ -248,13 +248,15 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
|
|
|
248
248
|
</div>
|
|
249
249
|
<div>
|
|
250
250
|
<span className="text-theme-text-tertiary">Protocol: </span>
|
|
251
|
-
<span className="text-theme-text-primary">{flow.l7Protocol
|
|
251
|
+
<span className="text-theme-text-primary">{protocolLabel(flow.l7Protocol, flow.protocol)}</span>
|
|
252
252
|
{flow.httpProtocol && <span className="text-theme-text-tertiary"> ({flow.httpProtocol})</span>}
|
|
253
253
|
</div>
|
|
254
|
-
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
254
|
+
{flow.port !== 0 && (
|
|
255
|
+
<div>
|
|
256
|
+
<span className="text-theme-text-tertiary">Port: </span>
|
|
257
|
+
<span className="text-theme-text-primary">{flow.port}</span>
|
|
258
|
+
</div>
|
|
259
|
+
)}
|
|
258
260
|
{flow.trafficDirection && (
|
|
259
261
|
<div>
|
|
260
262
|
<span className="text-theme-text-tertiary">Direction: </span>
|