@skyhook-io/radar-app 1.21.0 → 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.tsx +13 -5
- package/src/api/radarFeatures.ts +4 -0
- package/src/api/velero.ts +176 -0
- package/src/api/vulnerabilities.ts +58 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +4 -2
- package/src/components/audit/ChecksViewTabs.tsx +3 -2
- package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
- package/src/components/audit/Java4ShellPanel.tsx +313 -0
- package/src/components/audit/VulnerabilitiesView.tsx +46 -9
- package/src/components/gitops/FluxOperatorCard.test.tsx +37 -0
- package/src/components/gitops/FluxOperatorCard.tsx +27 -0
- package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
- package/src/components/gitops/GitOpsView.tsx +7 -4
- package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
- package/src/components/gitops/gitopsRowEvents.ts +31 -0
- package/src/components/velero/VeleroDetailPage.tsx +12 -2
- package/src/components/velero/VeleroRunArtifacts.test.tsx +241 -0
- package/src/components/velero/VeleroRunArtifacts.tsx +112 -0
- package/src/components/velero/VeleroRunVolumes.test.tsx +247 -0
- package/src/components/velero/VeleroRunVolumes.tsx +122 -0
- package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
- package/src/components/velero/VeleroSchedulePause.tsx +191 -0
- package/src/components/velero/host.tsx +9 -3
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +20 -8
- package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
- package/src/components/whats-new/releaseNotes.ts +67 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { guardRadarFeature, type RadarFeatureSupport } from '../../api/radarFeatures'
|
|
7
|
+
import type { VeleroRunVolumesResponse, VeleroVolumeOperationsResponse } from '../../api/velero'
|
|
8
|
+
import { setApiBase } from '../../api/config'
|
|
9
|
+
|
|
10
|
+
const state = vi.hoisted(() => ({ support: 'supported' as RadarFeatureSupport, supportFor: {} as Record<string, RadarFeatureSupport>, fetch: vi.fn() }))
|
|
11
|
+
vi.mock('../../api/client', async (original) => ({
|
|
12
|
+
...(await original<typeof import('../../api/client')>()),
|
|
13
|
+
useRadarFeature: (feature: 'veleroRunVolumes') => {
|
|
14
|
+
const support = state.supportFor[feature] ?? state.support
|
|
15
|
+
return {
|
|
16
|
+
gatedKey: [support],
|
|
17
|
+
guard: <T,>(request: () => Promise<T>) => guardRadarFeature(feature, support, { currentVersion: 'v1.16.0' }, request),
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
fetchJSON: (path: string, init: RequestInit) => state.fetch(path, init),
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
import { ApiError } from '../../api/client'
|
|
24
|
+
import { VeleroRunVolumes } from './VeleroRunVolumes'
|
|
25
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
26
|
+
let host: HTMLDivElement
|
|
27
|
+
let root: Root
|
|
28
|
+
let client: QueryClient
|
|
29
|
+
const props = { kind: 'backups' as const, namespace: 'velero', name: 'nightly' }
|
|
30
|
+
const record = (patch: Partial<VeleroRunVolumesResponse> = {}): VeleroRunVolumesResponse => ({
|
|
31
|
+
volumes: [
|
|
32
|
+
{ pvcName: 'native', pvcNamespace: 'app', pvName: 'pv-native', method: 'NativeSnapshot', preserveLocalSnapshot: false, result: 'succeeded', snapshotDataMoved: false, nativeSnapshotInfo: { snapshotHandle: 'snap-123' } },
|
|
33
|
+
{ pvcName: 'csi', method: 'CSISnapshot', preserveLocalSnapshot: true, snapshotDataMoved: false, csiSnapshotInfo: { driver: 'ebs.csi.aws.com', size: 1024 } },
|
|
34
|
+
{ pvcName: 'moved', method: 'CSISnapshot', snapshotDataMoved: true, snapshotDataMovementInfo: { dataMover: 'velero', operationID: 'op-moved' } },
|
|
35
|
+
{ method: 'PodVolumeBackup', result: 'failed', snapshotDataMoved: false, podVolumeInfo: { podName: 'worker', podNamespace: 'app', volumeName: 'data' } },
|
|
36
|
+
{ pvcName: 'skipped', snapshotDataMoved: false, skipped: true, skippedReason: 'excluded by policy' },
|
|
37
|
+
], total: 5, truncated: false, finishedAtRead: true, ...patch,
|
|
38
|
+
})
|
|
39
|
+
const live = (patch: Partial<VeleroVolumeOperationsResponse> = {}): VeleroVolumeOperationsResponse => ({
|
|
40
|
+
observedAt: '2026-11-15T12:00:00Z', runPhase: 'Completed', coverage: { podVolumeBackups: { state: 'full' }, dataUploads: { state: 'full' } }, operations: [], ...patch,
|
|
41
|
+
})
|
|
42
|
+
function respond(volumes = record(), operations = live()) {
|
|
43
|
+
state.fetch.mockImplementation((path: string) => Promise.resolve(path.includes('volume-operations') ? operations : volumes))
|
|
44
|
+
}
|
|
45
|
+
async function mount(node: ReactNode = <VeleroRunVolumes {...props} />) {
|
|
46
|
+
await act(async () => { root.render(<QueryClientProvider client={client}>{node}</QueryClientProvider>) })
|
|
47
|
+
}
|
|
48
|
+
async function settle(test: () => boolean) {
|
|
49
|
+
for (let i = 0; i < 50 && !test(); i++) await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)) })
|
|
50
|
+
expect(test()).toBe(true)
|
|
51
|
+
}
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
state.support = 'supported'
|
|
54
|
+
state.supportFor = {}
|
|
55
|
+
state.fetch.mockReset()
|
|
56
|
+
host = document.createElement('div'); document.body.append(host); root = createRoot(host)
|
|
57
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
58
|
+
})
|
|
59
|
+
afterEach(async () => {
|
|
60
|
+
await act(async () => root.unmount())
|
|
61
|
+
client.clear(); host.remove(); setApiBase('/api'); vi.useRealTimers()
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
describe('Volumes tab', () => {
|
|
65
|
+
it('loads on opening: durable POST and operations GET', async () => {
|
|
66
|
+
state.fetch.mockImplementation(() => new Promise(() => {}))
|
|
67
|
+
expect(state.fetch).not.toHaveBeenCalled()
|
|
68
|
+
await mount()
|
|
69
|
+
expect(host.textContent).toContain('Loading volume record')
|
|
70
|
+
expect(host.textContent).toContain('Loading volume operations')
|
|
71
|
+
expect(state.fetch.mock.calls.find(([path]) => path.endsWith('/volumes?'))?.[1].method).toBe('POST')
|
|
72
|
+
expect(state.fetch.mock.calls.some(([path]) => path.endsWith('/volume-operations'))).toBe(true)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Velero keeps finished operation objects, so they alone don't keep a
|
|
76
|
+
// finished run polling.
|
|
77
|
+
it.each(['inFlight', 'activeOperation', 'retainedOperations', 'completedEmpty', 'syncing'] as const)('polls operations only when needed: %s', async (scenario) => {
|
|
78
|
+
vi.useFakeTimers()
|
|
79
|
+
const operations = scenario === 'retainedOperations' ? [{ kind: 'DataUpload', name: 'done', phase: 'Completed', longRunning: false }] : scenario === 'activeOperation' ? [{ kind: 'DataUpload', name: 'copying', phase: 'InProgress', longRunning: false }] : []
|
|
80
|
+
respond(record(), live({ runPhase: scenario === 'inFlight' ? 'InProgress' : 'Completed', coverage: { dataUploads: { state: scenario === 'syncing' ? 'syncing' : 'full' } }, operations }))
|
|
81
|
+
await mount()
|
|
82
|
+
await act(async () => { await vi.advanceTimersByTimeAsync(50) })
|
|
83
|
+
expect(host.textContent).toContain('snap-123')
|
|
84
|
+
await act(async () => { await vi.advanceTimersByTimeAsync(10_050) })
|
|
85
|
+
expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
|
|
86
|
+
expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volume-operations'))).toHaveLength(scenario === 'completedEmpty' || scenario === 'retainedOperations' ? 1 : 2)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('shows all methods, explicit outcomes, skipped reasons and unknown CSI results', async () => {
|
|
90
|
+
respond(); await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
91
|
+
for (const text of ['Native snapshot', 'CSI snapshot', 'Copy to the bucket (data mover)', 'File-system backup', 'excluded by policy', 'ebs.csi.aws.com', '1 KB', 'op-moved', 'Succeeded', 'Failed']) expect(host.textContent).toContain(text)
|
|
92
|
+
const skipped = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('excluded by policy'))!
|
|
93
|
+
expect(skipped.textContent).toContain('None (skipped)')
|
|
94
|
+
const csi = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('CSI snapshot') && !row.textContent!.includes('data mover'))!
|
|
95
|
+
expect(csi.textContent).toContain('Not recorded')
|
|
96
|
+
expect(csi.textContent).not.toContain('Succeeded')
|
|
97
|
+
const native = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('snap-123'))!
|
|
98
|
+
expect(native.textContent).not.toContain('Local snapshot retained')
|
|
99
|
+
expect(csi.textContent).toContain('Local snapshot retained: Yes')
|
|
100
|
+
expect(host.querySelector('a')).toBeNull()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('describes restore intent and never renders a result or skipped column', async () => {
|
|
104
|
+
respond(record({ volumes: [{ method: 'PodVolumeRestore', snapshotDataMoved: false, podVolumeInfo: { podName: 'recovered', volumeName: 'data' } }], total: 1 }))
|
|
105
|
+
await mount(<VeleroRunVolumes {...props} kind="restores" />)
|
|
106
|
+
await settle(() => host.textContent!.includes('recovered'))
|
|
107
|
+
expect(host.textContent).toContain('How each volume was to be restored')
|
|
108
|
+
expect(host.textContent).toContain('before plugin operations finish')
|
|
109
|
+
expect(host.textContent).toContain('File-system restore')
|
|
110
|
+
expect([...host.querySelectorAll('th')].map((e) => e.textContent)).not.toContain('Result')
|
|
111
|
+
expect(host.textContent).not.toContain('Succeeded')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it.each([['Velero has no volume record for this run', 404], ['no access to this Velero Backup', 403], ['the object store refused it', 503]])('keeps artifact error distinct from operation data: %s', async (message, status) => {
|
|
115
|
+
state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.resolve(live()) : Promise.reject(new ApiError(message, status)))
|
|
116
|
+
await mount(); await settle(() => host.textContent!.includes(message))
|
|
117
|
+
expect(host.textContent).toContain('Retry')
|
|
118
|
+
expect(host.textContent).not.toContain('Velero recorded no volumes')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
// A Radar that serves Contents and Log but predates the Volumes routes.
|
|
122
|
+
it('gates both reads on the new capability', async () => {
|
|
123
|
+
state.supportFor = { veleroRunArtifacts: 'supported', veleroRunVolumes: 'unsupported' }
|
|
124
|
+
await mount(); await settle(() => host.textContent!.includes('needs a newer Radar'))
|
|
125
|
+
expect(state.fetch).not.toHaveBeenCalled()
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('says once that a finished run recorded no volumes', async () => {
|
|
129
|
+
respond(record({ volumes: [], total: 0 }))
|
|
130
|
+
await mount(); await settle(() => host.textContent!.includes('Velero recorded no volumes for this run.'))
|
|
131
|
+
expect(host.textContent!.split('Velero recorded no volumes').length).toBe(2)
|
|
132
|
+
expect(host.textContent).not.toContain('They may have been removed')
|
|
133
|
+
expect(host.textContent).not.toContain('No volume operation objects found yet')
|
|
134
|
+
expect(host.textContent).not.toContain('The volume record does not update with live operations')
|
|
135
|
+
expect(host.textContent).not.toContain('0 recorded volumes')
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('says operations may have been removed when the record names volumes', async () => {
|
|
139
|
+
respond()
|
|
140
|
+
await mount(); await settle(() => host.textContent!.includes('snap-123') && host.textContent!.includes('They may have been removed'))
|
|
141
|
+
expect(host.textContent).toContain('5 recorded volumes')
|
|
142
|
+
expect(host.textContent).not.toContain('The volume record does not update with live operations')
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('reports denied, missing and partial operation kinds without implying none were used', async () => {
|
|
146
|
+
respond(record(), live({ coverage: { podVolumeBackups: { state: 'denied' }, dataUploads: { state: 'notInstalled' }, podVolumeRestores: { state: 'partial', allowedNamespaces: ['velero'] } } }))
|
|
147
|
+
await mount(); await settle(() => host.textContent!.includes('Not available now'))
|
|
148
|
+
expect(host.textContent).toContain('Access denied')
|
|
149
|
+
expect(host.textContent).toContain('Only part of this kind')
|
|
150
|
+
expect(host.textContent).toContain('Unavailable kinds do not mean this run used none')
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('groups failures first and shows ten with show all, progress, node-agent context and timestamps', async () => {
|
|
154
|
+
respond(record(), live({ runPhase: 'InProgress', operations: [
|
|
155
|
+
{ kind: 'DataUpload', name: 'complete', phase: 'Completed', longRunning: false },
|
|
156
|
+
...Array.from({ length: 12 }, (_, i) => ({ kind: 'DataUpload', name: `failure-${i}`, phase: 'Failed', pvc: 'data', pvcNamespace: 'app', longRunning: false, message: 'copy failed' })),
|
|
157
|
+
{ kind: 'PodVolumeBackup', name: 'copy', phase: 'InProgress', longRunning: true, nodeAgent: 'notRunning' as const, node: 'node-a', bytesDone: 512, bytesTotal: 1024, started: '2026-11-15T11:00:00Z' },
|
|
158
|
+
] }))
|
|
159
|
+
await mount(); await settle(() => host.textContent!.includes('failure-0'))
|
|
160
|
+
expect([...host.querySelectorAll('h3')].map((e) => e.textContent)).toEqual(['Failed · 12', 'InProgress · 1', 'Completed · 1'])
|
|
161
|
+
expect(host.textContent).not.toContain('failure-11')
|
|
162
|
+
expect(host.textContent).toContain('512 B / 1 KB')
|
|
163
|
+
expect(host.textContent).toContain('No Running node-agent pod found on this node')
|
|
164
|
+
expect(host.textContent).toContain('node-a')
|
|
165
|
+
const progress = host.querySelector('progress')!
|
|
166
|
+
expect(progress.value).toBe(512); expect(progress.max).toBe(1024)
|
|
167
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Show all 12')!.click())
|
|
168
|
+
expect(host.textContent).toContain('failure-11')
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it.each(['running', 'unknown'] as const)('shows node-agent %s without guessing progress', async (nodeAgent) => {
|
|
172
|
+
respond(record(), live({ operations: [{ kind: 'DataUpload', name: 'stuck', phase: 'Prepared', node: 'node', longRunning: true, nodeAgent }] }))
|
|
173
|
+
await mount(); await settle(() => host.textContent!.includes('stuck'))
|
|
174
|
+
expect(host.textContent).toContain(nodeAgent === 'running' ? 'Node-agent pod phase: Running on this node' : 'Node-agent status unknown')
|
|
175
|
+
expect(host.textContent).toContain('Unknown / Unknown')
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('does not retain another API base’s rows during a cluster switch', async () => {
|
|
179
|
+
respond(); await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
180
|
+
setApiBase('/c/other/api'); state.fetch.mockImplementation(() => new Promise(() => {}))
|
|
181
|
+
await mount(); expect(host.textContent).not.toContain('snap-123')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('marks an in-flight record as provisional and refreshes it explicitly', async () => {
|
|
185
|
+
respond(record({ finishedAtRead: false }), live({ runPhase: 'WaitingForPluginOperations' }))
|
|
186
|
+
await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
187
|
+
expect(host.textContent).toContain('Velero may write or update its volume record later')
|
|
188
|
+
expect(host.textContent).toContain('The volume record does not update with live operations')
|
|
189
|
+
expect(host.textContent).toContain('Record read:')
|
|
190
|
+
respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
|
|
191
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
|
|
192
|
+
await settle(() => !host.textContent!.includes('This run is still in progress'))
|
|
193
|
+
expect(host.textContent).not.toContain('The volume record does not update with live operations')
|
|
194
|
+
expect(host.textContent).toContain('The volume record was read before this run finished')
|
|
195
|
+
expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
|
|
196
|
+
respond(record(), live({ runPhase: 'Completed' }))
|
|
197
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh record')!.click())
|
|
198
|
+
await settle(() => state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?')).length === 2)
|
|
199
|
+
await settle(() => !host.textContent!.includes('was read before this run finished'))
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
// Velero rewrites a backup's record as its plugin operations finish, so a
|
|
203
|
+
// record read mid-finalization is provisional even when the first
|
|
204
|
+
// operations read already sees the run complete.
|
|
205
|
+
it('keeps a record read before the run finished provisional when operations already show it complete', async () => {
|
|
206
|
+
respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
|
|
207
|
+
await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
208
|
+
expect(host.textContent).toContain('The volume record was read before this run finished')
|
|
209
|
+
expect(host.textContent).not.toContain('This run is still in progress')
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('trusts a final record over an older operations read', async () => {
|
|
213
|
+
respond(record({ finishedAtRead: true }), live({ runPhase: 'Finalizing' }))
|
|
214
|
+
await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
215
|
+
expect(host.textContent).not.toContain('This run is still in progress')
|
|
216
|
+
expect(host.textContent).not.toContain('was read before this run finished')
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('says a provisional record was read in flight when operations could not be read', async () => {
|
|
220
|
+
state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.reject(new ApiError('operations denied', 403)) : Promise.resolve(record({ finishedAtRead: false })))
|
|
221
|
+
await mount(); await settle(() => host.textContent!.includes('operations denied'))
|
|
222
|
+
expect(host.textContent).toContain('The volume record was read while this run was in progress')
|
|
223
|
+
expect(host.textContent).not.toContain('read before this run finished')
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
it('keeps the provisional note when a refresh after completion fails', async () => {
|
|
227
|
+
respond(record({ finishedAtRead: false }), live({ runPhase: 'InProgress' }))
|
|
228
|
+
await mount(); await settle(() => host.textContent!.includes('snap-123'))
|
|
229
|
+
respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
|
|
230
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
|
|
231
|
+
await settle(() => host.textContent!.includes('was read before this run finished'))
|
|
232
|
+
state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.resolve(live()) : Promise.reject(new ApiError('record unavailable', 503)))
|
|
233
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh record')!.click())
|
|
234
|
+
await settle(() => host.textContent!.includes('record unavailable'))
|
|
235
|
+
expect(host.textContent).toContain('The volume record was read before this run finished')
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('shows truncation and retries operations independently', async () => {
|
|
239
|
+
state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.reject(new ApiError('operations denied', 403)) : Promise.resolve(record({ total: 5001, truncated: true })))
|
|
240
|
+
await mount(); await settle(() => host.textContent!.includes('operations denied'))
|
|
241
|
+
expect(host.textContent).toContain('first 5,000 of 5001')
|
|
242
|
+
respond()
|
|
243
|
+
await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
|
|
244
|
+
await settle(() => !host.textContent!.includes('operations denied'))
|
|
245
|
+
expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
|
|
246
|
+
})
|
|
247
|
+
})
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Badge, Collapse, TimeValue, formatBytes, pluralize } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useVeleroRunVolumes, useVeleroVolumeOperations, isVeleroRunFinished, type VeleroVolumeRecord, type VeleroVolumeDetails, type VeleroVolumeOperation } from '../../api/velero'
|
|
4
|
+
import { Notice, SectionTable } from '../workspace/layout'
|
|
5
|
+
import { ArtifactError } from './VeleroRunArtifacts'
|
|
6
|
+
|
|
7
|
+
function volumeMethod(row: VeleroVolumeRecord, restore: boolean) {
|
|
8
|
+
switch (row.method) {
|
|
9
|
+
case 'NativeSnapshot': return 'Native snapshot'
|
|
10
|
+
case 'CSISnapshot': return row.snapshotDataMoved ? `CSI snapshot · Copy ${restore ? 'from' : 'to'} the bucket (data mover)` : 'CSI snapshot'
|
|
11
|
+
case 'PodVolumeBackup': return 'File-system backup'
|
|
12
|
+
case 'PodVolumeRestore': return 'File-system restore'
|
|
13
|
+
default: return row.method || (row.skipped ? 'None (skipped)' : 'Not recorded')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const resultLabels = new Map([['succeeded', 'Succeeded'], ['failed', 'Failed']])
|
|
18
|
+
|
|
19
|
+
function VolumeDetails({ label, info }: { label: string; info?: VeleroVolumeDetails }) {
|
|
20
|
+
if (!info) return null
|
|
21
|
+
const fields = [
|
|
22
|
+
['Snapshot', info.snapshotHandle], ['Driver', info.driver], ['Snapshot content', info.vscName],
|
|
23
|
+
['Operation', info.operationID], ['Data mover', info.dataMover], ['Uploader', info.uploaderType],
|
|
24
|
+
['Source snapshot', info.retainedSnapshot], ['Volume group snapshot', info.volumeGroupSnapshotHandle],
|
|
25
|
+
['Volume type', info.volumeType], ['Zone', info.volumeAZ], ['IOPS', info.iops], ['Phase', info.phase],
|
|
26
|
+
['Pod', info.podName ? `${info.podNamespace ? info.podNamespace + '/' : ''}${info.podName}` : undefined],
|
|
27
|
+
['Volume', info.volumeName], ['Node', info.nodeName],
|
|
28
|
+
['Snapshot ready', info.readyToUse === undefined ? undefined : info.readyToUse ? 'Yes' : 'No'],
|
|
29
|
+
['Size', info.size === undefined || info.size === 0 ? undefined : formatBytes(info.size)],
|
|
30
|
+
['Incremental size', info.incrementalSize === undefined ? undefined : formatBytes(info.incrementalSize)],
|
|
31
|
+
].filter(([, value]) => value !== undefined && value !== '')
|
|
32
|
+
return <div className="space-y-1 text-xs text-theme-text-secondary"><div className="font-medium">{label}</div>{fields.map(([key, value]) => <div key={key} className="break-all">{key}: {value}</div>)}</div>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function OperationGroup({ phase, rows }: { phase: string; rows: VeleroVolumeOperation[] }) {
|
|
36
|
+
const [all, setAll] = useState(false)
|
|
37
|
+
const table = (items: VeleroVolumeOperation[]) => <SectionTable
|
|
38
|
+
minWidth={820}
|
|
39
|
+
columns={[
|
|
40
|
+
{ header: 'Operation', cell: (row) => <div className="break-all"><Badge kind={row.kind}>{row.kind}</Badge><div className="mt-1 font-mono text-xs">{row.name}</div></div> },
|
|
41
|
+
{ header: 'Volume', cell: (row) => <div className="break-all">{row.pvc ? `PVC ${row.pvcNamespace ? row.pvcNamespace + '/' : ''}${row.pvc}` : row.pod ? `${row.podNamespace ? row.podNamespace + '/' : ''}${row.pod} · ${row.volume || 'Volume not recorded'}` : 'Not recorded'}</div> },
|
|
42
|
+
{ header: 'Progress', cell: (row) => <div className="space-y-1"><div>{row.bytesDone === undefined ? 'Unknown' : formatBytes(row.bytesDone)} / {row.bytesTotal === undefined ? 'Unknown' : formatBytes(row.bytesTotal)}</div>{row.bytesDone !== undefined && row.bytesTotal !== undefined && row.bytesTotal > 0 && <progress className="w-full accent-accent" aria-label={`${row.name} bytes`} value={row.bytesDone} max={row.bytesTotal} />}</div> },
|
|
43
|
+
{ header: 'Node', cell: (row) => <div className="break-all">{row.node || 'Not recorded'}{row.longRunning && <div className="mt-1 text-xs text-theme-text-secondary">Over 10 min · {row.nodeAgent === 'running' ? 'Node-agent pod phase: Running on this node' : row.nodeAgent === 'notRunning' ? 'No Running node-agent pod found on this node' : 'Node-agent status unknown'}</div>}</div> },
|
|
44
|
+
{ header: 'Status', cell: (row) => <div className="space-y-1 break-words">{row.message && <div>{row.message}</div>}<div>Started: {row.started ? <TimeValue timestamp={row.started} /> : 'Not recorded'}</div><div>Finished: {row.completed ? <TimeValue timestamp={row.completed} /> : 'Not recorded'}</div></div> },
|
|
45
|
+
]}
|
|
46
|
+
rows={items}
|
|
47
|
+
rowKey={(row) => `${row.kind}/${row.name}`}
|
|
48
|
+
empty="No operations."
|
|
49
|
+
/>
|
|
50
|
+
return <section className="space-y-2">
|
|
51
|
+
<h3 className="text-sm font-semibold text-theme-text-primary"><Badge severity={phase === 'Failed' ? 'error' : phase === 'Completed' ? 'success' : 'neutral'}>{phase}</Badge> · {rows.length}</h3>
|
|
52
|
+
{table(rows.slice(0, 10))}
|
|
53
|
+
{rows.length > 10 && <>
|
|
54
|
+
<button type="button" aria-expanded={all} className="btn-secondary px-3 py-1.5 text-sm" onClick={() => setAll(!all)}>{all ? 'Show first 10' : `Show all ${rows.length}`}</button>
|
|
55
|
+
<Collapse open={all} mountLazily>{table(rows.slice(10))}</Collapse>
|
|
56
|
+
</>}
|
|
57
|
+
</section>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const phaseOrder = ['Failed', 'Canceling', 'Canceled', 'InProgress', 'Prepared', 'Accepted', 'New', 'Completed']
|
|
61
|
+
const operationNames: Record<string, string> = { podVolumeBackups: 'Pod volume backups', podVolumeRestores: 'Pod volume restores', dataUploads: 'Data uploads', dataDownloads: 'Data downloads' }
|
|
62
|
+
const coverageText: Record<string, string> = {
|
|
63
|
+
partial: 'Only part of this kind could be read.', denied: 'Access denied.', notInstalled: 'Not available now; this kind is not served by the cluster.',
|
|
64
|
+
syncing: 'Still loading; try refreshing.', uncached: 'Not collected by Radar in this namespace.', error: 'Could not read this kind; try refreshing.',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function VeleroRunVolumes({ kind, namespace, name }: { kind: 'backups' | 'restores'; namespace: string; name: string }) {
|
|
68
|
+
const record = useVeleroRunVolumes(kind, namespace, name)
|
|
69
|
+
const live = useVeleroVolumeOperations(kind, namespace, name)
|
|
70
|
+
const restore = kind === 'restores'
|
|
71
|
+
const data = record.data
|
|
72
|
+
const operations = live.data?.operations ?? []
|
|
73
|
+
const phases = [...new Set(operations.map((row) => row.phase || 'Not recorded'))].sort((a, b) => {
|
|
74
|
+
const rank = (p: string) => phaseOrder.includes(p) ? phaseOrder.indexOf(p) : phaseOrder.length
|
|
75
|
+
return rank(a) - rank(b) || a.localeCompare(b)
|
|
76
|
+
})
|
|
77
|
+
const inFlight = live.data && !isVeleroRunFinished(live.data.runPhase)
|
|
78
|
+
// The server says whether the run had finished when it read the record, so
|
|
79
|
+
// a record read mid-finalization stays provisional however soon the run
|
|
80
|
+
// completes.
|
|
81
|
+
// The record's own read decides whether it is final; the operations read
|
|
82
|
+
// (which can be older) only chooses the wording.
|
|
83
|
+
const finalRecord = !!data?.finishedAtRead
|
|
84
|
+
const readBeforeCompletion = !!data && !finalRecord && !inFlight
|
|
85
|
+
const coverage = Object.entries(live.data?.coverage ?? {})
|
|
86
|
+
const complete = coverage.length > 0 && coverage.every(([, value]) => value.state === 'full')
|
|
87
|
+
const recordedNone = data?.total === 0
|
|
88
|
+
return <div className="space-y-5 p-4">
|
|
89
|
+
<section className="space-y-3">
|
|
90
|
+
<div className="flex items-center justify-between gap-2"><h2 className="text-sm font-semibold text-theme-text-primary">Recorded volumes</h2><button type="button" className="btn-secondary px-3 py-1.5 text-sm" onClick={() => void record.refetch()}>Refresh record</button></div>
|
|
91
|
+
<p className="text-sm text-theme-text-secondary">{restore ? 'How each volume was to be restored. Velero writes this record before plugin operations finish; it does not record a restore result.' : 'How Velero protected each volume, as recorded with this backup. A reported success does not verify that it can be restored.'}</p>
|
|
92
|
+
{inFlight && !finalRecord && <Notice>This run is still in progress. Velero may write or update its volume record later. The volume record does not update with live operations. If this run has finished since you opened or refreshed this tab, refresh the record for final results.</Notice>}
|
|
93
|
+
{readBeforeCompletion && <Notice>{live.data ? 'The volume record was read before this run finished, and Velero may have updated it since.' : 'The volume record was read while this run was in progress, and Velero may update it.'} Refresh the record for final results.</Notice>}
|
|
94
|
+
{record.dataUpdatedAt > 0 && <p className="text-xs text-theme-text-tertiary">Record read: <TimeValue timestamp={new Date(record.dataUpdatedAt).toISOString()} /></p>}
|
|
95
|
+
{record.error && <ArtifactError label="Velero run volumes" error={record.error} hasData={!!data} retry={() => void record.refetch()} />}
|
|
96
|
+
{record.isPending && <p className="text-sm text-theme-text-secondary">Loading volume record…</p>}
|
|
97
|
+
{data?.truncated && <Notice>Showing the first 5,000 of {data.total} recorded volumes.</Notice>}
|
|
98
|
+
{recordedNone && <p className="text-sm text-theme-text-secondary">Velero recorded no volumes for this run.</p>}
|
|
99
|
+
{data && !recordedNone && <SectionTable
|
|
100
|
+
title={pluralize(data.total, 'recorded volume')}
|
|
101
|
+
minWidth={760}
|
|
102
|
+
columns={[
|
|
103
|
+
{ header: 'Volume', cell: (row) => <div className="space-y-1 break-all">{row.pvcName && <div>PVC {row.pvcNamespace ? row.pvcNamespace + '/' : ''}{row.pvcName}</div>}{row.pvName && <div className="text-xs text-theme-text-secondary">PV {row.pvName}</div>}{!row.pvcName && !row.pvName && <div>{row.podVolumeInfo?.podName ? `${row.podVolumeInfo.podNamespace || ''}/${row.podVolumeInfo.podName} · ${row.podVolumeInfo.volumeName || 'Volume not recorded'}` : 'Not recorded'}</div>}</div> },
|
|
104
|
+
{ header: 'Method', cell: (row) => <div className="space-y-1">{volumeMethod(row, restore)}{row.method === 'CSISnapshot' && row.preserveLocalSnapshot !== undefined && <div className="text-xs text-theme-text-secondary">Local snapshot retained: {row.preserveLocalSnapshot ? 'Yes' : 'No'}</div>}</div> },
|
|
105
|
+
...(!restore ? [{ header: 'Result', cell: (row: VeleroVolumeRecord) => <div className="space-y-1">{row.skipped ? <><Badge severity="neutral">Skipped</Badge><div>{row.skippedReason || 'Reason not recorded'}</div></> : row.result ? <Badge severity={row.result === 'failed' ? 'error' : row.result === 'succeeded' ? 'success' : 'neutral'}>{resultLabels.get(row.result) ?? row.result}</Badge> : 'Not recorded'}</div> }] : []),
|
|
106
|
+
{ header: 'Recorded details', cell: (row) => <div className="space-y-2"><VolumeDetails label="Native snapshot" info={row.nativeSnapshotInfo} /><VolumeDetails label="CSI snapshot" info={row.csiSnapshotInfo} /><VolumeDetails label="Data mover" info={row.snapshotDataMovementInfo} /><VolumeDetails label="File-system copy" info={row.podVolumeInfo} />{!row.nativeSnapshotInfo && !row.csiSnapshotInfo && !row.snapshotDataMovementInfo && !row.podVolumeInfo && 'Not recorded'}</div> },
|
|
107
|
+
]}
|
|
108
|
+
rows={data.volumes.map((row, index) => ({ ...row, index }))}
|
|
109
|
+
rowKey={(row) => String(row.index)}
|
|
110
|
+
empty="Velero recorded no volumes in this file."
|
|
111
|
+
/>}
|
|
112
|
+
</section>
|
|
113
|
+
<section className="space-y-3">
|
|
114
|
+
<div className="flex items-center justify-between gap-2"><h2 className="text-sm font-semibold text-theme-text-primary">Current volume operations</h2><button type="button" className="btn-secondary px-3 py-1.5 text-sm" onClick={() => void live.refetch()}>Refresh operations</button></div>
|
|
115
|
+
{live.error && <ArtifactError label="Velero run volumes" error={live.error} hasData={!!live.data} retry={() => void live.refetch()} />}
|
|
116
|
+
{live.isPending && <p className="text-sm text-theme-text-secondary">Loading volume operations…</p>}
|
|
117
|
+
{coverage.filter(([, value]) => value.state !== 'full').map(([key, value]) => <Notice key={key}>{operationNames[key] || key}: {coverageText[value.state] || 'Coverage unknown' } No conclusion about this run’s volume method can be drawn from missing operations.</Notice>)}
|
|
118
|
+
{live.data && operations.length === 0 && !(complete && recordedNone) && <Notice>{complete ? (inFlight ? 'No volume operation objects found yet for this run.' : 'No current volume operation objects found. They may have been removed; use the recorded volumes above for this run’s history.') : 'No readable volume operations found. Unavailable kinds do not mean this run used none.'}</Notice>}
|
|
119
|
+
{phases.map((phase) => <OperationGroup key={phase} phase={phase} rows={operations.filter((row) => (row.phase || 'Not recorded') === phase)} />)}
|
|
120
|
+
</section>
|
|
121
|
+
</div>
|
|
122
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { evaluateGitOpsWriteGuard, type GitOpsWriteGuardInput, type VeleroResumeChoices } from '@skyhook-io/k8s-ui'
|
|
6
|
+
|
|
7
|
+
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
8
|
+
|
|
9
|
+
const target = { kind: 'Schedule', group: 'velero.io', namespace: 'velero', name: 'nightly' }
|
|
10
|
+
const argoSelfHeal: Partial<GitOpsWriteGuardInput> = {
|
|
11
|
+
owner: { tool: 'argocd', kind: 'applications', namespace: 'argocd', name: 'backups' },
|
|
12
|
+
evidence: {
|
|
13
|
+
uid: 'u',
|
|
14
|
+
resourceVersion: '42',
|
|
15
|
+
owner: null,
|
|
16
|
+
policy: { tool: 'argocd', auto: true, selfHeal: true, prune: false, suspended: null },
|
|
17
|
+
paths: [
|
|
18
|
+
{ path: 'spec.paused', lastApplied: 'present', ownedBy: [], ownedByGitOps: false },
|
|
19
|
+
{ path: 'spec.skipImmediately', lastApplied: 'absent', ownedBy: [], ownedByGitOps: false },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const state = vi.hoisted(() => ({
|
|
25
|
+
support: 'supported',
|
|
26
|
+
mutate: vi.fn(),
|
|
27
|
+
error: null as Error | null,
|
|
28
|
+
resume: undefined as unknown,
|
|
29
|
+
serverStopped: false,
|
|
30
|
+
backupsDisabled: false,
|
|
31
|
+
guardInput: {} as Record<string, unknown>,
|
|
32
|
+
toast: vi.fn(),
|
|
33
|
+
refetch: vi.fn(),
|
|
34
|
+
updatedAt: 1,
|
|
35
|
+
}))
|
|
36
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: state.support }) }))
|
|
37
|
+
vi.mock('../../api/velero', () => ({
|
|
38
|
+
useVeleroSchedulePause: () => ({ mutate: state.mutate, isPending: false, error: state.error }),
|
|
39
|
+
useVeleroScheduleActivity: () => ({ data: { resume: state.resume, serverStopped: state.serverStopped, backupsDisabled: state.backupsDisabled }, refetch: state.refetch, isPending: false, dataUpdatedAt: state.updatedAt }),
|
|
40
|
+
}))
|
|
41
|
+
vi.mock('../../hooks/useGitOpsWriteGuard', () => ({
|
|
42
|
+
useGitOpsWriteGuard: ({ writes }: { writes: GitOpsWriteGuardInput['writes'] }) => ({
|
|
43
|
+
guard: evaluateGitOpsWriteGuard({ target, owner: null, writes, ...state.guardInput }),
|
|
44
|
+
}),
|
|
45
|
+
}))
|
|
46
|
+
vi.mock('../workspace/useWorkspaceNavigate', () => ({ useWorkspaceNavigate: () => vi.fn() }))
|
|
47
|
+
vi.mock('../ui/Toast', () => ({ showApiSuccess: state.toast }))
|
|
48
|
+
|
|
49
|
+
const { VeleroSchedulePause } = await import('./VeleroSchedulePause')
|
|
50
|
+
|
|
51
|
+
const active = { metadata: { namespace: 'velero', name: 'nightly', resourceVersion: '42' }, spec: { schedule: '0 1 * * *' } }
|
|
52
|
+
const paused = { ...active, spec: { ...active.spec, paused: true } }
|
|
53
|
+
|
|
54
|
+
const roots: ReturnType<typeof createRoot>[] = []
|
|
55
|
+
function render(node: React.ReactNode) {
|
|
56
|
+
const host = document.createElement('div')
|
|
57
|
+
document.body.append(host)
|
|
58
|
+
const root = createRoot(host)
|
|
59
|
+
roots.push(root)
|
|
60
|
+
act(() => root.render(node))
|
|
61
|
+
return root
|
|
62
|
+
}
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
act(() => roots.splice(0).forEach((r) => r.unmount()))
|
|
65
|
+
document.body.innerHTML = ''
|
|
66
|
+
state.support = 'supported'
|
|
67
|
+
state.error = null
|
|
68
|
+
state.resume = undefined
|
|
69
|
+
state.serverStopped = false
|
|
70
|
+
state.backupsDisabled = false
|
|
71
|
+
state.guardInput = {}
|
|
72
|
+
state.toast.mockReset()
|
|
73
|
+
state.mutate.mockReset()
|
|
74
|
+
state.refetch.mockReset()
|
|
75
|
+
state.updatedAt = 1
|
|
76
|
+
vi.useRealTimers()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const buttons = (label: string) => [...document.querySelectorAll('button')].filter((b) => b.textContent?.trim() === label)
|
|
80
|
+
const text = () => document.body.textContent ?? ''
|
|
81
|
+
const checkbox = (label: string) =>
|
|
82
|
+
[...document.querySelectorAll('label')].find((l) => l.textContent?.includes(label))?.querySelector('input') as HTMLInputElement | undefined
|
|
83
|
+
|
|
84
|
+
const due: VeleroResumeChoices = {
|
|
85
|
+
default: { outcome: 'runsNow', due: true, summary: 'A run is due, so Velero submits it as soon as the schedule resumes.' },
|
|
86
|
+
skipping: { outcome: 'skips', due: true, summary: 'Velero skips the run due now, if any, and submits the next one at its scheduled time.' },
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
describe('Pause and resume', () => {
|
|
90
|
+
it('pauses, saying what stops and that a started run continues, bound to the reviewed version', () => {
|
|
91
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
92
|
+
act(() => buttons('Pause')[0].click())
|
|
93
|
+
expect(text()).toContain('Velero stops submitting this schedule’s runs until it is resumed.')
|
|
94
|
+
expect(text()).toContain('A run already started continues to the end.')
|
|
95
|
+
expect(text()).toContain('Back up now still creates a backup from this schedule while it is paused.')
|
|
96
|
+
act(() => buttons('Pause schedule')[0].click())
|
|
97
|
+
expect(state.mutate).toHaveBeenCalledWith(
|
|
98
|
+
{ namespace: 'velero', name: 'nightly', paused: true, resourceVersion: '42', skipImmediately: null },
|
|
99
|
+
expect.anything(),
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('does not promise Back up now while Velero runs restore-only', () => {
|
|
104
|
+
state.backupsDisabled = true
|
|
105
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
106
|
+
act(() => buttons('Pause')[0].click())
|
|
107
|
+
expect(text()).toContain('Back up now stays unavailable while Velero runs restore-only.')
|
|
108
|
+
expect(text()).not.toContain('Back up now still creates a backup')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('resumes with the server deciding the skip unless the user skips the due run', () => {
|
|
112
|
+
state.resume = due
|
|
113
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
114
|
+
act(() => buttons('Resume')[0].click())
|
|
115
|
+
expect(text()).toContain(due.default.summary)
|
|
116
|
+
const skip = checkbox('Skip the run that’s due now')!
|
|
117
|
+
expect(skip.checked).toBe(false)
|
|
118
|
+
act(() => skip.click())
|
|
119
|
+
expect(text()).toContain(due.skipping!.summary)
|
|
120
|
+
expect(text()).not.toContain(due.default.summary)
|
|
121
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
122
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: true }), expect.anything())
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('reads the outlook again when the next run comes, and waits for it before confirming', () => {
|
|
126
|
+
vi.useFakeTimers()
|
|
127
|
+
const nextRun = new Date(Date.now() + 60_000).toISOString()
|
|
128
|
+
state.resume = { default: { outcome: 'waits', due: false, summary: 'No run is due, so Velero submits the next one at its scheduled time.', nextRun, nextRunCertain: true } }
|
|
129
|
+
const root = render(<VeleroSchedulePause schedule={paused} />)
|
|
130
|
+
act(() => buttons('Resume')[0].click())
|
|
131
|
+
const confirm = () => buttons('Resume schedule')[0] as HTMLButtonElement
|
|
132
|
+
act(() => void vi.advanceTimersByTime(30_000))
|
|
133
|
+
expect(state.refetch).not.toHaveBeenCalled()
|
|
134
|
+
expect(confirm().disabled).toBe(false)
|
|
135
|
+
act(() => void vi.advanceTimersByTime(30_000))
|
|
136
|
+
expect(state.refetch).toHaveBeenCalledTimes(1)
|
|
137
|
+
expect(confirm().disabled).toBe(true)
|
|
138
|
+
expect(text()).toContain('Reading what resuming does')
|
|
139
|
+
state.resume = due
|
|
140
|
+
state.updatedAt = 2
|
|
141
|
+
act(() => root.render(<VeleroSchedulePause schedule={paused} />))
|
|
142
|
+
expect(confirm().disabled).toBe(false)
|
|
143
|
+
expect(checkbox('Skip the run that’s due now')).toBeDefined()
|
|
144
|
+
expect(text()).toContain(due.default.summary)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('offers no skip when nothing is due', () => {
|
|
148
|
+
state.resume = { default: { outcome: 'waits', due: false, summary: 'No run is due, so Velero submits the next one at its scheduled time.' } }
|
|
149
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
150
|
+
act(() => buttons('Resume')[0].click())
|
|
151
|
+
expect(text()).toContain('No run is due')
|
|
152
|
+
expect(checkbox('Skip the run')).toBeUndefined()
|
|
153
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
154
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: null }), expect.anything())
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('offers no skip on a cron with no future time, where skipping changes nothing', () => {
|
|
158
|
+
const summary = 'This schedule’s cron expression has no future time, so once resumed Velero submits runs immediately and repeatedly until the cron is fixed. Skipping does not prevent it.'
|
|
159
|
+
state.resume = { default: { outcome: 'runsRepeatedly', reason: 'noFutureTime', due: false, summary } }
|
|
160
|
+
render(<VeleroSchedulePause schedule={paused} />)
|
|
161
|
+
act(() => buttons('Resume')[0].click())
|
|
162
|
+
expect(text()).toContain(summary)
|
|
163
|
+
expect(checkbox('Skip the run')).toBeUndefined()
|
|
164
|
+
act(() => buttons('Resume schedule')[0].click())
|
|
165
|
+
expect(state.mutate).toHaveBeenCalledWith(expect.objectContaining({ paused: false, skipImmediately: null }), expect.anything())
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('refuses to confirm once the schedule changed while open', () => {
|
|
169
|
+
const root = render(<VeleroSchedulePause schedule={active} />)
|
|
170
|
+
act(() => buttons('Pause')[0].click())
|
|
171
|
+
act(() => root.render(<VeleroSchedulePause schedule={{ ...active, metadata: { ...active.metadata, resourceVersion: '43' } }} />))
|
|
172
|
+
expect(text()).toContain('This schedule changed while this was open')
|
|
173
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(true)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('is disabled with a reason until the schedule has a version', () => {
|
|
177
|
+
render(<VeleroSchedulePause schedule={{ ...active, metadata: { namespace: 'velero', name: 'nightly' } }} />)
|
|
178
|
+
expect(buttons('Pause')[0].disabled).toBe(true)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('warns that Argo CD reverts it, and waits for the acknowledgement', () => {
|
|
182
|
+
state.guardInput = argoSelfHeal
|
|
183
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
184
|
+
act(() => buttons('Pause')[0].click())
|
|
185
|
+
expect(text()).toContain('will revert this change')
|
|
186
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(true)
|
|
187
|
+
act(() => checkbox('I understand Argo CD will revert this.')!.click())
|
|
188
|
+
expect(buttons('Pause schedule')[0].disabled).toBe(false)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('shows the server’s refusal in the dialog', () => {
|
|
192
|
+
state.error = new Error('the schedule changed since you opened it; review it again')
|
|
193
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
194
|
+
act(() => buttons('Pause')[0].click())
|
|
195
|
+
expect(text()).toContain('the schedule changed since you opened it')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('says when it was done', () => {
|
|
199
|
+
state.mutate.mockImplementation((_v: unknown, opts: { onSuccess: (r: unknown) => void }) => opts.onSuccess({ paused: true, changed: true }))
|
|
200
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
201
|
+
act(() => buttons('Pause')[0].click())
|
|
202
|
+
act(() => buttons('Pause schedule')[0].click())
|
|
203
|
+
expect(state.toast).toHaveBeenCalledWith('Schedule nightly paused')
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('is absent on a Radar without the action', () => {
|
|
207
|
+
state.support = 'unsupported'
|
|
208
|
+
render(<VeleroSchedulePause schedule={active} />)
|
|
209
|
+
expect(buttons('Pause')).toHaveLength(0)
|
|
210
|
+
})
|
|
211
|
+
})
|