@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
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useEffect } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { unreadReason } from '@skyhook-io/k8s-ui/components/kueue/related-read'
|
|
7
|
+
import { SecondaryNetworksSection } from '@skyhook-io/k8s-ui/components/resources/renderers/SecondaryNetworksSection'
|
|
8
|
+
import { getPodNetworks, uniqueNetworkAttachmentRefs, type NetworkAttachmentLookups, type NetworkAttachmentRef } from '@skyhook-io/k8s-ui/utils/multus'
|
|
9
|
+
import { useNetworkAttachmentLookups } from './networkAttachments'
|
|
10
|
+
|
|
11
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
12
|
+
let root: Root
|
|
13
|
+
let container: HTMLDivElement
|
|
14
|
+
let client: QueryClient
|
|
15
|
+
let lookups: NetworkAttachmentLookups
|
|
16
|
+
const requests: string[] = []
|
|
17
|
+
// Responses per definition name, served in order; the last one repeats.
|
|
18
|
+
let responses: Record<string, { status: number; body: unknown }[]>
|
|
19
|
+
|
|
20
|
+
const found = { status: 200, body: { resource: { metadata: { name: 'x' } } } }
|
|
21
|
+
const fail = (status: number, error_code?: string) => ({ status, body: { error: 'nope', ...(error_code ? { error_code } : {}) } })
|
|
22
|
+
|
|
23
|
+
function Lookups({ refs }: { refs: NetworkAttachmentRef[] }) {
|
|
24
|
+
const result = useNetworkAttachmentLookups(refs)
|
|
25
|
+
useEffect(() => { lookups = result }, [result])
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function Section({ names }: { names: string }) {
|
|
30
|
+
const pod = { metadata: { name: 'worker', namespace: 'apps', annotations: { 'k8s.v1.cni.cncf.io/networks': names } } }
|
|
31
|
+
const attachmentLookups = useNetworkAttachmentLookups(uniqueNetworkAttachmentRefs(getPodNetworks(pod).rows))
|
|
32
|
+
return <SecondaryNetworksSection pod={pod} attachmentLookups={attachmentLookups} onNavigate={() => undefined} />
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const ref = (name: string, namespace = 'apps'): NetworkAttachmentRef => ({ namespace, name })
|
|
36
|
+
const linked = (name: string) => [...container.querySelectorAll('button')].some(button => button.textContent === name)
|
|
37
|
+
const requestsFor = (name: string) => requests.filter(url => url.includes(`/${name}?`)).length
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
requests.length = 0
|
|
41
|
+
lookups = {}
|
|
42
|
+
responses = {}
|
|
43
|
+
vi.stubGlobal('fetch', async (input: string | URL | Request) => {
|
|
44
|
+
const url = String(input)
|
|
45
|
+
requests.push(url)
|
|
46
|
+
const name = new URL(url, 'http://localhost').pathname.split('/').pop() ?? ''
|
|
47
|
+
const queue = responses[name] ?? [found]
|
|
48
|
+
const next = queue.length > 1 ? queue.shift()! : queue[0]
|
|
49
|
+
return new Response(JSON.stringify(next.body), { status: next.status })
|
|
50
|
+
})
|
|
51
|
+
client = new QueryClient()
|
|
52
|
+
container = document.createElement('div')
|
|
53
|
+
root = createRoot(container)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
afterEach(async () => {
|
|
57
|
+
await act(async () => root.unmount())
|
|
58
|
+
client.clear()
|
|
59
|
+
vi.unstubAllGlobals()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
async function renderLookups(refs: NetworkAttachmentRef[]) {
|
|
63
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Lookups refs={refs} /></QueryClientProvider>))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function renderSection(names: string) {
|
|
67
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Section names={names} /></QueryClientProvider>))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
it('says whose access refused the read, and does not re-read a viewer denial', async () => {
|
|
71
|
+
const viewer = { state: 'unavailable', code: 'user_forbidden' } as const
|
|
72
|
+
const radar = { state: 'unavailable', code: 'radar_forbidden' } as const
|
|
73
|
+
responses = { hidden: [fail(403, 'user_forbidden')], blocked: [fail(503, 'radar_forbidden')] }
|
|
74
|
+
await renderSection('hidden,blocked')
|
|
75
|
+
await vi.waitFor(() => {
|
|
76
|
+
expect(container.textContent).toContain(unreadReason(viewer))
|
|
77
|
+
expect(container.textContent).toContain(unreadReason(radar))
|
|
78
|
+
}, { timeout: 6000 })
|
|
79
|
+
expect(linked('hidden') || linked('blocked')).toBe(false)
|
|
80
|
+
expect(requestsFor('hidden')).toBe(1)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('keeps reading while Radar is still connecting and links the definition once it answers', async () => {
|
|
84
|
+
responses = { later: [fail(503, 'cluster_connecting'), found] }
|
|
85
|
+
await renderSection('later')
|
|
86
|
+
await vi.waitFor(() => expect(linked('later')).toBe(true), { timeout: 6000 })
|
|
87
|
+
expect(requestsFor('later')).toBe(2)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('reads a definition as missing only when the server proved it absent', async () => {
|
|
91
|
+
responses = { gone: [fail(404, 'object_not_found')], vague: [fail(404)] }
|
|
92
|
+
await renderSection('gone,vague')
|
|
93
|
+
const unconfirmed = unreadReason({ state: 'unconfirmed' })
|
|
94
|
+
await vi.waitFor(() => expect(container.textContent).toContain(unconfirmed), { timeout: 6000 })
|
|
95
|
+
const cards = [...container.querySelectorAll('.card-inner')].map(card => card.textContent ?? '')
|
|
96
|
+
const missing = 'No NetworkAttachmentDefinition with this name'
|
|
97
|
+
expect(cards.find(card => card.startsWith('gone'))).toContain(missing)
|
|
98
|
+
expect(cards.find(card => card.startsWith('vague'))).not.toContain(missing)
|
|
99
|
+
expect(requestsFor('gone')).toBe(1)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('reads the definition by its exact group and hyphenated plural', async () => {
|
|
103
|
+
await renderLookups([ref('present', 'shared')])
|
|
104
|
+
await vi.waitFor(() => expect(lookups['shared/present']?.state).toBe('found'))
|
|
105
|
+
expect(requests[0]).toBe('/api/resources/network-attachment-definitions/shared/present?group=k8s.cni.cncf.io')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('makes no request for a Pod that names no definitions', async () => {
|
|
109
|
+
await renderLookups([])
|
|
110
|
+
expect(requests).toEqual([])
|
|
111
|
+
expect(lookups).toEqual({})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('bounds how many definitions one Pod can make Radar read and marks the rest unchecked', async () => {
|
|
115
|
+
await renderLookups(Array.from({ length: 30 }, (_, index) => ref(`net-${index}`)))
|
|
116
|
+
await vi.waitFor(() => expect(Object.values(lookups).filter(lookup => lookup.state === 'found')).toHaveLength(20))
|
|
117
|
+
expect(new Set(requests).size).toBe(20)
|
|
118
|
+
const unchecked = Object.entries(lookups).filter(([, lookup]) => lookup.state === 'unchecked').map(([key]) => key)
|
|
119
|
+
expect(unchecked).toEqual(Array.from({ length: 10 }, (_, index) => `apps/net-${index + 20}`))
|
|
120
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NETWORK_ATTACHMENT_DEFINITION_GROUP,
|
|
3
|
+
NETWORK_ATTACHMENT_DEFINITION_PLURAL,
|
|
4
|
+
networkAttachmentKey,
|
|
5
|
+
type NetworkAttachmentLookups,
|
|
6
|
+
type NetworkAttachmentRef,
|
|
7
|
+
} from '@skyhook-io/k8s-ui/utils/multus'
|
|
8
|
+
import { useRelatedReads } from '../components/kueue/useRelatedReads'
|
|
9
|
+
|
|
10
|
+
// The names come from a Pod annotation anyone who can create Pods controls.
|
|
11
|
+
const MAX_LOOKUPS = 20
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether each NetworkAttachmentDefinition a Pod names can be read, as the
|
|
15
|
+
* viewer. One read per definition rather than a list: a denied list comes back
|
|
16
|
+
* empty, which would look the same as a definition that does not exist.
|
|
17
|
+
*/
|
|
18
|
+
export function useNetworkAttachmentLookups(refs: NetworkAttachmentRef[]): NetworkAttachmentLookups {
|
|
19
|
+
const bounded = refs.slice(0, MAX_LOOKUPS)
|
|
20
|
+
const reads = useRelatedReads(bounded.map(ref => ({
|
|
21
|
+
kind: NETWORK_ATTACHMENT_DEFINITION_PLURAL,
|
|
22
|
+
group: NETWORK_ATTACHMENT_DEFINITION_GROUP,
|
|
23
|
+
namespace: ref.namespace,
|
|
24
|
+
name: ref.name,
|
|
25
|
+
})))
|
|
26
|
+
const lookups: NetworkAttachmentLookups = {}
|
|
27
|
+
bounded.forEach((ref, index) => { lookups[networkAttachmentKey(ref)] = reads[index] })
|
|
28
|
+
for (const ref of refs.slice(MAX_LOOKUPS)) lookups[networkAttachmentKey(ref)] = { state: 'unchecked' }
|
|
29
|
+
return lookups
|
|
30
|
+
}
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
} from './radarFeatures'
|
|
16
16
|
|
|
17
17
|
describe('radarFeatureSupport', () => {
|
|
18
|
+
it('requires explicit Event content support even when the older search endpoint is available', () => {
|
|
19
|
+
expect(radarFeatureSupport('searchEventContent', { features: { searchCoverage: true } }, 'v99.0.0')).toBe('unsupported')
|
|
20
|
+
expect(radarFeatureSupport('searchEventContent', { features: { searchEventContent: true } }, 'v1.0.0')).toBe('supported')
|
|
21
|
+
expect(radarFeatureSupport('searchEventContent', undefined, 'dev')).toBe('unknown')
|
|
22
|
+
})
|
|
18
23
|
it('trusts the advertised flag over the version', () => {
|
|
19
24
|
expect(radarFeatureSupport('policyResource', { features: { policyResource: true } }, 'v1.7.2')).toBe('supported')
|
|
20
25
|
expect(radarFeatureSupport('policyResource', { features: { policyResource: true } }, undefined)).toBe('supported')
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const RADAR_FEATURES = {
|
|
|
33
33
|
resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
|
|
34
34
|
searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
|
|
35
35
|
applicationEvidence: { label: 'Application evidence collection', flag: 'applicationEvidence', flagShippedWithEndpoint: true },
|
|
36
|
+
searchEventContent: { label: 'Event reason and message searches', flag: 'searchEventContent', flagShippedWithEndpoint: true },
|
|
36
37
|
resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
|
|
37
38
|
resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
|
|
38
39
|
podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
|
|
@@ -44,8 +45,15 @@ export const RADAR_FEATURES = {
|
|
|
44
45
|
drainPlan: { label: 'Drain plans', minimumVersion: 'v1.14.0' },
|
|
45
46
|
applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
|
|
46
47
|
workloadHistory: { label: 'Workload history', flag: 'workloadHistory', flagShippedWithEndpoint: true },
|
|
48
|
+
deploymentPause: { label: 'Deployment rollout pause and resume', flag: 'deploymentPause', flagShippedWithEndpoint: true },
|
|
49
|
+
substrateHealthMetrics: { label: 'Agent Substrate charts', flag: 'substrateHealthMetrics', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
|
|
47
50
|
cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
|
|
48
51
|
cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
|
|
52
|
+
veleroWorkspace: { label: 'Velero views', flag: 'veleroWorkspace', flagShippedWithEndpoint: true },
|
|
53
|
+
veleroBackupNow: { label: 'Back up now', flag: 'veleroBackupNow', flagShippedWithEndpoint: true },
|
|
54
|
+
veleroRuns: { label: 'Velero backup and restore lists', flag: 'veleroRuns', flagShippedWithEndpoint: true },
|
|
55
|
+
veleroDeleteBackup: { label: 'Delete a Velero backup', flag: 'veleroDeleteBackup', flagShippedWithEndpoint: true },
|
|
56
|
+
resourceDeletePreconditions: { label: 'Delete only the object you reviewed', flag: 'resourceDeletePreconditions', flagShippedWithEndpoint: true },
|
|
49
57
|
gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
|
|
50
58
|
serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
|
|
51
59
|
trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
|
|
@@ -69,6 +77,8 @@ export const RADAR_FEATURES = {
|
|
|
69
77
|
// Never blocks a control: on an older Radar the Helm view reads /helm/releases.
|
|
70
78
|
helmInventory: { label: 'Helm releases without Secret access', flag: 'helmInventory', flagShippedWithEndpoint: true },
|
|
71
79
|
agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
|
|
80
|
+
podFileUpload: { label: 'Pod file uploads', flag: 'podFileUpload', flagShippedWithEndpoint: true },
|
|
81
|
+
vulnerabilities: { label: 'Vulnerability views', flag: 'vulnerabilities', flagShippedWithEndpoint: true },
|
|
72
82
|
} as const satisfies Record<string, RadarFeatureSpec>
|
|
73
83
|
|
|
74
84
|
export type RadarFeature = keyof typeof RADAR_FEATURES
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { ApiError } from './client'
|
|
3
|
+
import { toSecretsStoreRead } from './secretsStore'
|
|
4
|
+
|
|
5
|
+
const complete = { status: 'complete' as const, scope: { type: 'namespaces' as const }, gaps: [] }
|
|
6
|
+
const partial = (code: string) => ({ status: 'partial' as const, scope: { type: 'namespaces' as const }, gaps: [{ code, action: 'retry' }] })
|
|
7
|
+
|
|
8
|
+
describe('toSecretsStoreRead', () => {
|
|
9
|
+
it('trusts absence only from a complete answer', () => {
|
|
10
|
+
expect(toSecretsStoreRead({ data: [], coverage: complete, error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: true })
|
|
11
|
+
expect(toSecretsStoreRead({ data: [{}], coverage: partial('radar_forbidden') as any, error: null, isLoading: false })).toEqual({ state: 'ok', items: [{}], complete: false })
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('does not trust absence from a list without coverage', () => {
|
|
15
|
+
expect(toSecretsStoreRead({ data: [], coverage: { status: 'unknown' }, error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: false })
|
|
16
|
+
expect(toSecretsStoreRead({ data: [], error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: false })
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('keeps a denial apart from an empty list', () => {
|
|
20
|
+
expect(toSecretsStoreRead({ error: new ApiError('forbidden', 403), isLoading: false })).toEqual({ state: 'forbidden' })
|
|
21
|
+
expect(toSecretsStoreRead({ data: [], coverage: partial('user_forbidden') as any, error: null, isLoading: false })).toEqual({ state: 'forbidden' })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('reports an unserved API as unavailable, not missing', () => {
|
|
25
|
+
const notServed = new ApiError('unknown resource kind: secretproviderclasses', 400, { error_code: 'kind_unknown' } as any)
|
|
26
|
+
expect(toSecretsStoreRead({ error: notServed, isLoading: false }).state).toBe('unavailable')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('stays loading while the kind syncs', () => {
|
|
30
|
+
expect(toSecretsStoreRead({ isLoading: true, error: null })).toEqual({ state: 'loading' })
|
|
31
|
+
expect(toSecretsStoreRead({ data: [], coverage: partial('kind_sync_pending') as any, error: null, isLoading: false })).toEqual({ state: 'loading' })
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
|
|
2
|
+
import type { SecretsStoreRead } from '@skyhook-io/k8s-ui/components/resources/resource-utils-secrets-store'
|
|
3
|
+
import { ApiError, isForbiddenError, isStillLoadingError } from './client'
|
|
4
|
+
|
|
5
|
+
interface ListQuery<T> {
|
|
6
|
+
data?: T[]
|
|
7
|
+
coverage?: ResourceCoverage
|
|
8
|
+
error: unknown
|
|
9
|
+
isLoading: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One namespace list read, as the Secrets Store renderers need it: what came
|
|
14
|
+
* back, and whether its absence of an object can be trusted. A denial, a kind
|
|
15
|
+
* that is not served and a read still warming up stay distinct from an empty
|
|
16
|
+
* answer.
|
|
17
|
+
*/
|
|
18
|
+
export function toSecretsStoreRead<T>(query: ListQuery<T>): SecretsStoreRead<T> {
|
|
19
|
+
if (query.error) {
|
|
20
|
+
if (isForbiddenError(query.error)) return { state: 'forbidden' }
|
|
21
|
+
if (isStillLoadingError(query.error)) return { state: 'loading' }
|
|
22
|
+
if (query.error instanceof ApiError && query.error.data?.error_code === 'kind_unknown') {
|
|
23
|
+
return { state: 'unavailable', message: 'The Secrets Store CSI driver’s API is not served in this cluster.' }
|
|
24
|
+
}
|
|
25
|
+
return { state: 'unavailable', message: query.error instanceof Error ? query.error.message : String(query.error) }
|
|
26
|
+
}
|
|
27
|
+
if (query.isLoading || !query.data) return { state: 'loading' }
|
|
28
|
+
const coverage = query.coverage
|
|
29
|
+
if (coverage?.status === 'partial') {
|
|
30
|
+
// The caller asked for one namespace, so a user denial leaves nothing read.
|
|
31
|
+
if (query.data.length === 0 && coverage.gaps.some(gap => gap.code === 'user_forbidden')) return { state: 'forbidden' }
|
|
32
|
+
if (query.data.length === 0 && coverage.gaps.some(gap => gap.code === 'kind_sync_pending')) return { state: 'loading' }
|
|
33
|
+
return { state: 'ok', items: query.data, complete: false }
|
|
34
|
+
}
|
|
35
|
+
// Without coverage (an older Radar) a list cannot establish absence.
|
|
36
|
+
return { state: 'ok', items: query.data, complete: coverage?.status === 'complete' }
|
|
37
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query'
|
|
2
|
+
import { getApiBase } from './config'
|
|
3
|
+
import type { TimeSeries } from '@skyhook-io/k8s-ui/components/charts'
|
|
4
|
+
import { ApiError, fetchJSON, useClusterInfo, useRadarFeature, type PrometheusTimeRange } from './client'
|
|
5
|
+
|
|
6
|
+
export type SubstrateChartState =
|
|
7
|
+
| 'ok'
|
|
8
|
+
| 'empty'
|
|
9
|
+
| 'noSeries'
|
|
10
|
+
| 'notAttributable'
|
|
11
|
+
| 'duplicateSources'
|
|
12
|
+
| 'ambiguous'
|
|
13
|
+
| 'mismatch'
|
|
14
|
+
| 'error'
|
|
15
|
+
|
|
16
|
+
export interface SubstrateChart {
|
|
17
|
+
id: string
|
|
18
|
+
title: string
|
|
19
|
+
unit: string
|
|
20
|
+
population: string
|
|
21
|
+
/** The metrics read, in the spelling Prometheus holds them. */
|
|
22
|
+
source: string
|
|
23
|
+
state: SubstrateChartState
|
|
24
|
+
/** Why there are no series; on an ok chart, which named series has no data. */
|
|
25
|
+
reason?: string
|
|
26
|
+
isolation: { mode: 'configured' | 'verified' | 'unverified' | ''; labels?: Record<string, string>; note: string }
|
|
27
|
+
/** One display label per series, under `series`. A null value is a gap. */
|
|
28
|
+
series: TimeSeries[]
|
|
29
|
+
/** Series beyond the first 12. */
|
|
30
|
+
omitted?: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type SubstrateVerdictState =
|
|
34
|
+
/** Substrate's own capacity alert condition has held for five minutes. */
|
|
35
|
+
| 'workerShortfall'
|
|
36
|
+
/** No API replica sees a free actor slot. */
|
|
37
|
+
| 'noFreeActorSlots'
|
|
38
|
+
/** Some worker has a free actor slot. Slots are counted by actors alone: an
|
|
39
|
+
* actor can still fail to place for lack of CPU or memory. */
|
|
40
|
+
| 'freeActorSlots'
|
|
41
|
+
/** No schedulable worker of a known class. */
|
|
42
|
+
| 'noSchedulableWorkers'
|
|
43
|
+
/** A node: some actor's snapshot upload is overdue. */
|
|
44
|
+
| 'uploadsOverdue'
|
|
45
|
+
/** A node: no overdue upload is counted. Snapshots with no storage
|
|
46
|
+
* destination are not counted, so this does not prove all are saved. */
|
|
47
|
+
| 'noUploadsOverdue'
|
|
48
|
+
| 'unknown'
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One number behind a verdict. resumeP95, resumeFailures and crashes summarize
|
|
52
|
+
* the requested range; workersWithFreeActorSlots, overdueUploads and oldestUnsaved read now.
|
|
53
|
+
*/
|
|
54
|
+
export interface SubstrateFact {
|
|
55
|
+
id: string
|
|
56
|
+
/** Display text. */
|
|
57
|
+
label: string
|
|
58
|
+
unit: 'workers' | 'seconds' | 'percent' | 'count'
|
|
59
|
+
/** ok has a value; empty means the series exist and recorded nothing here; unavailable says why. */
|
|
60
|
+
state: 'ok' | 'empty' | 'unavailable'
|
|
61
|
+
value?: number
|
|
62
|
+
/**
|
|
63
|
+
* Only on an ok fact that compares: workersWithFreeActorSlots, out of the
|
|
64
|
+
* schedulable workers of known classes; schedulableWorkers (present only on a
|
|
65
|
+
* workerShortfall verdict, listed first), out of the fewest desired over five
|
|
66
|
+
* minutes.
|
|
67
|
+
*/
|
|
68
|
+
of?: number
|
|
69
|
+
reason?: string
|
|
70
|
+
/** Only on an ok overdueUploads: Substrate's band keys with actors in them, worst first. */
|
|
71
|
+
parts?: { label: string; value: number }[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SubstrateVerdict {
|
|
75
|
+
state: SubstrateVerdictState
|
|
76
|
+
/** Why the state is unknown, or what qualifies a known one (a shortfall that could not be judged). */
|
|
77
|
+
reason?: string
|
|
78
|
+
facts: SubstrateFact[]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface SubstrateHealth {
|
|
82
|
+
/**
|
|
83
|
+
* available: some chart has data or a refusal of its own; read each chart's
|
|
84
|
+
* state. notFound: no chart has series for this subject in the range, which
|
|
85
|
+
* does not say whether Substrate or the object exists. notOnNode,
|
|
86
|
+
* notAttributable: a node's atelet series. error: every chart failed.
|
|
87
|
+
*/
|
|
88
|
+
status: 'available' | 'notFound' | 'notOnNode' | 'notAttributable' | 'error'
|
|
89
|
+
reason?: string
|
|
90
|
+
/** The range served: 1h when the request named an unknown one. */
|
|
91
|
+
range: string
|
|
92
|
+
/** Unix seconds. */
|
|
93
|
+
start: number
|
|
94
|
+
end: number
|
|
95
|
+
stepSeconds: number
|
|
96
|
+
charts: SubstrateChart[]
|
|
97
|
+
/** Set when status is available. */
|
|
98
|
+
verdict?: SubstrateVerdict
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export type SubstrateTarget =
|
|
102
|
+
| { kind: 'workerpool'; namespace: string; name: string }
|
|
103
|
+
| { kind: 'node'; name: string }
|
|
104
|
+
|
|
105
|
+
function substratePath(target: SubstrateTarget, range: PrometheusTimeRange): string {
|
|
106
|
+
const query = new URLSearchParams({ range })
|
|
107
|
+
return target.kind === 'workerpool'
|
|
108
|
+
? `/prometheus/substrate/workerpools/${encodeURIComponent(target.namespace)}/${encodeURIComponent(target.name)}?${query}`
|
|
109
|
+
: `/prometheus/substrate/nodes/${encodeURIComponent(target.name)}?${query}`
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Curated Agent Substrate charts for one WorkerPool or Node. Requests only a
|
|
114
|
+
* Radar that advertises the endpoints: Radar Hub can embed this UI against an
|
|
115
|
+
* older Radar, which would answer with a 404.
|
|
116
|
+
*/
|
|
117
|
+
/** The verdict and the charts read one response, so they share one range. */
|
|
118
|
+
export const SUBSTRATE_RANGE: PrometheusTimeRange = '1h'
|
|
119
|
+
|
|
120
|
+
export function useSubstrateHealth(target: SubstrateTarget, enabled: boolean) {
|
|
121
|
+
const range = SUBSTRATE_RANGE
|
|
122
|
+
const { data: cluster } = useClusterInfo()
|
|
123
|
+
const feature = useRadarFeature('substrateHealthMetrics')
|
|
124
|
+
const query = useQuery<SubstrateHealth>({
|
|
125
|
+
queryKey: ['substrate-health', getApiBase(), cluster?.context, target.kind, target.kind === 'workerpool' ? target.namespace : '', target.name, range],
|
|
126
|
+
queryFn: ({ signal }) => feature.guard(() => fetchJSON<SubstrateHealth>(substratePath(target, range), signal)),
|
|
127
|
+
enabled: enabled && feature.support === 'supported',
|
|
128
|
+
staleTime: 30_000,
|
|
129
|
+
refetchInterval: 60_000,
|
|
130
|
+
// A changed connection answers 409 and is safe to retry once; a denial is final.
|
|
131
|
+
retry: (failureCount, error) => failureCount < 1 && error instanceof ApiError && error.status === 409,
|
|
132
|
+
})
|
|
133
|
+
return { ...query, upgrade: feature.upgrade, blockedReason: feature.blockedReason, support: feature.support }
|
|
134
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { beforeEach, expect, it, vi } from 'vitest'
|
|
2
|
+
import { useMutation, useQuery } from '@tanstack/react-query'
|
|
3
|
+
import { fetchJSON } from './client'
|
|
4
|
+
import { useVeleroBackupDeletion, useVeleroDeleteBackup, useVeleroRuns } from './velero'
|
|
5
|
+
|
|
6
|
+
vi.mock('@tanstack/react-query', () => ({ useQuery: vi.fn(), useMutation: vi.fn(), useQueryClient: vi.fn() }))
|
|
7
|
+
vi.mock('./client', () => ({
|
|
8
|
+
apiFetch: vi.fn(),
|
|
9
|
+
fetchJSON: vi.fn(),
|
|
10
|
+
useRadarFeature: () => ({ gatedKey: [], guard: (request: () => Promise<unknown>) => request() }),
|
|
11
|
+
}))
|
|
12
|
+
beforeEach(() => vi.clearAllMocks())
|
|
13
|
+
|
|
14
|
+
function lastQuery() { return vi.mocked(useQuery).mock.calls.at(-1)![0] }
|
|
15
|
+
|
|
16
|
+
it('puts run filters in the URL and key and never reuses another filter’s answer', async () => {
|
|
17
|
+
useVeleroRuns('backups', 'velero', { schedule: 'nightly' })
|
|
18
|
+
const first = lastQuery()
|
|
19
|
+
useVeleroRuns('backups', 'velero', { schedule: 'weekly' })
|
|
20
|
+
const second = lastQuery()
|
|
21
|
+
const request = second.queryFn as (context: { signal: AbortSignal }) => Promise<unknown>
|
|
22
|
+
await request({ signal: new AbortController().signal })
|
|
23
|
+
expect(fetchJSON).toHaveBeenCalledWith('/velero/runs/backups?namespace=velero&schedule=weekly', expect.any(AbortSignal))
|
|
24
|
+
expect(second.queryKey).not.toEqual(first.queryKey)
|
|
25
|
+
const previous = { runs: [] }
|
|
26
|
+
const placeholder = second.placeholderData as (prev: unknown, query: { queryKey: readonly unknown[] }) => unknown
|
|
27
|
+
expect(placeholder(previous, { queryKey: first.queryKey })).toBeUndefined()
|
|
28
|
+
expect(placeholder(previous, { queryKey: second.queryKey })).toBe(previous)
|
|
29
|
+
useVeleroRuns('restores', undefined, { backup: 'source' })
|
|
30
|
+
const restore = lastQuery().queryFn as typeof request
|
|
31
|
+
await restore({ signal: new AbortController().signal })
|
|
32
|
+
expect(fetchJSON).toHaveBeenLastCalledWith('/velero/runs/restores?backup=source', expect.any(AbortSignal))
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('looks up deletion by backup UID without a request name or browser operation store', async () => {
|
|
36
|
+
useVeleroBackupDeletion('velero', 'nightly', 'uid-one')
|
|
37
|
+
const options = lastQuery()
|
|
38
|
+
const request = options.queryFn as (context: { signal: AbortSignal }) => Promise<unknown>
|
|
39
|
+
await request({ signal: new AbortController().signal })
|
|
40
|
+
expect(fetchJSON).toHaveBeenCalledWith('/velero/backups/velero/nightly/deletion?uid=uid-one', expect.any(AbortSignal))
|
|
41
|
+
expect(options.enabled).toBe(true)
|
|
42
|
+
useVeleroDeleteBackup()
|
|
43
|
+
const mutation = vi.mocked(useMutation).mock.calls.at(-1)![0]!.mutationFn as (variables: unknown) => Promise<unknown>
|
|
44
|
+
await mutation({ namespace: 'velero', name: 'nightly', uid: 'uid-one' })
|
|
45
|
+
expect(fetchJSON).toHaveBeenLastCalledWith('/velero/backups/velero/nightly/delete', expect.objectContaining({ body: JSON.stringify({ uid: 'uid-one' }) }))
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('stops deletion polling and retries on every 4xx, including with a previous reading', () => {
|
|
49
|
+
useVeleroBackupDeletion('velero', 'nightly', 'uid-one')
|
|
50
|
+
const options = lastQuery()
|
|
51
|
+
const poll = options.refetchInterval as (query: { state: { error?: unknown; data?: { state: string } } }) => number | false
|
|
52
|
+
const retry = options.retry as (count: number, error: unknown) => boolean
|
|
53
|
+
for (const status of [400, 401, 403, 404, 408, 409, 429]) {
|
|
54
|
+
expect(poll({ state: { error: { status }, data: { state: 'waiting' } } })).toBe(false)
|
|
55
|
+
expect(retry(0, { status })).toBe(false)
|
|
56
|
+
}
|
|
57
|
+
expect(poll({ state: { error: { status: 503 }, data: { state: 'waiting' } } })).toBe(2000)
|
|
58
|
+
expect(retry(0, { status: 503 })).toBe(true)
|
|
59
|
+
for (const state of ['refused', 'failed', 'deleted', 'unknown']) expect(poll({ state: { data: { state } } })).toBe(false)
|
|
60
|
+
})
|