@skyhook-io/radar-app 1.19.0 → 1.20.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/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +37 -9
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { guardRadarFeature, radarFeatureSupport } from '../../api/radarFeatures'
|
|
7
|
+
import { ApiError } from '../../api/client'
|
|
8
|
+
import { ApplicationEvidenceAction, ApplicationEvidenceObservation } from './ApplicationEvidenceAction'
|
|
9
|
+
import { copyText } from '@skyhook-io/k8s-ui/utils/clipboard'
|
|
10
|
+
|
|
11
|
+
vi.mock('@skyhook-io/k8s-ui/utils/clipboard', () => ({ copyText: vi.fn().mockResolvedValue(true) }))
|
|
12
|
+
|
|
13
|
+
const state = vi.hoisted(() => ({ fetch: vi.fn(), supported: true, ApiError: class extends Error { constructor(message: string, readonly status: number) { super(message) } } }))
|
|
14
|
+
vi.mock('../../api/client', () => ({
|
|
15
|
+
ApiError: state.ApiError,
|
|
16
|
+
fetchJSON: (...args: unknown[]) => state.fetch(...args),
|
|
17
|
+
useClusterInfo: () => ({ data: { context: 'test-cluster' } }),
|
|
18
|
+
useCapabilities: () => ({ data: { deployment: { mode: 'local' }, features: state.supported ? { applicationEvidence: true } : {} } }),
|
|
19
|
+
useRadarFeature: () => {
|
|
20
|
+
const support = radarFeatureSupport('applicationEvidence', { features: state.supported ? { applicationEvidence: true } : {} }, 'v1.16.0')
|
|
21
|
+
return { support, gatedKey: [], guard: <T,>(request: () => Promise<T>) => guardRadarFeature('applicationEvidence', support, {}, request) }
|
|
22
|
+
},
|
|
23
|
+
}))
|
|
24
|
+
const candidates = { enabled: true, context: 'test-cluster', subjectUID: 'subject-uid', candidates: [{ application: 'vault', target: { namespace: 'demo', pod: 'vault-0', uid: 'pod-uid', container: 'vault' }, expectedEvidence: ['sealed'], coverage: 'One selected Pod.' }] }
|
|
25
|
+
let root: ReturnType<typeof createRoot>
|
|
26
|
+
let host: HTMLDivElement
|
|
27
|
+
let client: QueryClient
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
state.fetch.mockReset(); state.supported = true
|
|
30
|
+
;(globalThis as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true
|
|
31
|
+
window.matchMedia = vi.fn().mockReturnValue({ matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() })
|
|
32
|
+
host = document.createElement('div'); document.body.append(host); root = createRoot(host)
|
|
33
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
34
|
+
})
|
|
35
|
+
afterEach(() => { act(() => root.unmount()); client.clear(); host.remove() })
|
|
36
|
+
it('keeps limitations expandable and in copied observations, with guidance for omitted Pods', async () => {
|
|
37
|
+
const limitations = ['One selected Pod only.', 'Identity checks do not attest endpoint contents.']
|
|
38
|
+
const observation = { adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', httpStatus: 501, facts: { vault: { initialized: false, sealed: true, standby: true, removedFromCluster: false } }, limitations }
|
|
39
|
+
state.fetch.mockResolvedValueOnce({ ...candidates, coverageLimited: true }).mockResolvedValueOnce(observation)
|
|
40
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Service" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
41
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
42
|
+
act(() => host.querySelector('button')!.click())
|
|
43
|
+
expect(document.body.textContent).toContain('To inspect another endpoint, open that Pod directly.')
|
|
44
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
45
|
+
const toggle = [...document.querySelectorAll('button')].find(item => item.textContent === 'Collection limits')!
|
|
46
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('false')
|
|
47
|
+
expect(document.body.textContent).toContain('Endpoint status: HTTP 501')
|
|
48
|
+
expect(document.body.textContent).toContain('This Pod at collection time; other replicas were not checked.')
|
|
49
|
+
act(() => toggle.click())
|
|
50
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('true')
|
|
51
|
+
expect(document.getElementById(toggle.getAttribute('aria-controls')!)!.textContent).toContain(limitations[1])
|
|
52
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Copy observation')!.click())
|
|
53
|
+
expect(JSON.parse(vi.mocked(copyText).mock.calls.at(-1)![0])).toEqual({ context: 'test-cluster', ...observation })
|
|
54
|
+
})
|
|
55
|
+
it('does not request endpoints from a Radar without the collection flag', async () => {
|
|
56
|
+
state.supported = false
|
|
57
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
58
|
+
expect(state.fetch).not.toHaveBeenCalled()
|
|
59
|
+
expect(host.textContent).toBe('')
|
|
60
|
+
})
|
|
61
|
+
it('collects only on explicit click and discards a cancelled response on reopen', async () => {
|
|
62
|
+
let finish: (value: unknown) => void = () => {}
|
|
63
|
+
const delayed = new Promise(resolve => { finish = resolve })
|
|
64
|
+
state.fetch.mockImplementation((path: string) => path.startsWith('/application-evidence/candidates') ? Promise.resolve(candidates) : delayed)
|
|
65
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
66
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
67
|
+
act(() => host.querySelector('button')!.click())
|
|
68
|
+
expect(state.fetch).toHaveBeenCalledTimes(1)
|
|
69
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
70
|
+
const [path, request] = state.fetch.mock.calls[1]
|
|
71
|
+
expect(path).toBe('/application-evidence/collect')
|
|
72
|
+
expect(JSON.parse(request.body)).toEqual({ application: 'vault', namespace: 'demo', pod: 'vault-0', uid: 'pod-uid', context: 'test-cluster', confirmNetworkAccess: true })
|
|
73
|
+
act(() => [...document.querySelectorAll('button')].find(item => item.textContent === 'Cancel')!.click())
|
|
74
|
+
expect(request.signal.aborted).toBe(true)
|
|
75
|
+
act(() => host.querySelector('button')!.click())
|
|
76
|
+
await act(async () => finish({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', facts: { vault: { initialized: true, sealed: false, standby: false } }, limitations: [] }))
|
|
77
|
+
expect(document.body.textContent).not.toContain('Endpoint observations')
|
|
78
|
+
expect(state.fetch).toHaveBeenCalledTimes(2)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('recovers from one transient cache failure without collecting an endpoint', async () => {
|
|
82
|
+
state.fetch.mockRejectedValueOnce(new ApiError('not connected', 503)).mockResolvedValue(candidates)
|
|
83
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
84
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'), { timeout: 2500 })
|
|
85
|
+
expect(state.fetch).toHaveBeenCalledTimes(2)
|
|
86
|
+
expect(state.fetch.mock.calls.every(([path]) => path.startsWith('/application-evidence/candidates'))).toBe(true)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('keeps an open observation and validated targets after a permission retry fails', async () => {
|
|
90
|
+
state.fetch.mockResolvedValueOnce({ ...candidates, permissionCheckTimedOut: true })
|
|
91
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
92
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
93
|
+
act(() => [...host.querySelectorAll('button')].find(item => item.textContent === 'Collect Vault evidence')!.click())
|
|
94
|
+
state.fetch.mockResolvedValueOnce({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', facts: { vault: { initialized: false, sealed: true, standby: true } }, limitations: [] })
|
|
95
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
96
|
+
expect(document.body.textContent).toContain('Endpoint observations')
|
|
97
|
+
state.fetch.mockRejectedValue(new ApiError('permission check failed', 500))
|
|
98
|
+
await act(async () => [...host.querySelectorAll('button')].find(item => item.textContent === 'Retry permission check')!.click())
|
|
99
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Could not refresh application evidence'))
|
|
100
|
+
expect(document.body.textContent).toContain('Endpoint observations')
|
|
101
|
+
expect(document.body.textContent).toContain('Copy observation')
|
|
102
|
+
expect(host.textContent).toContain('Collect Vault evidence')
|
|
103
|
+
state.fetch.mockResolvedValue(candidates)
|
|
104
|
+
await act(async () => [...host.querySelectorAll('button')].find(item => item.textContent === 'Retry permission check')!.click())
|
|
105
|
+
await vi.waitFor(() => expect(host.textContent).not.toContain('Could not refresh application evidence'))
|
|
106
|
+
expect(document.body.textContent).toContain('Endpoint observations')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it.each(['target_changed', 'pod_not_running', 'container_not_running'])('preserves a %s refusal without offering its stale target after a failed refresh', async reason => {
|
|
110
|
+
state.fetch.mockResolvedValueOnce(candidates)
|
|
111
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
112
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
113
|
+
act(() => host.querySelector('button')!.click())
|
|
114
|
+
state.fetch.mockResolvedValueOnce({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'unavailable', reason, limitations: [] }).mockRejectedValue(new ApiError('refresh failed', 500))
|
|
115
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
116
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Could not refresh application evidence'))
|
|
117
|
+
expect(document.body.textContent).toContain('Evidence unavailable')
|
|
118
|
+
expect(document.body.textContent).toContain('Copy observation')
|
|
119
|
+
expect(host.textContent).not.toContain('Collect Vault evidence')
|
|
120
|
+
state.fetch.mockResolvedValue({ ...candidates, candidates: [{ ...candidates.candidates[0], target: { ...candidates.candidates[0].target, uid: 'replacement-uid' } }] })
|
|
121
|
+
await act(async () => [...host.querySelectorAll('button')].find(item => item.textContent === 'Retry')!.click())
|
|
122
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
123
|
+
act(() => [...document.querySelectorAll('button')].find(item => item.textContent === 'Close')!.click())
|
|
124
|
+
act(() => [...host.querySelectorAll('button')].find(item => item.textContent === 'Collect Vault evidence')!.click())
|
|
125
|
+
state.fetch.mockResolvedValue({ adapter: 'vault', target: { ...candidates.candidates[0].target, uid: 'replacement-uid' }, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', limitations: [] })
|
|
126
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
127
|
+
const [, request] = state.fetch.mock.calls.at(-1)!
|
|
128
|
+
expect(JSON.parse(request.body).uid).toBe('replacement-uid')
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('allows the same Pod UID after a container restart and a successful refresh', async () => {
|
|
132
|
+
state.fetch.mockResolvedValueOnce(candidates)
|
|
133
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
134
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
135
|
+
act(() => host.querySelector('button')!.click())
|
|
136
|
+
state.fetch.mockResolvedValueOnce({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'unavailable', reason: 'target_changed', limitations: [] }).mockResolvedValue(candidates)
|
|
137
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
138
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
139
|
+
expect(document.body.textContent).toContain('Evidence unavailable')
|
|
140
|
+
act(() => [...document.querySelectorAll('button')].find(item => item.textContent === 'Close')!.click())
|
|
141
|
+
act(() => host.querySelector('button')!.click())
|
|
142
|
+
state.fetch.mockResolvedValue({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', limitations: [] })
|
|
143
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
144
|
+
expect(document.body.textContent).toContain('Endpoint observations')
|
|
145
|
+
const [, request] = state.fetch.mock.calls.at(-1)!
|
|
146
|
+
expect(JSON.parse(request.body).uid).toBe('pod-uid')
|
|
147
|
+
})
|
|
148
|
+
it('keeps an optional first-lookup failure quiet until the user has used the feature', async () => {
|
|
149
|
+
state.fetch.mockRejectedValue(new ApiError('access denied', 403))
|
|
150
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
151
|
+
await vi.waitFor(() => expect(state.fetch).toHaveBeenCalledTimes(1))
|
|
152
|
+
expect(host.textContent).toBe('')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('offers an explicit retry after permission evaluation fails without collecting', async () => {
|
|
156
|
+
state.fetch.mockResolvedValueOnce({ ...candidates, candidates: [], permissionCheckFailed: true })
|
|
157
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
158
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Application evidence permissions could not be verified'))
|
|
159
|
+
expect(host.textContent).not.toContain('Collect Vault evidence')
|
|
160
|
+
state.fetch.mockResolvedValue(candidates)
|
|
161
|
+
await act(async () => [...host.querySelectorAll('button')].find(item => item.textContent === 'Retry permission check')!.click())
|
|
162
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
163
|
+
expect(state.fetch.mock.calls.every(([path]) => path.startsWith('/application-evidence/candidates'))).toBe(true)
|
|
164
|
+
expect(state.fetch.mock.calls.at(-1)![0]).toContain('retryPermissions=true')
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
it.each(['pod-uid', 'replacement-uid'])('allows deliberate reselection of %s inside the dialog while keeping the refusal', async nextUID => {
|
|
168
|
+
state.fetch.mockResolvedValueOnce(candidates)
|
|
169
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
170
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect Vault evidence'))
|
|
171
|
+
act(() => host.querySelector('button')!.click())
|
|
172
|
+
const refreshed = { ...candidates, candidates: [{ ...candidates.candidates[0], target: { ...candidates.candidates[0].target, uid: nextUID } }] }
|
|
173
|
+
state.fetch.mockResolvedValueOnce({ adapter: 'vault', target: candidates.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'unavailable', reason: 'target_changed', limitations: [] }).mockResolvedValueOnce(nextUID === 'replacement-uid' ? { ...candidates, candidates: [], permissionCheckFailed: true } : refreshed).mockResolvedValue(refreshed)
|
|
174
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
175
|
+
if (nextUID === 'replacement-uid') {
|
|
176
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Application evidence permissions could not be verified'))
|
|
177
|
+
await vi.waitFor(() => expect(document.body.textContent).toContain('A current Pod endpoint has not been verified'))
|
|
178
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Refresh Pod choices')!.click())
|
|
179
|
+
expect(state.fetch.mock.calls.at(-1)![0]).toContain('retryPermissions=true')
|
|
180
|
+
}
|
|
181
|
+
await vi.waitFor(() => expect(document.querySelector<HTMLButtonElement>('button[aria-label="Pod endpoint"]')?.disabled).toBe(false))
|
|
182
|
+
expect(document.body.textContent).toContain('Evidence unavailable')
|
|
183
|
+
expect(document.body.textContent).toContain('Copy observation')
|
|
184
|
+
expect([...document.querySelectorAll<HTMLButtonElement>('button')].find(item => item.textContent === 'Collect again')!.disabled).toBe(true)
|
|
185
|
+
act(() => document.querySelector<HTMLButtonElement>('button[aria-label="Pod endpoint"]')!.click())
|
|
186
|
+
act(() => document.querySelector<HTMLButtonElement>('[role="option"]')!.click())
|
|
187
|
+
expect(document.body.textContent).toContain('Evidence unavailable')
|
|
188
|
+
expect(state.fetch.mock.calls.filter(([path]) => path === '/application-evidence/collect')).toHaveLength(1)
|
|
189
|
+
state.fetch.mockResolvedValue({ adapter: 'vault', target: refreshed.candidates[0].target, observedAt: '2026-10-13T00:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', limitations: [] })
|
|
190
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect again')!.click())
|
|
191
|
+
expect(JSON.parse(state.fetch.mock.calls.at(-1)![1].body).uid).toBe(nextUID)
|
|
192
|
+
expect(document.body.textContent).toContain('Endpoint observations')
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
it('keeps background refresh errors quiet for a resource with no eligible endpoints', async () => {
|
|
197
|
+
state.fetch.mockResolvedValueOnce({ ...candidates, candidates: [] })
|
|
198
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Deployment" group="apps" namespace="demo" name="vault" uid="subject-uid" /></QueryClientProvider>))
|
|
199
|
+
await vi.waitFor(() => expect(client.getQueryCache().getAll()[0]?.state.status).toBe('success'))
|
|
200
|
+
expect(host.textContent).toBe('')
|
|
201
|
+
state.fetch.mockRejectedValue(new ApiError('temporary refresh failure', 500))
|
|
202
|
+
await act(async () => { await client.invalidateQueries({ queryKey: ['application-evidence-candidates'] }) })
|
|
203
|
+
expect(state.fetch).toHaveBeenCalledTimes(2)
|
|
204
|
+
expect(host.textContent).toBe('')
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('copies exact RabbitMQ bytes and identity without an additional collection request', async () => {
|
|
208
|
+
const target = { namespace: 'demo', pod: 'rabbitmq-0', uid: 'rabbit-uid', container: 'rabbitmq' }
|
|
209
|
+
const observation = { adapter: 'rabbitmq', target, observedAt: '2026-11-03T10:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed', facts: { rabbitmq: { diskAlarm: true, memoryAlarm: false, diskAvailableBytes: 15277850624, diskWatermarkBytes: 1000000000000, memoryUsedBytes: 134975488, memoryWatermarkBytes: 2412409651 } }, limitations: ['Only the selected Pod was checked.'] }
|
|
210
|
+
state.fetch.mockResolvedValueOnce({ ...candidates, subjectUID: 'rabbit-uid', candidates: [{ application: 'rabbitmq', target, expectedEvidence: ['disk/memory alarms'], coverage: 'One selected Pod.' }] }).mockResolvedValueOnce(observation)
|
|
211
|
+
await act(async () => root.render(<QueryClientProvider client={client}><ApplicationEvidenceAction kind="Pod" namespace="demo" name="rabbitmq-0" uid="rabbit-uid" /></QueryClientProvider>))
|
|
212
|
+
await vi.waitFor(() => expect(host.textContent).toContain('Collect RabbitMQ evidence'))
|
|
213
|
+
act(() => host.querySelector('button')!.click())
|
|
214
|
+
expect(state.fetch).toHaveBeenCalledTimes(1)
|
|
215
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Collect evidence')!.click())
|
|
216
|
+
await act(async () => [...document.querySelectorAll('button')].find(item => item.textContent === 'Copy observation')!.click())
|
|
217
|
+
expect(JSON.parse(vi.mocked(copyText).mock.calls.at(-1)![0])).toEqual({ context: 'test-cluster', ...observation })
|
|
218
|
+
expect(state.fetch).toHaveBeenCalledTimes(2)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('keeps NATS progress collapsed until requested without changing the four-column count table', () => {
|
|
222
|
+
act(() => root.render(<ApplicationEvidenceObservation result={{ adapter: 'nats', target: { namespace: 'demo', pod: 'nats-0' }, observedAt: '2026-11-03T01:44:19Z', source: 'selected_pod_endpoint', outcome: 'observed', limitations: [], facts: { nats: { jetStreamEnabled: true, coverage: 'node_reported', returnedAccounts: 1, returnedStreams: 1, returnedConsumers: 1, truncated: false, consumers: [{ account: '$G', stream: 'events', name: 'worker', pending: 0, ackPending: 5, redelivered: 0, delivered: { consumerSequence: '5', streamSequence: '5' }, ackFloor: { consumerSequence: '0', streamSequence: '0' }, waitingPullRequests: 1 }] } } }} />))
|
|
223
|
+
const toggle = [...host.querySelectorAll('button')].find(item => item.textContent === 'Consumer progress')!
|
|
224
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('false')
|
|
225
|
+
expect(host.querySelectorAll('th')).toHaveLength(4)
|
|
226
|
+
act(() => toggle.click())
|
|
227
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('true')
|
|
228
|
+
const details = document.getElementById(toggle.getAttribute('aria-controls')!)!
|
|
229
|
+
expect(details.textContent).toContain('Consumer seq 5 · Stream seq 5')
|
|
230
|
+
expect(details.textContent).toContain('Ack floorConsumer seq 0 · Stream seq 0')
|
|
231
|
+
expect(details.textContent).toContain('Waiting pull requests on this node1')
|
|
232
|
+
act(() => toggle.click())
|
|
233
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('false')
|
|
234
|
+
})
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import type { ApplicationEvidenceResult } from '../../api/application-evidence'
|
|
4
|
+
import { ApplicationEvidenceObservation } from './ApplicationEvidenceAction'
|
|
5
|
+
|
|
6
|
+
const result: ApplicationEvidenceResult = {
|
|
7
|
+
adapter: 'rabbitmq', target: { namespace: 'demo', pod: 'rabbit-0', uid: 'uid', container: 'rabbitmq' },
|
|
8
|
+
observedAt: '2026-09-22T10:00:00Z', source: 'selected_pod_endpoint', outcome: 'observed',
|
|
9
|
+
limitations: ['One Pod only; other replicas were not checked.'],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('application observations', () => {
|
|
13
|
+
it('shows absent alarms as source observations, not a health verdict', () => {
|
|
14
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, facts: { rabbitmq: { diskAlarm: false, memoryAlarm: true } } }} />)
|
|
15
|
+
expect(html).toContain('Not reported')
|
|
16
|
+
expect(html).toContain('Reported')
|
|
17
|
+
expect(html).toContain('demo/rabbit-0')
|
|
18
|
+
expect(html).toContain('other replicas were not checked')
|
|
19
|
+
expect(html).not.toContain('Healthy')
|
|
20
|
+
})
|
|
21
|
+
it('shows reported resource values without inferring alarms or percentages', () => {
|
|
22
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, facts: { rabbitmq: {
|
|
23
|
+
diskAlarm: false, memoryAlarm: true, diskAvailableBytes: 0, diskWatermarkBytes: 50 * 1024 * 1024,
|
|
24
|
+
memoryUsedBytes: 128 * 1024 * 1024, memoryWatermarkBytes: 512 * 1024 * 1024,
|
|
25
|
+
} } }} />)
|
|
26
|
+
expect(html).toContain('Free disk</dt><dd class="break-words"><span class="block">0 B')
|
|
27
|
+
expect(html).toContain('Disk alarm below</dt><dd class="break-words"><span class="block">50 MiB')
|
|
28
|
+
expect(html).toContain('Memory used (RabbitMQ)</dt><dd class="break-words"><span class="block">128 MiB')
|
|
29
|
+
expect(html).toContain('Memory alarm above</dt><dd class="break-words"><span class="block">512 MiB')
|
|
30
|
+
expect(html).toContain('Disk alarm</dt><dd>Not reported')
|
|
31
|
+
expect(html).toContain('Memory alarm</dt><dd>Reported')
|
|
32
|
+
expect(html).toContain('can lag the alarm state')
|
|
33
|
+
expect(html).not.toContain('%')
|
|
34
|
+
})
|
|
35
|
+
it('keeps absent measurements unknown while preserving alarms and handles large exact values', () => {
|
|
36
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, facts: { rabbitmq: {
|
|
37
|
+
diskAlarm: false, memoryAlarm: false, diskAvailableBytes: Number.MAX_SAFE_INTEGER,
|
|
38
|
+
} } }} />)
|
|
39
|
+
expect(html).toContain('GiB')
|
|
40
|
+
expect(html.match(/Unknown<\/dd>/g)).toHaveLength(3)
|
|
41
|
+
expect(html).toContain('Disk alarm</dt><dd>Not reported')
|
|
42
|
+
expect(html).not.toContain('undefined')
|
|
43
|
+
expect(html).not.toContain('NaN')
|
|
44
|
+
})
|
|
45
|
+
it.each([
|
|
46
|
+
[49900000, 50000000, 2415000000, 2412409651],
|
|
47
|
+
[1048500, 1048576, 1073700000, 1073741824],
|
|
48
|
+
])('keeps exact measurements visible near thresholds and unit boundaries (%d, %d, %d, %d)', (diskAvailableBytes, diskWatermarkBytes, memoryUsedBytes, memoryWatermarkBytes) => {
|
|
49
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, facts: { rabbitmq: {
|
|
50
|
+
diskAlarm: true, memoryAlarm: true, diskAvailableBytes, diskWatermarkBytes, memoryUsedBytes, memoryWatermarkBytes,
|
|
51
|
+
} } }} />)
|
|
52
|
+
for (const value of [diskAvailableBytes, diskWatermarkBytes, memoryUsedBytes, memoryWatermarkBytes]) {
|
|
53
|
+
expect(html).toContain(`>${value.toLocaleString()} bytes</span>`)
|
|
54
|
+
}
|
|
55
|
+
expect(html).toContain('can lag the alarm state')
|
|
56
|
+
})
|
|
57
|
+
it('does not display facts when collection is unavailable', () => {
|
|
58
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, outcome: 'unavailable', reason: 'endpoint_denied', facts: { rabbitmq: { diskAlarm: false, memoryAlarm: false } } }} />)
|
|
59
|
+
expect(html).toContain('Evidence unavailable')
|
|
60
|
+
expect(html).toContain('requires authorization')
|
|
61
|
+
expect(html).not.toContain('Disk alarm')
|
|
62
|
+
})
|
|
63
|
+
it('keeps NATS partial coverage and account identity visible', () => {
|
|
64
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'nats', facts: { nats: { jetStreamEnabled: true, coverage: 'partial', returnedAccounts: 1, returnedStreams: 1, returnedConsumers: 1, truncated: true, consumers: [{ account: '$G', stream: 'events', name: 'worker', pending: 5, ackPending: 0, redelivered: 0 }] } } }} />)
|
|
65
|
+
expect(html).toContain('partial')
|
|
66
|
+
expect(html).toContain('Truncated')
|
|
67
|
+
expect(html).toContain('$G / events / worker')
|
|
68
|
+
expect(html).not.toContain('stuck')
|
|
69
|
+
})
|
|
70
|
+
it('preserves exact NATS positions and shows missing activity as unavailable', () => {
|
|
71
|
+
const facts: ApplicationEvidenceResult['facts'] = { nats: { jetStreamEnabled: true, coverage: 'node_reported', returnedAccounts: 1, returnedStreams: 1, returnedConsumers: 1, truncated: false, consumers: [{ account: '$G', stream: 'events', name: 'worker', pending: 5, ackPending: 0, redelivered: 0, delivered: { consumerSequence: '18446744073709551615', streamSequence: '9007199254740993' }, ackFloor: { consumerSequence: '0', streamSequence: '0', lastActive: '2026-11-03T01:44:18.902568436Z' }, waitingPullRequests: 0 }] } }
|
|
72
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'nats', facts }} />)
|
|
73
|
+
expect(html).toContain('18446744073709551615')
|
|
74
|
+
expect(html).toContain('9007199254740993')
|
|
75
|
+
expect(html).toContain(new Date('2026-11-03T01:44:18.902568436Z').toLocaleString())
|
|
76
|
+
expect(html).toContain('Last delivery</dt><dd class="break-words">Unavailable')
|
|
77
|
+
expect(html).toContain('Waiting pull requests on this node</dt><dd>0')
|
|
78
|
+
expect(html).toContain('zero can also reflect a push consumer or non-leader replica')
|
|
79
|
+
expect(html).toContain('a non-leader replica can report zero pending messages')
|
|
80
|
+
expect(html).toContain('one snapshot cannot establish stalled progress')
|
|
81
|
+
expect(html).not.toContain('never active')
|
|
82
|
+
const unavailable = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'nats', outcome: 'unavailable', reason: 'endpoint_denied', facts }} />)
|
|
83
|
+
expect(unavailable).not.toContain('Consumer progress')
|
|
84
|
+
expect(unavailable).not.toContain('18446744073709551615')
|
|
85
|
+
})
|
|
86
|
+
it.each([
|
|
87
|
+
{ initialized: false, sealed: true },
|
|
88
|
+
{ initialized: true, sealed: true },
|
|
89
|
+
])('does not present a Vault role while initialized=$initialized sealed=$sealed', state => {
|
|
90
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { ...state, standby: true, performanceStandby: false } } }} />)
|
|
91
|
+
expect(html).toContain('Initialized')
|
|
92
|
+
expect(html).toContain('Sealed')
|
|
93
|
+
expect(html).not.toContain('Standby')
|
|
94
|
+
expect(html).not.toContain('Performance standby')
|
|
95
|
+
})
|
|
96
|
+
it('shows reported Vault roles after initialization and unsealing', () => {
|
|
97
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { initialized: true, sealed: false, standby: true, performanceStandby: false } } }} />)
|
|
98
|
+
expect(html).toContain('Standby')
|
|
99
|
+
expect(html).toContain('Performance standby')
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it.each(['pod_not_running', 'container_not_running', 'endpoint_port_not_declared', 'unsupported_image', 'ambiguous_target', 'host_network_unsupported', 'cluster_unavailable', 'invalid_target'])('explains %s without exposing a raw code', reason => {
|
|
104
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, outcome: 'unavailable', reason }} />)
|
|
105
|
+
expect(html).not.toContain(reason)
|
|
106
|
+
expect(html).toContain('No conclusion about application health')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
describe('Vault HA observations', () => {
|
|
111
|
+
it.each([
|
|
112
|
+
{ value: true, text: 'Reported healthy' },
|
|
113
|
+
{ value: false, text: 'Reported unhealthy' },
|
|
114
|
+
{ value: undefined, text: 'Unknown' },
|
|
115
|
+
])('keeps standby connection $value distinct from unknown', ({ value, text }) => {
|
|
116
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { initialized: true, sealed: false, standby: true, haConnectionHealthy: value } } }} />)
|
|
117
|
+
expect(html).toContain('Connection to active node')
|
|
118
|
+
expect(html).toContain(text)
|
|
119
|
+
if (value === undefined) expect(html).toContain('Connectivity is unknown')
|
|
120
|
+
else expect(html).not.toContain('Connectivity is unknown')
|
|
121
|
+
expect(html).toContain('other replicas were not checked')
|
|
122
|
+
expect(html).not.toContain('Removal from HA cluster')
|
|
123
|
+
})
|
|
124
|
+
it.each([
|
|
125
|
+
{ initialized: false, sealed: true, standby: true },
|
|
126
|
+
{ initialized: true, sealed: true, standby: true },
|
|
127
|
+
{ initialized: true, sealed: false, standby: false },
|
|
128
|
+
])('does not present inapplicable HA connection for $initialized/$sealed/$standby', state => {
|
|
129
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { ...state, haConnectionHealthy: false } } }} />)
|
|
130
|
+
expect(html).not.toContain('Connection to active node')
|
|
131
|
+
expect(html).not.toContain('Reported unhealthy')
|
|
132
|
+
})
|
|
133
|
+
it('keeps performance standby connection evidence applicable', () => {
|
|
134
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { initialized: true, sealed: false, standby: false, performanceStandby: true, haConnectionHealthy: false } } }} />)
|
|
135
|
+
expect(html).toContain('Connection to active node')
|
|
136
|
+
expect(html).toContain('Reported unhealthy')
|
|
137
|
+
})
|
|
138
|
+
it.each([{ initialized: true, removedFromCluster: true }, { initialized: true, removedFromCluster: false }, { initialized: false, removedFromCluster: false }])('shows removal $removedFromCluster with initialized=$initialized even while sealed', ({ initialized, removedFromCluster }) => {
|
|
139
|
+
const html = renderToStaticMarkup(<ApplicationEvidenceObservation result={{ ...result, adapter: 'vault', facts: { vault: { initialized, sealed: true, standby: true, removedFromCluster } } }} />)
|
|
140
|
+
expect(html).toContain(`<dt>Removal from HA cluster</dt><dd>${removedFromCluster ? 'Reported' : 'Not reported'}</dd>`)
|
|
141
|
+
expect(html).not.toContain('Standby')
|
|
142
|
+
expect(html).not.toContain('Connection to active node')
|
|
143
|
+
})
|
|
144
|
+
})
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, useId } from 'react'
|
|
2
|
+
import { useQuery } from '@tanstack/react-query'
|
|
3
|
+
import { AlertBanner } from '@skyhook-io/k8s-ui/components/ui/drawer-components'
|
|
4
|
+
import { SelectMenu } from '@skyhook-io/k8s-ui/components/ui/SelectMenu'
|
|
5
|
+
import { copyText } from '@skyhook-io/k8s-ui/utils/clipboard'
|
|
6
|
+
import { DialogPortal } from '@skyhook-io/k8s-ui/components/ui/DialogPortal'
|
|
7
|
+
import { TimeValue } from '@skyhook-io/k8s-ui/components/ui/ScheduleValue'
|
|
8
|
+
import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure'
|
|
9
|
+
import { Tooltip } from '@skyhook-io/k8s-ui/components/ui/Tooltip'
|
|
10
|
+
import { formatMemoryBytes } from '@skyhook-io/k8s-ui/utils/format'
|
|
11
|
+
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
12
|
+
import { ApiError, fetchJSON, useClusterInfo, useCapabilities, useRadarFeature } from '../../api/client'
|
|
13
|
+
import { collectApplicationEvidence, type ApplicationEvidenceResult, type EvidenceCandidate, type EvidenceCandidates } from '../../api/application-evidence'
|
|
14
|
+
|
|
15
|
+
const unavailableReasons: Record<string, string> = {
|
|
16
|
+
pod_not_running: 'The selected Pod is no longer running.',
|
|
17
|
+
container_not_running: 'The selected application container is not running.',
|
|
18
|
+
endpoint_port_not_declared: 'The Pod no longer declares the supported application endpoint port.',
|
|
19
|
+
unsupported_image: 'The Pod no longer uses a supported application image.',
|
|
20
|
+
ambiguous_target: 'Radar could not identify one supported application container in this Pod.',
|
|
21
|
+
host_network_unsupported: 'Evidence collection is not supported for Pods using host networking.',
|
|
22
|
+
cluster_unavailable: 'The Kubernetes connection is unavailable.',
|
|
23
|
+
invalid_target: 'The selected Pod identity is incomplete.',
|
|
24
|
+
unsupported_adapter: 'The requested application is not supported.',
|
|
25
|
+
endpoint_denied: 'The application endpoint requires authorization.',
|
|
26
|
+
endpoint_unavailable: 'The application endpoint could not be reached.',
|
|
27
|
+
endpoint_response_unavailable: 'The application endpoint did not return a readable response.',
|
|
28
|
+
port_forward_unavailable: 'Radar could not open a Kubernetes port-forward to this Pod.',
|
|
29
|
+
pod_read_unavailable: 'Radar could not read the selected Pod.',
|
|
30
|
+
pod_recheck_unavailable: 'Radar could not verify the Pod identity after collection.',
|
|
31
|
+
target_changed: 'The selected Pod changed. Select a current Pod before collecting again.',
|
|
32
|
+
collection_busy: 'Other evidence collections are running. Try again shortly.',
|
|
33
|
+
collection_cancelled: 'Collection was cancelled or timed out.',
|
|
34
|
+
response_too_large: 'The endpoint response exceeded the collection size limit.',
|
|
35
|
+
missing_alarm_metrics: 'The response did not include the required RabbitMQ alarm metrics.',
|
|
36
|
+
invalid_alarm_metric: 'The endpoint returned invalid RabbitMQ metrics.',
|
|
37
|
+
ambiguous_alarm_metric: 'The endpoint returned conflicting alarm values.',
|
|
38
|
+
unexpected_shape: 'The response did not match the supported application format.',
|
|
39
|
+
unexpected_http_status: 'The endpoint returned an unsupported HTTP status.',
|
|
40
|
+
redirect_refused: 'The endpoint redirected the request; Radar does not follow redirects.',
|
|
41
|
+
}
|
|
42
|
+
const refreshTargetReasons = new Set(['target_changed', 'pod_not_running', 'container_not_running', 'endpoint_port_not_declared', 'unsupported_image', 'ambiguous_target', 'host_network_unsupported'])
|
|
43
|
+
const applicationNames = { rabbitmq: 'RabbitMQ', nats: 'NATS', vault: 'Vault' }
|
|
44
|
+
type AvailableCandidates = EvidenceCandidates & { context: string }
|
|
45
|
+
interface Props { kind: string; group?: string; namespace: string; name: string; uid: string }
|
|
46
|
+
|
|
47
|
+
export function ApplicationEvidenceAction(props: Props) {
|
|
48
|
+
const { data: cluster } = useClusterInfo()
|
|
49
|
+
const { data: capabilities } = useCapabilities()
|
|
50
|
+
const { guard, gatedKey, support } = useRadarFeature('applicationEvidence')
|
|
51
|
+
const context = cluster?.context
|
|
52
|
+
const subjectKey = `${context}:${props.kind}:${props.group}:${props.namespace}:${props.name}:${props.uid}`
|
|
53
|
+
const permissionRetryTarget = useRef<string | undefined>(undefined)
|
|
54
|
+
const { data, dataUpdatedAt, error, refetch, isFetching } = useQuery({
|
|
55
|
+
queryKey: ['application-evidence-candidates', context, props.kind, props.group, props.namespace, props.name, props.uid, ...gatedKey],
|
|
56
|
+
queryFn: ({ signal }) => guard(() => fetchJSON<EvidenceCandidates>(`/application-evidence/candidates?${new URLSearchParams({ kind: props.kind, group: props.group ?? '', namespace: props.namespace, name: props.name, retryPermissions: String(permissionRetryTarget.current === subjectKey) })}`, signal)),
|
|
57
|
+
enabled: support !== 'unsupported' && !!context && !!props.uid && !!props.namespace && capabilities?.deployment?.mode === 'local',
|
|
58
|
+
placeholderData: previous => previous,
|
|
59
|
+
retry: (failures, failure) => failures < 1 && failure instanceof ApiError && (failure.status === 503 || failure.status === 409),
|
|
60
|
+
staleTime: 30_000,
|
|
61
|
+
refetchOnWindowFocus: false,
|
|
62
|
+
})
|
|
63
|
+
const available = data
|
|
64
|
+
const retry = () => { if (available?.permissionCheckTimedOut || available?.permissionCheckFailed) permissionRetryTarget.current = subjectKey; void refetch() }
|
|
65
|
+
if (support === 'unsupported' || !context || !props.namespace || capabilities?.deployment?.mode !== 'local') return null
|
|
66
|
+
const retryError = error && (permissionRetryTarget.current === subjectKey || available?.enabled && available.context === context && available.subjectUID === props.uid && available.candidates.length > 0) ? <div className="mt-3"><AlertBanner variant="warning" title="Could not refresh application evidence" message={<>{error instanceof Error ? error.message : 'Could not verify application evidence permissions.'} <button type="button" className="text-accent-text hover:underline disabled:opacity-50" disabled={isFetching} onClick={retry}>{isFetching ? 'Checking…' : available?.permissionCheckTimedOut || available?.permissionCheckFailed ? 'Retry permission check' : 'Retry'}</button></>} /></div> : null
|
|
67
|
+
if (!available?.enabled || !available.context || available.context !== context || available.subjectUID !== props.uid) return retryError
|
|
68
|
+
const candidates = error instanceof ApiError && [403, 404, 409, 503].includes(error.status) ? [] : available.candidates
|
|
69
|
+
return <>
|
|
70
|
+
{retryError}
|
|
71
|
+
{!retryError && (available.permissionCheckTimedOut || available.permissionCheckFailed) && <div className="mt-3 text-sm text-theme-text-secondary">Application evidence permissions could not be verified{available.permissionCheckTimedOut ? ' in time' : ''}. <button type="button" className="text-accent-text hover:underline disabled:opacity-50" disabled={isFetching} onClick={retry}>{isFetching ? 'Checking…' : 'Retry permission check'}</button></div>}
|
|
72
|
+
<EvidenceControl key={`${context}:${props.uid}`} data={{ ...available, context: available.context, candidates }} refreshing={isFetching} dataUpdatedAt={dataUpdatedAt} onTargetChanged={retry} />
|
|
73
|
+
</>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function EvidenceControl({ data, refreshing, dataUpdatedAt, onTargetChanged }: { data: AvailableCandidates; refreshing: boolean; dataUpdatedAt: number; onTargetChanged: () => void }) {
|
|
77
|
+
const [snapshot, setSnapshot] = useState<AvailableCandidates>()
|
|
78
|
+
const [open, setOpen] = useState(false)
|
|
79
|
+
const [session, setSession] = useState(0)
|
|
80
|
+
const [rejectedAt, setRejectedAt] = useState<number>()
|
|
81
|
+
const current = { ...data, candidates: rejectedAt !== undefined && (rejectedAt === dataUpdatedAt || refreshing) ? [] : data.candidates }
|
|
82
|
+
if (!snapshot && current.candidates.length === 0) return null
|
|
83
|
+
const names = [...new Set(current.candidates.map(item => applicationNames[item.application]))].join(', ')
|
|
84
|
+
return <div className="mt-3">
|
|
85
|
+
{current.candidates.length > 0 && <button type="button" className="text-sm text-accent-text hover:underline disabled:opacity-50" disabled={refreshing} onClick={() => { setSnapshot(current); setSession(value => value + 1); setOpen(true) }}>Collect {names} evidence</button>}
|
|
86
|
+
{snapshot && <EvidenceDialog key={session} open={open} data={snapshot} currentData={current} refreshing={refreshing} onTargetChanged={() => { setRejectedAt(dataUpdatedAt); onTargetChanged() }} onClose={() => setOpen(false)} />}
|
|
87
|
+
</div>
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function EvidenceDialog({ open, data, currentData, refreshing, onClose, onTargetChanged }: { open: boolean; data: AvailableCandidates; currentData: AvailableCandidates; refreshing: boolean; onClose: () => void; onTargetChanged: () => void }) {
|
|
91
|
+
const titleId = useId()
|
|
92
|
+
const targetId = useId()
|
|
93
|
+
const [selected, setSelected] = useState<EvidenceCandidate | undefined>(data.candidates[0])
|
|
94
|
+
const [useCurrentTargets, setUseCurrentTargets] = useState(false)
|
|
95
|
+
const [result, setResult] = useState<ApplicationEvidenceResult>()
|
|
96
|
+
const [error, setError] = useState<string>()
|
|
97
|
+
const [copied, setCopied] = useState(false)
|
|
98
|
+
const [pending, setPending] = useState(false)
|
|
99
|
+
const request = useRef<AbortController | undefined>(undefined)
|
|
100
|
+
useEffect(() => () => request.current?.abort(), [])
|
|
101
|
+
const choices = useCurrentTargets ? currentData : data
|
|
102
|
+
const candidate = choices.candidates.find(item => item.application === selected?.application && item.target.uid === selected?.target.uid && item.target.container === selected?.target.container)
|
|
103
|
+
const collect = async () => {
|
|
104
|
+
if (!candidate) return
|
|
105
|
+
request.current?.abort()
|
|
106
|
+
const controller = new AbortController()
|
|
107
|
+
request.current = controller
|
|
108
|
+
setPending(true)
|
|
109
|
+
setResult(undefined)
|
|
110
|
+
setCopied(false)
|
|
111
|
+
setError(undefined)
|
|
112
|
+
try {
|
|
113
|
+
const response = await collectApplicationEvidence(candidate, data.context, controller.signal)
|
|
114
|
+
if (!controller.signal.aborted) {
|
|
115
|
+
setResult(response)
|
|
116
|
+
if (response.reason && refreshTargetReasons.has(response.reason)) {
|
|
117
|
+
setSelected(undefined)
|
|
118
|
+
setUseCurrentTargets(true)
|
|
119
|
+
onTargetChanged()
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
if (!controller.signal.aborted) setError(e instanceof Error ? e.message : 'Collection failed')
|
|
124
|
+
} finally {
|
|
125
|
+
if (!controller.signal.aborted) setPending(false)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const close = () => { request.current?.abort(); onClose() }
|
|
129
|
+
return <DialogPortal ariaLabelledBy={titleId} open={open} onClose={close} className="w-[min(92vw,640px)] max-h-[85vh] overflow-y-auto p-5">
|
|
130
|
+
<h2 id={titleId} className="text-lg font-semibold text-theme-text-primary">Collect application evidence</h2>
|
|
131
|
+
<p className="mt-2 text-sm text-theme-text-secondary">Read one Pod’s application endpoint through a temporary Kubernetes port-forward using your current permissions.</p>
|
|
132
|
+
<p className="mt-2 break-all text-xs text-theme-text-tertiary">Context: {data.context}</p>
|
|
133
|
+
<label className="mt-4 block text-sm text-theme-text-primary" htmlFor={targetId}>Pod endpoint</label>
|
|
134
|
+
<SelectMenu id={targetId} ariaLabel="Pod endpoint" className="mt-1" value={candidate ? String(choices.candidates.indexOf(candidate)) : ''} placeholder="Select a current Pod" disabled={pending || useCurrentTargets && refreshing || choices.candidates.length === 0}
|
|
135
|
+
options={choices.candidates.map((item, index) => ({ value: String(index), label: `${applicationNames[item.application]} · ${item.target.namespace}/${item.target.pod} · ${item.target.container}` }))}
|
|
136
|
+
onChange={value => { setSelected(choices.candidates[Number(value)]); setError(undefined); setCopied(false) }} />
|
|
137
|
+
{candidate ? <>
|
|
138
|
+
<p className="mt-2 text-sm text-theme-text-secondary">Collects: {candidate.expectedEvidence.join(', ')}.</p>
|
|
139
|
+
<p className="mt-1 text-xs text-theme-text-tertiary">{candidate.coverage}</p>
|
|
140
|
+
</> : <p className="mt-2 text-sm text-theme-text-secondary">{refreshing ? 'Refreshing available Pods…' : choices.candidates.length > 0 ? 'Select a current Pod before collecting again.' : <>A current Pod endpoint has not been verified. <button type="button" className="text-accent-text hover:underline" onClick={onTargetChanged}>Refresh Pod choices</button></>}</p>}
|
|
141
|
+
{(choices.truncated || choices.coverageLimited) && <p className="mt-2 text-xs text-theme-text-secondary">Discovery or permission limits may exclude endpoints. To inspect another endpoint, open that Pod directly.</p>}
|
|
142
|
+
<p className="mt-2 text-xs text-theme-text-tertiary">Requires a reachable default plaintext endpoint; credentials, TLS and custom ports are not supported.</p>
|
|
143
|
+
{error && <div role="alert" className="mt-4"><AlertBanner variant="error" title="Could not complete the request" message={error} /></div>}
|
|
144
|
+
{result && <ApplicationEvidenceObservation result={result} />}
|
|
145
|
+
<div className="mt-5 flex flex-wrap justify-end gap-2">
|
|
146
|
+
{result && <button type="button" className="btn-brand-muted px-3 py-2 text-sm" onClick={async () => { const success = await copyText(JSON.stringify({ context: data.context, ...result }, null, 2)); setCopied(success); if (!success) setError('Could not copy the observation.'); }}>{copied ? 'Copied' : 'Copy observation'}</button>}
|
|
147
|
+
<button type="button" className="btn-brand-muted px-3 py-2 text-sm" onClick={close}>{pending ? 'Cancel' : 'Close'}</button>
|
|
148
|
+
<button type="button" className="btn-brand px-3 py-2 text-sm" disabled={pending || !candidate} onClick={collect}>{pending ? 'Collecting…' : result ? 'Collect again' : 'Collect evidence'}</button>
|
|
149
|
+
</div>
|
|
150
|
+
</DialogPortal>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function RabbitMQMeasurement({ value }: { value: number | undefined }) {
|
|
154
|
+
return <dd className="break-words">{value === undefined ? 'Unknown' : <>
|
|
155
|
+
<span className="block">{formatMemoryBytes(value)}</span>
|
|
156
|
+
<span className="block text-xs text-theme-text-tertiary">{value.toLocaleString()} bytes</span>
|
|
157
|
+
</>}</dd>
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function ApplicationEvidenceObservation({ result }: { result: ApplicationEvidenceResult }) {
|
|
161
|
+
const facts = result.outcome === 'observed' ? result.facts : undefined
|
|
162
|
+
const rabbitmq = facts?.rabbitmq
|
|
163
|
+
const nats = facts?.nats
|
|
164
|
+
const vault = facts?.vault
|
|
165
|
+
return <section aria-label="Application observations" className="card-inner mt-4 p-3 text-sm text-theme-text-primary">
|
|
166
|
+
<h3 className="font-semibold">{result.outcome === 'observed' ? 'Endpoint observations' : 'Evidence unavailable'}</h3>
|
|
167
|
+
<p className="mt-1 break-all text-xs text-theme-text-secondary">{result.target.namespace}/{result.target.pod}{result.target.container && ` · ${result.target.container}`}</p>
|
|
168
|
+
<p className="mt-1 text-xs text-theme-text-tertiary"><TimeValue timestamp={result.observedAt} /> · {result.source.replaceAll('_', ' ')}{result.httpStatus !== undefined && ` · Endpoint status: HTTP ${result.httpStatus}`}</p>
|
|
169
|
+
{facts && <p className="mt-2 text-xs text-theme-text-secondary">This Pod at collection time; other replicas were not checked.</p>}
|
|
170
|
+
{result.reason && <p className="mt-2">{unavailableReasons[result.reason] ?? `Collection unavailable (${result.reason}).`} No conclusion about application health can be drawn from unavailable evidence.</p>}
|
|
171
|
+
{rabbitmq && <>
|
|
172
|
+
<dl className="mt-3 grid grid-cols-2 gap-2">
|
|
173
|
+
<dt>Disk alarm</dt><dd>{rabbitmq.diskAlarm ? 'Reported' : 'Not reported'}</dd>
|
|
174
|
+
<dt>Free disk</dt><RabbitMQMeasurement value={rabbitmq.diskAvailableBytes} />
|
|
175
|
+
<dt>Disk alarm below</dt><RabbitMQMeasurement value={rabbitmq.diskWatermarkBytes} />
|
|
176
|
+
<dt>Memory alarm</dt><dd>{rabbitmq.memoryAlarm ? 'Reported' : 'Not reported'}</dd>
|
|
177
|
+
<dt>Memory used (RabbitMQ)</dt><RabbitMQMeasurement value={rabbitmq.memoryUsedBytes} />
|
|
178
|
+
<dt>Memory alarm above</dt><RabbitMQMeasurement value={rabbitmq.memoryWatermarkBytes} />
|
|
179
|
+
</dl>
|
|
180
|
+
<p className="mt-2 text-xs text-theme-text-secondary">Measurements are RabbitMQ’s periodic statistics and can lag the alarm state. Its memory watermark is not the container memory limit; the container can be OOM-killed before this alarm fires. Unknown values were absent or could not be interpreted.</p>
|
|
181
|
+
<p className="mt-2 text-xs text-theme-text-secondary">A disk or memory alarm on another node can block publishers across the cluster.</p>
|
|
182
|
+
</>}
|
|
183
|
+
{vault && <dl className="mt-3 grid grid-cols-2 gap-2">
|
|
184
|
+
<dt>Initialized</dt><dd>{vault.initialized ? 'Yes' : 'No'}</dd>
|
|
185
|
+
<dt>Sealed</dt><dd>{vault.sealed ? 'Yes' : 'No'}</dd>
|
|
186
|
+
{vault.initialized && !vault.sealed && <>
|
|
187
|
+
<dt>Standby</dt><dd>{vault.standby ? 'Yes' : 'No'}</dd>
|
|
188
|
+
{vault.performanceStandby !== undefined && <><dt>Performance standby</dt><dd>{vault.performanceStandby ? 'Yes' : 'No'}</dd></>}
|
|
189
|
+
{(vault.standby || vault.performanceStandby) && <><dt>Connection to active node</dt><dd>{vault.haConnectionHealthy === undefined ? 'Unknown' : vault.haConnectionHealthy ? 'Reported healthy' : 'Reported unhealthy'}</dd></>}
|
|
190
|
+
</>}
|
|
191
|
+
{vault.removedFromCluster !== undefined && <><dt>Removal from HA cluster</dt><dd>{vault.removedFromCluster ? 'Reported' : 'Not reported'}</dd></>}
|
|
192
|
+
</dl>}
|
|
193
|
+
{vault?.initialized && !vault.sealed && (vault.standby || vault.performanceStandby) && vault.haConnectionHealthy === undefined && <p className="mt-2 text-xs text-theme-text-secondary">Vault can omit the heartbeat report after a leader change. Connectivity is unknown.</p>}
|
|
194
|
+
{nats && <div className="mt-3 space-y-2">
|
|
195
|
+
<p>JetStream: {nats.jetStreamEnabled ? 'Enabled' : 'Disabled'}</p>
|
|
196
|
+
<p className="text-xs text-theme-text-secondary">Coverage: {nats.coverage.replaceAll('_', ' ')} · {pluralize(nats.returnedAccounts, 'account')} · {pluralize(nats.returnedStreams, 'stream')} · {pluralize(nats.returnedConsumers, 'consumer')} returned{nats.truncated ? ' · Truncated' : ''}</p>
|
|
197
|
+
{nats.totals && <p>Node reports {pluralize(nats.totals.messages, 'message')} across {pluralize(nats.totals.streams, 'stream')} and {pluralize(nats.totals.consumers, 'consumer')}.</p>}
|
|
198
|
+
{nats.consumers.length > 0 && <div className="overflow-x-auto"><table className="w-full min-w-[480px] text-left text-xs"><thead><tr><th className="pr-3">Account / stream / consumer</th><th className="pr-3">Pending</th><th className="pr-3">Ack pending</th><th>Redelivered</th></tr></thead><tbody>{nats.consumers.map(item => <tr key={JSON.stringify([item.account, item.stream, item.name])}><td className="py-2 pr-3 break-all">{item.account} / {item.stream} / {item.name}</td><td>{item.pending}</td><td>{item.ackPending}</td><td>{item.redelivered}</td></tr>)}</tbody></table></div>}
|
|
199
|
+
{nats.consumers.length > 0 && <p className="text-xs text-theme-text-secondary">Counts are node-reported; a non-leader replica can report zero pending messages.</p>}
|
|
200
|
+
{nats.consumers.length > 0 && <Disclosure summary="Consumer progress" summaryClassName="text-xs text-theme-text-secondary">
|
|
201
|
+
<p className="mt-2 text-xs text-theme-text-secondary">Positions are not lag; one snapshot cannot establish stalled progress. Missing or invalid values are unavailable, not proof of inactivity. Waiting requests apply to pull consumers; zero can also reflect a push consumer or non-leader replica.</p>
|
|
202
|
+
<div className="mt-2 space-y-3">{nats.consumers.map(item => <div key={JSON.stringify([item.account, item.stream, item.name])} className="card-inner p-2 text-xs">
|
|
203
|
+
<p className="break-all font-medium">{item.account} / {item.stream} / {item.name}</p>
|
|
204
|
+
<dl className="mt-2 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-2">
|
|
205
|
+
<dt>Delivered</dt><dd className="break-words">Consumer seq {item.delivered?.consumerSequence ?? 'unavailable'} · Stream seq {item.delivered?.streamSequence ?? 'unavailable'}</dd>
|
|
206
|
+
<dt>Last delivery</dt><dd className="break-words">{item.delivered?.lastActive ? <Tooltip content={item.delivered.lastActive}><span>{new Date(item.delivered.lastActive).toLocaleString()}</span></Tooltip> : 'Unavailable'}</dd>
|
|
207
|
+
<dt>Ack floor</dt><dd className="break-words">Consumer seq {item.ackFloor?.consumerSequence ?? 'unavailable'} · Stream seq {item.ackFloor?.streamSequence ?? 'unavailable'}</dd>
|
|
208
|
+
<dt>Last ack</dt><dd className="break-words">{item.ackFloor?.lastActive ? <Tooltip content={item.ackFloor.lastActive}><span>{new Date(item.ackFloor.lastActive).toLocaleString()}</span></Tooltip> : 'Unavailable'}</dd>
|
|
209
|
+
<dt className="max-w-36">Waiting pull requests on this node</dt><dd>{item.waitingPullRequests ?? 'Unavailable'}</dd>
|
|
210
|
+
</dl>
|
|
211
|
+
</div>)}</div>
|
|
212
|
+
</Disclosure>}
|
|
213
|
+
</div>}
|
|
214
|
+
{result.limitations.length > 0 && <Disclosure summary="Collection limits" className="mt-3" summaryClassName="text-xs text-theme-text-secondary">
|
|
215
|
+
<ul className="mt-2 space-y-1 text-xs text-theme-text-secondary">{result.limitations.map(item => <li key={item}>{item}</li>)}</ul>
|
|
216
|
+
</Disclosure>}
|
|
217
|
+
</section>
|
|
218
|
+
}
|