@skyhook-io/radar-app 1.20.3 → 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 +54 -10
- 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 +7 -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/NamespaceSwitcher.tsx +3 -1
- 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/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/GitOpsView.tsx +1 -1
- 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 +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/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,485 @@
|
|
|
1
|
+
import { useMemo, useState, type ReactNode } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Collapse,
|
|
4
|
+
CollapseChevron,
|
|
5
|
+
ProblemList,
|
|
6
|
+
StatusDot,
|
|
7
|
+
Tooltip,
|
|
8
|
+
VELERO_MANUAL_RUN,
|
|
9
|
+
VELERO_MANUAL_RUN_TITLE,
|
|
10
|
+
VELERO_NONE_KEPT_SHORT,
|
|
11
|
+
VELERO_RUNS_UNKNOWN,
|
|
12
|
+
VeleroScheduleStateBadge,
|
|
13
|
+
formatRelativeAgeTime,
|
|
14
|
+
veleroScheduleNeverRan,
|
|
15
|
+
veleroScheduleTone,
|
|
16
|
+
veleroLocalTime,
|
|
17
|
+
type ResourceRef,
|
|
18
|
+
type StatusTone,
|
|
19
|
+
type VeleroLocationReading,
|
|
20
|
+
type VeleroScheduleReading,
|
|
21
|
+
type WorkspaceProblem,
|
|
22
|
+
} from '@skyhook-io/k8s-ui'
|
|
23
|
+
import { refToSelectedResource } from '../../utils/navigation'
|
|
24
|
+
import { ScreenBody, SectionTable, Sub, type TableColumn } from '../workspace/layout'
|
|
25
|
+
import { coverageEmpty } from '../workspace/coverage'
|
|
26
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
27
|
+
import { readInPart, veleroAttention, veleroAttentionPartial } from './attention'
|
|
28
|
+
import { VELERO_LOCATIONS_PATH, VELERO_SCHEDULES_PATH } from './routes'
|
|
29
|
+
import { KEPT_FOR_HEADER, KeptForCell, KeptForLine, NextRunCell } from './VeleroSchedules'
|
|
30
|
+
import { useMediaQuery } from '../../hooks/useMediaQuery'
|
|
31
|
+
import { namespacesNoScheduleIncludes, veleroSelectionProblem } from './coverage'
|
|
32
|
+
import {
|
|
33
|
+
VELERO_WIDE,
|
|
34
|
+
VeleroCoverageNotice,
|
|
35
|
+
VeleroName,
|
|
36
|
+
VeleroWorkspaceHeader,
|
|
37
|
+
WholeNames,
|
|
38
|
+
inInstallation,
|
|
39
|
+
namesAndMore,
|
|
40
|
+
veleroResource,
|
|
41
|
+
type VeleroScreenProps,
|
|
42
|
+
} from './shared'
|
|
43
|
+
|
|
44
|
+
export const VELERO_NOTHING_NEEDS_ATTENTION = 'Nothing needs attention.'
|
|
45
|
+
/** The same, when part of Velero could not be read: an empty list there proves less. */
|
|
46
|
+
export const VELERO_NOTHING_IN_WHAT_WAS_READ = 'Nothing in what Radar can read needs attention.'
|
|
47
|
+
|
|
48
|
+
// Rows shown across all groups before folding, so a burst of failed runs cannot
|
|
49
|
+
// push the server, schedule and storage groups off the screen. Every group
|
|
50
|
+
// shows at least its first row.
|
|
51
|
+
const ATTENTION_BUDGET = 8
|
|
52
|
+
|
|
53
|
+
type AttentionGroupId = 'server' | 'schedules' | 'storage' | 'runs'
|
|
54
|
+
|
|
55
|
+
const ATTENTION_GROUPS: { id: AttentionGroupId; title: string }[] = [
|
|
56
|
+
{ id: 'server', title: 'Velero server' },
|
|
57
|
+
{ id: 'schedules', title: 'Schedules' },
|
|
58
|
+
{ id: 'storage', title: 'Storage' },
|
|
59
|
+
{ id: 'runs', title: 'Backups and restores' },
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
const STORAGE_KINDS = new Set(['BackupStorageLocation', 'VolumeSnapshotLocation', 'BackupRepository'])
|
|
63
|
+
|
|
64
|
+
/** Which part of Velero a problem is about, the way an operator sorts them: the server, a schedule, storage, or a run. */
|
|
65
|
+
function attentionGroup(p: WorkspaceProblem): AttentionGroupId {
|
|
66
|
+
if (p.category === 'server') return 'server'
|
|
67
|
+
if (p.category === 'schedule' || p.subject.kind === 'Schedule') return 'schedules'
|
|
68
|
+
if (p.category === 'location' || STORAGE_KINDS.has(p.subject.kind)) return 'storage'
|
|
69
|
+
return 'runs'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** "Showing 50 of 120 issues in velero", per installation the server capped. */
|
|
73
|
+
function cappedIssueNotes(data: VeleroScreenProps['data'], shown: VeleroScreenProps['data']['issues'], installation: string | null): string[] {
|
|
74
|
+
const notes: string[] = []
|
|
75
|
+
for (const [ns, total] of Object.entries(data.issueTotals ?? {})) {
|
|
76
|
+
if (installation !== null && ns !== installation) continue
|
|
77
|
+
const count = shown.filter((i) => (i.namespace ?? '') === ns).length
|
|
78
|
+
if (total > count) notes.push(`Showing ${count} of ${total} issues in ${ns}, the newest.`)
|
|
79
|
+
}
|
|
80
|
+
return notes
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface SummaryFact {
|
|
84
|
+
label: string
|
|
85
|
+
value: ReactNode
|
|
86
|
+
tone: StatusTone
|
|
87
|
+
/** The kind list this fact summarises, opened from its label. */
|
|
88
|
+
list?: { path: string; title: string }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function serverFact(installations: VeleroScreenProps['data']['installations']): SummaryFact {
|
|
92
|
+
const read = installations.filter((i) => i.server.replicas !== undefined)
|
|
93
|
+
const down = read.filter((i) => i.server.replicas === 0)
|
|
94
|
+
// Kubernetes leaves readyReplicas out at zero, so absent reads as none ready.
|
|
95
|
+
const notReady = read.filter((i) => (i.server.replicas ?? 0) > 0 && !i.server.readyReplicas)
|
|
96
|
+
const where = (list: typeof installations) => (installations.length > 1 ? ` in ${list.map((i) => i.namespace).join(', ')}` : '')
|
|
97
|
+
if (installations.length === 0 || read.length === 0) return { label: 'Velero server', value: 'unknown', tone: 'unknown' }
|
|
98
|
+
if (down.length > 0) return { label: 'Velero server', value: `not running${where(down)}`, tone: 'unhealthy' }
|
|
99
|
+
if (notReady.length > 0) return { label: 'Velero server', value: `not ready${where(notReady)}`, tone: 'degraded' }
|
|
100
|
+
return { label: 'Velero server', value: read.length < installations.length ? 'running where Radar can read it' : 'running', tone: 'healthy' }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Whether a kind was read only in part, so a count of it is a lower bound and an empty list proves nothing. */
|
|
104
|
+
function schedulesFact(schedules: VeleroScheduleReading[], partial: boolean): SummaryFact {
|
|
105
|
+
if (schedules.length === 0) {
|
|
106
|
+
return partial ? { label: 'Schedules', value: 'unknown — not read', tone: 'unknown' } : { label: 'Schedules', value: 'none', tone: 'neutral' }
|
|
107
|
+
}
|
|
108
|
+
const of = partial ? `${schedules.length} Radar can read` : `${schedules.length}`
|
|
109
|
+
const needing = schedules.filter((s) => s.attention || s.state === 'rejected')
|
|
110
|
+
const paused = schedules.filter((s) => s.state === 'paused').length
|
|
111
|
+
const ofPaused = paused > 0 ? `${of}, ${paused} paused` : of
|
|
112
|
+
if (needing.length === 0) {
|
|
113
|
+
// A cron Radar cannot read is not known to be fine.
|
|
114
|
+
const unreadable = schedules.filter((s) => s.state === 'unknown').length
|
|
115
|
+
if (unreadable > 0) return { label: 'Schedules', value: `${ofPaused}, ${unreadable} with a cron Radar can’t read`, tone: 'unknown' }
|
|
116
|
+
return { label: 'Schedules', value: `${ofPaused}, none need attention`, tone: 'healthy' }
|
|
117
|
+
}
|
|
118
|
+
const worst = needing.some((s) => veleroScheduleTone(s) === 'unhealthy') ? 'unhealthy' : 'alert'
|
|
119
|
+
return { label: 'Schedules', value: `${needing.length} of ${of} need attention${paused > 0 ? `, ${paused} paused` : ''}`, tone: worst }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function newestBackupFact(schedules: VeleroScheduleReading[], schedulesPartial: boolean, onInspect: VeleroScreenProps['onInspect']): SummaryFact {
|
|
123
|
+
const label = 'Newest successful scheduled backup'
|
|
124
|
+
let newest: { at: string; namespace: string; name: string; manual?: boolean } | undefined
|
|
125
|
+
for (const s of schedules) {
|
|
126
|
+
const run = s.runs.newestCompleted
|
|
127
|
+
if (!run) continue
|
|
128
|
+
const at = run.completed ?? run.ranAt
|
|
129
|
+
if (!newest || Date.parse(at) > Date.parse(newest.at)) newest = { at, namespace: s.namespace, name: run.name, manual: run.manual }
|
|
130
|
+
}
|
|
131
|
+
// Schedules or their backups Radar could not read may hold a newer one.
|
|
132
|
+
const unread = schedulesPartial || schedules.some((s) => s.runs.read === 'unknown')
|
|
133
|
+
if (!newest) {
|
|
134
|
+
if (unread) return { label, value: schedulesPartial && schedules.length === 0 ? 'unknown — not read' : 'unknown — backups were not read', tone: 'unknown' }
|
|
135
|
+
return { label, value: schedules.length === 0 ? 'no schedules' : 'none kept', tone: schedules.length === 0 ? 'neutral' : 'alert' }
|
|
136
|
+
}
|
|
137
|
+
const run = newest
|
|
138
|
+
return {
|
|
139
|
+
label,
|
|
140
|
+
// An age is not a verdict: whether it is late is each schedule's state.
|
|
141
|
+
tone: 'neutral',
|
|
142
|
+
value: (
|
|
143
|
+
<Tooltip content={`${run.name} · ${veleroLocalTime(run.at)}${run.manual ? ` · ${VELERO_MANUAL_RUN_TITLE}` : ''}${unread ? ' · some schedules or their backups were not read' : ''}`}>
|
|
144
|
+
<button type="button" onClick={() => onInspect(veleroResource('Backup', run.namespace, run.name))} className="text-accent-text hover:underline">
|
|
145
|
+
{formatRelativeAgeTime(run.at)}
|
|
146
|
+
{run.manual && `, ${VELERO_MANUAL_RUN}`}
|
|
147
|
+
</button>
|
|
148
|
+
</Tooltip>
|
|
149
|
+
),
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function storageFact(locations: VeleroLocationReading[], partial: boolean): SummaryFact {
|
|
154
|
+
if (locations.length === 0) {
|
|
155
|
+
return partial ? { label: 'Storage', value: 'unknown — not read', tone: 'unknown' } : { label: 'Storage', value: 'no locations', tone: 'unhealthy' }
|
|
156
|
+
}
|
|
157
|
+
const available = locations.filter((l) => l.phase === 'Available').length
|
|
158
|
+
const unavailable = locations.filter((l) => l.phase === 'Unavailable').length
|
|
159
|
+
const tone: StatusTone = unavailable > 0 ? 'unhealthy' : available === locations.length ? 'healthy' : 'unknown'
|
|
160
|
+
const of = `${locations.length}${partial ? ' Radar can read' : ''}`
|
|
161
|
+
return { label: 'Storage', value: `${available} of ${of} ${locations.length === 1 && !partial ? 'location' : 'locations'} available`, tone }
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** One line answering "is Velero working?" before the detail below it. */
|
|
165
|
+
function VeleroSummary({ facts, onOpenList }: { facts: SummaryFact[]; onOpenList: (path: string) => void }) {
|
|
166
|
+
return (
|
|
167
|
+
<dl className="flex flex-wrap gap-x-7 gap-y-2 text-sm" aria-label="Velero at a glance">
|
|
168
|
+
{facts.map((f) => (
|
|
169
|
+
<div key={f.label} className="flex items-center gap-1.5">
|
|
170
|
+
<StatusDot tone={f.tone} />
|
|
171
|
+
<dt className="text-theme-text-tertiary">
|
|
172
|
+
{f.list ? (
|
|
173
|
+
<Tooltip content={f.list.title}>
|
|
174
|
+
<button type="button" onClick={() => onOpenList(f.list!.path)} className="text-accent-text hover:underline">
|
|
175
|
+
{f.label}
|
|
176
|
+
</button>
|
|
177
|
+
</Tooltip>
|
|
178
|
+
) : (
|
|
179
|
+
f.label
|
|
180
|
+
)}
|
|
181
|
+
:
|
|
182
|
+
</dt>
|
|
183
|
+
<dd className="font-medium text-theme-text-primary">
|
|
184
|
+
{f.list ? (
|
|
185
|
+
<button type="button" onClick={() => onOpenList(f.list!.path)} className="text-left hover:underline">
|
|
186
|
+
{f.value}
|
|
187
|
+
</button>
|
|
188
|
+
) : (
|
|
189
|
+
f.value
|
|
190
|
+
)}
|
|
191
|
+
</dd>
|
|
192
|
+
</div>
|
|
193
|
+
))}
|
|
194
|
+
</dl>
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function AttentionGroup({ id, title, problems, visible, onNavigate }: { id: string; title: string; problems: WorkspaceProblem[]; visible: number; onNavigate: (ref: ResourceRef) => void }) {
|
|
199
|
+
const [showAll, setShowAll] = useState(false)
|
|
200
|
+
const shown = problems.slice(0, visible)
|
|
201
|
+
const folded = problems.slice(visible)
|
|
202
|
+
const foldId = `velero-attention-${id}-more`
|
|
203
|
+
return (
|
|
204
|
+
<div>
|
|
205
|
+
<h3 className="mb-1 text-xs font-semibold uppercase tracking-wide text-theme-text-tertiary">
|
|
206
|
+
{title} <span className="font-normal">· {problems.length}</span>
|
|
207
|
+
</h3>
|
|
208
|
+
<ProblemList problems={shown} rootKind="" onNavigate={onNavigate} hideOrigin subjectFirst />
|
|
209
|
+
{folded.length > 0 && (
|
|
210
|
+
<>
|
|
211
|
+
<Collapse open={showAll} id={foldId}>
|
|
212
|
+
<div className="pt-2">
|
|
213
|
+
<ProblemList problems={folded} rootKind="" onNavigate={onNavigate} hideOrigin subjectFirst />
|
|
214
|
+
</div>
|
|
215
|
+
</Collapse>
|
|
216
|
+
<button
|
|
217
|
+
type="button"
|
|
218
|
+
aria-expanded={showAll}
|
|
219
|
+
aria-controls={foldId}
|
|
220
|
+
onClick={() => setShowAll((v) => !v)}
|
|
221
|
+
className="mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline"
|
|
222
|
+
>
|
|
223
|
+
<CollapseChevron open={showAll} />
|
|
224
|
+
{showAll ? 'Show fewer' : `Show ${folded.length} more`}
|
|
225
|
+
</button>
|
|
226
|
+
</>
|
|
227
|
+
)}
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const NAMES_SHOWN = 8
|
|
233
|
+
|
|
234
|
+
function CoverageRow({ tone, label, title, children }: { tone: StatusTone; label: string; title?: string; children: ReactNode }) {
|
|
235
|
+
return (
|
|
236
|
+
<div className="flex items-baseline gap-2 text-sm">
|
|
237
|
+
<span className="translate-y-[1px]"><StatusDot tone={tone} /></span>
|
|
238
|
+
<div className="min-w-0">
|
|
239
|
+
<span className="text-theme-text-tertiary">{title ? <Tooltip content={title}><span className="underline decoration-dotted underline-offset-2">{label}</span></Tooltip> : label}:</span>{' '}
|
|
240
|
+
<span className="text-theme-text-primary">{children}</span>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* What the schedules leave out, as information: namespaces no schedule's
|
|
248
|
+
* template selects, and schedules paused on purpose. Neither counts toward the
|
|
249
|
+
* attention badge.
|
|
250
|
+
*/
|
|
251
|
+
function ScheduleCoverage({ data, schedules, namespaces, onInspect }: { data: VeleroScreenProps['data']; schedules: VeleroScheduleReading[]; namespaces: VeleroNamespaceList; onInspect: VeleroScreenProps['onInspect'] }) {
|
|
252
|
+
// An empty list is not "every namespace is covered": the cluster always has some.
|
|
253
|
+
const namespaceList = Array.isArray(namespaces) && namespaces.length > 0 ? namespaces : undefined
|
|
254
|
+
const isError = namespaces === 'error'
|
|
255
|
+
const noneListed = Array.isArray(namespaces) && namespaces.length === 0
|
|
256
|
+
const invalid = useMemo(
|
|
257
|
+
() => data.schedules.flatMap((schedule) => {
|
|
258
|
+
const problem = veleroSelectionProblem(schedule)
|
|
259
|
+
return problem ? [{ schedule, problem }] : []
|
|
260
|
+
}),
|
|
261
|
+
[data.schedules],
|
|
262
|
+
)
|
|
263
|
+
const paused = schedules.filter((s) => s.state === 'paused')
|
|
264
|
+
const coverage = useMemo(() => {
|
|
265
|
+
// Every schedule Radar can see counts, whichever installation is picked:
|
|
266
|
+
// a namespace is backed up if any installation's schedule selects it.
|
|
267
|
+
if (!namespaceList || data.forcedNamespace || readInPart(data.coverage.schedules)) return undefined
|
|
268
|
+
return namespacesNoScheduleIncludes(namespaceList, data.schedules, data.installations.map((i) => i.namespace))
|
|
269
|
+
}, [namespaceList, data])
|
|
270
|
+
const unknown = !!data.forcedNamespace || readInPart(data.coverage.schedules)
|
|
271
|
+
if (!coverage && !unknown && !isError && !noneListed && invalid.length === 0 && paused.length === 0) return null
|
|
272
|
+
const leftOut = coverage && coverage.leftOut > 0 ? ' Kubernetes’ own namespaces and Velero’s are not listed.' : ''
|
|
273
|
+
const title = `Namespaces you can see that no schedule's template selects. A schedule counts even when it is paused or failing, or selects only some resources by label or kind.${leftOut}`
|
|
274
|
+
return (
|
|
275
|
+
<section aria-labelledby="velero-coverage">
|
|
276
|
+
<h2 id="velero-coverage" className="mb-2 text-sm font-semibold text-theme-text-primary">Coverage</h2>
|
|
277
|
+
<div className="space-y-1.5 rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
|
|
278
|
+
{unknown ? (
|
|
279
|
+
<CoverageRow tone="unknown" label="Namespaces not in any schedule" title={title}>
|
|
280
|
+
unknown, Radar can’t read every schedule
|
|
281
|
+
</CoverageRow>
|
|
282
|
+
) : isError ? (
|
|
283
|
+
<CoverageRow tone="unknown" label="Namespaces not in any schedule" title={title}>
|
|
284
|
+
unknown, Radar couldn’t list namespaces
|
|
285
|
+
</CoverageRow>
|
|
286
|
+
) : noneListed ? (
|
|
287
|
+
<CoverageRow tone="unknown" label="Namespaces not in any schedule" title={title}>
|
|
288
|
+
unknown, Radar listed no namespaces
|
|
289
|
+
</CoverageRow>
|
|
290
|
+
) : coverage && coverage.uncovered.length === 0 ? (
|
|
291
|
+
<CoverageRow tone="healthy" label="Namespaces not in any schedule" title={title}>
|
|
292
|
+
none
|
|
293
|
+
</CoverageRow>
|
|
294
|
+
) : coverage ? (
|
|
295
|
+
<CoverageRow tone="degraded" label="Namespaces not in any schedule" title={title}>
|
|
296
|
+
{coverage.uncovered.length > NAMES_SHOWN ? (
|
|
297
|
+
<Tooltip content={coverage.uncovered.join(', ')}>
|
|
298
|
+
<span><WholeNames text={namesAndMore(coverage.uncovered, NAMES_SHOWN)} /></span>
|
|
299
|
+
</Tooltip>
|
|
300
|
+
) : (
|
|
301
|
+
<WholeNames text={namesAndMore(coverage.uncovered, NAMES_SHOWN)} />
|
|
302
|
+
)}
|
|
303
|
+
</CoverageRow>
|
|
304
|
+
) : null}
|
|
305
|
+
{invalid.length > 0 && (
|
|
306
|
+
<CoverageRow tone="degraded" label="Selects nothing">
|
|
307
|
+
{invalid.map(({ schedule: s, problem }, i) => (
|
|
308
|
+
<span key={`${s.namespace}/${s.name}`}>
|
|
309
|
+
{i > 0 && '; '}
|
|
310
|
+
<button type="button" onClick={() => onInspect(veleroResource('Schedule', s.namespace, s.name))} className="font-mono text-accent-text hover:underline">
|
|
311
|
+
{s.name}
|
|
312
|
+
</button>
|
|
313
|
+
{`: ${problem}`}
|
|
314
|
+
</span>
|
|
315
|
+
))}
|
|
316
|
+
{' '}— Velero refuses {invalid.length === 1 ? 'this namespace selection' : 'these namespace selections'}, so {invalid.length === 1 ? 'it backs' : 'they back'} up nothing
|
|
317
|
+
</CoverageRow>
|
|
318
|
+
)}
|
|
319
|
+
{paused.length > 0 && (
|
|
320
|
+
<CoverageRow tone="neutral" label="Paused">
|
|
321
|
+
{paused.map((s, i) => (
|
|
322
|
+
<span key={`${s.namespace}/${s.name}`}>
|
|
323
|
+
{i > 0 && ', '}
|
|
324
|
+
<button type="button" onClick={() => onInspect(veleroResource('Schedule', s.namespace, s.name))} className="font-mono text-accent-text hover:underline">
|
|
325
|
+
{s.name}
|
|
326
|
+
</button>
|
|
327
|
+
</span>
|
|
328
|
+
))}
|
|
329
|
+
{' '}— no backups until {paused.length === 1 ? 'it is' : 'they are'} resumed
|
|
330
|
+
</CoverageRow>
|
|
331
|
+
)}
|
|
332
|
+
</div>
|
|
333
|
+
</section>
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function LastSuccessCell({ s }: { s: VeleroScheduleReading }) {
|
|
338
|
+
if (s.runs.read === 'unknown') return <span className="text-theme-text-tertiary">{VELERO_RUNS_UNKNOWN}</span>
|
|
339
|
+
const run = s.runs.newestCompleted
|
|
340
|
+
if (!run) return <span className="text-theme-text-tertiary">{veleroScheduleNeverRan(s) ? 'Never' : VELERO_NONE_KEPT_SHORT}</span>
|
|
341
|
+
const at = run.completed ?? run.ranAt
|
|
342
|
+
return (
|
|
343
|
+
<Tooltip content={`${run.name} · ${veleroLocalTime(at)}${run.manual ? ` · ${VELERO_MANUAL_RUN_TITLE}` : ''}`}>
|
|
344
|
+
<span>
|
|
345
|
+
{formatRelativeAgeTime(at)}
|
|
346
|
+
{run.manual && <span className="ml-1.5 text-xs text-theme-text-secondary">{VELERO_MANUAL_RUN}</span>}
|
|
347
|
+
</span>
|
|
348
|
+
</Tooltip>
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function StoredInCell({ s, locations }: { s: VeleroScheduleReading; locations: VeleroLocationReading[] }) {
|
|
353
|
+
if (!s.location.name) return <span className="text-theme-text-tertiary">Unresolved</span>
|
|
354
|
+
const loc = locations.find((l) => l.namespace === s.namespace && l.name === s.location.name)
|
|
355
|
+
const tone: StatusTone = !loc ? 'unknown' : loc.phase === 'Available' ? 'healthy' : loc.phase === 'Unavailable' ? 'unhealthy' : 'unknown'
|
|
356
|
+
return (
|
|
357
|
+
<span className="flex min-w-0 items-center gap-1.5">
|
|
358
|
+
<StatusDot tone={tone} />
|
|
359
|
+
<VeleroName name={s.location.name} />
|
|
360
|
+
{loc && loc.phase !== 'Available' && <span className="shrink-0 text-xs text-theme-text-tertiary">{loc.phase ? loc.phase.toLowerCase() : 'not validated'}</span>}
|
|
361
|
+
</span>
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Each schedule's protection in one row: its state, newest success, where it
|
|
367
|
+
* writes and for how long, so a healthy installation shows its evidence rather
|
|
368
|
+
* than only the absence of problems.
|
|
369
|
+
*/
|
|
370
|
+
function ScheduleProtection({ schedules, locations, multi, onInspect, inspected, empty }: { schedules: VeleroScheduleReading[]; locations: VeleroLocationReading[]; multi: boolean; onInspect: VeleroScreenProps['onInspect']; inspected: VeleroScreenProps['inspected']; empty: string }) {
|
|
371
|
+
// Narrow: the retention goes under where the runs are stored.
|
|
372
|
+
const wide = useMediaQuery(VELERO_WIDE)
|
|
373
|
+
const columns: TableColumn<VeleroScheduleReading>[] = [
|
|
374
|
+
{
|
|
375
|
+
header: 'Schedule',
|
|
376
|
+
cell: (s) => (
|
|
377
|
+
<>
|
|
378
|
+
<VeleroName name={s.name} />
|
|
379
|
+
{multi && <Sub><WholeNames text={s.namespace} /></Sub>}
|
|
380
|
+
</>
|
|
381
|
+
),
|
|
382
|
+
},
|
|
383
|
+
{ header: 'State', width: wide ? '130px' : '120px', cell: (s) => <VeleroScheduleStateBadge reading={s} /> },
|
|
384
|
+
{ header: 'Last success', width: wide ? '110px' : '100px', cell: (s) => <LastSuccessCell s={s} /> },
|
|
385
|
+
{ header: 'Next run', width: wide ? '120px' : '110px', cell: (s) => <NextRunCell s={s} /> },
|
|
386
|
+
{
|
|
387
|
+
header: 'Stored in',
|
|
388
|
+
width: wide ? '170px' : '140px',
|
|
389
|
+
cell: (s) => (
|
|
390
|
+
<>
|
|
391
|
+
<StoredInCell s={s} locations={locations} />
|
|
392
|
+
{!wide && <KeptForLine s={s} />}
|
|
393
|
+
</>
|
|
394
|
+
),
|
|
395
|
+
},
|
|
396
|
+
...(wide ? [{ header: KEPT_FOR_HEADER, width: '110px', cell: (s: VeleroScheduleReading) => <KeptForCell s={s} /> }] : []),
|
|
397
|
+
]
|
|
398
|
+
return (
|
|
399
|
+
<SectionTable
|
|
400
|
+
title="Schedules"
|
|
401
|
+
columns={columns}
|
|
402
|
+
rows={schedules}
|
|
403
|
+
rowKey={(s) => `${s.namespace}/${s.name}`}
|
|
404
|
+
rowResource={(s) => veleroResource('Schedule', s.namespace, s.name)}
|
|
405
|
+
onInspect={onInspect}
|
|
406
|
+
inspected={inspected}
|
|
407
|
+
empty={empty}
|
|
408
|
+
minWidth={wide ? 860 : 580}
|
|
409
|
+
/>
|
|
410
|
+
)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** The namespaces the caller can see, from the namespace list; undefined while it loads. */
|
|
414
|
+
export type VeleroNamespaceList = string[] | 'error' | undefined
|
|
415
|
+
|
|
416
|
+
export function VeleroOverview({ data, installation, onInstallation, onInspect, inspected, namespaces, deleteObject = false }: VeleroScreenProps & {
|
|
417
|
+
namespaces?: VeleroNamespaceList
|
|
418
|
+
/** The connected Radar supports Delete object (resourceDeletePreconditions), so a held schedule's next step may offer it. */
|
|
419
|
+
deleteObject?: boolean
|
|
420
|
+
}) {
|
|
421
|
+
const navigateTo = useWorkspaceNavigate()
|
|
422
|
+
const schedules = useMemo(() => inInstallation(data.schedules, installation), [data.schedules, installation])
|
|
423
|
+
const locations = useMemo(() => inInstallation(data.locations, installation), [data.locations, installation])
|
|
424
|
+
const issues = useMemo(
|
|
425
|
+
() => (installation === null ? data.issues : data.issues.filter((i) => (i.namespace ?? '') === installation)),
|
|
426
|
+
[data.issues, installation],
|
|
427
|
+
)
|
|
428
|
+
const attention = useMemo(() => veleroAttention(data, installation, { deleteObject }), [data, installation, deleteObject])
|
|
429
|
+
const capped = cappedIssueNotes(data, issues, installation)
|
|
430
|
+
const groups = useMemo(() => {
|
|
431
|
+
let budget = ATTENTION_BUDGET
|
|
432
|
+
return ATTENTION_GROUPS.map((g) => ({ ...g, problems: attention.filter((p) => attentionGroup(p) === g.id) }))
|
|
433
|
+
.filter((g) => g.problems.length > 0)
|
|
434
|
+
.map((g) => {
|
|
435
|
+
const visible = Math.max(1, Math.min(g.problems.length, budget))
|
|
436
|
+
budget = Math.max(0, budget - visible)
|
|
437
|
+
return { ...g, visible }
|
|
438
|
+
})
|
|
439
|
+
}, [attention])
|
|
440
|
+
const facts: SummaryFact[] = [
|
|
441
|
+
serverFact(inInstallation(data.installations, installation)),
|
|
442
|
+
{ ...schedulesFact(schedules, readInPart(data.coverage.schedules)), list: { path: VELERO_SCHEDULES_PATH, title: 'Every schedule, its next run and its newest runs' } },
|
|
443
|
+
newestBackupFact(schedules, readInPart(data.coverage.schedules), onInspect),
|
|
444
|
+
{ ...storageFact(locations, readInPart(data.coverage.backupStorageLocations)), list: { path: VELERO_LOCATIONS_PATH, title: 'Every storage location, the backups in it and the schedules writing to it' } },
|
|
445
|
+
]
|
|
446
|
+
const navigate = (ref: ResourceRef) => onInspect(refToSelectedResource(ref))
|
|
447
|
+
|
|
448
|
+
return (
|
|
449
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
450
|
+
<VeleroWorkspaceHeader title="Overview" data={data} installation={installation} onInstallation={onInstallation} />
|
|
451
|
+
<ScreenBody>
|
|
452
|
+
<VeleroCoverageNotice data={data} kinds={['schedules', 'backups', 'backupStorageLocations', 'restores', 'backupRepositories']} />
|
|
453
|
+
<VeleroSummary facts={facts} onOpenList={(path) => navigateTo(path)} />
|
|
454
|
+
<section aria-labelledby="velero-attention">
|
|
455
|
+
<h2 id="velero-attention" className="mb-2 text-sm font-semibold text-theme-text-primary">Needs attention</h2>
|
|
456
|
+
<div className="rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
|
|
457
|
+
{attention.length === 0 ? (
|
|
458
|
+
<p className="text-sm text-theme-text-tertiary">
|
|
459
|
+
{veleroAttentionPartial(data, installation) ? VELERO_NOTHING_IN_WHAT_WAS_READ : VELERO_NOTHING_NEEDS_ATTENTION}
|
|
460
|
+
</p>
|
|
461
|
+
) : (
|
|
462
|
+
<div className="space-y-4">
|
|
463
|
+
{groups.map((g) => (
|
|
464
|
+
<AttentionGroup key={g.id} id={g.id} title={g.title} problems={g.problems} visible={g.visible} onNavigate={navigate} />
|
|
465
|
+
))}
|
|
466
|
+
</div>
|
|
467
|
+
)}
|
|
468
|
+
{capped.map((note) => (
|
|
469
|
+
<p key={note} className="mt-2 text-xs text-theme-text-tertiary">{note}</p>
|
|
470
|
+
))}
|
|
471
|
+
</div>
|
|
472
|
+
</section>
|
|
473
|
+
<ScheduleCoverage data={data} schedules={schedules} namespaces={namespaces} onInspect={onInspect} />
|
|
474
|
+
<ScheduleProtection
|
|
475
|
+
schedules={schedules}
|
|
476
|
+
locations={locations}
|
|
477
|
+
multi={data.installations.length > 1}
|
|
478
|
+
onInspect={onInspect}
|
|
479
|
+
inspected={inspected}
|
|
480
|
+
empty={coverageEmpty(data.coverage.schedules, 'Velero schedules')}
|
|
481
|
+
/>
|
|
482
|
+
</ScreenBody>
|
|
483
|
+
</div>
|
|
484
|
+
)
|
|
485
|
+
}
|