@skyhook-io/radar-app 1.20.3 → 1.21.1
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 +67 -15
- 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.ts +129 -5
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/radarFeatures.ts +11 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +377 -0
- package/src/api/vulnerabilities.ts +313 -0
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +35 -5
- package/src/components/audit/ChecksViewTabs.tsx +12 -1
- package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
- package/src/components/audit/Java4ShellPanel.tsx +313 -0
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +944 -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/diagnose/diagnoseEvidenceTypes.ts +2 -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/gitops/FluxOperatorCard.test.tsx +37 -0
- package/src/components/gitops/FluxOperatorCard.tsx +27 -0
- package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
- package/src/components/gitops/GitOpsView.tsx +8 -5
- package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
- package/src/components/gitops/gitopsRowEvents.ts +31 -0
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmView.tsx +20 -16
- package/src/components/helm/OwnedResources.tsx +4 -3
- package/src/components/home/ClusterHealthCard.tsx +3 -1
- 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 +15 -2
- 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/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/ResourcesView.tsx +12 -6
- 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 +3 -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 +46 -129
- package/src/components/traffic/trafficFilters.test.ts +172 -1
- package/src/components/traffic/trafficFilters.ts +139 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +31 -2
- package/src/components/ui/UpdateNotification.tsx +34 -17
- package/src/components/ui/command-items.ts +24 -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 +158 -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/VeleroRunArtifacts.test.tsx +241 -0
- package/src/components/velero/VeleroRunArtifacts.tsx +112 -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/VeleroRunVolumes.test.tsx +247 -0
- package/src/components/velero/VeleroRunVolumes.tsx +122 -0
- package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
- package/src/components/velero/VeleroSchedulePause.tsx +191 -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 +92 -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 +179 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
- package/src/components/whats-new/releaseNotes.ts +67 -1
- package/src/components/workload/WorkloadView.tsx +64 -27
- 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/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 +14 -2
- package/src/integrations/resourceHosts.tsx +22 -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/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import type { VeleroWorkspaceResponse } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { VeleroLocations } from './VeleroLocations'
|
|
6
|
+
import { VeleroOverview } from './VeleroOverview'
|
|
7
|
+
import { hoursAgo, location, workspace } from './velero.fixtures'
|
|
8
|
+
|
|
9
|
+
const text = (html: string) => html.replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&')
|
|
10
|
+
|
|
11
|
+
function render(data: VeleroWorkspaceResponse) {
|
|
12
|
+
return text(renderToStaticMarkup(
|
|
13
|
+
<VeleroLocations data={data} installation={null} onInstallation={() => {}} onInspect={() => {}} inspected={null} />,
|
|
14
|
+
))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('Velero storage locations', () => {
|
|
18
|
+
it('shows unread backups and schedules as unknown, never as zero or none', () => {
|
|
19
|
+
const html = render(workspace({
|
|
20
|
+
coverage: { schedules: { state: 'denied' }, backups: { state: 'denied' }, backupStorageLocations: { state: 'full' }, restores: { state: 'full' }, backupRepositories: { state: 'full' } },
|
|
21
|
+
installations: [{ namespace: 'velero', server: { source: 'unread' }, defaultSource: 'unknown' }],
|
|
22
|
+
locations: [location({ backups: null, schedules: null, default: false, defaultSource: 'unknown', frequency: undefined })],
|
|
23
|
+
}))
|
|
24
|
+
expect(html).toContain('Unknown — backups were not read')
|
|
25
|
+
expect(html).toContain('Unknown — no access to schedules')
|
|
26
|
+
expect(html).toContain('frequency unknown')
|
|
27
|
+
expect(html).toContain('default unknown')
|
|
28
|
+
expect(html).not.toMatch(/tabular-nums">0</)
|
|
29
|
+
expect(html).toContain('Radar couldn’t read some of the Velero data on this screen')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('counts the backups each location is named by and flags overdue validation', () => {
|
|
33
|
+
const data = workspace({
|
|
34
|
+
installations: [{ namespace: 'velero', server: { source: 'deployment' }, defaultLocation: 'default', defaultSource: 'spec' }],
|
|
35
|
+
locations: [location({ validationOverdue: true, attention: true, lastValidation: hoursAgo(2), schedules: [{ name: 'nightly' }, { name: 'weekly', viaDefault: true }] })],
|
|
36
|
+
})
|
|
37
|
+
const html = render(data)
|
|
38
|
+
expect(html).toContain('overdue')
|
|
39
|
+
expect(html).toContain('(as the default)')
|
|
40
|
+
// The usual frequency lives in the overdue badge's tooltip, not on every row.
|
|
41
|
+
expect(html).not.toContain('server flag')
|
|
42
|
+
|
|
43
|
+
const overview = text(renderToStaticMarkup(
|
|
44
|
+
<MemoryRouter>
|
|
45
|
+
<VeleroOverview data={data} installation={null} onInstallation={() => {}} onInspect={() => {}} inspected={null} />
|
|
46
|
+
</MemoryRouter>,
|
|
47
|
+
))
|
|
48
|
+
expect(overview).toContain('Velero last validated this location 2h ago; it validates every 1m.')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('says validation is disabled when its frequency is zero', () => {
|
|
52
|
+
const html = render(workspace({ locations: [location({ frequency: { seconds: 0, source: 'spec', disabled: true } })] }))
|
|
53
|
+
expect(html).toContain('validation disabled')
|
|
54
|
+
})
|
|
55
|
+
it('says when Velero never validated a location', () => {
|
|
56
|
+
const html = text(render(workspace({ locations: [location({ neverValidated: true, attention: true, lastValidation: undefined })] })))
|
|
57
|
+
expect(html).toContain('Not validated yet')
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('says why a location is unavailable in plain words, and marks the default once, under its name', () => {
|
|
61
|
+
const html = render(workspace({
|
|
62
|
+
locations: [
|
|
63
|
+
location(),
|
|
64
|
+
location({ name: 'dr', phase: 'Unavailable', default: false, message: 'rpc error: code = Unknown desc = NoSuchBucket: The specified bucket does not exist' }),
|
|
65
|
+
],
|
|
66
|
+
}))
|
|
67
|
+
expect(html).toContain('The bucket doesn’t exist')
|
|
68
|
+
// The default location named "default" reads once as its name and once as a note on a line of its own, not as a badge beside it.
|
|
69
|
+
expect(html).not.toMatch(/badge[^"]*">default</)
|
|
70
|
+
expect(html.match(/>default</g)?.length).toBe(1)
|
|
71
|
+
expect(html).toMatch(/<div class="mt-0\.5 text-xs[^"]*"><span[^>]*><span>the default location<\/span>/)
|
|
72
|
+
// On one line, the reason on hover; jsdom has no matchMedia, so this is the narrow table, whose counts share a column.
|
|
73
|
+
expect(html).toMatch(/whitespace-nowrap[^"]*">not restorable</)
|
|
74
|
+
expect(html).toContain('Last checked')
|
|
75
|
+
expect(html).toMatch(/— <span class="text-red[^"]*">failed</)
|
|
76
|
+
expect(html).toContain('completed · ')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('marks the default location and folds a long schedule list into a count', () => {
|
|
80
|
+
const schedules = ['a', 'b', 'c', 'd', 'e'].map((name) => ({ name }))
|
|
81
|
+
const html = render(workspace({ locations: [location({ schedules })] }))
|
|
82
|
+
expect(html).toContain('>the default location<')
|
|
83
|
+
expect(html).toContain('and 2 more')
|
|
84
|
+
expect(html).not.toContain('>d<')
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Tooltip,
|
|
5
|
+
VELERO_RUNS_UNKNOWN,
|
|
6
|
+
formatRelativeAgeTime,
|
|
7
|
+
getBSLStatus,
|
|
8
|
+
veleroDefaultText,
|
|
9
|
+
toneTextClass,
|
|
10
|
+
veleroLocationReasonText,
|
|
11
|
+
veleroPlainReason,
|
|
12
|
+
type VeleroLocationReading,
|
|
13
|
+
veleroLocalTime,
|
|
14
|
+
} from '@skyhook-io/k8s-ui'
|
|
15
|
+
import { useMediaQuery } from '../../hooks/useMediaQuery'
|
|
16
|
+
import { ScreenBody, SectionTable, Sub, type TableColumn } from '../workspace/layout'
|
|
17
|
+
import { coverageEmpty } from '../workspace/coverage'
|
|
18
|
+
import { VELERO_WIDE, VeleroCoverageNotice, VeleroName, VeleroWorkspaceHeader, WholeNames, inInstallation, veleroResource, type VeleroScreenProps } from './shared'
|
|
19
|
+
|
|
20
|
+
const SCHEDULES_UNKNOWN = 'Unknown — no access to schedules'
|
|
21
|
+
|
|
22
|
+
/** Availability, and under it why a location is unavailable in plain words; Velero's text on hover. */
|
|
23
|
+
function AvailabilityCell({ l }: { l: VeleroLocationReading }) {
|
|
24
|
+
const status = getBSLStatus({ status: { phase: l.phase ?? '' } })
|
|
25
|
+
const plain = l.phase === 'Unavailable' ? veleroPlainReason(l.message) : undefined
|
|
26
|
+
return (
|
|
27
|
+
<Tooltip content={l.message} disabled={!l.message} wrapperClassName="flex-col items-start">
|
|
28
|
+
<Badge colorClass={status.color} size="sm">{status.text}</Badge>
|
|
29
|
+
{plain && (
|
|
30
|
+
<div className={`mt-0.5 text-xs ${toneTextClass('unhealthy')}`}>
|
|
31
|
+
<WholeNames text={plain} />
|
|
32
|
+
</div>
|
|
33
|
+
)}
|
|
34
|
+
</Tooltip>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Velero stamps the time of each attempt, whether or not the location passed.
|
|
39
|
+
function ValidationCell({ l }: { l: VeleroLocationReading }) {
|
|
40
|
+
const when = l.lastValidation ? (
|
|
41
|
+
<Tooltip content={veleroLocalTime(l.lastValidation)}>
|
|
42
|
+
{l.phase === 'Unavailable' ? (
|
|
43
|
+
<span>
|
|
44
|
+
Last checked {formatRelativeAgeTime(l.lastValidation)} — <span className={toneTextClass('unhealthy')}>failed</span>
|
|
45
|
+
</span>
|
|
46
|
+
) : (
|
|
47
|
+
<span>{formatRelativeAgeTime(l.lastValidation)}</span>
|
|
48
|
+
)}
|
|
49
|
+
</Tooltip>
|
|
50
|
+
) : (
|
|
51
|
+
<span className="text-theme-text-tertiary">Not validated yet</span>
|
|
52
|
+
)
|
|
53
|
+
const f = l.frequency
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<span className="inline-flex flex-wrap items-center gap-1.5">
|
|
57
|
+
{when}
|
|
58
|
+
{l.validationOverdue && (
|
|
59
|
+
<Tooltip content={veleroLocationReasonText(l)}>
|
|
60
|
+
<Badge severity="warning" size="sm">overdue</Badge>
|
|
61
|
+
</Tooltip>
|
|
62
|
+
)}
|
|
63
|
+
</span>
|
|
64
|
+
{/* The usual frequency is in the overdue badge's tooltip; only an unusual one is worth a line. */}
|
|
65
|
+
{(!f || f.disabled) && <Sub>{!f ? 'frequency unknown' : 'validation disabled'}</Sub>}
|
|
66
|
+
</>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Whether the location is the installation's default, said only when it is or when Radar cannot tell. */
|
|
71
|
+
function DefaultMark({ l }: { l: VeleroLocationReading }) {
|
|
72
|
+
const d = veleroDefaultText(l)
|
|
73
|
+
if (d.text === 'No') return null
|
|
74
|
+
return (
|
|
75
|
+
<Sub>
|
|
76
|
+
<Tooltip content={d.detail}>
|
|
77
|
+
<span>{d.text === 'Yes' ? 'the default location' : 'default unknown'}</span>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
</Sub>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A location's row grows with every schedule listed, so long lists fold.
|
|
84
|
+
const SCHEDULES_SHOWN = 3
|
|
85
|
+
|
|
86
|
+
function BackupCount({ l, count }: { l: VeleroLocationReading; count: (b: NonNullable<VeleroLocationReading['backups']>) => number }) {
|
|
87
|
+
if (!l.backups) return <span className="text-theme-text-tertiary">{VELERO_RUNS_UNKNOWN}</span>
|
|
88
|
+
return <span className="tabular-nums">{count(l.backups)}</span>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Completed backups can't be restored while their location is unavailable. */
|
|
92
|
+
function NotRestorable({ l }: { l: VeleroLocationReading }) {
|
|
93
|
+
if (l.phase !== 'Unavailable' || !l.backups?.completedNotExpired) return null
|
|
94
|
+
return (
|
|
95
|
+
<div className="mt-0.5">
|
|
96
|
+
<Tooltip content="Velero refuses a restore from an unavailable location, so none of these can be restored until it is available again.">
|
|
97
|
+
<span className={`whitespace-nowrap text-xs ${toneTextClass('unhealthy')}`}>not restorable</span>
|
|
98
|
+
</Tooltip>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The three counts in one cell, for a narrow table: "38 backups", then "27 completed · 9 expired". */
|
|
104
|
+
function BackupCountsCell({ l }: { l: VeleroLocationReading }) {
|
|
105
|
+
const b = l.backups
|
|
106
|
+
if (!b) return <span className="text-theme-text-tertiary">{VELERO_RUNS_UNKNOWN}</span>
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
<span className="tabular-nums">
|
|
110
|
+
{b.targeting} {b.targeting === 1 ? 'backup' : 'backups'}
|
|
111
|
+
</span>
|
|
112
|
+
<Sub>
|
|
113
|
+
<span className="tabular-nums">{b.completedNotExpired}</span> completed · <span className="tabular-nums">{b.expired}</span> expired
|
|
114
|
+
</Sub>
|
|
115
|
+
<NotRestorable l={l} />
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function SchedulesCell({ l, onInspect }: { l: VeleroLocationReading; onInspect: VeleroScreenProps['onInspect'] }) {
|
|
121
|
+
const [showAll, setShowAll] = useState(false)
|
|
122
|
+
if (l.schedules === null) return <span className="text-theme-text-tertiary">{SCHEDULES_UNKNOWN}</span>
|
|
123
|
+
if (l.schedules.length === 0) return <span className="text-theme-text-tertiary">None</span>
|
|
124
|
+
const shown = showAll ? l.schedules : l.schedules.slice(0, SCHEDULES_SHOWN)
|
|
125
|
+
const hidden = l.schedules.length - shown.length
|
|
126
|
+
return (
|
|
127
|
+
<ul className="space-y-0.5">
|
|
128
|
+
{shown.map((s) => (
|
|
129
|
+
<li key={s.name}>
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
onClick={(e) => {
|
|
133
|
+
e.stopPropagation()
|
|
134
|
+
onInspect(veleroResource('Schedule', l.namespace, s.name))
|
|
135
|
+
}}
|
|
136
|
+
className="block max-w-full text-left text-accent-text hover:underline"
|
|
137
|
+
>
|
|
138
|
+
<VeleroName name={s.name} />
|
|
139
|
+
</button>
|
|
140
|
+
{s.viaDefault && (
|
|
141
|
+
<Tooltip content="The schedule names no location, so its backups go to the installation’s default.">
|
|
142
|
+
<span className="whitespace-nowrap text-xs text-theme-text-tertiary"> (as the default)</span>
|
|
143
|
+
</Tooltip>
|
|
144
|
+
)}
|
|
145
|
+
</li>
|
|
146
|
+
))}
|
|
147
|
+
{l.schedules.length > SCHEDULES_SHOWN && (
|
|
148
|
+
<li>
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
aria-expanded={showAll}
|
|
152
|
+
onClick={(e) => {
|
|
153
|
+
e.stopPropagation()
|
|
154
|
+
setShowAll((v) => !v)
|
|
155
|
+
}}
|
|
156
|
+
className="text-xs font-medium text-accent-text hover:underline"
|
|
157
|
+
>
|
|
158
|
+
{showAll ? 'Show fewer' : `and ${hidden} more`}
|
|
159
|
+
</button>
|
|
160
|
+
</li>
|
|
161
|
+
)}
|
|
162
|
+
</ul>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function VeleroLocations({ data, installation, onInstallation, onInspect, inspected }: VeleroScreenProps) {
|
|
167
|
+
const multi = data.installations.length > 1
|
|
168
|
+
const locations = useMemo(() => inInstallation(data.locations, installation), [data.locations, installation])
|
|
169
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
170
|
+
|
|
171
|
+
const columns: TableColumn<VeleroLocationReading>[] = [
|
|
172
|
+
{
|
|
173
|
+
header: 'Location',
|
|
174
|
+
width: wide ? '18%' : '22%',
|
|
175
|
+
cell: (l) => (
|
|
176
|
+
<>
|
|
177
|
+
<VeleroName name={l.name} />
|
|
178
|
+
<DefaultMark l={l} />
|
|
179
|
+
{multi && <Sub><WholeNames text={l.namespace} /></Sub>}
|
|
180
|
+
{(l.provider || l.bucket) && (
|
|
181
|
+
<Sub>
|
|
182
|
+
<WholeNames text={[l.provider, l.bucket].filter(Boolean).join(' · ')} />
|
|
183
|
+
</Sub>
|
|
184
|
+
)}
|
|
185
|
+
{l.accessMode === 'ReadOnly' && (
|
|
186
|
+
<Sub>
|
|
187
|
+
<Tooltip content="Velero restores from this location but writes no new backups to it.">
|
|
188
|
+
<span>read-only</span>
|
|
189
|
+
</Tooltip>
|
|
190
|
+
</Sub>
|
|
191
|
+
)}
|
|
192
|
+
</>
|
|
193
|
+
),
|
|
194
|
+
},
|
|
195
|
+
{ header: 'Availability', width: wide ? '14%' : '17%', cell: (l) => <AvailabilityCell l={l} /> },
|
|
196
|
+
{ header: 'Last validation', width: wide ? '15%' : '18%', cell: (l) => <ValidationCell l={l} /> },
|
|
197
|
+
// Narrow: the three counts share one column.
|
|
198
|
+
...(wide
|
|
199
|
+
? [
|
|
200
|
+
{ header: 'Backups', width: '10%', cell: (l: VeleroLocationReading) => <BackupCount l={l} count={(b) => b.targeting} /> },
|
|
201
|
+
{
|
|
202
|
+
header: (
|
|
203
|
+
<Tooltip content="Completed and not yet expired. Velero restores only from an available location.">
|
|
204
|
+
<span>Completed</span>
|
|
205
|
+
</Tooltip>
|
|
206
|
+
),
|
|
207
|
+
width: '10%',
|
|
208
|
+
cell: (l: VeleroLocationReading) => (
|
|
209
|
+
<>
|
|
210
|
+
<BackupCount l={l} count={(b) => b.completedNotExpired} />
|
|
211
|
+
<NotRestorable l={l} />
|
|
212
|
+
</>
|
|
213
|
+
),
|
|
214
|
+
},
|
|
215
|
+
{ header: 'Expired', width: '9%', cell: (l: VeleroLocationReading) => <BackupCount l={l} count={(b) => b.expired} /> },
|
|
216
|
+
]
|
|
217
|
+
: [{ header: 'Backups', width: '20%', cell: (l: VeleroLocationReading) => <BackupCountsCell l={l} /> }]),
|
|
218
|
+
{ header: wide ? 'Schedules writing here' : 'Schedules', width: wide ? '24%' : '23%', cell: (l) => <SchedulesCell l={l} onInspect={onInspect} /> },
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
223
|
+
<VeleroWorkspaceHeader title="Storage locations" data={data} installation={installation} onInstallation={onInstallation} />
|
|
224
|
+
<ScreenBody>
|
|
225
|
+
<VeleroCoverageNotice data={data} kinds={['backupStorageLocations', 'backups', 'schedules']} />
|
|
226
|
+
<SectionTable
|
|
227
|
+
subtitle={`${locations.length} ${locations.length === 1 ? 'location' : 'locations'}`}
|
|
228
|
+
columns={columns}
|
|
229
|
+
rows={locations}
|
|
230
|
+
rowKey={(l) => `${l.namespace}/${l.name}`}
|
|
231
|
+
rowResource={(l) => veleroResource('BackupStorageLocation', l.namespace, l.name)}
|
|
232
|
+
onInspect={onInspect}
|
|
233
|
+
inspected={inspected}
|
|
234
|
+
empty={coverageEmpty(data.coverage.backupStorageLocations, 'Velero storage locations')}
|
|
235
|
+
minWidth={wide ? 960 : 600}
|
|
236
|
+
/>
|
|
237
|
+
</ScreenBody>
|
|
238
|
+
</div>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import type { VeleroWorkspaceResponse } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { VELERO_NOTHING_IN_WHAT_WAS_READ, VELERO_NOTHING_NEEDS_ATTENTION, VeleroOverview, type VeleroNamespaceList } from './VeleroOverview'
|
|
6
|
+
import { VeleroSchedules } from './VeleroSchedules'
|
|
7
|
+
import { hoursAgo, location, schedule, workspace } from './velero.fixtures'
|
|
8
|
+
|
|
9
|
+
// The Overview and the Schedule kind's list read the same workspace data; a
|
|
10
|
+
// reader moves between them, so these checks cover what the two say together,
|
|
11
|
+
// the Overview first.
|
|
12
|
+
function render(data: VeleroWorkspaceResponse, installation: string | null = null) {
|
|
13
|
+
const props = { data, installation, onInstallation: () => {}, onInspect: () => {}, inspected: null }
|
|
14
|
+
return renderToStaticMarkup(
|
|
15
|
+
<MemoryRouter>
|
|
16
|
+
<VeleroOverview {...props} namespaces={undefined} />
|
|
17
|
+
<VeleroSchedules {...props} />
|
|
18
|
+
</MemoryRouter>,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function renderOverview(data: VeleroWorkspaceResponse, namespaces: VeleroNamespaceList = undefined) {
|
|
23
|
+
return renderToStaticMarkup(
|
|
24
|
+
<MemoryRouter>
|
|
25
|
+
<VeleroOverview data={data} installation={null} onInstallation={() => {}} onInspect={() => {}} inspected={null} namespaces={namespaces} />
|
|
26
|
+
</MemoryRouter>,
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// renderToStaticMarkup escapes apostrophes; compare against the text a reader sees.
|
|
31
|
+
const text = (html: string) => html.replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&')
|
|
32
|
+
|
|
33
|
+
describe('Velero overview', () => {
|
|
34
|
+
it('links the lists it summarises, from their labels and their values', () => {
|
|
35
|
+
const html = text(renderOverview(workspace()))
|
|
36
|
+
expect(html).toContain('Needs attention')
|
|
37
|
+
expect(html).toContain('>Schedules</button>')
|
|
38
|
+
expect(html).toContain('>Storage</button>')
|
|
39
|
+
expect(html).toMatch(/>Storage<\/button><\/span>:<\/dt><dd[^>]*><button[^>]*>1 of 1 location available/)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('shows each schedule’s protection below Needs attention, so a healthy installation has evidence', () => {
|
|
43
|
+
// Backup sync recreated this run's object: created 2h ago, expiring a day later, while the schedule keeps runs 30 days.
|
|
44
|
+
const run = { name: 'nightly-1', phase: 'Completed', created: hoursAgo(2), ranAt: hoursAgo(2), expiration: new Date(Date.parse(hoursAgo(2)) + 24 * 3_600_000).toISOString() }
|
|
45
|
+
const html = text(renderOverview(workspace({
|
|
46
|
+
schedules: [schedule({ ttl: '720h0m0s', runs: { read: 'full', kept: 1, newest: run, newestCompleted: run } }), schedule({ name: 'weekly', runs: { read: 'full', kept: 1, newest: run, newestCompleted: run } })],
|
|
47
|
+
locations: [location({ phase: 'Unavailable' })],
|
|
48
|
+
})))
|
|
49
|
+
const table = html.slice(html.indexOf('>Schedules</h2>'))
|
|
50
|
+
expect(html.indexOf('Needs attention')).toBeLessThan(html.indexOf('>Schedules</h2>'))
|
|
51
|
+
expect(table).toContain('nightly')
|
|
52
|
+
expect(table).toContain('On schedule')
|
|
53
|
+
expect(table).toContain('2h ago')
|
|
54
|
+
expect(table).toContain('unavailable')
|
|
55
|
+
expect(table).toContain('30 days')
|
|
56
|
+
expect(table).not.toContain('1 day')
|
|
57
|
+
// jsdom has no matchMedia: the narrow table says the retention under Stored in.
|
|
58
|
+
expect(table).toContain('kept for 30 days')
|
|
59
|
+
expect(table).toContain('kept for the server’s default')
|
|
60
|
+
expect(table).toContain('Next run')
|
|
61
|
+
expect(table).toMatch(/in 2[12]h/)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('says the server is running only when a replica is ready', () => {
|
|
65
|
+
const server = (replicas: number, readyReplicas?: number) =>
|
|
66
|
+
text(renderOverview(workspace({ installations: [{ namespace: 'velero', server: { source: 'deployment', replicas, readyReplicas }, defaultSource: 'spec' }] })))
|
|
67
|
+
expect(server(1, 1)).toMatch(/Velero server:<\/dt><dd[^>]*>running/)
|
|
68
|
+
expect(server(1, 0)).toMatch(/Velero server:<\/dt><dd[^>]*>not ready/)
|
|
69
|
+
expect(server(1)).toMatch(/Velero server:<\/dt><dd[^>]*>not ready/)
|
|
70
|
+
expect(server(0)).toMatch(/Velero server:<\/dt><dd[^>]*>not running/)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('leads an issue it recognises with a plain reason, Velero’s text folded under it', () => {
|
|
74
|
+
const html = text(renderOverview(workspace({
|
|
75
|
+
issues: [{ id: 'i1', severity: 'critical', category: 'location', kind: 'BackupStorageLocation', group: 'velero.io', namespace: 'velero', name: 'dr', reason: 'BackupStorageLocationUnavailable', message: 'BackupStorageLocation "dr" is unavailable: rpc error: code = Unknown desc = NoSuchBucket: The specified bucket does not exist' }],
|
|
76
|
+
})))
|
|
77
|
+
expect(html).toContain('The bucket doesn’t exist.')
|
|
78
|
+
expect(html).toContain('Velero’s message')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('lists late, probably-late and cannot-run schedules under Needs attention, each with its reason', () => {
|
|
82
|
+
const html = text(render(workspace({
|
|
83
|
+
schedules: [
|
|
84
|
+
schedule({ name: 'hourly', state: 'late', attention: true, lastSubmitted: hoursAgo(4), missedRuns: 3 }),
|
|
85
|
+
schedule({ name: 'offset', state: 'probablyLate', reason: 'zoneUnconfirmed', attention: true, nextRunCertain: false, zone: { name: 'UTC', source: 'unknown' } }),
|
|
86
|
+
schedule({ name: `a-${'x'.repeat(70)}`, state: 'cannotRun', reason: 'nameTooLong', attention: true }),
|
|
87
|
+
schedule({ name: 'quiet', state: 'possiblyLate', reason: 'zoneUnconfirmed', attention: false }),
|
|
88
|
+
],
|
|
89
|
+
})))
|
|
90
|
+
const attention = html.slice(html.indexOf('Needs attention'), html.indexOf('>Schedules</h2>'))
|
|
91
|
+
expect(attention).toContain('3 scheduled times passed. Velero does not catch up on missed runs.')
|
|
92
|
+
expect(attention).toContain('No backup submitted since')
|
|
93
|
+
expect(attention).toContain('Looks late, but Radar couldn’t confirm the Velero server’s time zone.')
|
|
94
|
+
expect(attention).toContain('This schedule’s name is longer than 63 characters, too long for the label Velero puts on its backups, so Velero submits no runs.')
|
|
95
|
+
// possiblyLate stays in the table, not in Needs attention.
|
|
96
|
+
expect(attention).not.toContain('quiet')
|
|
97
|
+
expect(attention).not.toContain(VELERO_NOTHING_NEEDS_ATTENTION)
|
|
98
|
+
// The table marks an estimated next run.
|
|
99
|
+
expect(html).toContain('~in ')
|
|
100
|
+
// Radar never calls a backup restorable, so no disclaimer repeats under every table.
|
|
101
|
+
expect(html).not.toContain('It is not a test of a restore.')
|
|
102
|
+
// The rows say what's wrong, not where Radar found it.
|
|
103
|
+
expect(html).not.toContain('Radar’s reading of')
|
|
104
|
+
expect(html).not.toContain('Detected by Radar')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('reads runs Radar could not read as unknown, never as none', () => {
|
|
108
|
+
const html = text(render(workspace({
|
|
109
|
+
coverage: { schedules: { state: 'full' }, backups: { state: 'denied' }, backupStorageLocations: { state: 'full' }, restores: { state: 'full' }, backupRepositories: { state: 'full' } },
|
|
110
|
+
schedules: [schedule({ runs: { read: 'unknown', kept: 0 } })],
|
|
111
|
+
})))
|
|
112
|
+
expect(html).toContain('Unknown — backups were not read')
|
|
113
|
+
expect(html).not.toContain('None among the backups Velero still keeps')
|
|
114
|
+
expect(html).toContain('Radar couldn’t read some of the Velero data on this screen')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('says what was read when nothing needs attention, and never calls it healthy', () => {
|
|
118
|
+
const html = text(render(workspace({ schedules: [schedule({ runs: { read: 'full', kept: 0 } })] })))
|
|
119
|
+
expect(html).toContain(VELERO_NOTHING_NEEDS_ATTENTION)
|
|
120
|
+
expect(html).toContain('None kept')
|
|
121
|
+
expect(html.toLowerCase()).not.toContain('all healthy')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('groups what needs attention by what it is about, and folds a long group', () => {
|
|
125
|
+
const issues = Array.from({ length: 10 }, (_, i) => ({
|
|
126
|
+
id: `i${i}`, severity: 'critical' as const, category: 'backup', kind: 'Backup', group: 'velero.io', namespace: 'velero', name: `run-${i}`, reason: 'BackupFailed', message: 'boom',
|
|
127
|
+
}))
|
|
128
|
+
const late = schedule({ name: 'late-one', state: 'late', attention: true, missedRuns: 2 })
|
|
129
|
+
const html = text(render(workspace({ issues, schedules: [late] })))
|
|
130
|
+
expect(html.indexOf('late-one')).toBeLessThan(html.indexOf('run-0'))
|
|
131
|
+
expect(html.indexOf('Schedules <span')).toBeLessThan(html.indexOf('Backups and restores'))
|
|
132
|
+
// One schedule row, then the rest of an eight-row budget for the runs.
|
|
133
|
+
expect(html).toContain('Show 3 more')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('answers "is Velero working?" in one line before the detail', () => {
|
|
137
|
+
const late = schedule({ name: 'late-one', state: 'late', attention: true, missedRuns: 2, reason: 'serverDown' })
|
|
138
|
+
const html = text(render(workspace({
|
|
139
|
+
schedules: [late, schedule({ name: 'ok', runs: { read: 'full', kept: 1, newestCompleted: { name: 'ok-1', phase: 'Completed', created: hoursAgo(3), ranAt: hoursAgo(3) } } })],
|
|
140
|
+
installations: [{ namespace: 'velero', server: { source: 'deployment', deployment: 'velero', replicas: 0 }, defaultSource: 'spec' }],
|
|
141
|
+
locations: [location(), location({ name: 'dr', phase: 'Unavailable' })],
|
|
142
|
+
})))
|
|
143
|
+
expect(html).toContain('Velero server:</dt><dd class="font-medium text-theme-text-primary">not running')
|
|
144
|
+
expect(html).toContain('1 of 2 need attention')
|
|
145
|
+
expect(html).toContain('2h ago')
|
|
146
|
+
expect(html).toContain('1 of 2 locations available')
|
|
147
|
+
expect(html.indexOf('Velero at a glance')).toBeLessThan(html.indexOf('Needs attention'))
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('never reads unread kinds as none in the headline', () => {
|
|
151
|
+
const denied = { state: 'denied' as const }
|
|
152
|
+
const full = { state: 'full' as const }
|
|
153
|
+
const html = text(render(workspace({
|
|
154
|
+
coverage: { schedules: denied, backups: full, backupStorageLocations: denied, restores: full, backupRepositories: full },
|
|
155
|
+
schedules: [],
|
|
156
|
+
locations: [],
|
|
157
|
+
})))
|
|
158
|
+
expect(html).toMatch(/>Schedules<\/button><\/span>:<\/dt><dd[^>]*><button[^>]*>unknown — not read/)
|
|
159
|
+
expect(html).toMatch(/>Storage<\/button><\/span>:<\/dt><dd[^>]*><button[^>]*>unknown — not read/)
|
|
160
|
+
expect(html).not.toContain('no locations')
|
|
161
|
+
expect(html).not.toContain('no schedules')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('keeps every group visible but holds the whole list to eight rows', () => {
|
|
165
|
+
const issues = Array.from({ length: 10 }, (_, i) => ({
|
|
166
|
+
id: `i${i}`, severity: 'critical' as const, category: 'backup', kind: 'Backup', group: 'velero.io', namespace: 'velero', name: `run-${i}`, reason: 'BackupFailed', message: 'boom',
|
|
167
|
+
}))
|
|
168
|
+
const late = Array.from({ length: 9 }, (_, i) => schedule({ name: `late-${i}`, state: 'late', attention: true, missedRuns: 2 }))
|
|
169
|
+
const html = text(render(workspace({ issues, schedules: late })))
|
|
170
|
+
// The schedules take the budget; the runs group still shows its first row.
|
|
171
|
+
expect(html).toContain('run-0')
|
|
172
|
+
expect(html).toContain('Show 1 more')
|
|
173
|
+
expect(html).toContain('Show 9 more')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('does not call a schedule fine when Radar cannot read its cron', () => {
|
|
177
|
+
const html = text(render(workspace({ schedules: [schedule({ state: 'unknown', attention: false })] })))
|
|
178
|
+
expect(html).toContain('1, 1 with a cron Radar can’t read')
|
|
179
|
+
expect(html).not.toContain('none need attention')
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('never reads unread backups as no successful backup', () => {
|
|
183
|
+
const html = text(render(workspace({ schedules: [schedule({ runs: { read: 'unknown', kept: 0 } })] })))
|
|
184
|
+
expect(html).toContain('unknown — backups were not read')
|
|
185
|
+
expect(html).not.toContain('none kept</dd>')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('names a stopped Velero server first, and as the cause of late schedules', () => {
|
|
189
|
+
const late = schedule({ name: 'late-one', state: 'late', attention: true, missedRuns: 2, reason: 'serverDown' })
|
|
190
|
+
const html = text(render(workspace({
|
|
191
|
+
schedules: [late],
|
|
192
|
+
installations: [{ namespace: 'velero', server: { source: 'deployment', deployment: 'velero', replicas: 0 }, defaultSource: 'spec' }],
|
|
193
|
+
})))
|
|
194
|
+
expect(html).toContain('Velero server not running')
|
|
195
|
+
expect(html.indexOf('Velero server not running')).toBeLessThan(html.indexOf('late-one'))
|
|
196
|
+
// Named once, in its own row: the late schedule below it doesn't repeat the cause.
|
|
197
|
+
expect(html).not.toContain('The Velero server has no pods, so nothing submits backups.')
|
|
198
|
+
expect(html).not.toContain('Deployment velero in velero')
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('reads a schedule due within its grace as on schedule, not as a problem', () => {
|
|
202
|
+
const html = text(render(workspace({ schedules: [schedule({ state: 'due', nextRun: new Date(Date.now() - 30_000).toISOString() })] })))
|
|
203
|
+
const list = html.slice(html.indexOf('>Schedules</h1>'))
|
|
204
|
+
expect(list).toContain('On schedule')
|
|
205
|
+
expect(list).toContain('due now')
|
|
206
|
+
expect(list).not.toContain('>Due<')
|
|
207
|
+
expect(list).not.toContain('was due')
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('says a schedule’s last run failed instead of a green state, with that run in the merged Last run cell', () => {
|
|
211
|
+
const failed = { name: 'nightly-2', phase: 'Failed', created: hoursAgo(1), ranAt: hoursAgo(1) }
|
|
212
|
+
const ok = { name: 'nightly-1', phase: 'Completed', created: hoursAgo(25), ranAt: hoursAgo(25) }
|
|
213
|
+
const html = text(render(workspace({ schedules: [schedule({ runs: { read: 'full', kept: 2, newest: failed, newestCompleted: ok } })] })))
|
|
214
|
+
const list = html.slice(html.indexOf('>Schedules</h1>'))
|
|
215
|
+
expect(list).toContain('Last run failed')
|
|
216
|
+
expect(list).not.toContain('On schedule')
|
|
217
|
+
expect(list).toContain('>Last run<')
|
|
218
|
+
expect(list).not.toContain('Last submission')
|
|
219
|
+
expect(list).toContain('last success 1d ago')
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('keeps a healthy schedule out of green when Radar has not confirmed its zone', () => {
|
|
223
|
+
const html = text(render(workspace({ schedules: [schedule({ zone: { name: 'UTC+02:00', source: 'inferred' } })] })))
|
|
224
|
+
const list = html.slice(html.indexOf('>Schedules</h1>'))
|
|
225
|
+
expect(list).toMatch(/<span class="badge-sm [^"]*text-theme-text-secondary[^"]*">On schedule/)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('says a next run in the past was due, not that it ran', () => {
|
|
229
|
+
const html = text(render(workspace({ schedules: [schedule({ state: 'late', attention: true, nextRun: new Date(Date.now() - 3 * 3_600_000).toISOString() })] })))
|
|
230
|
+
expect(html).toContain('was due 3h ago')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
it('says how many issues were left out when an installation was capped', () => {
|
|
234
|
+
const issues = Array.from({ length: 50 }, (_, i) => ({
|
|
235
|
+
id: `i${i}`, severity: 'critical' as const, category: 'backup', kind: 'Backup', group: 'velero.io', namespace: 'velero', name: `run-${i}`, reason: 'BackupFailed', message: 'boom',
|
|
236
|
+
}))
|
|
237
|
+
const html = text(render(workspace({ issues, issueTotals: { velero: 120 } })))
|
|
238
|
+
expect(html).toContain('Showing 50 of 120 issues in velero, the newest.')
|
|
239
|
+
expect(html).not.toContain(VELERO_NOTHING_NEEDS_ATTENTION)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('narrows to one installation and names namespaces only when there is more than one', () => {
|
|
243
|
+
const data = workspace({
|
|
244
|
+
installations: [
|
|
245
|
+
{ namespace: 'velero', server: { source: 'deployment' }, defaultSource: 'spec' },
|
|
246
|
+
{ namespace: 'velero-dr', server: { source: 'unread' }, defaultSource: 'unknown' },
|
|
247
|
+
],
|
|
248
|
+
schedules: [schedule(), schedule({ namespace: 'velero-dr', name: 'dr-daily' })],
|
|
249
|
+
locations: [location(), location({ namespace: 'velero-dr', name: 'dr' })],
|
|
250
|
+
})
|
|
251
|
+
const all = text(render(data))
|
|
252
|
+
expect(all).toContain('All installations')
|
|
253
|
+
expect(all).toContain('dr-daily')
|
|
254
|
+
const one = text(render(data, 'velero'))
|
|
255
|
+
expect(one).not.toContain('dr-daily')
|
|
256
|
+
expect(one).toContain('nightly')
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it('says nothing about scope for one installation, names a forced namespace, and offers installations when there are several', () => {
|
|
260
|
+
expect(text(render(workspace()))).not.toMatch(/namespace filter|Velero in namespace/)
|
|
261
|
+
expect(text(render(workspace({ forcedNamespace: 'velero' })))).toContain('Radar is limited to namespace velero')
|
|
262
|
+
const two = workspace()
|
|
263
|
+
two.installations = [two.installations[0], { ...two.installations[0], namespace: 'kommander' }]
|
|
264
|
+
expect(text(render(two))).toContain('kommander')
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
describe('Velero overview coverage', () => {
|
|
269
|
+
const two = (overrides = {}) => workspace({ schedules: [schedule({ includedNamespaces: ['shop'] }), schedule({ name: 'weekly', state: 'paused', includedNamespaces: ['db-*'] })], ...overrides })
|
|
270
|
+
|
|
271
|
+
it('names the namespaces no schedule selects, leaving out Kubernetes’ own and Velero’s', () => {
|
|
272
|
+
const html = text(renderOverview(two(), ['shop', 'db-main', 'web', 'kube-system', 'velero']))
|
|
273
|
+
expect(html).toMatch(/Namespaces not in any schedule<\/span><\/span>:<\/span> <span[^>]*>web</)
|
|
274
|
+
expect(html).not.toMatch(/not in any schedule.*kube-system/)
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
it('says none when every namespace is in a schedule, and unknown when the schedules were read in part', () => {
|
|
278
|
+
expect(text(renderOverview(two(), ['shop', 'db-main']))).toMatch(/Namespaces not in any schedule<\/span><\/span>:<\/span> <span[^>]*>none</)
|
|
279
|
+
const partial = two({ coverage: { ...workspace().coverage, schedules: { state: 'partial' } } })
|
|
280
|
+
expect(text(renderOverview(partial, ['shop']))).toContain('unknown, Radar can’t read every schedule')
|
|
281
|
+
expect(text(renderOverview(two(), 'error'))).toContain('unknown, Radar couldn’t list namespaces')
|
|
282
|
+
expect(text(renderOverview(two(), []))).toContain('unknown, Radar listed no namespaces')
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('says a schedule whose namespace selection Velero refuses selects nothing', () => {
|
|
286
|
+
const data = workspace({ schedules: [schedule({ name: 'mixed', includedNamespaces: ['*', 'payments'] }), schedule({ name: 'fine', includedNamespaces: ['shop'] })] })
|
|
287
|
+
const html = text(renderOverview(data, ['shop', 'payments']))
|
|
288
|
+
expect(html).toMatch(/Selects nothing:<\/span> <span[^>]*><span><button[^>]*>mixed<\/button>: it includes “\*” beside other namespaces<\/span> — Velero refuses this namespace selection, so it backs up nothing/)
|
|
289
|
+
expect(html).toMatch(/Namespaces not in any schedule<\/span><\/span>:<\/span> <span[^>]*>payments</)
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
it('marks the newest successful backup when Back up now made it', () => {
|
|
293
|
+
const manual = { name: 'nightly-2', phase: 'Completed', created: hoursAgo(1), ranAt: hoursAgo(1), completed: hoursAgo(1), manual: true }
|
|
294
|
+
const data = workspace({ schedules: [schedule({ runs: { read: 'full', kept: 2, newest: manual, newestCompleted: manual } })] })
|
|
295
|
+
expect(text(renderOverview(data, ['shop']))).toMatch(/1h ago(<!-- -->)?, (<!-- -->)?manual/)
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('does not say nothing needs attention while the server Deployment is unread', () => {
|
|
299
|
+
const unread = workspace({ installations: [{ ...workspace().installations[0], server: { source: 'unread' } }] })
|
|
300
|
+
const html = text(renderOverview(unread, ['shop']))
|
|
301
|
+
expect(html).toContain(VELERO_NOTHING_IN_WHAT_WAS_READ)
|
|
302
|
+
expect(html).not.toContain(VELERO_NOTHING_NEEDS_ATTENTION)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('lists paused schedules as information, outside Needs attention', () => {
|
|
306
|
+
const html = text(renderOverview(two(), ['shop']))
|
|
307
|
+
expect(html).toMatch(/Paused:<\/span> <span[^>]*><span><button[^>]*>weekly<\/button><\/span> — no backups until it is resumed/)
|
|
308
|
+
expect(html).toContain(VELERO_NOTHING_NEEDS_ATTENTION)
|
|
309
|
+
expect(html).toContain('2, 1 paused, none need attention')
|
|
310
|
+
})
|
|
311
|
+
})
|