@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import type { AggregatedFlow, TrafficFlow } from '../../types'
|
|
3
|
-
import { matchesStatusRanges, bucketsFromCounts, bucketsFromStatus, isRateBasedSource, keepAvailable, effectiveThreshold, volumeUnit, isExternalKind, isPolicyDropReason, requestRateOf, errorRateOf, formatRate, displayVolume, 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, 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, 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', () => {
|
|
@@ -697,3 +697,191 @@ describe('verdictChoices', () => {
|
|
|
697
697
|
expect(verdictChoices(['forwarded', 'redirected'])).toEqual(['forwarded'])
|
|
698
698
|
})
|
|
699
699
|
})
|
|
700
|
+
|
|
701
|
+
describe('flows warning kinds', () => {
|
|
702
|
+
// A cluster warning is the answer about a shared metrics store, not a failed
|
|
703
|
+
// fetch: retrying it only repeats the store's queries.
|
|
704
|
+
it('retries only warnings that may clear on their own', () => {
|
|
705
|
+
expect(warningRetries(undefined)).toBe(true)
|
|
706
|
+
expect(warningRetries('transient')).toBe(true)
|
|
707
|
+
expect(warningRetries('partial')).toBe(false)
|
|
708
|
+
expect(warningRetries('incomplete')).toBe(false)
|
|
709
|
+
expect(warningRetries('cluster')).toBe(false)
|
|
710
|
+
})
|
|
711
|
+
|
|
712
|
+
it('does not call a cluster warning a fetch failure or missing traffic', () => {
|
|
713
|
+
expect(emptyWarningHeadline('cluster')).not.toBe(emptyWarningHeadline('transient'))
|
|
714
|
+
expect(warningBannerTitle('cluster')).not.toBe(warningBannerTitle('transient'))
|
|
715
|
+
})
|
|
716
|
+
})
|
|
717
|
+
|
|
718
|
+
describe('protocolLabel', () => {
|
|
719
|
+
it('names the application and transport protocols when they differ', () => {
|
|
720
|
+
expect(protocolLabel('HTTP', 'tcp')).toBe('HTTP / tcp')
|
|
721
|
+
})
|
|
722
|
+
it('names a protocol once when a mesh reports it as both', () => {
|
|
723
|
+
expect(protocolLabel('HTTP', 'http')).toBe('HTTP')
|
|
724
|
+
expect(protocolLabel('GRPC', 'grpc')).toBe('GRPC')
|
|
725
|
+
})
|
|
726
|
+
it('falls back to the transport protocol', () => {
|
|
727
|
+
expect(protocolLabel(undefined, 'tcp')).toBe('tcp')
|
|
728
|
+
expect(protocolLabel('', 'udp')).toBe('udp')
|
|
729
|
+
})
|
|
730
|
+
})
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
describe('groupAddonFlows', () => {
|
|
734
|
+
const addon = (_name: string, namespace: string | undefined) => namespace === 'monitoring'
|
|
735
|
+
const flow = (source: AggregatedFlow['source'], destination: AggregatedFlow['destination'], bytesSent: number): GraphFlow => {
|
|
736
|
+
const f = { source, destination, bytesSent, bytesRecv: bytesSent * 2, bytesByProtocol: { tcp: { bytesSent, bytesRecv: bytesSent * 2 } }, connections: 0, flowCount: 1, port: 443, protocol: 'tcp', lastSeen: '' }
|
|
737
|
+
return { ...f, rawPairs: [endpointPair(f)] }
|
|
738
|
+
}
|
|
739
|
+
const internet = { name: 'Internet', namespace: '', kind: 'Internet' }
|
|
740
|
+
const prometheus = { name: 'prometheus', namespace: 'monitoring', kind: 'Pod' }
|
|
741
|
+
const grafana = { name: 'grafana', namespace: 'monitoring', kind: 'Pod' }
|
|
742
|
+
const kubernetes = { name: 'kubernetes', namespace: 'default', kind: 'Service' }
|
|
743
|
+
|
|
744
|
+
it('keeps both group edges with bytes and selection records when no connections are measured', () => {
|
|
745
|
+
const incoming = [flow(internet, prometheus, 100), flow(internet, grafana, 200)]
|
|
746
|
+
const outgoing = [flow(prometheus, kubernetes, 300), flow(grafana, kubernetes, 400)]
|
|
747
|
+
const original = [...incoming, ...outgoing]
|
|
748
|
+
const snapshot = structuredClone(original)
|
|
749
|
+
const grouped = groupAddonFlows(original, addon)
|
|
750
|
+
const edges = grouped.filter(f => f.source.kind !== 'SkipEdge' && f.destination.kind !== 'SkipEdge')
|
|
751
|
+
expect(edges).toHaveLength(2)
|
|
752
|
+
expect(edges[0]).toMatchObject({ connections: 0, bytesSent: 300, bytesRecv: 600, flowCount: 2, protocol: 'tcp', port: 443 })
|
|
753
|
+
expect(edges[1]).toMatchObject({ connections: 0, bytesSent: 700, bytesRecv: 1400, flowCount: 2, protocol: 'tcp', port: 443 })
|
|
754
|
+
expect(selectionRawPairs(grouped, { type: 'edge', sourceId: 'addon-internet', destId: 'addon-group', port: 443 }))
|
|
755
|
+
.toEqual(selectionRawPairs(incoming, { type: 'node', nodeId: 'Internet' }))
|
|
756
|
+
expect(selectionRawPairs(grouped, { type: 'edge', sourceId: 'addon-group', destId: 'default/kubernetes', port: 443 }))
|
|
757
|
+
.toHaveLength(2)
|
|
758
|
+
expect(original).toEqual(snapshot)
|
|
759
|
+
})
|
|
760
|
+
|
|
761
|
+
it('sums HTTP rates together with bytes-only contributions', () => {
|
|
762
|
+
const tcp = flow(internet, prometheus, 100)
|
|
763
|
+
const http = { ...flow(internet, grafana, 200), connections: 2, requestRate: 1.7 }
|
|
764
|
+
const grouped = groupAddonFlows([tcp, http], addon)
|
|
765
|
+
expect(grouped.find(f => f.source.kind === 'AddonInternet'))
|
|
766
|
+
.toMatchObject({ connections: 2, requestRate: 1.7, bytesSent: 300, bytesRecv: 600 })
|
|
767
|
+
})
|
|
768
|
+
|
|
769
|
+
it('keeps group selection when the first contributor has unknown direction', () => {
|
|
770
|
+
const incoming = { ...flow(internet, prometheus, 100), directionUnknown: true, l7Protocol: 'HTTP' }
|
|
771
|
+
incoming.rawPairs = [endpointPair(incoming)]
|
|
772
|
+
const grouped = groupAddonFlows([incoming], addon)
|
|
773
|
+
const virtual = grouped.find(f => f.source.kind === 'AddonInternet')!
|
|
774
|
+
expect(virtual.directionUnknown).toBeUndefined()
|
|
775
|
+
expect(virtual.l7Protocol).toBe('HTTP')
|
|
776
|
+
expect(selectionRawPairs(grouped, { type: 'edge', sourceId: 'addon-internet', destId: 'addon-group', port: 443 }))
|
|
777
|
+
.toEqual(incoming.rawPairs)
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
for (const direction of ['incoming', 'outgoing']) {
|
|
781
|
+
const contributors = () => direction === 'incoming'
|
|
782
|
+
? [flow(internet, prometheus, 100), flow(internet, grafana, 200)]
|
|
783
|
+
: [flow(prometheus, kubernetes, 100), flow(grafana, kubernetes, 200)]
|
|
784
|
+
const virtualFlow = (flows: GraphFlow[]) => groupAddonFlows(flows, addon).find(f =>
|
|
785
|
+
f.source.kind === 'AddonInternet' || f.source.kind === 'AddonGroupSource')!
|
|
786
|
+
|
|
787
|
+
it(`keeps common HTTP metadata and unreported ports for ${direction} contributors`, () => {
|
|
788
|
+
const http = contributors().map(f => ({ ...f, port: 0, protocol: 'http', l7Protocol: 'HTTP', bytesByProtocol: { http: { bytesSent: f.bytesSent, bytesRecv: f.bytesRecv } } }))
|
|
789
|
+
expect(virtualFlow(http)).toMatchObject({ port: 0, protocol: 'http', l7Protocol: 'HTTP' })
|
|
790
|
+
expect(virtualFlow(http.map(f => ({ ...f, port: 8080 })))).toMatchObject({ port: 8080, protocol: 'http', l7Protocol: 'HTTP' })
|
|
791
|
+
})
|
|
792
|
+
|
|
793
|
+
it(`shows mixed protocols and the lowest reported port for ${direction} contributors in either order`, () => {
|
|
794
|
+
const [a, b] = contributors()
|
|
795
|
+
const mixed: GraphFlow[] = [{ ...a, port: 8080, protocol: 'http', l7Protocol: 'HTTP', bytesByProtocol: { http: { bytesSent: a.bytesSent, bytesRecv: a.bytesRecv } } }, { ...b, port: 443 }]
|
|
796
|
+
for (const inputs of [mixed, [...mixed].reverse()]) {
|
|
797
|
+
expect(virtualFlow(inputs)).toMatchObject({ port: 443, protocol: 'mixed', l7Protocol: 'mixed', bytesSent: 300, bytesRecv: 600 })
|
|
798
|
+
expect(dataByProtocol(virtualFlow(inputs))).toEqual([{ protocol: 'http', sent: 100, recv: 200 }, { protocol: 'tcp', sent: 200, recv: 400 }])
|
|
799
|
+
expect(virtualFlow([{ ...inputs[0], port: 0 }, inputs[1]]).port).toBe(inputs[1].port)
|
|
800
|
+
}
|
|
801
|
+
})
|
|
802
|
+
|
|
803
|
+
it(`keeps a common transport while marking mixed L7 metadata for ${direction} contributors`, () => {
|
|
804
|
+
const [a, b] = contributors()
|
|
805
|
+
expect(virtualFlow([{ ...a, l7Protocol: 'HTTP' }, { ...b, l7Protocol: 'DNS' }]))
|
|
806
|
+
.toMatchObject({ protocol: 'tcp', l7Protocol: 'mixed' })
|
|
807
|
+
})
|
|
808
|
+
|
|
809
|
+
it(`keeps all raw pairs when selecting mixed ${direction} contributors across a port change`, () => {
|
|
810
|
+
const [a, b] = contributors()
|
|
811
|
+
const http = { ...a, port: 0, protocol: 'http', l7Protocol: 'HTTP' }
|
|
812
|
+
const inputs = [http, b].map(f => ({ ...f, rawPairs: [endpointPair(f)] }))
|
|
813
|
+
const grouped = groupAddonFlows(inputs, addon)
|
|
814
|
+
const ids = direction === 'incoming'
|
|
815
|
+
? { sourceId: 'addon-internet', destId: 'addon-group' }
|
|
816
|
+
: { sourceId: 'addon-group', destId: 'default/kubernetes' }
|
|
817
|
+
for (const port of [0, 443]) {
|
|
818
|
+
expect(selectionRawPairs(grouped, { type: 'edge', ...ids, port })).toEqual([endpointPair(b), endpointPair(http)])
|
|
819
|
+
}
|
|
820
|
+
})
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
it('adds no virtual edges without contributing flows', () => {
|
|
824
|
+
const plain = flow({ name: 'client', namespace: 'shop', kind: 'Pod' }, kubernetes, 100)
|
|
825
|
+
expect(groupAddonFlows([plain], addon)).toEqual([plain])
|
|
826
|
+
expect(groupAddonFlows([], addon)).toEqual([])
|
|
827
|
+
})
|
|
828
|
+
})
|
|
829
|
+
|
|
830
|
+
describe('protocol byte figures', () => {
|
|
831
|
+
const base: AggregatedFlow = {
|
|
832
|
+
source: { name: 'client', namespace: 'demo', kind: 'Pod' },
|
|
833
|
+
destination: { name: 'server', namespace: 'demo', kind: 'Pod' },
|
|
834
|
+
port: 0, protocol: 'http', connections: 1, flowCount: 1, lastSeen: '',
|
|
835
|
+
bytesSent: 5969, bytesRecv: 260965, bytesByProtocol: { http: { bytesSent: 5969, bytesRecv: 260965 } },
|
|
836
|
+
}
|
|
837
|
+
const tcp: AggregatedFlow = { ...base, protocol: 'tcp', bytesSent: 32699, bytesRecv: 391439, bytesByProtocol: { tcp: { bytesSent: 32699, bytesRecv: 391439 } } }
|
|
838
|
+
|
|
839
|
+
it('merges fresh buckets in either order across repeated shallow-copy collapses', () => {
|
|
840
|
+
for (const flows of [[base, tcp], [tcp, base]]) {
|
|
841
|
+
const snapshot = structuredClone(flows)
|
|
842
|
+
const external = { ...flows[0] }
|
|
843
|
+
mergeFlowVolume(external, flows[1])
|
|
844
|
+
const internet = { ...external }
|
|
845
|
+
mergeFlowVolume(internet, base)
|
|
846
|
+
expect(dataByProtocol(external)).toEqual([{ protocol: 'http', sent: 5969, recv: 260965 }, { protocol: 'tcp', sent: 32699, recv: 391439 }])
|
|
847
|
+
expect(dataByProtocol(internet)[0]).toEqual({ protocol: 'http', sent: 11938, recv: 521930 })
|
|
848
|
+
expect(flows).toEqual(snapshot)
|
|
849
|
+
expect(external.bytesByProtocol).not.toBe(internet.bytesByProtocol)
|
|
850
|
+
expect(external.bytesByProtocol!.http).not.toBe(internet.bytesByProtocol!.http)
|
|
851
|
+
}
|
|
852
|
+
})
|
|
853
|
+
|
|
854
|
+
it('sorts payloads first and retains zero-byte protocols', () => {
|
|
855
|
+
expect(protocolsOf({ bytesByProtocol: { udp: { bytesSent: 0, bytesRecv: 0 }, tcp: { bytesSent: 1, bytesRecv: 2 }, http: { bytesSent: 3, bytesRecv: 4 }, grpc: { bytesSent: 5, bytesRecv: 6 } } }))
|
|
856
|
+
.toEqual(['grpc', 'http', 'tcp', 'udp'])
|
|
857
|
+
expect(protocolName('grpc')).toBe('gRPC')
|
|
858
|
+
expect(protocolName('http')).toBe('HTTP')
|
|
859
|
+
})
|
|
860
|
+
|
|
861
|
+
it('never attributes a released HTTP/gRPC scalar to the first protocol through merges or node totals', () => {
|
|
862
|
+
const legacy = { ...base, bytesByProtocol: undefined, bytesSent: 100, bytesRecv: 200 }
|
|
863
|
+
expect(dataByProtocol(legacy)).toEqual([{ protocol: null, sent: 100, recv: 200 }])
|
|
864
|
+
const merged = { ...legacy }
|
|
865
|
+
mergeFlowVolume(merged, legacy)
|
|
866
|
+
expect(merged.bytesByProtocol).toBeUndefined()
|
|
867
|
+
expect(dataByProtocol(merged)).toEqual([{ protocol: null, sent: 200, recv: 400 }])
|
|
868
|
+
expect(totalDataByProtocol([merged, legacy])).toEqual([{ protocol: null, sent: 300, recv: 600 }])
|
|
869
|
+
})
|
|
870
|
+
})
|
|
871
|
+
|
|
872
|
+
describe('rateWindowSeconds', () => {
|
|
873
|
+
it('follows the server: the range, five minutes under a minute, at most an hour', () => {
|
|
874
|
+
expect([ '1m', '5m', '15m', '1h', '30s', '2h', 'bogus' ].map(rateWindowSeconds)).toEqual([60, 300, 900, 3600, 300, 3600, 300])
|
|
875
|
+
})
|
|
876
|
+
})
|
|
877
|
+
|
|
878
|
+
describe('throughputLabel', () => {
|
|
879
|
+
it('divides the bytes of each protocol by the window and skips protocols that moved nothing', () => {
|
|
880
|
+
const base = { protocol: 'tcp', bytesSent: 0, bytesRecv: 0 }
|
|
881
|
+
expect(throughputLabel({ ...base, bytesByProtocol: { tcp: { bytesSent: 29999, bytesRecv: 119999 }, udp: { bytesSent: 0, bytesRecv: 0 } } }, 60)).toBe('TCP · 2.4 KB/s')
|
|
882
|
+
expect(throughputLabel({ ...base, bytesByProtocol: { tcp: { bytesSent: 600, bytesRecv: 0 } } }, 300)).toBe('TCP · 2 B/s')
|
|
883
|
+
// An older Radar sends only the sum, which can mix TCP and UDP: no protocol, no throughput.
|
|
884
|
+
expect(throughputLabel({ ...base, bytesSent: 4200, bytesRecv: 7500 }, 300)).toBe('')
|
|
885
|
+
expect(throughputLabel({ ...base, bytesByProtocol: { tcp: { bytesSent: 0, bytesRecv: 0 } } }, 60)).toBe('')
|
|
886
|
+
})
|
|
887
|
+
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { formatBytes } from '@skyhook-io/k8s-ui/utils/format'
|
|
2
|
+
import type { AggregatedFlow, TrafficFlow, TrafficWarningKind } from '../../types'
|
|
2
3
|
import type { TrafficEndpointPair, TrafficEndpointRef, TrafficMatch } from '../../api/traffic'
|
|
3
4
|
import type { TrafficGraphSelection } from './TrafficGraph'
|
|
4
5
|
|
|
@@ -71,6 +72,96 @@ export function errorRateOf(flow: Pick<AggregatedFlow, 'errorRate' | 'errorCount
|
|
|
71
72
|
return flow.errorRate ?? flow.errorCount ?? 0
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
/**
|
|
76
|
+
* An edge's protocol as "application / transport", or one name when the two
|
|
77
|
+
* are the same: a mesh source reports HTTP as both, and "HTTP / HTTP" reads as
|
|
78
|
+
* two protocols.
|
|
79
|
+
*/
|
|
80
|
+
export function protocolLabel(l7Protocol: string | undefined, protocol: string): string {
|
|
81
|
+
if (!l7Protocol || l7Protocol.toLowerCase() === protocol.toLowerCase()) return l7Protocol || protocol
|
|
82
|
+
return `${l7Protocol} / ${protocol}`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function protocolName(protocol: string): string {
|
|
86
|
+
return protocol.toLowerCase() === 'grpc' ? 'gRPC' : protocol.toUpperCase() || 'Unknown'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ProtocolData {
|
|
90
|
+
protocol: string | null
|
|
91
|
+
sent: number
|
|
92
|
+
recv: number
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type ByteFigures = Pick<AggregatedFlow, 'bytesByProtocol' | 'bytesSent' | 'bytesRecv'>
|
|
96
|
+
|
|
97
|
+
const transportProtocols = new Set(['tcp', 'udp', 'icmp', 'icmpv6', 'sctp'])
|
|
98
|
+
|
|
99
|
+
export function isPayloadProtocol(protocol: string): boolean {
|
|
100
|
+
return !transportProtocols.has(protocol.toLowerCase())
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The protocols an edge's traffic was observed on, payload protocols first,
|
|
104
|
+
* whether or not they carried byte figures. */
|
|
105
|
+
export function protocolsOf(flow: Pick<AggregatedFlow, 'bytesByProtocol'>): string[] {
|
|
106
|
+
return Object.keys(flow.bytesByProtocol ?? {})
|
|
107
|
+
.sort((a, b) => Number(isPayloadProtocol(b)) - Number(isPayloadProtocol(a)) || a.localeCompare(b))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** An edge's Data per protocol, payload protocols first. Only protocols that
|
|
111
|
+
* carried bytes: a zero there usually means not measured (a failed byte query,
|
|
112
|
+
* a source that reports none), and "0 B" would read as a measurement. A Radar
|
|
113
|
+
* that predates the breakdown sends only the cross-protocol sum, which can
|
|
114
|
+
* already mix HTTP and gRPC under one protocol name, so it comes back as one
|
|
115
|
+
* figure with no protocol claimed. */
|
|
116
|
+
export function dataByProtocol(flow: ByteFigures): ProtocolData[] {
|
|
117
|
+
const buckets = flow.bytesByProtocol
|
|
118
|
+
if (!buckets) return [{ protocol: null, sent: flow.bytesSent, recv: flow.bytesRecv }]
|
|
119
|
+
return protocolsOf(flow)
|
|
120
|
+
.map(protocol => ({ protocol, sent: buckets[protocol].bytesSent, recv: buckets[protocol].bytesRecv }))
|
|
121
|
+
.filter(e => e.sent + e.recv > 0)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The span a rate-based source's byte totals cover, in seconds: the view's
|
|
125
|
+
* range, five minutes when it is under a minute, at most an hour — the same
|
|
126
|
+
* rule the server's rate window follows. */
|
|
127
|
+
export function rateWindowSeconds(timeRange: string): number {
|
|
128
|
+
const m = /^(\d+)([smh])$/.exec(timeRange)
|
|
129
|
+
const seconds = m ? Number(m[1]) * ({ s: 1, m: 60, h: 3600 } as const)[m[2] as 's' | 'm' | 'h'] : 0
|
|
130
|
+
return seconds < 60 ? 300 : Math.min(seconds, 3600)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Label for an edge a rate-based source measured only in bytes: its
|
|
134
|
+
* throughput per protocol over the window, never added across protocols.
|
|
135
|
+
* Empty without a per-protocol breakdown: an older Radar's byte sum can mix
|
|
136
|
+
* TCP and UDP under one protocol name, so no protocol can be claimed for it. */
|
|
137
|
+
export function throughputLabel(flow: ByteFigures, windowSeconds: number): string {
|
|
138
|
+
if (!flow.bytesByProtocol) return ''
|
|
139
|
+
return dataByProtocol(flow)
|
|
140
|
+
.map(e => {
|
|
141
|
+
const perSecond = (e.sent + e.recv) / windowSeconds
|
|
142
|
+
return `${protocolName(e.protocol!)} · ${perSecond < 1 ? '<1 B' : formatBytes(perSecond)}/s`
|
|
143
|
+
})
|
|
144
|
+
.join(' · ')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Data across several edges, added only within each protocol. */
|
|
148
|
+
export function totalDataByProtocol(flows: ByteFigures[]): ProtocolData[] {
|
|
149
|
+
if (!flows.some(f => f.bytesByProtocol)) {
|
|
150
|
+
return [{ protocol: null, sent: flows.reduce((n, f) => n + f.bytesSent, 0), recv: flows.reduce((n, f) => n + f.bytesRecv, 0) }]
|
|
151
|
+
}
|
|
152
|
+
return dataByProtocol({ bytesSent: 0, bytesRecv: 0, bytesByProtocol: flows.reduce<AggregatedFlow['bytesByProtocol']>((acc, f) => mergeProtocolBytes(acc, f.bytesByProtocol), undefined) })
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function mergeProtocolBytes(a: AggregatedFlow['bytesByProtocol'], b: AggregatedFlow['bytesByProtocol']): AggregatedFlow['bytesByProtocol'] {
|
|
156
|
+
if (!b) return a
|
|
157
|
+
const merged = { ...a }
|
|
158
|
+
for (const [protocol, bytes] of Object.entries(b)) {
|
|
159
|
+
const prev = merged[protocol]
|
|
160
|
+
merged[protocol] = { bytesSent: (prev?.bytesSent ?? 0) + bytes.bytesSent, bytesRecv: (prev?.bytesRecv ?? 0) + bytes.bytesRecv }
|
|
161
|
+
}
|
|
162
|
+
return merged
|
|
163
|
+
}
|
|
164
|
+
|
|
74
165
|
/**
|
|
75
166
|
* The volume shown for an edge. For a rate-based source `connections` is its
|
|
76
167
|
* request rate rounded with a floor of one — the graph sizes, sorts and filters
|
|
@@ -130,6 +221,7 @@ export function mergeFlowVolume(into: AggregatedFlow, flow: AggregatedFlow): voi
|
|
|
130
221
|
}
|
|
131
222
|
const weighted: LatencyWeighted = into
|
|
132
223
|
weighted.latencyWeight = wInto + wFlow
|
|
224
|
+
into.bytesByProtocol = mergeProtocolBytes(into.bytesByProtocol, flow.bytesByProtocol)
|
|
133
225
|
into.connections += flow.connections
|
|
134
226
|
into.bytesSent += flow.bytesSent
|
|
135
227
|
into.bytesRecv += flow.bytesRecv
|
|
@@ -372,6 +464,53 @@ export function mergeRawPairs(into: GraphFlow, from: GraphFlow): void {
|
|
|
372
464
|
for (const pair of from.rawPairs ?? []) target.push(pair)
|
|
373
465
|
}
|
|
374
466
|
|
|
467
|
+
export function groupAddonFlows(flows: GraphFlow[], isAddon: (name: string, namespace: string | undefined) => boolean): GraphFlow[] {
|
|
468
|
+
let internet: GraphFlow | undefined
|
|
469
|
+
let kubernetes: GraphFlow | undefined
|
|
470
|
+
const grouped: GraphFlow[] = []
|
|
471
|
+
for (const flow of flows) {
|
|
472
|
+
if (flow.source.kind === 'Internet' && isAddon(flow.destination.name, flow.destination.namespace)) {
|
|
473
|
+
if (!internet) {
|
|
474
|
+
internet = {
|
|
475
|
+
connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
|
|
476
|
+
source: { name: 'addon-internet', namespace: '', kind: 'AddonInternet' },
|
|
477
|
+
destination: { name: 'addon-group-target', namespace: '', kind: 'AddonGroupTarget' },
|
|
478
|
+
protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
|
|
479
|
+
rawPairs: [],
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
internet.port = mergedEdgePort(internet.port, flow.port)
|
|
483
|
+
if (internet.protocol !== flow.protocol) internet.protocol = 'mixed'
|
|
484
|
+
if (internet.l7Protocol !== flow.l7Protocol) internet.l7Protocol = 'mixed'
|
|
485
|
+
mergeFlowVolume(internet, flow)
|
|
486
|
+
mergeRawPairs(internet, flow)
|
|
487
|
+
grouped.push({ ...flow, source: { name: 'addon-internet', namespace: '', kind: 'SkipEdge' } })
|
|
488
|
+
} else if (isAddon(flow.source.name, flow.source.namespace) && flow.destination.name === 'kubernetes' &&
|
|
489
|
+
(!flow.destination.namespace || flow.destination.namespace === 'default')) {
|
|
490
|
+
if (!kubernetes) {
|
|
491
|
+
kubernetes = {
|
|
492
|
+
connections: 0, bytesSent: 0, bytesRecv: 0, flowCount: 0, lastSeen: flow.lastSeen,
|
|
493
|
+
source: { name: 'addon-group-source', namespace: '', kind: 'AddonGroupSource' },
|
|
494
|
+
destination: { name: 'kubernetes', namespace: 'default', kind: 'Service' },
|
|
495
|
+
protocol: flow.protocol, port: flow.port, l7Protocol: flow.l7Protocol,
|
|
496
|
+
rawPairs: [],
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
kubernetes.port = mergedEdgePort(kubernetes.port, flow.port)
|
|
500
|
+
if (kubernetes.protocol !== flow.protocol) kubernetes.protocol = 'mixed'
|
|
501
|
+
if (kubernetes.l7Protocol !== flow.l7Protocol) kubernetes.l7Protocol = 'mixed'
|
|
502
|
+
mergeFlowVolume(kubernetes, flow)
|
|
503
|
+
mergeRawPairs(kubernetes, flow)
|
|
504
|
+
grouped.push({ ...flow, destination: { ...flow.destination, kind: 'SkipEdge' } })
|
|
505
|
+
} else {
|
|
506
|
+
grouped.push(flow)
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (internet) grouped.push(internet)
|
|
510
|
+
if (kubernetes) grouped.push(kubernetes)
|
|
511
|
+
return grouped
|
|
512
|
+
}
|
|
513
|
+
|
|
375
514
|
// The renderer draws the addon group's virtual endpoints as one group node.
|
|
376
515
|
function selectableId(e: { namespace?: string; name: string; kind?: string }): string {
|
|
377
516
|
if (e.kind === 'AddonGroupTarget' || e.kind === 'AddonGroupSource') return 'addon-group'
|
|
@@ -708,3 +847,32 @@ export function verdictChoices(seen: Iterable<string>): string[] {
|
|
|
708
847
|
if (present.size === 1 && present.has('forwarded')) return []
|
|
709
848
|
return ['forwarded', 'dropped', 'error'].filter(v => present.has(v))
|
|
710
849
|
}
|
|
850
|
+
|
|
851
|
+
/** Whether an empty map with this warning is worth fetching again at once. Only
|
|
852
|
+
* a transient one (or one from a Radar that sends no kind) may clear on its own;
|
|
853
|
+
* the rest are the answer, and polling them costs the source a burst of queries. */
|
|
854
|
+
export function warningRetries(kind: TrafficWarningKind | undefined): boolean {
|
|
855
|
+
return kind !== 'partial' && kind !== 'incomplete' && kind !== 'cluster'
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** Title of the banner shown beside flows that carry a warning. */
|
|
859
|
+
export function warningBannerTitle(kind: TrafficWarningKind | undefined): string {
|
|
860
|
+
switch (kind) {
|
|
861
|
+
// About values on edges that are shown - a port reported as 0, UDP as TCP -
|
|
862
|
+
// so "unreliable", not "incomplete", which would send the reader looking
|
|
863
|
+
// for missing workloads.
|
|
864
|
+
case 'partial': return 'Some values on this map are unreliable'
|
|
865
|
+
case 'cluster': return "This map may include other clusters' traffic"
|
|
866
|
+
default: return 'Some traffic may be missing from this map'
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/** Headline of the empty map when the source explained why it is empty. */
|
|
871
|
+
export function emptyWarningHeadline(kind: TrafficWarningKind | undefined): string {
|
|
872
|
+
switch (kind) {
|
|
873
|
+
case 'partial': return 'No traffic Radar can place on the map'
|
|
874
|
+
case 'incomplete': return 'No traffic seen, but some may be missing'
|
|
875
|
+
case 'cluster': return 'No traffic labeled as this cluster'
|
|
876
|
+
default: return 'Unable to fetch traffic data'
|
|
877
|
+
}
|
|
878
|
+
}
|
|
@@ -6,6 +6,7 @@ import { openExternal } from '../../utils/navigation'
|
|
|
6
6
|
import { useDiagnostics } from '../../api/client'
|
|
7
7
|
import type { DiagnosticsSnapshot, DiagEnvVar, DiagMetricsSourceHealth, DiagDropRecord, DiagErrorEntry, DiagCacheSyncStatus, DiagInformerSyncStatus, DiagSyncPhase, DiagSampleWindow } from '../../api/client'
|
|
8
8
|
import { getK8sUIPerfSnapshot, type K8sUIPerfSnapshot } from '@skyhook-io/k8s-ui'
|
|
9
|
+
import { SLACK_COLORS_ON_HOVER, SlackIcon } from '../community'
|
|
9
10
|
|
|
10
11
|
export type DiagnosticsFocus = 'timeline'
|
|
11
12
|
|
|
@@ -14,9 +15,10 @@ interface DiagnosticsOverlayProps {
|
|
|
14
15
|
isOpen?: boolean
|
|
15
16
|
/** Section to scroll to on open, for callers linking to one specific problem. */
|
|
16
17
|
focus?: DiagnosticsFocus
|
|
18
|
+
communityUrl?: string
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export function DiagnosticsOverlay({ onClose, isOpen = true, focus }: DiagnosticsOverlayProps) {
|
|
21
|
+
export function DiagnosticsOverlay({ onClose, isOpen = true, focus, communityUrl }: DiagnosticsOverlayProps) {
|
|
20
22
|
const { data, isLoading, error } = useDiagnostics(true)
|
|
21
23
|
const [copied, setCopied] = useState<'json' | 'formatted' | null>(null)
|
|
22
24
|
const [reportOpened, setReportOpened] = useState(false)
|
|
@@ -157,6 +159,17 @@ export function DiagnosticsOverlay({ onClose, isOpen = true, focus }: Diagnostic
|
|
|
157
159
|
<CopyButton label="Copy as Markdown" onClick={() => copyToClipboard('formatted')} copied={copied === 'formatted'} />
|
|
158
160
|
<CopyButton label="Copy Raw JSON" onClick={() => copyToClipboard('json')} copied={copied === 'json'} />
|
|
159
161
|
<div className="flex-1" />
|
|
162
|
+
{communityUrl && (
|
|
163
|
+
<a
|
|
164
|
+
href={communityUrl}
|
|
165
|
+
target="_blank"
|
|
166
|
+
rel="noopener noreferrer"
|
|
167
|
+
className="group flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated"
|
|
168
|
+
>
|
|
169
|
+
<SlackIcon className={clsx('w-3.5 h-3.5', SLACK_COLORS_ON_HOVER)} />
|
|
170
|
+
Ask in Slack
|
|
171
|
+
</a>
|
|
172
|
+
)}
|
|
160
173
|
<button
|
|
161
174
|
onClick={openBugReport}
|
|
162
175
|
disabled={!data}
|
|
@@ -124,6 +124,8 @@ export interface OmnibarProps {
|
|
|
124
124
|
* note says part of the scope wasn't searched, so an empty result is then
|
|
125
125
|
* qualified rather than reported as no match. */
|
|
126
126
|
note?: OmnibarNote
|
|
127
|
+
/** The connected server supports searching Event reasons and messages. */
|
|
128
|
+
eventContentSearch?: boolean
|
|
127
129
|
/** Bounded modifier value sets to autocomplete (e.g. { ns: [...], kind: [...] }). */
|
|
128
130
|
modifierOptions?: Record<string, string[]>
|
|
129
131
|
/** Namespaces to seed as removable `ns:` pills when the launcher opens empty
|
|
@@ -185,6 +187,7 @@ export const Omnibar = forwardRef<OmnibarHandle, OmnibarProps>(function Omnibar(
|
|
|
185
187
|
isError = false,
|
|
186
188
|
isPlaceholderData = false,
|
|
187
189
|
note,
|
|
190
|
+
eventContentSearch = false,
|
|
188
191
|
modifierOptions,
|
|
189
192
|
seedNamespaces,
|
|
190
193
|
loadRecents,
|
|
@@ -653,7 +656,7 @@ export const Omnibar = forwardRef<OmnibarHandle, OmnibarProps>(function Omnibar(
|
|
|
653
656
|
leftSlot={<Search className={hero ? 'w-5 h-5 shrink-0 text-theme-text-tertiary' : 'w-3.5 h-3.5 shrink-0 text-theme-text-tertiary'} />}
|
|
654
657
|
rightSlot={
|
|
655
658
|
<div className="flex items-center gap-1.5 shrink-0">
|
|
656
|
-
<SearchSyntaxHelp />
|
|
659
|
+
<SearchSyntaxHelp eventContentSearch={eventContentSearch} />
|
|
657
660
|
{!hero && !text && pills.length === 0 && (
|
|
658
661
|
<kbd className="text-[10px] text-theme-text-tertiary bg-theme-surface px-1 py-0.5 rounded border border-theme-border-light">
|
|
659
662
|
{mac ? '⌘' : 'Ctrl+'}K
|
|
@@ -11,12 +11,13 @@ vi.mock('../diagnose/DiagnoseContext', () => ({ useDiagnose: () => ({ available:
|
|
|
11
11
|
vi.mock('../../hooks/useRecentResources', () => ({ loadRecentResources: () => [], recordRecentResource: vi.fn() }))
|
|
12
12
|
vi.mock('../../api/apiResources', async (importOriginal) => ({ ...(await importOriginal<object>()), useAPIResources: () => ({ data: [] }) }))
|
|
13
13
|
vi.mock('./command-items', async (importOriginal) => ({ ...(await importOriginal<object>()), useCommandItems: () => [] }))
|
|
14
|
-
const caps = vi.hoisted(() => ({ data: undefined as undefined | { authEnabled?: boolean } }))
|
|
14
|
+
const caps = vi.hoisted(() => ({ data: undefined as undefined | { authEnabled?: boolean; features?: { searchCoverage?: boolean; searchEventContent?: boolean } } }))
|
|
15
15
|
vi.mock('../../api/client', async (importOriginal) => ({
|
|
16
16
|
...(await importOriginal<object>()),
|
|
17
17
|
useNamespaceScope: () => ({ data: undefined }),
|
|
18
18
|
useContexts: () => ({ data: [] }),
|
|
19
19
|
useCapabilities: () => caps,
|
|
20
|
+
useRadarFeature: () => ({ support: caps.data ? (caps.data.features?.searchEventContent ? 'supported' : 'unsupported') : 'unknown' }),
|
|
20
21
|
}))
|
|
21
22
|
|
|
22
23
|
import { RadarOmnibar } from './RadarOmnibar'
|
|
@@ -33,10 +34,11 @@ const failed: SearchCoverageEntry[] = [{ kind: 'SpStall', group: 'stall.sp-live.
|
|
|
33
34
|
beforeEach(() => {
|
|
34
35
|
vi.useFakeTimers()
|
|
35
36
|
Element.prototype.scrollIntoView = vi.fn()
|
|
36
|
-
caps.data =
|
|
37
|
+
caps.data = { features: { searchEventContent: true } }
|
|
37
38
|
searches = 0
|
|
38
39
|
vi.stubGlobal('fetch', vi.fn(async (input: string) => {
|
|
39
40
|
const url = new URL(input, 'http://localhost')
|
|
41
|
+
if (url.pathname.endsWith('/version-check')) return new Response(JSON.stringify({ currentVersion: 'dev' }), { status: 200 })
|
|
40
42
|
if (!url.pathname.endsWith('/search')) throw new Error(`Unexpected request: ${input}`)
|
|
41
43
|
searches++
|
|
42
44
|
return new Response(JSON.stringify({ hits: [], total: 0, searched: 0, total_matched: 0, coverage: coverageOf(unsearched) }), { status: 200 })
|
|
@@ -165,6 +167,57 @@ describe('RadarOmnibar namespace notes', () => {
|
|
|
165
167
|
})
|
|
166
168
|
})
|
|
167
169
|
|
|
170
|
+
describe('RadarOmnibar Event search', () => {
|
|
171
|
+
it.each(['CertificateExpirationWarning', 'kind:Event CertificateExpirationWarning', 'k:ev CertificateExpirationWarning'])('explains an older server without offering unsupported Event text search: %s', async (query) => {
|
|
172
|
+
caps.data = { features: { searchCoverage: true } }
|
|
173
|
+
unsearched = []
|
|
174
|
+
await typeQuery(query)
|
|
175
|
+
expect(page()).toContain('Update the connected Radar server to search Event reasons and messages.')
|
|
176
|
+
expect([...document.body.querySelectorAll('button')].some((b) => b.textContent === 'Search Events')).toBe(false)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('waits for server support instead of guessing while capabilities load', async () => {
|
|
180
|
+
caps.data = undefined
|
|
181
|
+
unsearched = []
|
|
182
|
+
await typeQuery('CertificateExpirationWarning')
|
|
183
|
+
expect(page()).not.toContain('Search Events')
|
|
184
|
+
expect(page()).not.toContain('Update the connected Radar server')
|
|
185
|
+
})
|
|
186
|
+
it('opts an empty broad search into Events and preserves its namespace and reason', async () => {
|
|
187
|
+
unsearched = []
|
|
188
|
+
const requests: string[] = []
|
|
189
|
+
vi.mocked(fetch).mockImplementation(async (input) => {
|
|
190
|
+
const query = new URL(String(input), 'http://localhost').searchParams.get('q') ?? ''
|
|
191
|
+
requests.push(query)
|
|
192
|
+
const hits = query.includes('kind:Event')
|
|
193
|
+
? [{ score: 1, kind: 'Event', namespace: 'prod', name: 'certificate-warning', matched: [{ token: 'CertificateExpirationWarning', site: 'content:reason', score: 12 }], snippets: [{ path: 'reason', text: 'CertificateExpirationWarning' }] }]
|
|
194
|
+
: []
|
|
195
|
+
return new Response(JSON.stringify({ hits, total: hits.length, total_matched: hits.length, coverage: coverageOf([]) }), { status: 200 })
|
|
196
|
+
})
|
|
197
|
+
await typeQuery('ns:prod')
|
|
198
|
+
act(() => host.querySelector('input')!.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true })))
|
|
199
|
+
await typeQuery('CertificateExpirationWarning')
|
|
200
|
+
expect(page()).toContain("Kubernetes Events aren't included in a broad search.")
|
|
201
|
+
const button = [...document.body.querySelectorAll('button')].find((b) => b.textContent === 'Search Events')
|
|
202
|
+
expect(button).toBeDefined()
|
|
203
|
+
act(() => button?.click())
|
|
204
|
+
await advance(300)
|
|
205
|
+
await advance(100)
|
|
206
|
+
expect(requests.at(-1)).toBe('ns:prod kind:Event CertificateExpirationWarning')
|
|
207
|
+
expect(page()).toContain('certificate-warning')
|
|
208
|
+
expect(page()).toContain('in event')
|
|
209
|
+
expect(page()).not.toContain('in spec')
|
|
210
|
+
expect(host.querySelector('input')!.value).toBe('CertificateExpirationWarning')
|
|
211
|
+
expect([...document.body.querySelectorAll('button')].some((b) => b.textContent === 'Search Events')).toBe(false)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
it.each(['kind:Pod CertificateExpirationWarning', 'k:events renewal', 'kind:"Event" renewal'])('does not redirect an explicitly scoped search: %s', async (query) => {
|
|
215
|
+
unsearched = []
|
|
216
|
+
await typeQuery(query)
|
|
217
|
+
expect(page()).not.toContain('Search Events')
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
|
|
168
221
|
describe('RadarOmnibar read recovery', () => {
|
|
169
222
|
it.each([
|
|
170
223
|
['alone', []],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, useEffect, useMemo, useState, useRef, useImperativeHandle } from 'react'
|
|
2
2
|
import { Omnibar, type OmnibarHandle } from './Omnibar'
|
|
3
|
-
import { useSearch, useNamespaceScope, useContexts, type SearchHit, type SearchResult } from '../../api/client'
|
|
3
|
+
import { useSearch, useNamespaceScope, useContexts, useRadarFeature, type SearchHit, type SearchResult } from '../../api/client'
|
|
4
4
|
import { useAPIResources } from '../../api/apiResources'
|
|
5
5
|
import { loadRecentResources, recordRecentResource } from '../../hooks/useRecentResources'
|
|
6
6
|
import { useCommandItems, type CommandItemCallbacks } from './command-items'
|
|
@@ -48,6 +48,7 @@ export const RadarOmnibar = forwardRef<OmnibarHandle, RadarOmnibarProps>(functio
|
|
|
48
48
|
const { data: nsScope } = useNamespaceScope()
|
|
49
49
|
const { data: apiResources } = useAPIResources()
|
|
50
50
|
const { data: contexts } = useContexts()
|
|
51
|
+
const { support: eventContentSupport } = useRadarFeature('searchEventContent')
|
|
51
52
|
const contextKey = useMemo(() => contexts?.find((c) => c.isCurrent)?.name ?? '', [contexts])
|
|
52
53
|
|
|
53
54
|
const modifierOptions = useMemo(() => ({
|
|
@@ -70,6 +71,10 @@ export const RadarOmnibar = forwardRef<OmnibarHandle, RadarOmnibarProps>(functio
|
|
|
70
71
|
hits: searchData?.hits,
|
|
71
72
|
query,
|
|
72
73
|
recheckKind: (kind) => omnibarRef.current?.addModifier({ key: 'kind', value: kind }),
|
|
74
|
+
searchEvents: eventContentSupport === 'supported' && !isFetching && !isPlaceholderData && !isError
|
|
75
|
+
? () => omnibarRef.current?.addModifier({ key: 'kind', value: 'Event' })
|
|
76
|
+
: undefined,
|
|
77
|
+
eventSearchNeedsUpgrade: eventContentSupport === 'unsupported' && !isFetching && !isPlaceholderData && !isError,
|
|
73
78
|
pendingExhausted: exhaustedQuery === query,
|
|
74
79
|
openKindList: (kind, group) => {
|
|
75
80
|
const resource = apiResources?.find((r) => r.kind === kind && r.group === group)
|
|
@@ -88,6 +93,7 @@ export const RadarOmnibar = forwardRef<OmnibarHandle, RadarOmnibarProps>(functio
|
|
|
88
93
|
isError={isError}
|
|
89
94
|
isPlaceholderData={isPlaceholderData}
|
|
90
95
|
note={note}
|
|
96
|
+
eventContentSearch={eventContentSupport === 'supported'}
|
|
91
97
|
modifierOptions={modifierOptions}
|
|
92
98
|
seedNamespaces={nsScope?.actives}
|
|
93
99
|
onInvestigateQuery={onInvestigateQuery}
|
|
@@ -11,16 +11,23 @@ afterEach(() => {
|
|
|
11
11
|
host?.remove()
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
function render() {
|
|
14
|
+
function render(eventContentSearch = false) {
|
|
15
15
|
host = document.createElement('div')
|
|
16
16
|
document.body.appendChild(host)
|
|
17
17
|
root = createRoot(host)
|
|
18
|
-
act(() => root!.render(<SearchSyntaxHelp />))
|
|
18
|
+
act(() => root!.render(<SearchSyntaxHelp eventContentSearch={eventContentSearch} />))
|
|
19
19
|
return host.querySelector('button')!
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const cardShown = () => document.body.textContent?.includes('Search syntax') ?? false
|
|
23
23
|
|
|
24
|
+
it.each([false, true])('describes only Event search supported by the server: %s', (supported) => {
|
|
25
|
+
const button = render(supported)
|
|
26
|
+
act(() => button.click())
|
|
27
|
+
expect(document.body.textContent).toContain(supported ? 'search Event reasons and messages' : 'search Events by name')
|
|
28
|
+
expect(document.body.textContent).not.toContain(supported ? 'search Events by name' : 'search Event reasons and messages')
|
|
29
|
+
})
|
|
30
|
+
|
|
24
31
|
it('toggles on a click with no pointer before it (assistive activation)', () => {
|
|
25
32
|
const button = render()
|
|
26
33
|
act(() => button.click())
|
|
@@ -8,6 +8,7 @@ import { isTouchIntent } from '@skyhook-io/k8s-ui'
|
|
|
8
8
|
const OPERATORS: { syntax: string; desc: string }[] = [
|
|
9
9
|
{ syntax: 'ns:prod', desc: 'filter by namespace' },
|
|
10
10
|
{ syntax: 'kind:Deployment', desc: 'filter by resource kind' },
|
|
11
|
+
{ syntax: 'kind:Event', desc: 'search Events by name' },
|
|
11
12
|
{ syntax: 'label:app=api', desc: 'filter by label' },
|
|
12
13
|
{ syntax: 'image:nginx', desc: 'match container image' },
|
|
13
14
|
{ syntax: 'redis cache', desc: 'multiple terms — all must match' },
|
|
@@ -21,7 +22,7 @@ const OPERATORS: { syntax: string; desc: string }[] = [
|
|
|
21
22
|
// that just opened the search box, so hover ignores a tap's side effects. A
|
|
22
23
|
// click (a tap, or assistive-technology activation) toggles the card, except
|
|
23
24
|
// right after a mouse hover opened it; a tap elsewhere closes it.
|
|
24
|
-
export function SearchSyntaxHelp() {
|
|
25
|
+
export function SearchSyntaxHelp({ eventContentSearch = false }: { eventContentSearch?: boolean }) {
|
|
25
26
|
const [open, setOpen] = useState(false)
|
|
26
27
|
const btnRef = useRef<HTMLButtonElement>(null)
|
|
27
28
|
const popRef = useRef<HTMLDivElement>(null)
|
|
@@ -95,7 +96,7 @@ export function SearchSyntaxHelp() {
|
|
|
95
96
|
{OPERATORS.map((op) => (
|
|
96
97
|
<div key={op.syntax} className="flex items-baseline gap-2">
|
|
97
98
|
<code className="shrink-0 rounded bg-theme-elevated border border-theme-border-light px-1.5 py-0.5 text-xs text-theme-text-primary">{op.syntax}</code>
|
|
98
|
-
<span className="text-xs text-theme-text-secondary">{op.desc}</span>
|
|
99
|
+
<span className="text-xs text-theme-text-secondary">{op.syntax === 'kind:Event' && eventContentSearch ? 'search Event reasons and messages' : op.desc}</span>
|
|
99
100
|
</div>
|
|
100
101
|
))}
|
|
101
102
|
</div>
|