@skyhook-io/radar-app 1.20.1 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/src/App.tsx +65 -16
- package/src/api/client.audit-gating.test.tsx +105 -5
- package/src/api/client.auditBadgesSync.test.tsx +118 -0
- package/src/api/client.capabilitiesPoll.test.ts +61 -0
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +347 -16
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +10 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +201 -0
- package/src/api/vulnerabilities.ts +255 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
- package/src/components/audit/ChecksViewTabs.tsx +11 -1
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +907 -0
- package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
- package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
- package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
- package/src/components/cnpg/CNPGView.tsx +43 -117
- package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
- package/src/components/cnpg/host.tsx +2 -2
- package/src/components/cnpg/routes.ts +3 -1
- package/src/components/cnpg/shared.tsx +5 -53
- package/src/components/cnpg/useCNPGNavigate.ts +1 -21
- package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
- package/src/components/community.tsx +42 -0
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationMetrics.test.ts +20 -0
- package/src/components/diagnose/investigationMetrics.ts +2 -1
- package/src/components/dock/BottomDock.tsx +1 -0
- package/src/components/dock/LogsTab.tsx +3 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +2 -10
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
- package/src/components/helm/HelmView.tsx +25 -19
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +69 -11
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +25 -11
- package/src/components/home/HelmSummary.tsx +15 -15
- package/src/components/home/HomeAgentBlock.tsx +3 -0
- package/src/components/home/HomeView.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +19 -12
- package/src/components/home/MCPSetupDialog.tsx +4 -2
- package/src/components/home/mcpToolCatalog.ts +17 -4
- package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
- package/src/components/home/useVulnerabilitiesRow.ts +50 -0
- package/src/components/logs/LogsViewer.tsx +3 -1
- package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
- package/src/components/logs/MultiPodLogsTab.tsx +9 -5
- package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
- package/src/components/nav/PrimaryNavRail.tsx +174 -29
- package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
- package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
- package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
- package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
- package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
- package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
- package/src/components/timeline/TimelineView.tsx +3 -1
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
- package/src/components/traffic/TrafficData.test.tsx +37 -0
- package/src/components/traffic/TrafficData.tsx +27 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -7
- package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
- package/src/components/traffic/TrafficGraph.test.tsx +269 -0
- package/src/components/traffic/TrafficGraph.tsx +135 -64
- package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
- package/src/components/traffic/TrafficView.tsx +72 -155
- package/src/components/traffic/trafficFilters.test.ts +189 -1
- package/src/components/traffic/trafficFilters.ts +169 -1
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +54 -3
- package/src/components/ui/UpdateNotification.tsx +60 -19
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
- package/src/components/velero/VeleroBackupNow.tsx +143 -0
- package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
- package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
- package/src/components/velero/VeleroDetailPage.tsx +148 -0
- package/src/components/velero/VeleroKindLists.test.tsx +48 -0
- package/src/components/velero/VeleroKindLists.tsx +43 -0
- package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
- package/src/components/velero/VeleroLocations.test.tsx +86 -0
- package/src/components/velero/VeleroLocations.tsx +240 -0
- package/src/components/velero/VeleroOverview.test.tsx +311 -0
- package/src/components/velero/VeleroOverview.tsx +485 -0
- package/src/components/velero/VeleroPages.test.tsx +516 -0
- package/src/components/velero/VeleroPages.tsx +1056 -0
- package/src/components/velero/VeleroRunLists.tsx +309 -0
- package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
- package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
- package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
- package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
- package/src/components/velero/VeleroSchedules.tsx +255 -0
- package/src/components/velero/VeleroView.tsx +59 -0
- package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
- package/src/components/velero/attention.test.ts +178 -0
- package/src/components/velero/attention.ts +281 -0
- package/src/components/velero/backupDelete.test.tsx +91 -0
- package/src/components/velero/backupDelete.tsx +182 -0
- package/src/components/velero/coverage.test.ts +87 -0
- package/src/components/velero/coverage.ts +150 -0
- package/src/components/velero/host.tsx +86 -0
- package/src/components/velero/routes.ts +78 -0
- package/src/components/velero/runs.tsx +121 -0
- package/src/components/velero/shared.test.ts +84 -0
- package/src/components/velero/shared.tsx +423 -0
- package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
- package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
- package/src/components/velero/velero.fixtures.ts +61 -0
- package/src/components/velero/workspaceRoute.ts +21 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +114 -37
- package/src/components/workspace/DrawerTrailBack.tsx +32 -0
- package/src/components/workspace/WorkspaceFrame.tsx +71 -0
- package/src/components/workspace/coverage.ts +61 -0
- package/src/components/workspace/layout.test.tsx +29 -1
- package/src/components/workspace/layout.tsx +15 -5
- package/src/components/workspace/sidebar.ts +9 -0
- package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
- package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/desktop/AboutDialog.test.ts +12 -0
- package/src/desktop/AboutDialog.tsx +151 -0
- package/src/desktop/WindowsTitleBar.tsx +359 -0
- package/src/desktop/titleBar.test.ts +61 -0
- package/src/desktop/titleBar.ts +45 -0
- package/src/index.css +19 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +15 -3
- package/src/integrations/resourceHosts.tsx +26 -6
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.test.ts +11 -0
- package/src/integrations/workspaceRoutes.ts +3 -1
- package/src/integrations/workspaceScreens.tsx +2 -0
- package/src/main.tsx +8 -0
- package/src/utils/desktop-zoom.test.ts +53 -0
- package/src/utils/desktop-zoom.ts +30 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -0,0 +1,1056 @@
|
|
|
1
|
+
import { Fragment, createContext, useContext, useState, type ReactNode } from 'react'
|
|
2
|
+
import { useLocation, useSearchParams } from 'react-router-dom'
|
|
3
|
+
import {
|
|
4
|
+
Disclosure,
|
|
5
|
+
FactGrid,
|
|
6
|
+
FactRow,
|
|
7
|
+
OpenIssueContext,
|
|
8
|
+
SectionHeading,
|
|
9
|
+
StatusDot,
|
|
10
|
+
Tooltip,
|
|
11
|
+
WorkspaceProblemCallout,
|
|
12
|
+
formatRelativeAgeTime,
|
|
13
|
+
getBackupErrors,
|
|
14
|
+
getBackupStatus,
|
|
15
|
+
getBackupValidationErrors,
|
|
16
|
+
getBackupWarnings,
|
|
17
|
+
getRestoreBackupName,
|
|
18
|
+
getRestoreErrors,
|
|
19
|
+
getRestoreNamespaceMapping,
|
|
20
|
+
getRestoreStatus,
|
|
21
|
+
getRestoreValidationErrors,
|
|
22
|
+
getRestoreWarnings,
|
|
23
|
+
refToSelectedResource,
|
|
24
|
+
toneTextClass,
|
|
25
|
+
VeleroZoneValue,
|
|
26
|
+
veleroCadenceText,
|
|
27
|
+
veleroDefaultText,
|
|
28
|
+
veleroFrequencyText,
|
|
29
|
+
veleroLocalTime,
|
|
30
|
+
veleroLocationReasonText,
|
|
31
|
+
veleroMomentText,
|
|
32
|
+
veleroNextRunText,
|
|
33
|
+
veleroNextRunTitle,
|
|
34
|
+
veleroPlainReason,
|
|
35
|
+
veleroDeclaredRetention,
|
|
36
|
+
VELERO_SERVER_DEFAULT_RETENTION,
|
|
37
|
+
veleroScheduleBadge,
|
|
38
|
+
veleroScheduleNeverRan,
|
|
39
|
+
veleroScheduleReasonText,
|
|
40
|
+
VELERO_MANUAL_RUN,
|
|
41
|
+
VELERO_MANUAL_RUN_TITLE,
|
|
42
|
+
VELERO_SUBMISSION_ANNOTATION,
|
|
43
|
+
VELERO_NONE_KEPT_SHORT,
|
|
44
|
+
VELERO_RUNS_UNKNOWN,
|
|
45
|
+
type NavigateToResource,
|
|
46
|
+
type StatusTone,
|
|
47
|
+
type VeleroLocationReading,
|
|
48
|
+
type VeleroRun,
|
|
49
|
+
type VeleroScheduleReading,
|
|
50
|
+
type VeleroWorkspaceResponse,
|
|
51
|
+
} from '@skyhook-io/k8s-ui'
|
|
52
|
+
import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
|
|
53
|
+
import { useRadarFeature } from '../../api/client'
|
|
54
|
+
import { useVeleroRuns, useVeleroScheduleActivity, useVeleroWorkspace, type VeleroRestoreRow, type VeleroRunRow, type VeleroRunsResponse } from '../../api/velero'
|
|
55
|
+
import { useVeleroStoredBackups } from '../../api/policy'
|
|
56
|
+
import { useNavCustomization } from '../../context/NavCustomization'
|
|
57
|
+
import { currentPageLabel, issuesPathForSubject } from '../../utils/page-links'
|
|
58
|
+
import { Notice, RefreshFailedNotice, Segments, SectionTable } from '../workspace/layout'
|
|
59
|
+
import { INCOMPLETE_COVERAGE_STATES, coverageLabel } from '../workspace/coverage'
|
|
60
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
61
|
+
import { RunMessages } from './VeleroRunMessagesHost'
|
|
62
|
+
import { VeleroBackupDeletionRow } from './VeleroDeleteBackup'
|
|
63
|
+
import { Expires, FAILED, Outcome, RunCounts, RunOutcome, RunsReadNotice, When, durationText, expired, runViewOptions, runsEmpty, useRunView } from './runs'
|
|
64
|
+
import { VELERO_DETAIL_KINDS, veleroDetailPath } from './routes'
|
|
65
|
+
import { VELERO_DELETE_OBJECT, VELERO_MESSAGE_LABEL, VELERO_WIDE, VeleroName, restoreTargets, selectionText, veleroResource, type RestoreSelection } from './shared'
|
|
66
|
+
import { useVeleroDeleteObjectReason } from './backupDelete'
|
|
67
|
+
import { OutcomeCell, RestoreIntoCell, StartedCell } from './VeleroRunLists'
|
|
68
|
+
import { useMediaQuery } from '../../hooks/useMediaQuery'
|
|
69
|
+
import { veleroObjectProblems } from './attention'
|
|
70
|
+
|
|
71
|
+
// The pages' own sections, beside Radar's detail view: a composed Overview for
|
|
72
|
+
// each Velero kind, and the tabs that list what the object relates to. Every
|
|
73
|
+
// value says where it comes from or reads unknown. Declared settings are named
|
|
74
|
+
// as declared, and nothing here says a backup would restore: Velero never
|
|
75
|
+
// tests a restore.
|
|
76
|
+
|
|
77
|
+
const CARD = 'rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm'
|
|
78
|
+
|
|
79
|
+
/** Where an Overview is shown: on the object's page, or in the drawer over a list. */
|
|
80
|
+
interface SummaryPlace {
|
|
81
|
+
drawer: boolean
|
|
82
|
+
plural: string
|
|
83
|
+
namespace: string
|
|
84
|
+
name: string
|
|
85
|
+
}
|
|
86
|
+
const SummaryPlaceContext = createContext<SummaryPlace | null>(null)
|
|
87
|
+
|
|
88
|
+
// The drawer is already a panel, so its sections are not framed again.
|
|
89
|
+
function Card({ title, children }: { title?: string; children: ReactNode }) {
|
|
90
|
+
const drawer = !!useContext(SummaryPlaceContext)?.drawer
|
|
91
|
+
return (
|
|
92
|
+
<section className={drawer ? undefined : CARD}>
|
|
93
|
+
{title && <SectionHeading>{title}</SectionHeading>}
|
|
94
|
+
{children}
|
|
95
|
+
</section>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function Note({ children }: { children: ReactNode }) {
|
|
100
|
+
return <div className="text-xs text-theme-text-tertiary">{children}</div>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function Link({ children, onClick }: { children: ReactNode; onClick?: () => void }) {
|
|
104
|
+
if (!onClick) return <span>{children}</span>
|
|
105
|
+
return (
|
|
106
|
+
<button type="button" onClick={onClick} className="text-left text-accent-text hover:underline">
|
|
107
|
+
{children}
|
|
108
|
+
</button>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* "Restores →": on the page, opens another of its tabs as a tab click does;
|
|
114
|
+
* in the drawer, opens that tab on the object's page.
|
|
115
|
+
*/
|
|
116
|
+
function TabLink({ tab, children }: { tab: string; children: ReactNode }) {
|
|
117
|
+
const [params, setParams] = useSearchParams()
|
|
118
|
+
const location = useLocation()
|
|
119
|
+
const place = useContext(SummaryPlaceContext)
|
|
120
|
+
const navigate = useWorkspaceNavigate()
|
|
121
|
+
const open = () => {
|
|
122
|
+
// The page pins its context itself.
|
|
123
|
+
if (place?.drawer) {
|
|
124
|
+
navigate(veleroDetailPath({ plural: place.plural, namespace: place.namespace, name: place.name }, undefined, tab), { state: { returnLabel: currentPageLabel() } })
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
const next = new URLSearchParams(params)
|
|
128
|
+
next.set('tab', tab)
|
|
129
|
+
setParams(next, { state: location.state })
|
|
130
|
+
}
|
|
131
|
+
return (
|
|
132
|
+
<button type="button" onClick={open} className="whitespace-nowrap text-xs text-accent-text hover:underline">
|
|
133
|
+
{children} →
|
|
134
|
+
</button>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Velero's own text, folded under Radar's plain reading of it. */
|
|
139
|
+
function RawMessage({ message }: { message: string }) {
|
|
140
|
+
return (
|
|
141
|
+
<Disclosure summary={VELERO_MESSAGE_LABEL} className="mt-1" summaryClassName="text-xs text-theme-text-tertiary hover:text-theme-text-secondary">
|
|
142
|
+
<div className="mt-1 whitespace-pre-wrap break-words font-mono text-xs text-theme-text-secondary">{message}</div>
|
|
143
|
+
</Disclosure>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** "as declared", and that filters narrow it when they do. */
|
|
148
|
+
function declaredNote(narrowed: boolean): string {
|
|
149
|
+
return narrowed ? 'as declared · narrowed by resource or label filters' : 'as declared'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const TONE_TEXT = { ok: 'text-success-text', warn: 'text-warning-text', bad: 'text-error-text', unknown: 'text-theme-text-secondary' } as const
|
|
153
|
+
type Tone = keyof typeof TONE_TEXT
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A storage location's state as a page reads it. Missing is said only when the
|
|
157
|
+
* namespace's locations were read in full; otherwise it is unread.
|
|
158
|
+
*/
|
|
159
|
+
export function locationState(name: string, namespace: string, workspace: VeleroWorkspaceResponse | undefined): { loc?: VeleroLocationReading; text: string; tone: Tone; missing?: boolean } {
|
|
160
|
+
const loc = workspace?.locations.find((l) => l.namespace === namespace && l.name === name)
|
|
161
|
+
if (loc) {
|
|
162
|
+
if (loc.phase === 'Available') return { loc, text: 'available', tone: 'ok' }
|
|
163
|
+
if (!loc.phase) return { loc, text: 'not validated yet', tone: 'unknown' }
|
|
164
|
+
return { loc, text: loc.phase.toLowerCase(), tone: 'bad' }
|
|
165
|
+
}
|
|
166
|
+
const cov = workspace?.coverage.backupStorageLocations
|
|
167
|
+
if (workspace && cov?.state === 'full') return { text: 'not found: Velero has no such location', tone: 'bad', missing: true }
|
|
168
|
+
return { text: 'not read', tone: 'unknown' }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function LocationValue({ name, namespace, workspace, onNavigate }: { name: string; namespace: string; workspace: VeleroWorkspaceResponse | undefined; onNavigate?: NavigateToResource }) {
|
|
172
|
+
const state = locationState(name, namespace, workspace)
|
|
173
|
+
return (
|
|
174
|
+
<>
|
|
175
|
+
{state.loc ? <Link onClick={() => onNavigate?.(veleroResource('BackupStorageLocation', namespace, name))}>{name}</Link> : <span>{name}</span>}
|
|
176
|
+
<span className={`ml-2 text-xs ${TONE_TEXT[state.tone]}`}>{state.text}</span>
|
|
177
|
+
</>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function useWorkspace() {
|
|
182
|
+
const { support } = useRadarFeature('veleroWorkspace')
|
|
183
|
+
return useVeleroWorkspace({ enabled: support === 'supported' })
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** "finished 2h ago · took 3s", or how far it got. */
|
|
187
|
+
function whenText(status: any): string | undefined {
|
|
188
|
+
const took = durationText(status.startTimestamp, status.completionTimestamp)
|
|
189
|
+
if (status.completionTimestamp) return `finished ${veleroMomentText(status.completionTimestamp)}${took ? ` · took ${took}` : ''}`
|
|
190
|
+
if (status.startTimestamp) return `started ${veleroMomentText(status.startTimestamp)}`
|
|
191
|
+
return undefined
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function plural(n: number, word: string): string {
|
|
195
|
+
return `${n} ${word}${n === 1 ? '' : 's'}`
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** "2 errors · 1 warning": each red or amber when there are some, dimmed at zero. */
|
|
199
|
+
function CountsText({ errors, warnings }: { errors: number; warnings: number }) {
|
|
200
|
+
return (
|
|
201
|
+
<>
|
|
202
|
+
<span className={errors > 0 ? toneTextClass('unhealthy') : 'text-theme-text-tertiary'}>{plural(errors, 'error')}</span>
|
|
203
|
+
<span className="text-theme-text-tertiary"> · </span>
|
|
204
|
+
<span className={warnings > 0 ? toneTextClass('degraded') : 'text-theme-text-tertiary'}>{plural(warnings, 'warning')}</span>
|
|
205
|
+
</>
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ---- Issues -------------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The page's lead: what Radar has for this object, its Velero reading when that
|
|
213
|
+
* needs attention and Velero's issues about it, as plain banners, each with its
|
|
214
|
+
* next step (and, for an issue, a way to the Issues page). The operational
|
|
215
|
+
* issues the detail view found stand in when the Velero workspace isn't read
|
|
216
|
+
* or holds nothing for it (it keeps the newest 50 issues per installation).
|
|
217
|
+
*/
|
|
218
|
+
function PageLead({ kind, namespace, name, resource, leadContent, onNavigate }: { kind: string; namespace: string; name: string; resource?: any; leadContent?: ReactNode; onNavigate?: NavigateToResource }) {
|
|
219
|
+
const workspace = useWorkspace()
|
|
220
|
+
const navigate = useWorkspaceNavigate()
|
|
221
|
+
const [params] = useSearchParams()
|
|
222
|
+
const issuesTakenOver = !!useNavCustomization().fleetTakeoverHref?.('issues')
|
|
223
|
+
const deleteObject = useRadarFeature('resourceDeletePreconditions').support === 'supported'
|
|
224
|
+
// Velero won't act on a deletion request for this backup: its own fault's next step names the delete that works.
|
|
225
|
+
const deleteObjectReason = useVeleroDeleteObjectReason(kind === 'Backup' ? resource : undefined)
|
|
226
|
+
const problems = (workspace.data ? veleroObjectProblems(workspace.data, kind, namespace, name, { deleteObject }) : []).map((p) =>
|
|
227
|
+
deleteObjectReason && p.subject.kind === 'Backup' && p.subject.name === name && p.nextStep
|
|
228
|
+
? { ...p, nextStep: `${p.nextStep.replace(/\.$/, '')}; to remove this backup, use ${VELERO_DELETE_OBJECT} (nothing of it is in storage)` }
|
|
229
|
+
: p,
|
|
230
|
+
)
|
|
231
|
+
if (problems.length === 0) return <>{leadContent}</>
|
|
232
|
+
return (
|
|
233
|
+
<OpenIssueContext.Provider value={issuesTakenOver ? undefined : (p) => navigate(issuesPathForSubject(p.subject, params.get('namespaces')))}>
|
|
234
|
+
<div className="space-y-3">
|
|
235
|
+
{problems.map((problem) => (
|
|
236
|
+
<WorkspaceProblemCallout
|
|
237
|
+
key={problem.id}
|
|
238
|
+
problem={problem}
|
|
239
|
+
rootKind={kind}
|
|
240
|
+
subjectIsSelf={problem.subject.kind === kind && problem.subject.name === name}
|
|
241
|
+
onNavigate={(ref) => onNavigate?.(refToSelectedResource(ref))}
|
|
242
|
+
/>
|
|
243
|
+
))}
|
|
244
|
+
</div>
|
|
245
|
+
</OpenIssueContext.Provider>
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ---- Backup -------------------------------------------------------------
|
|
250
|
+
|
|
251
|
+
const FINISHED_WITH_CONTENTS = new Set(['Completed', 'PartiallyFailed'])
|
|
252
|
+
|
|
253
|
+
/** Whether a restore from this backup can work: "No" with the reason where certain, an uncertain answer where Velero would try, else not verified. */
|
|
254
|
+
function restoreAnswer(resource: any, location: ReturnType<typeof locationState> | null): { text: string; uncertain?: boolean } | null {
|
|
255
|
+
const phase: string = resource?.status?.phase ?? ''
|
|
256
|
+
// For a restore by backup name, Velero checks the location and reads the archive.
|
|
257
|
+
if (location?.missing) return { text: 'No: its storage location doesn’t exist' }
|
|
258
|
+
if (location?.loc?.phase === 'Unavailable') return { text: 'No: its storage location is unavailable, and Velero refuses a restore from an unavailable location' }
|
|
259
|
+
if (phase === 'Deleting' || resource?.metadata?.deletionTimestamp)
|
|
260
|
+
return { text: 'Uncertain: it is being deleted, so its contents may already be gone from storage', uncertain: true }
|
|
261
|
+
if (FINISHED_WITH_CONTENTS.has(phase)) return null
|
|
262
|
+
if (phase === 'Failed') return { text: 'Uncertain: the backup failed after it started. Some contents may have reached storage.', uncertain: true }
|
|
263
|
+
if (!phase || phase === 'New') return { text: 'Not yet: Velero hasn’t started the backup.' }
|
|
264
|
+
return { text: 'Wait for the backup to finish. Its stored contents may still be incomplete.', uncertain: true }
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function VeleroBackupOverview({ resource, onNavigate }: { resource: any; onNavigate?: NavigateToResource }) {
|
|
268
|
+
const namespace: string = resource?.metadata?.namespace ?? ''
|
|
269
|
+
const workspace = useWorkspace()
|
|
270
|
+
const status = resource?.status ?? {}
|
|
271
|
+
const spec = resource?.spec ?? {}
|
|
272
|
+
const phase: string = status.phase ?? ''
|
|
273
|
+
const locationName: string = spec.storageLocation ?? ''
|
|
274
|
+
const scheduleName: string | undefined = resource?.metadata?.labels?.['velero.io/schedule-name']
|
|
275
|
+
const sched = scheduleName ? workspace.data?.schedules.find((s) => s.namespace === namespace && s.name === scheduleName) : undefined
|
|
276
|
+
const selection = selectionText(spec, 'All namespaces')
|
|
277
|
+
// Rejected, or failed before it started: nothing was backed up, so there is nothing to keep or restore.
|
|
278
|
+
const rejected = phase === 'FailedValidation'
|
|
279
|
+
const nothing = rejected || (phase === 'Failed' && !status.startTimestamp)
|
|
280
|
+
const rawReason: string | undefined = rejected ? getBackupValidationErrors(resource).join('; ') || undefined : status.failureReason
|
|
281
|
+
const reason = veleroPlainReason(rawReason) ?? rawReason
|
|
282
|
+
const items = status.progress?.totalItems ? `${status.progress.itemsBackedUp ?? 0} of ${status.progress.totalItems} items backed up` : undefined
|
|
283
|
+
const volumes = [
|
|
284
|
+
status.volumeSnapshotsAttempted ? `${status.volumeSnapshotsCompleted ?? 0} of ${status.volumeSnapshotsAttempted} volume snapshots` : '',
|
|
285
|
+
status.csiVolumeSnapshotsAttempted ? `${status.csiVolumeSnapshotsCompleted ?? 0} of ${status.csiVolumeSnapshotsAttempted} CSI snapshots` : '',
|
|
286
|
+
status.backupItemOperationsAttempted ? `${status.backupItemOperationsCompleted ?? 0} of ${status.backupItemOperationsAttempted} plugin operations${status.backupItemOperationsFailed ? `, ${status.backupItemOperationsFailed} failed` : ''}` : '',
|
|
287
|
+
].filter(Boolean)
|
|
288
|
+
const when = whenText(status)
|
|
289
|
+
const location = locationName ? locationState(locationName, namespace, workspace.data) : null
|
|
290
|
+
const restore = restoreAnswer(resource, location)
|
|
291
|
+
const server = workspace.data?.installations.find((i) => i.namespace === namespace)?.server
|
|
292
|
+
const gcOff = server?.gcDisabled === true
|
|
293
|
+
const deletionOff = server?.deletionDisabled === true
|
|
294
|
+
const manual = resource?.metadata?.annotations?.[VELERO_SUBMISSION_ANNOTATION] !== undefined
|
|
295
|
+
const errors = getBackupErrors(resource)
|
|
296
|
+
const warnings = getBackupWarnings(resource)
|
|
297
|
+
const restores = useVeleroRuns('restores', namespace, { backup: resource?.metadata?.name ?? '' })
|
|
298
|
+
// Runs are newest first: the newest restore from this backup that Velero finished.
|
|
299
|
+
const restoredBefore = restores.data?.runs.find((r) => FINISHED_WITH_CONTENTS.has(r.phase ?? ''))
|
|
300
|
+
return (
|
|
301
|
+
<>
|
|
302
|
+
<RefreshFailedNotice queries={[workspace]} />
|
|
303
|
+
<Card title="At a glance">
|
|
304
|
+
<FactGrid>
|
|
305
|
+
<FactRow label="Outcome">
|
|
306
|
+
<span className="inline-flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
307
|
+
<Outcome badge={getBackupStatus(resource)} />
|
|
308
|
+
{when && <span className="text-xs text-theme-text-secondary">{when}</span>}
|
|
309
|
+
</span>
|
|
310
|
+
{!nothing && (
|
|
311
|
+
<div className="mt-0.5 text-xs text-theme-text-secondary">
|
|
312
|
+
{items && <>{items} · </>}
|
|
313
|
+
<CountsText errors={errors} warnings={warnings} />
|
|
314
|
+
</div>
|
|
315
|
+
)}
|
|
316
|
+
<RunMessages kind="backups" resource={resource} />
|
|
317
|
+
</FactRow>
|
|
318
|
+
<VeleroBackupDeletionRow
|
|
319
|
+
backup={resource}
|
|
320
|
+
renderName={(n) => {
|
|
321
|
+
const mono = <span className="whitespace-nowrap font-mono text-[0.95em]">{n}</span>
|
|
322
|
+
const exists = workspace.data?.locations.some((l) => l.namespace === namespace && l.name === n)
|
|
323
|
+
return exists ? <Link onClick={() => onNavigate?.(veleroResource('BackupStorageLocation', namespace, n))}>{mono}</Link> : mono
|
|
324
|
+
}}
|
|
325
|
+
/>
|
|
326
|
+
{nothing && (
|
|
327
|
+
<FactRow label="Backed up">
|
|
328
|
+
<span className={toneTextClass('unhealthy')}>Nothing</span>
|
|
329
|
+
{' — '}
|
|
330
|
+
{rejected ? 'Velero rejected it' : 'it failed before it started'}
|
|
331
|
+
{reason ? `: ${reason}` : ''}
|
|
332
|
+
{reason && rawReason && reason !== rawReason && <RawMessage message={rawReason} />}
|
|
333
|
+
</FactRow>
|
|
334
|
+
)}
|
|
335
|
+
<FactRow label="Namespaces">
|
|
336
|
+
{selection.text}
|
|
337
|
+
<Note>{declaredNote(selection.narrowed)}</Note>
|
|
338
|
+
</FactRow>
|
|
339
|
+
{volumes.length > 0 && <FactRow label="Volumes">{volumes.join(' · ')}</FactRow>}
|
|
340
|
+
<FactRow label="Stored in">
|
|
341
|
+
{locationName ? <LocationValue name={locationName} namespace={namespace} workspace={workspace.data} onNavigate={onNavigate} /> : <span className="text-theme-text-secondary">Not assigned yet</span>}
|
|
342
|
+
</FactRow>
|
|
343
|
+
{!nothing && (
|
|
344
|
+
<FactRow label="Kept until">
|
|
345
|
+
{status.expiration ? (
|
|
346
|
+
<>
|
|
347
|
+
{veleroLocalTime(status.expiration)}
|
|
348
|
+
<Note>
|
|
349
|
+
{gcOff
|
|
350
|
+
? `${expired(status.expiration) ? 'Past its retention' : veleroMomentText(status.expiration)}, but Velero’s garbage collection is disabled (--restore-only or --disable-controllers=gc), so it is not deleted then`
|
|
351
|
+
: deletionOff
|
|
352
|
+
? `${expired(status.expiration) ? 'Past its retention' : veleroMomentText(status.expiration)}. The backup-deletion controller is disabled, so deletion requests remain pending.`
|
|
353
|
+
: expired(status.expiration)
|
|
354
|
+
? 'Past its retention and eligible for garbage collection'
|
|
355
|
+
: veleroMomentText(status.expiration)}
|
|
356
|
+
{veleroDeclaredRetention(spec.ttl) ? ` · retention ${veleroDeclaredRetention(spec.ttl)}` : ''}
|
|
357
|
+
</Note>
|
|
358
|
+
</>
|
|
359
|
+
) : (
|
|
360
|
+
<span className="text-theme-text-secondary">Not reported yet</span>
|
|
361
|
+
)}
|
|
362
|
+
</FactRow>
|
|
363
|
+
)}
|
|
364
|
+
<FactRow label="Made by">
|
|
365
|
+
{scheduleName ? (
|
|
366
|
+
<>
|
|
367
|
+
{manual && 'Back up now, from '}
|
|
368
|
+
<Link onClick={() => onNavigate?.(veleroResource('Schedule', namespace, scheduleName))}>{manual ? 'schedule' : 'Schedule'} {scheduleName}</Link>
|
|
369
|
+
{sched && <span className="ml-2 text-xs text-theme-text-secondary">{veleroScheduleBadge(sched).label}</span>}
|
|
370
|
+
</>
|
|
371
|
+
) : (
|
|
372
|
+
'On demand, not by a schedule'
|
|
373
|
+
)}
|
|
374
|
+
</FactRow>
|
|
375
|
+
{(!nothing || restoredBefore) && (
|
|
376
|
+
<FactRow label="Restore">
|
|
377
|
+
<span className="inline-flex flex-wrap items-baseline gap-x-2">
|
|
378
|
+
{!nothing && (restore ? (
|
|
379
|
+
<span className={restore.uncertain ? 'text-theme-text-secondary' : undefined}>{restore.text}</span>
|
|
380
|
+
) : !restoredBefore && (
|
|
381
|
+
<span className="text-theme-text-secondary">Not verified — Velero never tests a restore</span>
|
|
382
|
+
))}
|
|
383
|
+
<TabLink tab="restores">Restores</TabLink>
|
|
384
|
+
</span>
|
|
385
|
+
{restoredBefore && (
|
|
386
|
+
<div>
|
|
387
|
+
<span>
|
|
388
|
+
Previous restore from this backup name:{' '}
|
|
389
|
+
<Link onClick={() => onNavigate?.(veleroResource('Restore', restoredBefore.namespace, restoredBefore.name))}>{restoredBefore.name}</Link>
|
|
390
|
+
<span className="text-theme-text-secondary">
|
|
391
|
+
{' · '}
|
|
392
|
+
{getRestoreStatus({ status: { phase: restoredBefore.phase } }).text.toLowerCase()}
|
|
393
|
+
{' · '}
|
|
394
|
+
<When iso={restoredBefore.completed ?? restoredBefore.started} fallback="time unknown" />
|
|
395
|
+
</span>
|
|
396
|
+
</span>
|
|
397
|
+
</div>
|
|
398
|
+
)}
|
|
399
|
+
</FactRow>
|
|
400
|
+
)}
|
|
401
|
+
</FactGrid>
|
|
402
|
+
</Card>
|
|
403
|
+
</>
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** The Restores tab's count: restores made from this backup. */
|
|
408
|
+
export function VeleroBackupRestoresMark({ namespace, name }: { namespace: string; name: string }) {
|
|
409
|
+
const query = useVeleroRuns('restores', namespace, { backup: name })
|
|
410
|
+
const n = query.data?.runs.length ?? 0
|
|
411
|
+
return n > 0 ? <span className="ml-1 badge-sm bg-theme-elevated">{n}</span> : null
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Restores made from one backup (spec.backupName). */
|
|
415
|
+
export function VeleroBackupRestores({ namespace, name, onNavigate }: { namespace: string; name: string; onNavigate?: NavigateToResource }) {
|
|
416
|
+
const query = useVeleroRuns('restores', namespace, { backup: name })
|
|
417
|
+
const rows = query.data?.runs ?? []
|
|
418
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
419
|
+
return (
|
|
420
|
+
<div className="space-y-3 p-4">
|
|
421
|
+
<RunsReadNotice query={query} noun="restores" />
|
|
422
|
+
<SectionTable
|
|
423
|
+
title="Restores from this backup"
|
|
424
|
+
subtitle="Restores made from this backup that Velero still keeps"
|
|
425
|
+
columns={[
|
|
426
|
+
{ header: 'Restore', cell: (r: VeleroRunRow) => <VeleroName name={r.name} middle /> },
|
|
427
|
+
{ header: 'Outcome', width: '170px', cell: (r: VeleroRunRow) => <OutcomeCell kind="Restore" run={r} counts={!wide} /> },
|
|
428
|
+
{ header: 'Into', width: wide ? '200px' : '160px', cell: (r: VeleroRestoreRow) => <RestoreIntoCell run={r} /> },
|
|
429
|
+
{ header: 'Started', width: '120px', cell: (r: VeleroRunRow) => <StartedCell run={r} folded={!wide} /> },
|
|
430
|
+
...(wide
|
|
431
|
+
? [
|
|
432
|
+
{ header: 'Took', width: '90px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
|
|
433
|
+
{ header: 'Errors · warnings', width: '140px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
|
|
434
|
+
]
|
|
435
|
+
: []),
|
|
436
|
+
]}
|
|
437
|
+
minWidth={wide ? 760 : 560}
|
|
438
|
+
rows={rows}
|
|
439
|
+
rowKey={(r) => r.uid || r.name}
|
|
440
|
+
rowResource={(r) => veleroResource('Restore', r.namespace, r.name)}
|
|
441
|
+
onInspect={onNavigate}
|
|
442
|
+
empty={runsEmpty(query, 'restores', 'No restores from this backup')}
|
|
443
|
+
/>
|
|
444
|
+
</div>
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// ---- Restore ------------------------------------------------------------
|
|
449
|
+
|
|
450
|
+
/** Where a restore puts things, each destination namespace a link. */
|
|
451
|
+
function RestoredIntoValue({ spec, onNavigate }: { spec: RestoreSelection; onNavigate?: NavigateToResource }) {
|
|
452
|
+
const { every, entries, excluded } = restoreTargets(spec)
|
|
453
|
+
const ns = (name: string) => <Link onClick={() => onNavigate?.(refToSelectedResource({ kind: 'Namespace', group: '', namespace: '', name }))}>{name}</Link>
|
|
454
|
+
const named = entries.map((e, i) => (
|
|
455
|
+
<Fragment key={e.from}>
|
|
456
|
+
{i > 0 && ', '}
|
|
457
|
+
{e.to ? (
|
|
458
|
+
<>
|
|
459
|
+
{e.from} → {ns(e.to)}
|
|
460
|
+
</>
|
|
461
|
+
) : (
|
|
462
|
+
ns(e.from)
|
|
463
|
+
)}
|
|
464
|
+
</Fragment>
|
|
465
|
+
))
|
|
466
|
+
return (
|
|
467
|
+
<>
|
|
468
|
+
{every ? (
|
|
469
|
+
<>
|
|
470
|
+
Every namespace in the backup
|
|
471
|
+
{entries.length > 0 && <>, with {named}</>}
|
|
472
|
+
</>
|
|
473
|
+
) : (
|
|
474
|
+
named
|
|
475
|
+
)}
|
|
476
|
+
{excluded.length > 0 && `, except ${excluded.join(', ')}`}
|
|
477
|
+
</>
|
|
478
|
+
)
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function VeleroRestoreOverview({ resource, onNavigate }: { resource: any; onNavigate?: NavigateToResource }) {
|
|
482
|
+
const namespace: string = resource?.metadata?.namespace ?? ''
|
|
483
|
+
const status = resource?.status ?? {}
|
|
484
|
+
const spec = resource?.spec ?? {}
|
|
485
|
+
const backupName = getRestoreBackupName(resource)
|
|
486
|
+
const mapping = getRestoreNamespaceMapping(resource)
|
|
487
|
+
const narrowed = selectionText(spec, '', 'restore').narrowed
|
|
488
|
+
const rejected = status.phase === 'FailedValidation'
|
|
489
|
+
const rawReason: string | undefined = rejected ? getRestoreValidationErrors(resource).join('; ') || undefined : undefined
|
|
490
|
+
const reason = veleroPlainReason(rawReason) ?? rawReason
|
|
491
|
+
// Velero counts every item it went through, including those it skipped or failed.
|
|
492
|
+
const progress = status.progress?.totalItems ? `${status.progress.itemsRestored ?? 0} of ${status.progress.totalItems} items processed` : undefined
|
|
493
|
+
const when = whenText(status)
|
|
494
|
+
const errors = getRestoreErrors(resource)
|
|
495
|
+
const warnings = getRestoreWarnings(resource)
|
|
496
|
+
return (
|
|
497
|
+
<Card title="At a glance">
|
|
498
|
+
<FactGrid>
|
|
499
|
+
{rejected ? (
|
|
500
|
+
<FactRow label="Restored">
|
|
501
|
+
<span className={toneTextClass('unhealthy')}>Nothing</span>
|
|
502
|
+
{' — Velero rejected it'}
|
|
503
|
+
{reason ? `: ${reason}` : ''}
|
|
504
|
+
{reason && rawReason && reason !== rawReason && <RawMessage message={rawReason} />}
|
|
505
|
+
</FactRow>
|
|
506
|
+
) : (
|
|
507
|
+
<FactRow label="Restored into">
|
|
508
|
+
<RestoredIntoValue spec={spec} onNavigate={onNavigate} />
|
|
509
|
+
<Note>
|
|
510
|
+
{declaredNote(narrowed)}
|
|
511
|
+
{Object.keys(mapping).length > 0 ? ' · unmapped namespaces keep their names' : ''}
|
|
512
|
+
</Note>
|
|
513
|
+
</FactRow>
|
|
514
|
+
)}
|
|
515
|
+
<FactRow label="Outcome">
|
|
516
|
+
<span className="inline-flex flex-wrap items-center gap-x-2 gap-y-1">
|
|
517
|
+
<Outcome badge={getRestoreStatus(resource)} />
|
|
518
|
+
{warnings > 0 && <span className={`text-xs ${toneTextClass('degraded')}`}>{plural(warnings, 'warning')}</span>}
|
|
519
|
+
{when && <span className="text-xs text-theme-text-secondary">{when}</span>}
|
|
520
|
+
</span>
|
|
521
|
+
{(progress || errors > 0) && (
|
|
522
|
+
<div className="mt-0.5 text-xs text-theme-text-secondary">
|
|
523
|
+
{progress}
|
|
524
|
+
{progress && errors > 0 && ' · '}
|
|
525
|
+
{errors > 0 && <span className={toneTextClass('unhealthy')}>{plural(errors, 'error')}</span>}
|
|
526
|
+
</div>
|
|
527
|
+
)}
|
|
528
|
+
<RunMessages kind="restores" resource={resource} />
|
|
529
|
+
</FactRow>
|
|
530
|
+
<FactRow label="From backup">
|
|
531
|
+
{backupName ? <Link onClick={() => onNavigate?.(veleroResource('Backup', namespace, backupName))}>{backupName}</Link> : spec.scheduleName ? `The newest backup of schedule ${spec.scheduleName}` : '—'}
|
|
532
|
+
</FactRow>
|
|
533
|
+
<FactRow label="Existing objects">
|
|
534
|
+
{spec.existingResourcePolicy === 'update' ? 'Update requested' : 'Left as they are (Velero’s default)'}
|
|
535
|
+
{spec.existingResourcePolicy === 'update' && <Note>Velero updates an existing object where it can, and reports a warning where it can’t.</Note>}
|
|
536
|
+
</FactRow>
|
|
537
|
+
</FactGrid>
|
|
538
|
+
</Card>
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// ---- Schedule -----------------------------------------------------------
|
|
543
|
+
|
|
544
|
+
// Recent runs shown as dots; the activity endpoint returns ten.
|
|
545
|
+
const RECENT_DOTS = 10
|
|
546
|
+
|
|
547
|
+
function runTone(phase: string | undefined): StatusTone {
|
|
548
|
+
return getBackupStatus({ status: { phase: phase ?? '' } }).level as StatusTone
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** The newest successful run, with a dot saying whether the newest run was it. */
|
|
552
|
+
function LastSuccess({ reading }: { reading: VeleroScheduleReading }) {
|
|
553
|
+
const runs = reading.runs
|
|
554
|
+
if (runs.read === 'unknown') return <span className="text-theme-text-tertiary">{VELERO_RUNS_UNKNOWN}</span>
|
|
555
|
+
const success = runs.newestCompleted
|
|
556
|
+
if (!success) {
|
|
557
|
+
if (veleroScheduleNeverRan(reading)) return <span className="text-theme-text-secondary">Never</span>
|
|
558
|
+
return (
|
|
559
|
+
<span className="inline-flex items-center gap-2">
|
|
560
|
+
<StatusDot tone="unknown" />
|
|
561
|
+
<span className="text-theme-text-secondary">{VELERO_NONE_KEPT_SHORT}</span>
|
|
562
|
+
</span>
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
const at = success.completed ?? success.ranAt
|
|
566
|
+
const newestFailed = !!runs.newest && runs.newest.name !== success.name && FAILED.has(runs.newest.phase ?? '')
|
|
567
|
+
return (
|
|
568
|
+
<span className="inline-flex flex-wrap items-center gap-x-2">
|
|
569
|
+
<StatusDot tone={newestFailed ? 'alert' : 'healthy'} />
|
|
570
|
+
<Tooltip content={`${success.name} · ${veleroLocalTime(at)}`}>
|
|
571
|
+
<span>{formatRelativeAgeTime(at)}</span>
|
|
572
|
+
</Tooltip>
|
|
573
|
+
{success.manual && (
|
|
574
|
+
<Tooltip content={VELERO_MANUAL_RUN_TITLE}>
|
|
575
|
+
<span className="text-xs text-theme-text-secondary">{VELERO_MANUAL_RUN}, not by the schedule</span>
|
|
576
|
+
</Tooltip>
|
|
577
|
+
)}
|
|
578
|
+
{newestFailed && <span className={`text-xs ${toneTextClass('alert')}`}>the newest run since then failed</span>}
|
|
579
|
+
</span>
|
|
580
|
+
)
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function RecentRunDots({ runs, namespace, onNavigate }: { runs: VeleroRun[]; namespace: string; onNavigate?: NavigateToResource }) {
|
|
584
|
+
return (
|
|
585
|
+
<span className="inline-flex flex-wrap items-center gap-0.5">
|
|
586
|
+
{runs.slice(0, RECENT_DOTS).map((run) => (
|
|
587
|
+
<Tooltip key={run.name} content={`${run.name} · ${getBackupStatus({ status: { phase: run.phase ?? '' } }).text} · ${formatRelativeAgeTime(run.ranAt)}`}>
|
|
588
|
+
<button type="button" onClick={() => onNavigate?.(veleroResource('Backup', namespace, run.name))} aria-label={`Open backup ${run.name}`} className="rounded-full p-1 hover:bg-theme-hover">
|
|
589
|
+
<StatusDot tone={runTone(run.phase)} />
|
|
590
|
+
</button>
|
|
591
|
+
</Tooltip>
|
|
592
|
+
))}
|
|
593
|
+
</span>
|
|
594
|
+
)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/** Counts by outcome: "all completed", or "40 completed · 6 failed or partially failed". */
|
|
598
|
+
function outcomeCounts(runs: VeleroRunRow[]): string {
|
|
599
|
+
const completed = runs.filter((r) => r.phase === 'Completed').length
|
|
600
|
+
const failed = runs.filter((r) => FAILED.has(r.phase ?? '')).length
|
|
601
|
+
const other = runs.length - completed - failed
|
|
602
|
+
if (runs.length > 0 && completed === runs.length) return 'all completed'
|
|
603
|
+
return [`${completed} completed`, failed ? `${failed} failed or partially failed` : '', other ? `${other} other` : ''].filter(Boolean).join(' · ')
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function readInPart(query: { data?: VeleroRunsResponse }): boolean {
|
|
607
|
+
return !!query.data && (INCOMPLETE_COVERAGE_STATES.has(query.data.coverage.state) || !!query.data.truncated)
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* A read that returned no inventory at all (no access, not cached, still
|
|
612
|
+
* loading, failed): its empty list says nothing, so no count or lower bound
|
|
613
|
+
* is drawn from it. A partial read still bounds the count from below.
|
|
614
|
+
*/
|
|
615
|
+
function readNothing(query: { data?: VeleroRunsResponse }): boolean {
|
|
616
|
+
const state = query.data?.coverage.state
|
|
617
|
+
return !!state && state !== 'full' && state !== 'partial'
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function VeleroScheduleOverview({ resource, onNavigate }: { resource: any; onNavigate?: NavigateToResource }) {
|
|
621
|
+
const namespace: string = resource?.metadata?.namespace ?? ''
|
|
622
|
+
const name: string = resource?.metadata?.name ?? ''
|
|
623
|
+
const { support } = useRadarFeature('veleroWorkspace')
|
|
624
|
+
const activity = useVeleroScheduleActivity(namespace, name, { enabled: support === 'supported' })
|
|
625
|
+
const workspace = useWorkspace()
|
|
626
|
+
const query = useVeleroRuns('backups', namespace, { schedule: name })
|
|
627
|
+
const runs = query.data?.runs ?? []
|
|
628
|
+
const reading: VeleroScheduleReading | undefined = activity.data?.reading
|
|
629
|
+
const template = resource?.spec?.template ?? {}
|
|
630
|
+
const locationName: string = template.storageLocation || reading?.location?.name || ''
|
|
631
|
+
const selection = selectionText(template, 'All namespaces')
|
|
632
|
+
const partial = readInPart(query)
|
|
633
|
+
const kept = reading && reading.runs.read !== 'unknown' ? reading.runs.kept : runs.length
|
|
634
|
+
const dueNow = reading?.state === 'due' && reading.reason !== 'serverDown'
|
|
635
|
+
const cron: string = reading?.cron ?? resource?.spec?.schedule ?? ''
|
|
636
|
+
const cadence = veleroCadenceText(cron)
|
|
637
|
+
// The banner above already says why it needs attention; the rows don't repeat it.
|
|
638
|
+
const inBanner = !!workspace.data?.schedules.find((s) => s.namespace === namespace && s.name === name)?.attention
|
|
639
|
+
return (
|
|
640
|
+
<>
|
|
641
|
+
<RefreshFailedNotice queries={[activity, query]} />
|
|
642
|
+
{activity.error && !reading && <LookupFailureNote errors={[activity.error]} what="this schedule’s activity" />}
|
|
643
|
+
<Card title="At a glance">
|
|
644
|
+
<FactGrid>
|
|
645
|
+
<FactRow label="Runs">
|
|
646
|
+
{cadence ?? <span className="font-mono text-sm">{cron || '—'}</span>}
|
|
647
|
+
{reading && (
|
|
648
|
+
<>
|
|
649
|
+
<span className="text-theme-text-tertiary"> · </span>
|
|
650
|
+
<VeleroZoneValue zone={reading.zone} />
|
|
651
|
+
</>
|
|
652
|
+
)}
|
|
653
|
+
{cadence && <div className="font-mono text-xs text-theme-text-tertiary">{cron}</div>}
|
|
654
|
+
</FactRow>
|
|
655
|
+
{reading && (
|
|
656
|
+
<>
|
|
657
|
+
<FactRow label="Last success">
|
|
658
|
+
<LastSuccess reading={reading} />
|
|
659
|
+
</FactRow>
|
|
660
|
+
<FactRow label="Next run">
|
|
661
|
+
{reading.nextRun ? (
|
|
662
|
+
<>
|
|
663
|
+
<Tooltip content={veleroNextRunTitle(reading)}>
|
|
664
|
+
<span>{dueNow ? 'due now' : veleroNextRunText(reading)}</span>
|
|
665
|
+
</Tooltip>
|
|
666
|
+
<span className="ml-2 text-xs text-theme-text-tertiary">{veleroLocalTime(reading.nextRun)}</span>
|
|
667
|
+
</>
|
|
668
|
+
) : (
|
|
669
|
+
<span className="text-theme-text-tertiary">None</span>
|
|
670
|
+
)}
|
|
671
|
+
{!dueNow && reading.state !== 'onSchedule' && !inBanner && <Note>{veleroScheduleReasonText(reading, { created: resource?.metadata?.creationTimestamp })}</Note>}
|
|
672
|
+
</FactRow>
|
|
673
|
+
<FactRow label="Recent runs">
|
|
674
|
+
{reading.runs.read === 'unknown' ? (
|
|
675
|
+
<span className="text-theme-text-tertiary">{VELERO_RUNS_UNKNOWN}</span>
|
|
676
|
+
) : (reading.runs.recent ?? []).length === 0 ? (
|
|
677
|
+
<span className="text-theme-text-secondary">{veleroScheduleNeverRan(reading) ? 'None' : VELERO_NONE_KEPT_SHORT}</span>
|
|
678
|
+
) : (
|
|
679
|
+
<span className="inline-flex flex-wrap items-center gap-x-3">
|
|
680
|
+
<RecentRunDots runs={reading.runs.recent ?? []} namespace={namespace} onNavigate={onNavigate} />
|
|
681
|
+
<TabLink tab="runs">All {kept} runs</TabLink>
|
|
682
|
+
</span>
|
|
683
|
+
)}
|
|
684
|
+
</FactRow>
|
|
685
|
+
</>
|
|
686
|
+
)}
|
|
687
|
+
<FactRow label="Covers">
|
|
688
|
+
{selection.text}
|
|
689
|
+
<Note>{declaredNote(selection.narrowed)}</Note>
|
|
690
|
+
</FactRow>
|
|
691
|
+
<FactRow label="Stored in">
|
|
692
|
+
{locationName ? (
|
|
693
|
+
<>
|
|
694
|
+
<LocationValue name={locationName} namespace={namespace} workspace={workspace.data} onNavigate={onNavigate} />
|
|
695
|
+
{!template.storageLocation && <Note>The installation’s default; the schedule names none</Note>}
|
|
696
|
+
</>
|
|
697
|
+
) : (
|
|
698
|
+
<span className="text-theme-text-secondary">The default storage location, which could not be read</span>
|
|
699
|
+
)}
|
|
700
|
+
</FactRow>
|
|
701
|
+
<FactRow label="Each run kept for">{veleroDeclaredRetention(template.ttl) ?? VELERO_SERVER_DEFAULT_RETENTION}</FactRow>
|
|
702
|
+
<FactRow label="Runs Velero keeps">
|
|
703
|
+
{query.isPending ? (
|
|
704
|
+
'Loading…'
|
|
705
|
+
) : !query.data ? (
|
|
706
|
+
<span className="text-theme-text-secondary">Not read: {(query.error as Error | null)?.message}</span>
|
|
707
|
+
) : readNothing(query) ? (
|
|
708
|
+
<span className="text-theme-text-tertiary">Unknown — {coverageLabel(query.data.coverage)}</span>
|
|
709
|
+
) : kept === 0 && runs.length === 0 && !partial ? (
|
|
710
|
+
'None'
|
|
711
|
+
) : (
|
|
712
|
+
<>
|
|
713
|
+
{partial ? `At least ${Math.max(kept, runs.length)}` : kept} kept · {outcomeCounts(runs)}
|
|
714
|
+
{partial && ` among the ${runs.length} Radar read`}
|
|
715
|
+
<Note>Expired runs are eligible for garbage collection, so this history can have gaps.</Note>
|
|
716
|
+
</>
|
|
717
|
+
)}
|
|
718
|
+
</FactRow>
|
|
719
|
+
</FactGrid>
|
|
720
|
+
</Card>
|
|
721
|
+
</>
|
|
722
|
+
)
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** A red dot on a tab whose list holds failed runs. */
|
|
726
|
+
function FailedMark({ count, shown }: { count: number; shown?: number }) {
|
|
727
|
+
if (count === 0) return null
|
|
728
|
+
const label = `${count} failed${shown === undefined ? '' : ` among the newest ${shown}`}`
|
|
729
|
+
return (
|
|
730
|
+
<Tooltip content={label} position="bottom">
|
|
731
|
+
<span role="img" aria-label={label} className="ml-1 inline-flex shrink-0">
|
|
732
|
+
<StatusDot tone="unhealthy" />
|
|
733
|
+
</span>
|
|
734
|
+
</Tooltip>
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/** The Runs tab's mark: some of the schedule's runs failed. */
|
|
739
|
+
export function VeleroScheduleRunsMark({ namespace, name }: { namespace: string; name: string }) {
|
|
740
|
+
const query = useVeleroRuns('backups', namespace, { schedule: name })
|
|
741
|
+
return <FailedMark count={(query.data?.runs ?? []).filter((r) => FAILED.has(r.phase ?? '')).length} />
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/** Every run of a schedule Velero still keeps, newest first, with the failed ones a segment away. */
|
|
745
|
+
export function VeleroScheduleRuns({ namespace, name, onNavigate }: { namespace: string; name: string; onNavigate?: NavigateToResource }) {
|
|
746
|
+
const query = useVeleroRuns('backups', namespace, { schedule: name })
|
|
747
|
+
const runs = query.data?.runs ?? []
|
|
748
|
+
const { failed, view, setView, shown } = useRunView(runs)
|
|
749
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
750
|
+
return (
|
|
751
|
+
<div className="space-y-3 p-4">
|
|
752
|
+
<Segments label="Runs" value={view} onChange={setView} options={runViewOptions(failed.length, runs.length, query)} />
|
|
753
|
+
<RunsReadNotice query={query} noun="backups" />
|
|
754
|
+
<SectionTable
|
|
755
|
+
columns={[
|
|
756
|
+
{
|
|
757
|
+
header: 'Run',
|
|
758
|
+
cell: (r: VeleroRunRow) => (
|
|
759
|
+
<>
|
|
760
|
+
<VeleroName name={r.name} middle />
|
|
761
|
+
{r.manual && (
|
|
762
|
+
<Tooltip content={VELERO_MANUAL_RUN_TITLE}>
|
|
763
|
+
<span className="block text-xs text-theme-text-secondary">{VELERO_MANUAL_RUN}</span>
|
|
764
|
+
</Tooltip>
|
|
765
|
+
)}
|
|
766
|
+
</>
|
|
767
|
+
),
|
|
768
|
+
},
|
|
769
|
+
{ header: 'Outcome', width: '170px', cell: (r: VeleroRunRow) => <OutcomeCell kind="Backup" run={r} counts={!wide} /> },
|
|
770
|
+
{ header: 'Started', width: wide ? '110px' : '170px', cell: (r: VeleroRunRow) => <StartedCell run={r} folded={!wide} items expires /> },
|
|
771
|
+
...(wide
|
|
772
|
+
? [
|
|
773
|
+
{ header: 'Took', width: '80px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
|
|
774
|
+
{ header: 'Items', width: '90px', cell: (r: VeleroRunRow) => (r.itemsTotal ? `${r.itemsDone ?? 0} / ${r.itemsTotal}` : '—') },
|
|
775
|
+
{ header: 'Errors · warnings', width: '130px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
|
|
776
|
+
{ header: 'Expires', width: '100px', cell: (r: VeleroRunRow) => <Expires iso={r.expiration} /> },
|
|
777
|
+
]
|
|
778
|
+
: []),
|
|
779
|
+
]}
|
|
780
|
+
rows={shown}
|
|
781
|
+
rowKey={(r) => r.uid || r.name}
|
|
782
|
+
rowResource={(r) => veleroResource('Backup', r.namespace, r.name)}
|
|
783
|
+
onInspect={onNavigate}
|
|
784
|
+
minWidth={wide ? 900 : 500}
|
|
785
|
+
empty={runsEmpty(query, 'backups', view === 'failed' ? 'No failed runs among those Velero keeps' : 'No runs kept')}
|
|
786
|
+
footer="This schedule’s backups that Velero still keeps (by the velero.io/schedule-name label)."
|
|
787
|
+
/>
|
|
788
|
+
</div>
|
|
789
|
+
)
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// ---- Storage location ---------------------------------------------------
|
|
793
|
+
|
|
794
|
+
const PROVIDER_SCHEME: Record<string, string> = { aws: 's3://', gcp: 'gs://' }
|
|
795
|
+
|
|
796
|
+
/** "s3://bucket/prefix" for the providers with a URL scheme; otherwise "bucket/prefix". */
|
|
797
|
+
function bucketText(provider: string | undefined, bucket: string | undefined, prefix: string | undefined): string {
|
|
798
|
+
if (!bucket) return ''
|
|
799
|
+
const scheme = PROVIDER_SCHEME[(provider ?? '').replace(/^velero\.io\//, '')] ?? ''
|
|
800
|
+
return `${scheme}${bucket}${prefix ? `/${prefix.replace(/^\/+/, '')}` : ''}`
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** The failed backups among those naming a location, when the list Radar holds is all of them. */
|
|
804
|
+
function useLocationBackups(namespace: string, name: string) {
|
|
805
|
+
const stored = useVeleroStoredBackups(namespace, name)
|
|
806
|
+
const failed = (stored.data?.backups ?? []).filter((b) => FAILED.has(b.phase ?? '')).length
|
|
807
|
+
return { stored, failed }
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/** "48 backups · 30 completed · 16 expired · 2 failed". */
|
|
811
|
+
function LocationBackupCounts({ loc, namespace, name, unavailable }: { loc?: VeleroLocationReading; namespace: string; name: string; unavailable: boolean }) {
|
|
812
|
+
const { stored, failed } = useLocationBackups(namespace, name)
|
|
813
|
+
const d = stored.data
|
|
814
|
+
const counts = d
|
|
815
|
+
? { total: d.stored ?? d.backups.length, usable: d.restorable, expired: d.expired ?? 0, exact: !d.truncated }
|
|
816
|
+
: loc?.backups
|
|
817
|
+
? { total: loc.backups.targeting, usable: loc.backups.completedNotExpired, expired: loc.backups.expired, exact: false }
|
|
818
|
+
: null
|
|
819
|
+
if (!counts) return <span className="text-theme-text-secondary">Backups not read</span>
|
|
820
|
+
const rest = Math.max(0, counts.total - counts.usable - counts.expired)
|
|
821
|
+
const tail = counts.exact
|
|
822
|
+
? [failed ? <span key="f" className={toneTextClass('unhealthy')}>{failed} failed</span> : null, rest - failed > 0 ? `${rest - failed} not finished` : null]
|
|
823
|
+
: [rest ? `${rest} failed or not finished` : null]
|
|
824
|
+
const parts: ReactNode[] = [plural(counts.total, 'backup'), `${counts.usable} completed`, `${counts.expired} expired`, ...tail].filter(Boolean)
|
|
825
|
+
return (
|
|
826
|
+
<>
|
|
827
|
+
<span className="inline-flex flex-wrap items-baseline gap-x-3">
|
|
828
|
+
<span>
|
|
829
|
+
{parts.map((p, i) => (
|
|
830
|
+
<span key={i}>
|
|
831
|
+
{i > 0 && ' · '}
|
|
832
|
+
{p}
|
|
833
|
+
</span>
|
|
834
|
+
))}
|
|
835
|
+
</span>
|
|
836
|
+
{counts.total > 0 && <TabLink tab="backups">Backups</TabLink>}
|
|
837
|
+
</span>
|
|
838
|
+
{unavailable && counts.usable > 0 && (
|
|
839
|
+
<div className={`text-xs ${toneTextClass('unhealthy')}`}>None of them can be restored while the location is unavailable: Velero refuses a restore from it.</div>
|
|
840
|
+
)}
|
|
841
|
+
<Note>Counted from the Backup objects that name this location, not from what is in the bucket. Completed: completed and inside their retention.</Note>
|
|
842
|
+
</>
|
|
843
|
+
)
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
function VeleroLocationOverview({ resource, onNavigate }: { resource: any; onNavigate?: NavigateToResource }) {
|
|
847
|
+
const namespace: string = resource?.metadata?.namespace ?? ''
|
|
848
|
+
const name: string = resource?.metadata?.name ?? ''
|
|
849
|
+
const workspace = useWorkspace()
|
|
850
|
+
const loc = workspace.data?.locations.find((l) => l.namespace === namespace && l.name === name)
|
|
851
|
+
const installation = workspace.data?.installations.find((i) => i.namespace === namespace)
|
|
852
|
+
const phase: string | undefined = loc?.phase ?? resource?.status?.phase
|
|
853
|
+
const tone: StatusTone = phase === 'Available' ? 'healthy' : phase === 'Unavailable' ? 'unhealthy' : 'unknown'
|
|
854
|
+
const message: string | undefined = loc?.message ?? resource?.status?.message
|
|
855
|
+
const plain = phase === 'Unavailable' ? veleroPlainReason(message) : undefined
|
|
856
|
+
const lastSynced: string | undefined = resource?.status?.lastSyncedTime
|
|
857
|
+
const spec = resource?.spec ?? {}
|
|
858
|
+
const objectStorage = spec.objectStorage ?? {}
|
|
859
|
+
const def = loc ? veleroDefaultText(loc) : null
|
|
860
|
+
const otherDefault = installation?.defaultLocation && installation.defaultLocation !== name ? installation.defaultLocation : undefined
|
|
861
|
+
return (
|
|
862
|
+
<>
|
|
863
|
+
<RefreshFailedNotice queries={[workspace]} />
|
|
864
|
+
<Card title="At a glance">
|
|
865
|
+
<FactGrid>
|
|
866
|
+
<FactRow label="Availability">
|
|
867
|
+
<span className="inline-flex items-center gap-2">
|
|
868
|
+
<StatusDot tone={tone} />
|
|
869
|
+
<span className={toneTextClass(tone)}>{phase ?? 'Not validated yet'}</span>
|
|
870
|
+
</span>
|
|
871
|
+
{plain && <div className={`text-sm ${toneTextClass('unhealthy')}`}>{plain}</div>}
|
|
872
|
+
{message && (plain ? <RawMessage message={message} /> : <Note>{message}</Note>)}
|
|
873
|
+
</FactRow>
|
|
874
|
+
<FactRow label="Validation">
|
|
875
|
+
{loc ? (
|
|
876
|
+
<>
|
|
877
|
+
{/* Velero stamps the time of each attempt, whether or not the location passed. */}
|
|
878
|
+
{!loc.lastValidation ? (
|
|
879
|
+
'Never validated'
|
|
880
|
+
) : phase === 'Unavailable' ? (
|
|
881
|
+
<>
|
|
882
|
+
Last checked {veleroMomentText(loc.lastValidation)} — <span className={toneTextClass('unhealthy')}>failed</span>
|
|
883
|
+
</>
|
|
884
|
+
) : (
|
|
885
|
+
`Last validated ${veleroMomentText(loc.lastValidation)}`
|
|
886
|
+
)}
|
|
887
|
+
<Note>
|
|
888
|
+
{!loc.frequency ? 'Validation interval not known' : loc.frequency.disabled ? 'Recurring validation is off' : `Every ${veleroFrequencyText(loc.frequency.seconds)}`}
|
|
889
|
+
{lastSynced && (
|
|
890
|
+
<>
|
|
891
|
+
{' · '}
|
|
892
|
+
<Tooltip content={`${veleroLocalTime(lastSynced)} · when Velero last tried to sync the backups in the bucket into the cluster`}>
|
|
893
|
+
<span>last sync attempt {formatRelativeAgeTime(lastSynced)}</span>
|
|
894
|
+
</Tooltip>
|
|
895
|
+
</>
|
|
896
|
+
)}
|
|
897
|
+
{(loc.validationOverdue || loc.neverValidated) && ` · ${veleroLocationReasonText(loc)}`}
|
|
898
|
+
</Note>
|
|
899
|
+
</>
|
|
900
|
+
) : (
|
|
901
|
+
<span className="text-theme-text-secondary">Not read</span>
|
|
902
|
+
)}
|
|
903
|
+
</FactRow>
|
|
904
|
+
<FactRow label="Default">
|
|
905
|
+
{!def ? (
|
|
906
|
+
<span className="text-theme-text-secondary">Not read</span>
|
|
907
|
+
) : def.text === 'Yes' ? (
|
|
908
|
+
<Tooltip content={def.detail}>
|
|
909
|
+
<span>Yes · {loc?.defaultSource === 'spec' ? 'set on this location' : 'named by the Velero server'}</span>
|
|
910
|
+
</Tooltip>
|
|
911
|
+
) : def.text === 'No' && otherDefault ? (
|
|
912
|
+
<span>
|
|
913
|
+
No —{' '}
|
|
914
|
+
<Link onClick={() => onNavigate?.(veleroResource('BackupStorageLocation', namespace, otherDefault))}>{otherDefault}</Link>{' '}
|
|
915
|
+
<Tooltip content={def.detail}>
|
|
916
|
+
<span>is the default location</span>
|
|
917
|
+
</Tooltip>
|
|
918
|
+
</span>
|
|
919
|
+
) : (
|
|
920
|
+
<>
|
|
921
|
+
{def.text}
|
|
922
|
+
<Note>{def.detail}</Note>
|
|
923
|
+
</>
|
|
924
|
+
)}
|
|
925
|
+
</FactRow>
|
|
926
|
+
<FactRow label="Access">{spec.accessMode === 'ReadOnly' ? 'Read-only: Velero writes no backups here and deletes none' : 'Read-write'}</FactRow>
|
|
927
|
+
<FactRow label="Bucket">{[spec.provider, bucketText(spec.provider, objectStorage.bucket, objectStorage.prefix)].filter(Boolean).join(' · ') || '—'}</FactRow>
|
|
928
|
+
<FactRow label="Backups targeting it">
|
|
929
|
+
<LocationBackupCounts loc={loc} namespace={namespace} name={name} unavailable={phase === 'Unavailable'} />
|
|
930
|
+
</FactRow>
|
|
931
|
+
<FactRow label="Written to by">
|
|
932
|
+
{loc?.schedules == null ? (
|
|
933
|
+
<span className="text-theme-text-secondary">Schedules not read</span>
|
|
934
|
+
) : loc.schedules.length === 0 ? (
|
|
935
|
+
'No schedule'
|
|
936
|
+
) : (
|
|
937
|
+
<span className="flex flex-wrap gap-x-3">
|
|
938
|
+
{loc.schedules.map((s) => (
|
|
939
|
+
<Link key={s.name} onClick={() => onNavigate?.(veleroResource('Schedule', namespace, s.name))}>
|
|
940
|
+
{s.name}
|
|
941
|
+
{s.viaDefault ? ' (as the default)' : ''}
|
|
942
|
+
</Link>
|
|
943
|
+
))}
|
|
944
|
+
</span>
|
|
945
|
+
)}
|
|
946
|
+
</FactRow>
|
|
947
|
+
</FactGrid>
|
|
948
|
+
</Card>
|
|
949
|
+
</>
|
|
950
|
+
)
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/** The Backups tab's mark: some backups naming the location failed. */
|
|
954
|
+
export function VeleroLocationBackupsMark({ namespace, name }: { namespace: string; name: string }) {
|
|
955
|
+
const { stored, failed } = useLocationBackups(namespace, name)
|
|
956
|
+
return <FailedMark count={failed} shown={stored.data?.truncated ? stored.data.backups.length : undefined} />
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/** The backups that name a location, newest first, with the failed ones a segment away. */
|
|
960
|
+
export function VeleroLocationBackups({ namespace, name, onNavigate }: { namespace: string; name: string; onNavigate?: NavigateToResource }) {
|
|
961
|
+
const stored = useVeleroStoredBackups(namespace, name)
|
|
962
|
+
const rows = stored.data?.backups ?? []
|
|
963
|
+
const failed = rows.filter((b) => FAILED.has(b.phase ?? ''))
|
|
964
|
+
const [view, setView] = useState<'all' | 'failed'>('all')
|
|
965
|
+
const shown = view === 'failed' ? failed : rows
|
|
966
|
+
const partial = !!stored.data?.truncated
|
|
967
|
+
const failedCount = partial ? `${failed.length} shown` : String(failed.length)
|
|
968
|
+
return (
|
|
969
|
+
<div className="space-y-3 p-4">
|
|
970
|
+
<Segments
|
|
971
|
+
label="Backups"
|
|
972
|
+
value={view}
|
|
973
|
+
onChange={setView}
|
|
974
|
+
options={[
|
|
975
|
+
{ id: 'all' as const, label: 'All', count: String(stored.data?.stored ?? rows.length) },
|
|
976
|
+
{ id: 'failed' as const, label: 'Failed', count: failed.length > 0 ? <span className={toneTextClass('unhealthy')}>{failedCount}</span> : failedCount },
|
|
977
|
+
]}
|
|
978
|
+
/>
|
|
979
|
+
{stored.error && stored.data && <Notice>The last refresh failed ({(stored.error as Error).message}); what is shown is from before it.</Notice>}
|
|
980
|
+
<SectionTable
|
|
981
|
+
title="Backups targeting this location"
|
|
982
|
+
subtitle={
|
|
983
|
+
stored.data
|
|
984
|
+
? `${stored.data.stored ?? rows.length} · ${stored.data.restorable} completed · ${stored.data.expired ?? 0} expired · ${failed.length} failed${partial ? ` among the newest ${rows.length}` : ''}`
|
|
985
|
+
: undefined
|
|
986
|
+
}
|
|
987
|
+
columns={[
|
|
988
|
+
{
|
|
989
|
+
header: 'Backup',
|
|
990
|
+
cell: (b) => (
|
|
991
|
+
<>
|
|
992
|
+
<VeleroName name={b.name} middle />
|
|
993
|
+
{b.manual && (
|
|
994
|
+
<Tooltip content={VELERO_MANUAL_RUN_TITLE}>
|
|
995
|
+
<span className="block text-xs text-theme-text-secondary">{VELERO_MANUAL_RUN}</span>
|
|
996
|
+
</Tooltip>
|
|
997
|
+
)}
|
|
998
|
+
</>
|
|
999
|
+
),
|
|
1000
|
+
},
|
|
1001
|
+
{ header: 'Outcome', width: '160px', cell: (b) => <RunOutcome kind="Backup" phase={b.phase} /> },
|
|
1002
|
+
{ header: 'Finished', width: '140px', cell: (b) => <When iso={b.completed} fallback="—" /> },
|
|
1003
|
+
{ header: 'Expires', width: '130px', cell: (b) => <Expires iso={b.expiration} /> },
|
|
1004
|
+
]}
|
|
1005
|
+
rows={shown}
|
|
1006
|
+
rowKey={(b) => b.name}
|
|
1007
|
+
rowResource={(b) => veleroResource('Backup', b.namespace, b.name)}
|
|
1008
|
+
onInspect={onNavigate}
|
|
1009
|
+
minWidth={560}
|
|
1010
|
+
empty={
|
|
1011
|
+
stored.isPending
|
|
1012
|
+
? 'Loading backups…'
|
|
1013
|
+
: stored.error && !stored.data
|
|
1014
|
+
? `Backups could not be read: ${(stored.error as Error).message}`
|
|
1015
|
+
: view === 'failed'
|
|
1016
|
+
? partial ? `No failed backups among the newest ${rows.length} at this location.` : 'No failed backups name this location.'
|
|
1017
|
+
: 'No backups name this location.'
|
|
1018
|
+
}
|
|
1019
|
+
footer={stored.data?.truncated ? `The newest ${rows.length} of ${stored.data.stored}.` : 'Counted from the Backup objects that name this location, not from what is in the bucket.'}
|
|
1020
|
+
/>
|
|
1021
|
+
</div>
|
|
1022
|
+
)
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* The composed Overview of a Velero object, led by Velero's issues for it: on
|
|
1027
|
+
* its page, and in the drawer beside Spec & status, as CloudNativePG's is.
|
|
1028
|
+
*/
|
|
1029
|
+
export function renderVeleroSummary({ apiKind, resource, context, onNavigate, leadContent }: { apiKind: string; resource: any; context: 'drawer' | 'expanded'; onNavigate?: NavigateToResource; leadContent?: ReactNode }) {
|
|
1030
|
+
if (!resource) return null
|
|
1031
|
+
const body = (() => {
|
|
1032
|
+
switch (apiKind) {
|
|
1033
|
+
case 'backups':
|
|
1034
|
+
return <VeleroBackupOverview resource={resource} onNavigate={onNavigate} />
|
|
1035
|
+
case 'restores':
|
|
1036
|
+
return <VeleroRestoreOverview resource={resource} onNavigate={onNavigate} />
|
|
1037
|
+
case 'schedules':
|
|
1038
|
+
return <VeleroScheduleOverview resource={resource} onNavigate={onNavigate} />
|
|
1039
|
+
case 'backupstoragelocations':
|
|
1040
|
+
return <VeleroLocationOverview resource={resource} onNavigate={onNavigate} />
|
|
1041
|
+
default:
|
|
1042
|
+
return null
|
|
1043
|
+
}
|
|
1044
|
+
})()
|
|
1045
|
+
if (!body) return null
|
|
1046
|
+
const namespace: string = resource?.metadata?.namespace ?? ''
|
|
1047
|
+
const name: string = resource?.metadata?.name ?? ''
|
|
1048
|
+
return (
|
|
1049
|
+
<SummaryPlaceContext.Provider value={{ drawer: context === 'drawer', plural: apiKind, namespace, name }}>
|
|
1050
|
+
<div className="space-y-4 p-4">
|
|
1051
|
+
<PageLead kind={VELERO_DETAIL_KINDS[apiKind].kind} namespace={namespace} name={name} resource={resource} leadContent={leadContent} onNavigate={onNavigate} />
|
|
1052
|
+
{body}
|
|
1053
|
+
</div>
|
|
1054
|
+
</SummaryPlaceContext.Provider>
|
|
1055
|
+
)
|
|
1056
|
+
}
|