@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,122 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Badge, Collapse, TimeValue, formatBytes, pluralize } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useVeleroRunVolumes, useVeleroVolumeOperations, isVeleroRunFinished, type VeleroVolumeRecord, type VeleroVolumeDetails, type VeleroVolumeOperation } from '../../api/velero'
|
|
4
|
+
import { Notice, SectionTable } from '../workspace/layout'
|
|
5
|
+
import { ArtifactError } from './VeleroRunArtifacts'
|
|
6
|
+
|
|
7
|
+
function volumeMethod(row: VeleroVolumeRecord, restore: boolean) {
|
|
8
|
+
switch (row.method) {
|
|
9
|
+
case 'NativeSnapshot': return 'Native snapshot'
|
|
10
|
+
case 'CSISnapshot': return row.snapshotDataMoved ? `CSI snapshot · Copy ${restore ? 'from' : 'to'} the bucket (data mover)` : 'CSI snapshot'
|
|
11
|
+
case 'PodVolumeBackup': return 'File-system backup'
|
|
12
|
+
case 'PodVolumeRestore': return 'File-system restore'
|
|
13
|
+
default: return row.method || (row.skipped ? 'None (skipped)' : 'Not recorded')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const resultLabels = new Map([['succeeded', 'Succeeded'], ['failed', 'Failed']])
|
|
18
|
+
|
|
19
|
+
function VolumeDetails({ label, info }: { label: string; info?: VeleroVolumeDetails }) {
|
|
20
|
+
if (!info) return null
|
|
21
|
+
const fields = [
|
|
22
|
+
['Snapshot', info.snapshotHandle], ['Driver', info.driver], ['Snapshot content', info.vscName],
|
|
23
|
+
['Operation', info.operationID], ['Data mover', info.dataMover], ['Uploader', info.uploaderType],
|
|
24
|
+
['Source snapshot', info.retainedSnapshot], ['Volume group snapshot', info.volumeGroupSnapshotHandle],
|
|
25
|
+
['Volume type', info.volumeType], ['Zone', info.volumeAZ], ['IOPS', info.iops], ['Phase', info.phase],
|
|
26
|
+
['Pod', info.podName ? `${info.podNamespace ? info.podNamespace + '/' : ''}${info.podName}` : undefined],
|
|
27
|
+
['Volume', info.volumeName], ['Node', info.nodeName],
|
|
28
|
+
['Snapshot ready', info.readyToUse === undefined ? undefined : info.readyToUse ? 'Yes' : 'No'],
|
|
29
|
+
['Size', info.size === undefined || info.size === 0 ? undefined : formatBytes(info.size)],
|
|
30
|
+
['Incremental size', info.incrementalSize === undefined ? undefined : formatBytes(info.incrementalSize)],
|
|
31
|
+
].filter(([, value]) => value !== undefined && value !== '')
|
|
32
|
+
return <div className="space-y-1 text-xs text-theme-text-secondary"><div className="font-medium">{label}</div>{fields.map(([key, value]) => <div key={key} className="break-all">{key}: {value}</div>)}</div>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function OperationGroup({ phase, rows }: { phase: string; rows: VeleroVolumeOperation[] }) {
|
|
36
|
+
const [all, setAll] = useState(false)
|
|
37
|
+
const table = (items: VeleroVolumeOperation[]) => <SectionTable
|
|
38
|
+
minWidth={820}
|
|
39
|
+
columns={[
|
|
40
|
+
{ header: 'Operation', cell: (row) => <div className="break-all"><Badge kind={row.kind}>{row.kind}</Badge><div className="mt-1 font-mono text-xs">{row.name}</div></div> },
|
|
41
|
+
{ header: 'Volume', cell: (row) => <div className="break-all">{row.pvc ? `PVC ${row.pvcNamespace ? row.pvcNamespace + '/' : ''}${row.pvc}` : row.pod ? `${row.podNamespace ? row.podNamespace + '/' : ''}${row.pod} · ${row.volume || 'Volume not recorded'}` : 'Not recorded'}</div> },
|
|
42
|
+
{ header: 'Progress', cell: (row) => <div className="space-y-1"><div>{row.bytesDone === undefined ? 'Unknown' : formatBytes(row.bytesDone)} / {row.bytesTotal === undefined ? 'Unknown' : formatBytes(row.bytesTotal)}</div>{row.bytesDone !== undefined && row.bytesTotal !== undefined && row.bytesTotal > 0 && <progress className="w-full accent-accent" aria-label={`${row.name} bytes`} value={row.bytesDone} max={row.bytesTotal} />}</div> },
|
|
43
|
+
{ header: 'Node', cell: (row) => <div className="break-all">{row.node || 'Not recorded'}{row.longRunning && <div className="mt-1 text-xs text-theme-text-secondary">Over 10 min · {row.nodeAgent === 'running' ? 'Node-agent pod phase: Running on this node' : row.nodeAgent === 'notRunning' ? 'No Running node-agent pod found on this node' : 'Node-agent status unknown'}</div>}</div> },
|
|
44
|
+
{ header: 'Status', cell: (row) => <div className="space-y-1 break-words">{row.message && <div>{row.message}</div>}<div>Started: {row.started ? <TimeValue timestamp={row.started} /> : 'Not recorded'}</div><div>Finished: {row.completed ? <TimeValue timestamp={row.completed} /> : 'Not recorded'}</div></div> },
|
|
45
|
+
]}
|
|
46
|
+
rows={items}
|
|
47
|
+
rowKey={(row) => `${row.kind}/${row.name}`}
|
|
48
|
+
empty="No operations."
|
|
49
|
+
/>
|
|
50
|
+
return <section className="space-y-2">
|
|
51
|
+
<h3 className="text-sm font-semibold text-theme-text-primary"><Badge severity={phase === 'Failed' ? 'error' : phase === 'Completed' ? 'success' : 'neutral'}>{phase}</Badge> · {rows.length}</h3>
|
|
52
|
+
{table(rows.slice(0, 10))}
|
|
53
|
+
{rows.length > 10 && <>
|
|
54
|
+
<button type="button" aria-expanded={all} className="btn-secondary px-3 py-1.5 text-sm" onClick={() => setAll(!all)}>{all ? 'Show first 10' : `Show all ${rows.length}`}</button>
|
|
55
|
+
<Collapse open={all} mountLazily>{table(rows.slice(10))}</Collapse>
|
|
56
|
+
</>}
|
|
57
|
+
</section>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const phaseOrder = ['Failed', 'Canceling', 'Canceled', 'InProgress', 'Prepared', 'Accepted', 'New', 'Completed']
|
|
61
|
+
const operationNames: Record<string, string> = { podVolumeBackups: 'Pod volume backups', podVolumeRestores: 'Pod volume restores', dataUploads: 'Data uploads', dataDownloads: 'Data downloads' }
|
|
62
|
+
const coverageText: Record<string, string> = {
|
|
63
|
+
partial: 'Only part of this kind could be read.', denied: 'Access denied.', notInstalled: 'Not available now; this kind is not served by the cluster.',
|
|
64
|
+
syncing: 'Still loading; try refreshing.', uncached: 'Not collected by Radar in this namespace.', error: 'Could not read this kind; try refreshing.',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function VeleroRunVolumes({ kind, namespace, name }: { kind: 'backups' | 'restores'; namespace: string; name: string }) {
|
|
68
|
+
const record = useVeleroRunVolumes(kind, namespace, name)
|
|
69
|
+
const live = useVeleroVolumeOperations(kind, namespace, name)
|
|
70
|
+
const restore = kind === 'restores'
|
|
71
|
+
const data = record.data
|
|
72
|
+
const operations = live.data?.operations ?? []
|
|
73
|
+
const phases = [...new Set(operations.map((row) => row.phase || 'Not recorded'))].sort((a, b) => {
|
|
74
|
+
const rank = (p: string) => phaseOrder.includes(p) ? phaseOrder.indexOf(p) : phaseOrder.length
|
|
75
|
+
return rank(a) - rank(b) || a.localeCompare(b)
|
|
76
|
+
})
|
|
77
|
+
const inFlight = live.data && !isVeleroRunFinished(live.data.runPhase)
|
|
78
|
+
// The server says whether the run had finished when it read the record, so
|
|
79
|
+
// a record read mid-finalization stays provisional however soon the run
|
|
80
|
+
// completes.
|
|
81
|
+
// The record's own read decides whether it is final; the operations read
|
|
82
|
+
// (which can be older) only chooses the wording.
|
|
83
|
+
const finalRecord = !!data?.finishedAtRead
|
|
84
|
+
const readBeforeCompletion = !!data && !finalRecord && !inFlight
|
|
85
|
+
const coverage = Object.entries(live.data?.coverage ?? {})
|
|
86
|
+
const complete = coverage.length > 0 && coverage.every(([, value]) => value.state === 'full')
|
|
87
|
+
const recordedNone = data?.total === 0
|
|
88
|
+
return <div className="space-y-5 p-4">
|
|
89
|
+
<section className="space-y-3">
|
|
90
|
+
<div className="flex items-center justify-between gap-2"><h2 className="text-sm font-semibold text-theme-text-primary">Recorded volumes</h2><button type="button" className="btn-secondary px-3 py-1.5 text-sm" onClick={() => void record.refetch()}>Refresh record</button></div>
|
|
91
|
+
<p className="text-sm text-theme-text-secondary">{restore ? 'How each volume was to be restored. Velero writes this record before plugin operations finish; it does not record a restore result.' : 'How Velero protected each volume, as recorded with this backup. A reported success does not verify that it can be restored.'}</p>
|
|
92
|
+
{inFlight && !finalRecord && <Notice>This run is still in progress. Velero may write or update its volume record later. The volume record does not update with live operations. If this run has finished since you opened or refreshed this tab, refresh the record for final results.</Notice>}
|
|
93
|
+
{readBeforeCompletion && <Notice>{live.data ? 'The volume record was read before this run finished, and Velero may have updated it since.' : 'The volume record was read while this run was in progress, and Velero may update it.'} Refresh the record for final results.</Notice>}
|
|
94
|
+
{record.dataUpdatedAt > 0 && <p className="text-xs text-theme-text-tertiary">Record read: <TimeValue timestamp={new Date(record.dataUpdatedAt).toISOString()} /></p>}
|
|
95
|
+
{record.error && <ArtifactError label="Velero run volumes" error={record.error} hasData={!!data} retry={() => void record.refetch()} />}
|
|
96
|
+
{record.isPending && <p className="text-sm text-theme-text-secondary">Loading volume record…</p>}
|
|
97
|
+
{data?.truncated && <Notice>Showing the first 5,000 of {data.total} recorded volumes.</Notice>}
|
|
98
|
+
{recordedNone && <p className="text-sm text-theme-text-secondary">Velero recorded no volumes for this run.</p>}
|
|
99
|
+
{data && !recordedNone && <SectionTable
|
|
100
|
+
title={pluralize(data.total, 'recorded volume')}
|
|
101
|
+
minWidth={760}
|
|
102
|
+
columns={[
|
|
103
|
+
{ header: 'Volume', cell: (row) => <div className="space-y-1 break-all">{row.pvcName && <div>PVC {row.pvcNamespace ? row.pvcNamespace + '/' : ''}{row.pvcName}</div>}{row.pvName && <div className="text-xs text-theme-text-secondary">PV {row.pvName}</div>}{!row.pvcName && !row.pvName && <div>{row.podVolumeInfo?.podName ? `${row.podVolumeInfo.podNamespace || ''}/${row.podVolumeInfo.podName} · ${row.podVolumeInfo.volumeName || 'Volume not recorded'}` : 'Not recorded'}</div>}</div> },
|
|
104
|
+
{ header: 'Method', cell: (row) => <div className="space-y-1">{volumeMethod(row, restore)}{row.method === 'CSISnapshot' && row.preserveLocalSnapshot !== undefined && <div className="text-xs text-theme-text-secondary">Local snapshot retained: {row.preserveLocalSnapshot ? 'Yes' : 'No'}</div>}</div> },
|
|
105
|
+
...(!restore ? [{ header: 'Result', cell: (row: VeleroVolumeRecord) => <div className="space-y-1">{row.skipped ? <><Badge severity="neutral">Skipped</Badge><div>{row.skippedReason || 'Reason not recorded'}</div></> : row.result ? <Badge severity={row.result === 'failed' ? 'error' : row.result === 'succeeded' ? 'success' : 'neutral'}>{resultLabels.get(row.result) ?? row.result}</Badge> : 'Not recorded'}</div> }] : []),
|
|
106
|
+
{ header: 'Recorded details', cell: (row) => <div className="space-y-2"><VolumeDetails label="Native snapshot" info={row.nativeSnapshotInfo} /><VolumeDetails label="CSI snapshot" info={row.csiSnapshotInfo} /><VolumeDetails label="Data mover" info={row.snapshotDataMovementInfo} /><VolumeDetails label="File-system copy" info={row.podVolumeInfo} />{!row.nativeSnapshotInfo && !row.csiSnapshotInfo && !row.snapshotDataMovementInfo && !row.podVolumeInfo && 'Not recorded'}</div> },
|
|
107
|
+
]}
|
|
108
|
+
rows={data.volumes.map((row, index) => ({ ...row, index }))}
|
|
109
|
+
rowKey={(row) => String(row.index)}
|
|
110
|
+
empty="Velero recorded no volumes in this file."
|
|
111
|
+
/>}
|
|
112
|
+
</section>
|
|
113
|
+
<section className="space-y-3">
|
|
114
|
+
<div className="flex items-center justify-between gap-2"><h2 className="text-sm font-semibold text-theme-text-primary">Current volume operations</h2><button type="button" className="btn-secondary px-3 py-1.5 text-sm" onClick={() => void live.refetch()}>Refresh operations</button></div>
|
|
115
|
+
{live.error && <ArtifactError label="Velero run volumes" error={live.error} hasData={!!live.data} retry={() => void live.refetch()} />}
|
|
116
|
+
{live.isPending && <p className="text-sm text-theme-text-secondary">Loading volume operations…</p>}
|
|
117
|
+
{coverage.filter(([, value]) => value.state !== 'full').map(([key, value]) => <Notice key={key}>{operationNames[key] || key}: {coverageText[value.state] || 'Coverage unknown' } No conclusion about this run’s volume method can be drawn from missing operations.</Notice>)}
|
|
118
|
+
{live.data && operations.length === 0 && !(complete && recordedNone) && <Notice>{complete ? (inFlight ? 'No volume operation objects found yet for this run.' : 'No current volume operation objects found. They may have been removed; use the recorded volumes above for this run’s history.') : 'No readable volume operations found. Unavailable kinds do not mean this run used none.'}</Notice>}
|
|
119
|
+
{phases.map((phase) => <OperationGroup key={phase} phase={phase} rows={operations.filter((row) => (row.phase || 'Not recorded') === phase)} />)}
|
|
120
|
+
</section>
|
|
121
|
+
</div>
|
|
122
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { evaluateGitOpsWriteGuard, type GitOpsWriteGuardInput, type VeleroResumeChoices } from '@skyhook-io/k8s-ui'
|
|
6
|
+
|
|
7
|
+
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
8
|
+
|
|
9
|
+
const target = { kind: 'Schedule', group: 'velero.io', namespace: 'velero', name: 'nightly' }
|
|
10
|
+
const argoSelfHeal: Partial<GitOpsWriteGuardInput> = {
|
|
11
|
+
owner: { tool: 'argocd', kind: 'applications', namespace: 'argocd', name: 'backups' },
|
|
12
|
+
evidence: {
|
|
13
|
+
uid: 'u',
|
|
14
|
+
resourceVersion: '42',
|
|
15
|
+
owner: null,
|
|
16
|
+
policy: { tool: 'argocd', auto: true, selfHeal: true, prune: false, suspended: null },
|
|
17
|
+
paths: [
|
|
18
|
+
{ path: 'spec.paused', lastApplied: 'present', ownedBy: [], ownedByGitOps: false },
|
|
19
|
+
{ path: 'spec.skipImmediately', lastApplied: 'absent', ownedBy: [], ownedByGitOps: false },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const state = vi.hoisted(() => ({
|
|
25
|
+
support: 'supported',
|
|
26
|
+
mutate: vi.fn(),
|
|
27
|
+
error: null as Error | null,
|
|
28
|
+
resume: undefined as unknown,
|
|
29
|
+
serverStopped: false,
|
|
30
|
+
backupsDisabled: false,
|
|
31
|
+
guardInput: {} as Record<string, unknown>,
|
|
32
|
+
toast: vi.fn(),
|
|
33
|
+
refetch: vi.fn(),
|
|
34
|
+
updatedAt: 1,
|
|
35
|
+
}))
|
|
36
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: state.support }) }))
|
|
37
|
+
vi.mock('../../api/velero', () => ({
|
|
38
|
+
useVeleroSchedulePause: () => ({ mutate: state.mutate, isPending: false, error: state.error }),
|
|
39
|
+
useVeleroScheduleActivity: () => ({ data: { resume: state.resume, serverStopped: state.serverStopped, backupsDisabled: state.backupsDisabled }, refetch: state.refetch, isPending: false, dataUpdatedAt: state.updatedAt }),
|
|
40
|
+
}))
|
|
41
|
+
vi.mock('../../hooks/useGitOpsWriteGuard', () => ({
|
|
42
|
+
useGitOpsWriteGuard: ({ writes }: { writes: GitOpsWriteGuardInput['writes'] }) => ({
|
|
43
|
+
guard: evaluateGitOpsWriteGuard({ target, owner: null, writes, ...state.guardInput }),
|
|
44
|
+
}),
|
|
45
|
+
}))
|
|
46
|
+
vi.mock('../workspace/useWorkspaceNavigate', () => ({ useWorkspaceNavigate: () => vi.fn() }))
|
|
47
|
+
vi.mock('../ui/Toast', () => ({ showApiSuccess: state.toast }))
|
|
48
|
+
|
|
49
|
+
const { VeleroSchedulePause } = await import('./VeleroSchedulePause')
|
|
50
|
+
|
|
51
|
+
const active = { metadata: { namespace: 'velero', name: 'nightly', resourceVersion: '42' }, spec: { schedule: '0 1 * * *' } }
|
|
52
|
+
const paused = { ...active, spec: { ...active.spec, paused: true } }
|
|
53
|
+
|
|
54
|
+
const roots: ReturnType<typeof createRoot>[] = []
|
|
55
|
+
function render(node: React.ReactNode) {
|
|
56
|
+
const host = document.createElement('div')
|
|
57
|
+
document.body.append(host)
|
|
58
|
+
const root = createRoot(host)
|
|
59
|
+
roots.push(root)
|
|
60
|
+
act(() => root.render(node))
|
|
61
|
+
return root
|
|
62
|
+
}
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
act(() => roots.splice(0).forEach((r) => r.unmount()))
|
|
65
|
+
document.body.innerHTML = ''
|
|
66
|
+
state.support = 'supported'
|
|
67
|
+
state.error = null
|
|
68
|
+
state.resume = undefined
|
|
69
|
+
state.serverStopped = false
|
|
70
|
+
state.backupsDisabled = false
|
|
71
|
+
state.guardInput = {}
|
|
72
|
+
state.toast.mockReset()
|
|
73
|
+
state.mutate.mockReset()
|
|
74
|
+
state.refetch.mockReset()
|
|
75
|
+
state.updatedAt = 1
|
|
76
|
+
vi.useRealTimers()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const buttons = (label: string) => [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === label)
|
|
80
|
+
const text = () => document.body.textContent ?? ''
|
|
81
|
+
const checkbox = (label: string) =>
|
|
82
|
+
[...document.querySelectorAll('label')].find((l) => l.textContent?.includes(label))?.querySelector('input') as HTMLInputElement | undefined
|
|
83
|
+
|
|
84
|
+
const due: VeleroResumeChoices = {
|
|
85
|
+
default: { outcome: 'runsNow', due: true, summary: 'A run is due, so Velero submits it as soon as the schedule resumes.' },
|
|
86
|
+
skipping: { outcome: 'skips', due: true, summary: 'Velero skips the run due now, if any, and submits the next one at its scheduled time.' },
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe('Pause and resume', () => {
|
|
90
|
+
it('pauses, saying what stops and that a started run continues, bound to the reviewed version', () => {
|
|
91
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
92
|
+
act(() => buttons('Pause')[0].click())
|
|
93
|
+
expect(text()).toContain('Velero stops submitting this schedule’s runs until it is resumed.')
|
|
94
|
+
expect(text()).toContain('A run already started continues to the end.')
|
|
95
|
+
expect(text()).toContain('Back up now still creates a backup from this schedule while it is paused.')
|
|
96
|
+
act(() => buttons('Pause schedule')[0].click())
|
|
97
|
+
expect(state.mutate).toHaveBeenCalledWith(
|
|
98
|
+
{ namespace: 'velero', name: 'nightly', paused: true, resourceVersion: '42', skipImmediately: null },
|
|
99
|
+
expect.anything(),
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('does not promise Back up now while Velero runs restore-only', () => {
|
|
104
|
+
state.backupsDisabled = true
|
|
105
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
106
|
+
act(() => buttons('Pause')[0].click())
|
|
107
|
+
expect(text()).toContain('Back up now stays unavailable while Velero runs restore-only.')
|
|
108
|
+
expect(text()).not.toContain('Back up now still creates a backup')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('resumes with the server deciding the skip unless the user skips the due run', () => {
|
|
112
|
+
state.resume = due
|
|
113
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
114
|
+
act(() => buttons('Resume')[0].click())
|
|
115
|
+
expect(text()).toContain(due.default.summary)
|
|
116
|
+
const skip = checkbox('Skip the run that’s due now')!
|
|
117
|
+
expect(skip.checked).toBe(false)
|
|
118
|
+
act(() => skip.click())
|
|
119
|
+
expect(text()).toContain(due.skipping!.summary)
|
|
120
|
+
expect(text()).not.toContain(due.default.summary)
|
|
121
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
122
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: true }), expect.anything())
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('reads the outlook again when the next run comes, and waits for it before confirming', () => {
|
|
126
|
+
vi.useFakeTimers()
|
|
127
|
+
const nextRun = new Date(Date.now() + 60_000).toISOString()
|
|
128
|
+
state.resume = { default: { outcome: 'waits', due: false, summary: 'No run is due, so Velero submits the next one at its scheduled time.', nextRun, nextRunCertain: true } }
|
|
129
|
+
const root = render(<VeleroSchedulePause schedule={paused} />)
|
|
130
|
+
act(() => buttons('Resume')[0].click())
|
|
131
|
+
const confirm = () => buttons('Resume schedule')[0] as HTMLButtonElement
|
|
132
|
+
act(() => void vi.advanceTimersByTime(30_000))
|
|
133
|
+
expect(state.refetch).not.toHaveBeenCalled()
|
|
134
|
+
expect(confirm().disabled).toBe(false)
|
|
135
|
+
act(() => void vi.advanceTimersByTime(30_000))
|
|
136
|
+
expect(state.refetch).toHaveBeenCalledTimes(1)
|
|
137
|
+
expect(confirm().disabled).toBe(true)
|
|
138
|
+
expect(text()).toContain('Reading what resuming does')
|
|
139
|
+
state.resume = due
|
|
140
|
+
state.updatedAt = 2
|
|
141
|
+
act(() => root.render(<VeleroSchedulePause schedule={paused} />))
|
|
142
|
+
expect(confirm().disabled).toBe(false)
|
|
143
|
+
expect(checkbox('Skip the run that’s due now')).toBeDefined()
|
|
144
|
+
expect(text()).toContain(due.default.summary)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('offers no skip when nothing is due', () => {
|
|
148
|
+
state.resume = { default: { outcome: 'waits', due: false, summary: 'No run is due, so Velero submits the next one at its scheduled time.' } }
|
|
149
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
150
|
+
act(() => buttons('Resume')[0].click())
|
|
151
|
+
expect(text()).toContain('No run is due')
|
|
152
|
+
expect(checkbox('Skip the run')).toBeUndefined()
|
|
153
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
154
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: null }), expect.anything())
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('offers no skip on a cron with no future time, where skipping changes nothing', () => {
|
|
158
|
+
const summary = 'This schedule’s cron expression has no future time, so once resumed Velero submits runs immediately and repeatedly until the cron is fixed. Skipping does not prevent it.'
|
|
159
|
+
state.resume = { default: { outcome: 'runsRepeatedly', reason: 'noFutureTime', due: false, summary } }
|
|
160
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
161
|
+
act(() => buttons('Resume')[0].click())
|
|
162
|
+
expect(text()).toContain(summary)
|
|
163
|
+
expect(checkbox('Skip the run')).toBeUndefined()
|
|
164
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
165
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: null }), expect.anything())
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('refuses to confirm once the schedule changed while open', () => {
|
|
169
|
+
const root = render(<VeleroSchedulePause schedule={active} />)
|
|
170
|
+
act(() => buttons('Pause')[0].click())
|
|
171
|
+
act(() => root.render(<VeleroSchedulePause schedule={{ ...active, metadata: { ...active.metadata, resourceVersion: '43' } }} />))
|
|
172
|
+
expect(text()).toContain('This schedule changed while this was open')
|
|
173
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(true)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('is disabled with a reason until the schedule has a version', () => {
|
|
177
|
+
render(<VeleroSchedulePause schedule={{ ...active, metadata: { namespace: 'velero', name: 'nightly' } }} />)
|
|
178
|
+
expect(buttons('Pause')[0].disabled).toBe(true)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('warns that Argo CD reverts it, and waits for the acknowledgement', () => {
|
|
182
|
+
state.guardInput = argoSelfHeal
|
|
183
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
184
|
+
act(() => buttons('Pause')[0].click())
|
|
185
|
+
expect(text()).toContain('will revert this change')
|
|
186
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(true)
|
|
187
|
+
act(() => checkbox('I understand Argo CD will revert this.')!.click())
|
|
188
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(false)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('shows the server’s refusal in the dialog', () => {
|
|
192
|
+
state.error = new Error('the schedule changed since you opened it; review it again')
|
|
193
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
194
|
+
act(() => buttons('Pause')[0].click())
|
|
195
|
+
expect(text()).toContain('the schedule changed since you opened it')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('says when it was done', () => {
|
|
199
|
+
state.mutate.mockImplementation((_v: unknown, opts: { onSuccess: (r: unknown) => void }) => opts.onSuccess({ paused: true, changed: true }))
|
|
200
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
201
|
+
act(() => buttons('Pause')[0].click())
|
|
202
|
+
act(() => buttons('Pause schedule')[0].click())
|
|
203
|
+
expect(state.toast).toHaveBeenCalledWith('Schedule nightly paused')
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('is absent on a Radar without the action', () => {
|
|
207
|
+
state.support = 'unsupported'
|
|
208
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
209
|
+
expect(buttons('Pause')).toHaveLength(0)
|
|
210
|
+
})
|
|
211
|
+
})
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { CirclePause, CirclePlay } from 'lucide-react'
|
|
3
|
+
import {
|
|
4
|
+
ActionConfirmDialog,
|
|
5
|
+
GitOpsWriteWarning,
|
|
6
|
+
Tooltip,
|
|
7
|
+
canConfirmGitOpsWrite,
|
|
8
|
+
gitOpsRouteForOwner,
|
|
9
|
+
veleroNextRunText,
|
|
10
|
+
type GitOpsWrite,
|
|
11
|
+
} from '@skyhook-io/k8s-ui'
|
|
12
|
+
import { showApiSuccess } from '../ui/Toast'
|
|
13
|
+
import { useRadarFeature } from '../../api/client'
|
|
14
|
+
import { useVeleroSchedulePause, useVeleroScheduleActivity } from '../../api/velero'
|
|
15
|
+
import { useGitOpsWriteGuard } from '../../hooks/useGitOpsWriteGuard'
|
|
16
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
17
|
+
import { VELERO_GROUP } from './routes'
|
|
18
|
+
|
|
19
|
+
const BUTTON =
|
|
20
|
+
'btn-secondary inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap px-2.5 py-1.5 text-xs font-medium disabled:cursor-not-allowed disabled:opacity-50'
|
|
21
|
+
|
|
22
|
+
const GUARDED_WRITES: GitOpsWrite[] = [{ scope: 'spec', paths: ['spec.paused', 'spec.skipImmediately'] }]
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pause or Resume for a Velero Schedule, beside Back up now: sets
|
|
26
|
+
* spec.paused as `velero schedule pause|unpause` does. The confirmation is
|
|
27
|
+
* bound to the schedule's version when it opened, and Resume says what
|
|
28
|
+
* Velero does on its next pass, with the choice to skip a run that's due.
|
|
29
|
+
*/
|
|
30
|
+
export function VeleroSchedulePause({ schedule }: { schedule: any }) {
|
|
31
|
+
const { support } = useRadarFeature('veleroSchedulePause')
|
|
32
|
+
const namespace: string = schedule?.metadata?.namespace ?? ''
|
|
33
|
+
const name: string = schedule?.metadata?.name ?? ''
|
|
34
|
+
const resourceVersion: string = schedule?.metadata?.resourceVersion ?? ''
|
|
35
|
+
const paused = schedule?.spec?.paused === true
|
|
36
|
+
// The version the confirmation was opened on, and which way it goes.
|
|
37
|
+
const [reviewed, setReviewed] = useState<{ resourceVersion: string; pause: boolean } | null>(null)
|
|
38
|
+
if (support !== 'supported' || !namespace || !name) return null
|
|
39
|
+
|
|
40
|
+
const label = paused ? 'Resume' : 'Pause'
|
|
41
|
+
const unavailable = !resourceVersion ? 'The schedule hasn’t loaded yet.' : null
|
|
42
|
+
const button = (
|
|
43
|
+
<button type="button" onClick={() => setReviewed({ resourceVersion, pause: !paused })} disabled={unavailable !== null} className={BUTTON}>
|
|
44
|
+
{paused ? <CirclePlay className="h-3.5 w-3.5" aria-hidden /> : <CirclePause className="h-3.5 w-3.5" aria-hidden />}
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
)
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{unavailable ? (
|
|
51
|
+
<Tooltip content={unavailable} position="bottom">
|
|
52
|
+
<span>{button}</span>
|
|
53
|
+
</Tooltip>
|
|
54
|
+
) : (
|
|
55
|
+
button
|
|
56
|
+
)}
|
|
57
|
+
{reviewed && (
|
|
58
|
+
<SchedulePauseDialog
|
|
59
|
+
namespace={namespace}
|
|
60
|
+
name={name}
|
|
61
|
+
pause={reviewed.pause}
|
|
62
|
+
reviewedVersion={reviewed.resourceVersion}
|
|
63
|
+
changed={resourceVersion !== reviewed.resourceVersion}
|
|
64
|
+
onClose={() => setReviewed(null)}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
67
|
+
</>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Mounted only while open, so the GitOps evidence is read only for a
|
|
72
|
+
// confirmation the user opened.
|
|
73
|
+
function SchedulePauseDialog({ namespace, name, pause, reviewedVersion, changed, onClose }: {
|
|
74
|
+
namespace: string
|
|
75
|
+
name: string
|
|
76
|
+
pause: boolean
|
|
77
|
+
reviewedVersion: string
|
|
78
|
+
changed: boolean
|
|
79
|
+
onClose: () => void
|
|
80
|
+
}) {
|
|
81
|
+
const workspace = useRadarFeature('veleroWorkspace')
|
|
82
|
+
const activity = useVeleroScheduleActivity(namespace, name, { enabled: workspace.support === 'supported' })
|
|
83
|
+
const mutation = useVeleroSchedulePause()
|
|
84
|
+
const navigate = useWorkspaceNavigate()
|
|
85
|
+
const [skip, setSkip] = useState(false)
|
|
86
|
+
const [acked, setAcked] = useState(false)
|
|
87
|
+
const { guard } = useGitOpsWriteGuard({ target: { kind: 'Schedule', group: VELERO_GROUP, namespace, name }, writes: GUARDED_WRITES })
|
|
88
|
+
|
|
89
|
+
const resume = activity.data?.resume
|
|
90
|
+
const skipping = !pause && skip && resume?.skipping ? resume.skipping : undefined
|
|
91
|
+
const outlook = skipping ?? resume?.default
|
|
92
|
+
// A dialog left open past the next run would still say nothing is due and
|
|
93
|
+
// offer no skip, so at that time the outlook is read again, and the
|
|
94
|
+
// confirmation waits for the new answer.
|
|
95
|
+
const waitUntil = !pause && resume?.default.outcome === 'waits' ? resume.default.nextRun : undefined
|
|
96
|
+
const refetchActivity = activity.refetch
|
|
97
|
+
const [expired, setExpired] = useState(false)
|
|
98
|
+
const updatedAt = activity.dataUpdatedAt
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setExpired(false)
|
|
101
|
+
if (!waitUntil) return
|
|
102
|
+
const delay = Date.parse(waitUntil) - Date.now()
|
|
103
|
+
if (!(delay < 2 ** 31 - 1)) return
|
|
104
|
+
// Past the time already (an answer read just before it): ask again in a
|
|
105
|
+
// second rather than at once, so a server a moment behind isn't polled.
|
|
106
|
+
const timer = setTimeout(() => {
|
|
107
|
+
setExpired(true)
|
|
108
|
+
void refetchActivity()
|
|
109
|
+
}, delay > 0 ? delay : 1000)
|
|
110
|
+
return () => clearTimeout(timer)
|
|
111
|
+
}, [waitUntil, refetchActivity, updatedAt])
|
|
112
|
+
const outlookPending = !pause && workspace.support === 'supported' && (activity.isPending || expired)
|
|
113
|
+
const effect = pause ? (
|
|
114
|
+
'Velero stops submitting this schedule’s runs until it is resumed.'
|
|
115
|
+
) : outlook ? (
|
|
116
|
+
<>
|
|
117
|
+
{outlook.summary}
|
|
118
|
+
{(outlook.outcome === 'waits' || outlook.outcome === 'skips') && outlook.nextRun && <> Next run {veleroNextRunText({ nextRun: outlook.nextRun, nextRunCertain: !!outlook.nextRunCertain })}.</>}
|
|
119
|
+
</>
|
|
120
|
+
) : activity.isPending && workspace.support === 'supported' ? (
|
|
121
|
+
'Reading what Velero does when this schedule resumes…'
|
|
122
|
+
) : (
|
|
123
|
+
'Velero submits this schedule’s runs again. Radar could not read what it does first: a run that’s due may be submitted at once.'
|
|
124
|
+
)
|
|
125
|
+
const notes = pause
|
|
126
|
+
? [
|
|
127
|
+
'A run already started continues to the end.',
|
|
128
|
+
activity.data?.backupsDisabled
|
|
129
|
+
? 'Back up now stays unavailable while Velero runs restore-only.'
|
|
130
|
+
: 'Back up now still creates a backup from this schedule while it is paused.',
|
|
131
|
+
]
|
|
132
|
+
: []
|
|
133
|
+
const warnings = [
|
|
134
|
+
...(activity.data?.serverStopped ? ['The Velero server isn’t running, so nothing happens until it starts.'] : []),
|
|
135
|
+
...(changed ? ['This schedule changed while this was open. Close it and review the schedule again.'] : []),
|
|
136
|
+
]
|
|
137
|
+
const skipValue = !pause && skipping ? true : null
|
|
138
|
+
const route = guard?.owner ? gitOpsRouteForOwner(guard.owner) : null
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<ActionConfirmDialog
|
|
142
|
+
open
|
|
143
|
+
onClose={onClose}
|
|
144
|
+
onConfirm={() =>
|
|
145
|
+
mutation.mutate(
|
|
146
|
+
{ namespace, name, paused: pause, resourceVersion: reviewedVersion, skipImmediately: skipValue },
|
|
147
|
+
{
|
|
148
|
+
onSuccess: (result) => {
|
|
149
|
+
onClose()
|
|
150
|
+
showApiSuccess(
|
|
151
|
+
result.changed ? `Schedule ${name} ${pause ? 'paused' : 'resumed'}` : `Schedule ${name} was already ${pause ? 'paused' : 'running'}`,
|
|
152
|
+
)
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
title={pause ? `Pause ${name}?` : `Resume ${name}?`}
|
|
158
|
+
subject={{ kind: 'Schedule', namespace, name }}
|
|
159
|
+
effect={effect}
|
|
160
|
+
notes={notes}
|
|
161
|
+
warnings={warnings}
|
|
162
|
+
guard={
|
|
163
|
+
guard ? (
|
|
164
|
+
<GitOpsWriteWarning
|
|
165
|
+
guard={guard}
|
|
166
|
+
acknowledged={acked}
|
|
167
|
+
onAcknowledgedChange={setAcked}
|
|
168
|
+
onOpenOwner={route ? () => navigate(route) : undefined}
|
|
169
|
+
onOpenManager={(owner) => navigate(gitOpsRouteForOwner(owner))}
|
|
170
|
+
/>
|
|
171
|
+
) : null
|
|
172
|
+
}
|
|
173
|
+
guardSatisfied={guard ? canConfirmGitOpsWrite(guard, acked) : false}
|
|
174
|
+
writes={[{
|
|
175
|
+
summary: `patch Schedule ${namespace}/${name}`,
|
|
176
|
+
detail: `spec.paused = ${pause}\nspec.skipImmediately = ${skipValue === true ? 'true' : 'null (the Velero server decides)'}`,
|
|
177
|
+
}]}
|
|
178
|
+
confirmLabel={pause ? 'Pause schedule' : 'Resume schedule'}
|
|
179
|
+
isLoading={mutation.isPending}
|
|
180
|
+
result={mutation.error ? { state: 'error', message: mutation.error.message } : undefined}
|
|
181
|
+
incompleteReason={changed ? 'The schedule changed' : outlookPending ? 'Reading what resuming does' : undefined}
|
|
182
|
+
>
|
|
183
|
+
{!pause && resume?.skipping && (
|
|
184
|
+
<label className="flex items-center gap-2 text-sm">
|
|
185
|
+
<input type="checkbox" checked={skip} onChange={(e) => setSkip(e.target.checked)} />
|
|
186
|
+
Skip the run that’s due now
|
|
187
|
+
</label>
|
|
188
|
+
)}
|
|
189
|
+
</ActionConfirmDialog>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { schedule } from './velero.fixtures'
|
|
4
|
+
|
|
5
|
+
const state = vi.hoisted(() => ({ support: 'supported' as string, data: undefined as unknown }))
|
|
6
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: state.support }) }))
|
|
7
|
+
vi.mock('../../api/velero', () => ({ useVeleroScheduleActivity: () => ({ data: state.data }) }))
|
|
8
|
+
|
|
9
|
+
const { VeleroScheduleStatusBadge } = await import('./VeleroScheduleStatusBadge')
|
|
10
|
+
|
|
11
|
+
const enabled = { apiVersion: 'velero.io/v1', kind: 'Schedule', metadata: { namespace: 'velero', name: 'nightly' }, spec: { schedule: '0 1 * * *' }, status: { phase: 'Enabled' } }
|
|
12
|
+
|
|
13
|
+
describe('Velero Schedule header chip', () => {
|
|
14
|
+
it('says what the schedule is doing, not that Velero accepted it', () => {
|
|
15
|
+
state.support = 'supported'
|
|
16
|
+
state.data = { reading: schedule({ state: 'late', attention: true }) }
|
|
17
|
+
const html = renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)
|
|
18
|
+
expect(html).toContain('Late')
|
|
19
|
+
expect(html).not.toContain('Enabled')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('falls back to the phase until the reading arrives, and on an older Radar', () => {
|
|
23
|
+
state.data = undefined
|
|
24
|
+
expect(renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)).toContain('Enabled')
|
|
25
|
+
state.support = 'unsupported'
|
|
26
|
+
expect(renderToStaticMarkup(<VeleroScheduleStatusBadge resource={enabled} />)).toContain('Enabled')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { VeleroScheduleStateBadge, getResourceStatus } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useRadarFeature } from '../../api/client'
|
|
4
|
+
import { useVeleroScheduleActivity } from '../../api/velero'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Velero Schedule's header chip: what the schedule is doing (late, held, on
|
|
8
|
+
* schedule) rather than Velero's phase, which only says Velero accepted it. A
|
|
9
|
+
* schedule can be Enabled and hours late. Until the reading arrives, or on a
|
|
10
|
+
* Radar without it, the phase stands in.
|
|
11
|
+
*/
|
|
12
|
+
export function VeleroScheduleStatusBadge({ resource }: { resource: any }) {
|
|
13
|
+
const namespace = resource?.metadata?.namespace ?? ''
|
|
14
|
+
const name = resource?.metadata?.name ?? ''
|
|
15
|
+
const { support } = useRadarFeature('veleroWorkspace')
|
|
16
|
+
const activity = useVeleroScheduleActivity(namespace, name, { enabled: support === 'supported' })
|
|
17
|
+
const reading = activity.data?.reading
|
|
18
|
+
if (reading) return <VeleroScheduleStateBadge reading={reading} />
|
|
19
|
+
const phase = getResourceStatus('schedules', resource)
|
|
20
|
+
return phase ? <span className={clsx('badge', phase.color)}>{phase.text}</span> : null
|
|
21
|
+
}
|