@skyhook-io/radar-app 1.20.0 → 1.20.3

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.
Files changed (109) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +18 -11
  3. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  4. package/src/api/client.pauseDeployment.test.tsx +77 -0
  5. package/src/api/client.restartError.test.ts +14 -0
  6. package/src/api/client.revisionRefresh.test.tsx +44 -0
  7. package/src/api/client.rollbackError.test.ts +14 -0
  8. package/src/api/client.ts +287 -21
  9. package/src/api/helmInventory.test.tsx +108 -0
  10. package/src/api/networkAttachments.test.tsx +120 -0
  11. package/src/api/networkAttachments.ts +30 -0
  12. package/src/api/radarFeatures.test.ts +5 -0
  13. package/src/api/radarFeatures.ts +5 -0
  14. package/src/api/secretsStore.test.ts +33 -0
  15. package/src/api/secretsStore.ts +37 -0
  16. package/src/components/ConnectionErrorView.test.tsx +11 -0
  17. package/src/components/ConnectionErrorView.tsx +19 -0
  18. package/src/components/ContextSwitcher.tsx +9 -2
  19. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  20. package/src/components/applications/ApplicationsView.tsx +8 -11
  21. package/src/components/cost/CostView.tsx +27 -9
  22. package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
  23. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  24. package/src/components/diagnose/InvestigationView.tsx +12 -3
  25. package/src/components/diagnose/investigationCase.test.tsx +41 -0
  26. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  27. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  28. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +61 -16
  29. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  30. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  31. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  32. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  33. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  34. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  35. package/src/components/dock/TerminalPreferences.tsx +73 -0
  36. package/src/components/gitops/GitOpsView.tsx +1 -9
  37. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  38. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  39. package/src/components/helm/HelmReleaseDrawer.tsx +47 -98
  40. package/src/components/helm/HelmView.tsx +215 -71
  41. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  42. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  43. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  44. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  45. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  46. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  47. package/src/components/helm/OwnedResources.test.tsx +86 -0
  48. package/src/components/helm/OwnedResources.tsx +69 -10
  49. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  50. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  51. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  52. package/src/components/home/ClusterHealthCard.tsx +49 -14
  53. package/src/components/home/HelmSummary.tsx +38 -19
  54. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  55. package/src/components/home/HomeAgentBlock.tsx +7 -0
  56. package/src/components/home/MCPSetupDialog.test.tsx +38 -12
  57. package/src/components/home/MCPSetupDialog.tsx +5 -2
  58. package/src/components/home/mcpToolCatalog.ts +45 -5
  59. package/src/components/issues/uncheckedSources.test.ts +2 -0
  60. package/src/components/issues/uncheckedSources.ts +3 -0
  61. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  62. package/src/components/resource/RightsizingStrip.tsx +53 -4
  63. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  64. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  65. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  66. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  67. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  68. package/src/components/resources/pod-file-upload.ts +266 -0
  69. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  70. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  71. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  72. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  73. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  74. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  75. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  76. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  77. package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
  78. package/src/components/rightsizing/model.test.ts +11 -0
  79. package/src/components/rightsizing/model.ts +3 -1
  80. package/src/components/rightsizing/presentation.test.ts +46 -0
  81. package/src/components/rightsizing/presentation.ts +17 -2
  82. package/src/components/traffic/TrafficView.tsx +27 -27
  83. package/src/components/traffic/trafficFilters.test.ts +18 -1
  84. package/src/components/traffic/trafficFilters.ts +30 -1
  85. package/src/components/ui/Omnibar.tsx +4 -1
  86. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  87. package/src/components/ui/RadarOmnibar.tsx +7 -1
  88. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  89. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  90. package/src/components/ui/UpdateNotification.test.tsx +23 -1
  91. package/src/components/ui/UpdateNotification.tsx +26 -2
  92. package/src/components/ui/omnibar-match.test.ts +7 -0
  93. package/src/components/ui/omnibar-match.ts +1 -0
  94. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  95. package/src/components/ui/searchCoverageNote.ts +31 -7
  96. package/src/components/useContextSwitchFlow.tsx +9 -1
  97. package/src/components/whats-new/releaseNotes.ts +1 -1
  98. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  99. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  100. package/src/components/workload/WorkloadView.tsx +51 -11
  101. package/src/context/ConnectionContext.test.ts +1 -0
  102. package/src/context/ConnectionContext.tsx +2 -2
  103. package/src/contexts/CapabilitiesContext.tsx +2 -0
  104. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  105. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  106. package/src/integrations/resourceHosts.test.tsx +2 -2
  107. package/src/integrations/resourceHosts.tsx +9 -0
  108. package/src/utils/namespacePick.test.ts +87 -0
  109. package/src/utils/namespacePick.ts +88 -0
@@ -3,6 +3,7 @@ import type { RightsizingRow } from '../../api/client'
3
3
  import {
4
4
  getRightsizingExplanation,
5
5
  getRightsizingPresentation,
6
+ podLevelOverUseNote,
6
7
  RIGHTSIZING_METHODOLOGY,
7
8
  RIGHTSIZING_DOCS_URL,
8
9
  RIGHTSIZING_SUMMARY,
@@ -145,3 +146,59 @@ describe('live pod inventory', () => {
145
146
  )
146
147
  })
147
148
  })
149
+
150
+ describe('pod-level request rows', () => {
151
+ it('explains the pod-level value instead of promising a per-container verdict', () => {
152
+ const message = getRightsizingExplanation(
153
+ row({
154
+ fit: 'pod_level_request',
155
+ recommendationReason: 'pod_level_request',
156
+ podLevelRequest: '128Mi',
157
+ resource: 'memory',
158
+ }),
159
+ )
160
+ expect(message).toContain('128Mi')
161
+ })
162
+
163
+ it('labels a fit this frontend does not know instead of rendering nothing', () => {
164
+ const unknownFit = 'future_fit' as unknown as Parameters<typeof getRightsizingPresentation>[0]
165
+ expect(getRightsizingPresentation(unknownFit).label).toBe('future_fit')
166
+ })
167
+ })
168
+
169
+ describe('pod-level request below one container\'s usage', () => {
170
+ const podLevel = (observed: number, formatted: string) =>
171
+ row({
172
+ fit: 'pod_level_request',
173
+ recommendationReason: 'pod_level_request',
174
+ podLevelRequest: '200m',
175
+ podLevelRequestValue: 0.2,
176
+ observed: { name: 'P95', value: observed, formatted },
177
+ })
178
+
179
+ it('names the overuse when one container alone used more than the pod request', () => {
180
+ const message = getRightsizingExplanation(podLevel(0.44, '440m'))
181
+ expect(message).toContain('440m')
182
+ expect(podLevelOverUseNote(podLevel(0.44, '440m'))).toBe(message)
183
+ })
184
+
185
+ it('says nothing about overuse when the container stayed under the pod request', () => {
186
+ expect(podLevelOverUseNote(podLevel(0.15, '150m'))).toBeUndefined()
187
+ })
188
+
189
+ it('does not ask to raise the request when an HPA scales on it', () => {
190
+ const note = podLevelOverUseNote({ ...podLevel(0.44, '440m'), hpaManaged: true })
191
+ expect(note).toContain('440m')
192
+ expect(note).toContain('HPA')
193
+ })
194
+
195
+ it('asks for an autoscaling check when Radar could not read HPAs', () => {
196
+ const note = podLevelOverUseNote({ ...podLevel(0.44, '440m'), hpaEvidenceAvailable: false })
197
+ expect(note).toContain('440m')
198
+ expect(note).toContain('HPA')
199
+ })
200
+
201
+ it('stays quiet before six hours of samples', () => {
202
+ expect(podLevelOverUseNote({ ...podLevel(0.44, '440m'), sampleCount: 1, coverage: 0 })).toBeUndefined()
203
+ })
204
+ })
@@ -213,10 +213,10 @@ function FitCard({ row, window }: { row: RightsizingRow; window: string }) {
213
213
  <div className="flex items-baseline gap-2 tabular-nums">
214
214
  <div>
215
215
  <div className="text-[10px] uppercase tracking-wide text-theme-text-quaternary">
216
- Current request
216
+ {row.podLevelRequest ? 'Pod-level request' : 'Current request'}
217
217
  </div>
218
218
  <div className="text-lg font-semibold text-theme-text-primary">
219
- {row.currentRequest ?? 'Unset'}
219
+ {row.podLevelRequest ?? row.currentRequest ?? 'Unset'}
220
220
  </div>
221
221
  </div>
222
222
  <ArrowRight className="h-4 w-4 text-theme-text-quaternary" />
@@ -247,7 +247,9 @@ function CompactFitRow({ row }: { row: RightsizingRow }) {
247
247
  <span className="w-12 text-[10px] uppercase tracking-wide text-theme-text-quaternary">
248
248
  {row.resource}
249
249
  </span>
250
- <span className="min-w-14 text-theme-text-secondary">{row.currentRequest ?? 'unset'}</span>
250
+ <span className="min-w-14 text-theme-text-secondary">
251
+ {row.podLevelRequest ? `pod ${row.podLevelRequest}` : (row.currentRequest ?? 'unset')}
252
+ </span>
251
253
  {row.recommendedRequest && (
252
254
  <>
253
255
  <ArrowRight className="h-3 w-3 text-theme-text-quaternary" />
@@ -298,6 +300,7 @@ export function getRightsizingPresentation(fit: RightsizingFit, queryError?: str
298
300
  under_requested: 'Under-requested',
299
301
  missing_request: 'Missing request',
300
302
  insufficient_history: 'Insufficient history',
303
+ pod_level_request: 'Pod-level request',
301
304
  }
302
305
  const severities: Record<RightsizingFit, 'success' | 'info' | 'warning' | 'neutral'> = {
303
306
  balanced: 'success',
@@ -305,8 +308,10 @@ export function getRightsizingPresentation(fit: RightsizingFit, queryError?: str
305
308
  under_requested: 'warning',
306
309
  missing_request: 'warning',
307
310
  insufficient_history: 'neutral',
311
+ pod_level_request: 'neutral',
308
312
  }
309
- return { label: labels[fit], severity: severities[fit] }
313
+ // An older frontend can meet a fit added by a newer agent.
314
+ return { label: labels[fit] ?? fit, severity: severities[fit] ?? ('neutral' as const) }
310
315
  }
311
316
 
312
317
  function FitExplanation({ row }: { row: RightsizingRow }) {
@@ -327,6 +332,8 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
327
332
  'Radar could not verify recent OOM history, so it withheld a lower memory request.',
328
333
  recommended_request_exceeds_limit:
329
334
  'The evidence-based request would exceed the current limit; review the limit first.',
335
+ requests_exceed_pod_limit:
336
+ "Together with the other containers' requests and suggested increases, this request would take the pod above its pod-level limit (spec.resources), which Kubernetes rejects. Decide how to split the limit between containers, or raise the pod limit.",
330
337
  }
331
338
  // A denied pod read leaves currentPodOOM unknown rather than false, so it
332
339
  // qualifies whatever else is said instead of replacing it — including a
@@ -336,6 +343,8 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
336
343
  ? "Radar could not read this workload's pods, so it could not check them for out-of-memory restarts."
337
344
  : undefined
338
345
  const qualified = (base: string) => (inventoryNote ? `${base} ${inventoryNote}` : base)
346
+ if (row.fit === 'pod_level_request' && row.podLevelRequest && !row.queryError)
347
+ return qualified(podLevelRequestExplanation(row, row.podLevelRequest))
339
348
  if (row.reductionLimited && row.calculatedRequest && row.recommendedRequest) {
340
349
  const burstNote = row.bursty && row.peak ? ` CPU P99 reached ${row.peak.formatted}.` : ''
341
350
  return qualified(
@@ -352,6 +361,46 @@ export function getRightsizingExplanation(row: RightsizingRow): string | undefin
352
361
  )
353
362
  }
354
363
 
364
+ function podLevelRequestExplanation(row: RightsizingRow, podLevelRequest: string): string {
365
+ const overUse = podLevelOverUseNote(row)
366
+ if (overUse) return overUse
367
+ const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
368
+ const own = row.currentRequest
369
+ ? ` This container's own request (${row.currentRequest}) no longer decides what is reserved.`
370
+ : ''
371
+ return `This pod sets one ${resource} request for all its containers: ${podLevelRequest} in spec.resources. The scheduler reserves that instead of container requests, so Radar doesn't suggest a request per container; check the pod-level request against the usage of its containers.${own}`
372
+ }
373
+
374
+ /**
375
+ * One container's usage above the pod's whole request is a sound lower bound on
376
+ * the pod's own use. Adding containers up would overstate it, so only this case
377
+ * is called out.
378
+ */
379
+ export function podLevelOverUseNote(row: RightsizingRow): string | undefined {
380
+ if (
381
+ row.fit !== 'pod_level_request' ||
382
+ row.sampleCount < RIGHTSIZING_MIN_SAMPLES ||
383
+ !row.observed ||
384
+ !row.podLevelRequest ||
385
+ row.podLevelRequestValue == null ||
386
+ row.observed.value <= row.podLevelRequestValue
387
+ )
388
+ return undefined
389
+ const resource = row.resource === 'cpu' ? 'CPU' : 'memory'
390
+ const finding = `This container alone used ${row.observed.formatted} (${row.observed.name}), more than the pod's whole ${row.podLevelRequest} ${resource} request. Radar can't size pod-level requests yet.`
391
+ // An HPA scaling on this resource divides usage by the pod request, so
392
+ // raising it changes scaling; Radar never suggests that unreviewed.
393
+ if (row.hpaManaged)
394
+ return `${finding} The HPA scales on this request, so review its target before raising spec.resources.requests.${row.resource}.`
395
+ if (!row.hpaEvidenceAvailable)
396
+ return `${finding} Radar couldn't check for an HPA on this resource, so check autoscaling before raising spec.resources.requests.${row.resource}.`
397
+ return `${finding} Consider raising spec.resources.requests.${row.resource}.`
398
+ }
399
+
400
+ // Mirrors rightsizingMinSamples (six hours of 5-minute samples) in
401
+ // internal/prometheus/rightsizing.go: below it Radar draws no conclusion.
402
+ const RIGHTSIZING_MIN_SAMPLES = 72
403
+
355
404
  function confidenceLabel(row: RightsizingRow) {
356
405
  return `${row.confidence[0].toUpperCase()}${row.confidence.slice(1)} confidence`
357
406
  }
@@ -5,17 +5,24 @@ import { afterEach, expect, it, vi } from 'vitest'
5
5
  import { ImageFilesystemModal } from './ImageFilesystemModal'
6
6
  import { ApiError } from '../../api/client'
7
7
 
8
- const state = vi.hoisted(() => ({ authEnabled: false, showMetadata: false }))
8
+ const state = vi.hoisted(() => ({
9
+ authEnabled: false,
10
+ showMetadata: false,
11
+ metadataImage: 'gcr.io/project/app:v1',
12
+ errorStatus: 401,
13
+ errorData: { registryType: 'google' } as Record<string, unknown>,
14
+ refetch: (() => {}) as () => void,
15
+ }))
9
16
  vi.mock('../../contexts/CapabilitiesContext', () => ({ useIsAuthEnabled: () => state.authEnabled }))
10
17
  vi.mock('../../api/client', () => ({
11
18
  ApiError: class extends Error {
12
- status = 401
13
- data = { registryType: 'google' }
19
+ status = state.errorStatus
20
+ data = state.errorData
14
21
  },
15
22
  useImageMetadata: () => state.showMetadata ? ({
16
- data: { image: 'gcr.io/project/app:v1', digest: 'sha256:abc', platform: 'linux/amd64', totalSize: 1024, layerCount: 1, authMethod: 'google', cached: false },
17
- refetch: vi.fn(),
18
- }) : ({ error: new ApiError('Authentication required', 401), refetch: vi.fn() }),
23
+ data: { image: state.metadataImage, digest: 'sha256:abc', platform: 'linux/amd64', totalSize: 1024, layerCount: 1, authMethod: 'google', cached: false },
24
+ refetch: state.refetch,
25
+ }) : ({ error: new ApiError('Authentication required', 401), refetch: state.refetch }),
19
26
  }))
20
27
 
21
28
  vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
@@ -24,8 +31,22 @@ let root: ReturnType<typeof createRoot>
24
31
  afterEach(async () => {
25
32
  await act(async () => root.unmount())
26
33
  state.showMetadata = false
34
+ state.metadataImage = 'gcr.io/project/app:v1'
35
+ state.errorStatus = 401
36
+ state.errorData = { registryType: 'google' }
37
+ state.refetch = () => {}
38
+ vi.unstubAllGlobals()
39
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
27
40
  })
28
41
 
42
+ async function renderModal(props: { onSwitchToPodFiles?: () => void } = {}) {
43
+ root = createRoot(document.createElement('div'))
44
+ await act(async () => {
45
+ root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} {...props} />)
46
+ })
47
+ return document.body.textContent || ''
48
+ }
49
+
29
50
  it.each([true, false])('shows private-image guidance for authEnabled=%s', async (authEnabled) => {
30
51
  state.authEnabled = authEnabled
31
52
  root = createRoot(document.createElement('div'))
@@ -66,3 +87,50 @@ it.each([true, false])('shows download confirmation for authEnabled=%s', async (
66
87
  expect(text).toContain('gcloud')
67
88
  }
68
89
  })
90
+
91
+ it.each(['node_only', 'registry_unreachable'])('explains a %s image instead of a generic or sign-in error', async (reason) => {
92
+ state.errorStatus = reason === 'node_only' ? 404 : 502
93
+ state.errorData = { error: 'x', reason, registry: 'registry.example' }
94
+ const refetch = vi.fn()
95
+ state.refetch = refetch
96
+ const text = await renderModal({ onSwitchToPodFiles: () => {} })
97
+ expect(text).toContain('registry.example')
98
+ expect(text).toContain('Browse live files from running pod below')
99
+ expect(text).not.toContain('Failed to inspect image')
100
+ expect(text).not.toContain('Authentication Required')
101
+ const retry = [...document.body.querySelectorAll('button')].find((b) => b.textContent?.includes('Retry'))
102
+ if (reason === 'node_only') {
103
+ expect(retry).toBeUndefined()
104
+ } else {
105
+ await act(async () => retry?.click())
106
+ expect(refetch).toHaveBeenCalledTimes(1)
107
+ }
108
+ })
109
+
110
+ it('keeps the generic error box for an error without a known reason', async () => {
111
+ state.errorStatus = 500
112
+ state.errorData = { error: 'Failed to inspect image' }
113
+ const text = await renderModal()
114
+ expect(text).toContain('Failed to inspect image')
115
+ })
116
+
117
+ it('shows the pulled digest and downloads that exact image, not the tag', async () => {
118
+ const digest = 'sha256:' + 'a'.repeat(64)
119
+ state.showMetadata = true
120
+ state.metadataImage = 'gcr.io/project/app@' + digest
121
+ const fetchMock = vi.fn(async () => new Response(JSON.stringify({ image: state.metadataImage, root: { name: '/', path: '/', type: 'dir' }, totalFiles: 0, totalSize: 0 })))
122
+ vi.stubGlobal('fetch', fetchMock)
123
+ const text = await renderModal()
124
+ expect(text).toContain(digest)
125
+ const download = [...document.body.querySelectorAll('button')].find((b) => b.textContent === 'Download & View')
126
+ await act(async () => download?.click())
127
+ expect(fetchMock).toHaveBeenCalledTimes(1)
128
+ const url = new URL(String((fetchMock.mock.calls[0] as unknown[])[0]), 'http://radar.test')
129
+ expect(url.searchParams.get('image')).toBe(state.metadataImage)
130
+ })
131
+
132
+ it('shows no pulled digest when the server inspects the tag as given', async () => {
133
+ state.showMetadata = true
134
+ const text = await renderModal()
135
+ expect(text).not.toContain('sha256:')
136
+ })
@@ -1,6 +1,6 @@
1
1
  import { useState, useRef, useEffect, useMemo, useCallback } from 'react'
2
2
  import { createPortal } from 'react-dom'
3
- import { X, Folder, File, Link2, ChevronRight, ChevronDown, AlertTriangle, Loader2, Search, Download, HardDrive, Shield, ShieldCheck, Terminal, Copy, Check, RefreshCw } from 'lucide-react'
3
+ import { X, Folder, File, Link2, ChevronRight, ChevronDown, AlertTriangle, Loader2, Search, Download, HardDrive, Shield, ShieldCheck, Terminal, Copy, Check, RefreshCw, WifiOff } from 'lucide-react'
4
4
  import radarLoadingIcon from '@skyhook-io/k8s-ui/assets/radar/radar-icon-loading.svg'
5
5
  import { assetUrl } from '@skyhook-io/k8s-ui'
6
6
  import { clsx } from 'clsx'
@@ -78,6 +78,13 @@ export function ImageFilesystemModal({
78
78
  // Detect auth errors from metadata fetch
79
79
  const isAuthError = metadataError instanceof ApiError && metadataError.status === 401
80
80
  const registryType = isAuthError ? (metadataError.data?.registryType as string) : undefined
81
+ const unavailable = metadataError instanceof ApiError ? registryUnavailable(metadataError.data) : undefined
82
+
83
+ // The server may pin a tag to the digest the Pod pulled. Later requests
84
+ // name that exact reference, so the listing and file downloads can't drift
85
+ // to whatever the tag points at by then.
86
+ const inspectImage = metadata?.image || image
87
+ const pulledDigest = inspectImage !== image ? inspectImage.split('@')[1] : undefined
81
88
 
82
89
  // Use cached filesystem from metadata if available
83
90
  const displayFilesystem: ImageFilesystem | undefined = metadata?.cached
@@ -89,14 +96,14 @@ export function ImageFilesystemModal({
89
96
  setIsLoadingFilesystem(true)
90
97
  setFilesystemError(null)
91
98
  try {
92
- const result = await fetchImageFilesystem(image, namespace, podName, pullSecrets)
99
+ const result = await fetchImageFilesystem(inspectImage, namespace, podName, pullSecrets)
93
100
  setFilesystem(result)
94
101
  } catch (err) {
95
102
  setFilesystemError(err instanceof Error ? err : new Error('Failed to fetch filesystem'))
96
103
  } finally {
97
104
  setIsLoadingFilesystem(false)
98
105
  }
99
- }, [image, namespace, podName, pullSecrets])
106
+ }, [inspectImage, namespace, podName, pullSecrets])
100
107
 
101
108
  // Reset state when modal closes or image changes
102
109
  useEffect(() => {
@@ -153,6 +160,13 @@ export function ImageFilesystemModal({
153
160
  {image}
154
161
  </p>
155
162
  </Tooltip>
163
+ {pulledDigest && (
164
+ <Tooltip content={inspectImage} wrapperClassName="!block w-full">
165
+ <p className="text-xs text-theme-text-tertiary mt-1 truncate">
166
+ Pulled digest: <span className="font-mono">{pulledDigest}</span>
167
+ </p>
168
+ </Tooltip>
169
+ )}
156
170
  {(displayFilesystem?.platform || metadata?.platform) && (
157
171
  <p className="text-xs text-theme-text-tertiary mt-1">
158
172
  Platform: {displayFilesystem?.platform || metadata?.platform}
@@ -208,8 +222,16 @@ export function ImageFilesystemModal({
208
222
  />
209
223
  )}
210
224
 
211
- {/* Non-auth errors keep the existing red error box */}
212
- {error && !isAuthError && (
225
+ {unavailable && (
226
+ <RegistryUnavailable
227
+ {...unavailable}
228
+ liveFilesLinkShown={Boolean(onSwitchToPodFiles)}
229
+ onRetry={() => refetchMetadata()}
230
+ />
231
+ )}
232
+
233
+ {/* Other errors keep the existing red error box */}
234
+ {error && !isAuthError && !unavailable && (
213
235
  <div className="p-4 bg-red-500/10 border border-red-500/30 rounded-lg">
214
236
  <div className="flex items-start gap-3">
215
237
  <AlertTriangle className="w-5 h-5 text-red-400 shrink-0 mt-0.5" />
@@ -237,7 +259,7 @@ export function ImageFilesystemModal({
237
259
  <FileTreeView
238
260
  root={displayFilesystem.root}
239
261
  searchQuery={searchQuery}
240
- image={image}
262
+ image={displayFilesystem.image || inspectImage}
241
263
  namespace={namespace}
242
264
  podName={podName}
243
265
  pullSecrets={pullSecrets}
@@ -513,6 +535,76 @@ function AuthenticationHelp({ image, registryType, onRetry }: AuthenticationHelp
513
535
  )
514
536
  }
515
537
 
538
+ // ============================================================================
539
+ // Registry Unavailable Component (image Radar can't download)
540
+ // ============================================================================
541
+
542
+ interface RegistryUnavailableInfo {
543
+ reason: 'node_only' | 'registry_unreachable'
544
+ registry: string
545
+ }
546
+
547
+ function registryUnavailable(data: Record<string, unknown> | undefined): RegistryUnavailableInfo | undefined {
548
+ const reason = data?.reason
549
+ const registry = typeof data?.registry === 'string' ? data.registry : ''
550
+ if (reason === 'node_only' || reason === 'registry_unreachable') return { reason, registry }
551
+ return undefined
552
+ }
553
+
554
+ interface RegistryUnavailableProps extends RegistryUnavailableInfo {
555
+ liveFilesLinkShown: boolean
556
+ onRetry: () => void
557
+ }
558
+
559
+ function RegistryUnavailable({ reason, registry, liveFilesLinkShown, onRetry }: RegistryUnavailableProps) {
560
+ const liveFiles = liveFilesLinkShown && (
561
+ <p className="text-xs text-theme-text-tertiary text-center max-w-md mb-2">
562
+ To see the files now, use Browse live files from running pod below.
563
+ </p>
564
+ )
565
+
566
+ if (reason === 'node_only') {
567
+ return (
568
+ <div className="flex flex-col items-center justify-center py-8">
569
+ <HardDrive className="w-16 h-16 text-amber-400 mb-4" />
570
+ <h4 className="text-lg font-medium text-theme-text-primary mb-2">
571
+ This image was added to the node, not pulled
572
+ </h4>
573
+ <p className="text-sm text-theme-text-secondary text-center max-w-md mb-2">
574
+ The node didn't pull this image from a registry. It was added to the node directly, for example with <span className="font-mono">kind load</span> or <span className="font-mono">ctr images import</span>. Radar can only open images it downloads from a registry, and it couldn't get this one from <span className="inline-code">{registry}</span>.
575
+ </p>
576
+ <p className="text-xs text-theme-text-tertiary text-center max-w-md mb-2">
577
+ To browse it here, push the image to a registry Radar can reach and run the Pod from there.
578
+ </p>
579
+ {liveFiles}
580
+ </div>
581
+ )
582
+ }
583
+
584
+ return (
585
+ <div className="flex flex-col items-center justify-center py-8">
586
+ <WifiOff className="w-16 h-16 text-amber-400 mb-4" />
587
+ <h4 className="text-lg font-medium text-theme-text-primary mb-2">
588
+ Radar can't reach this image's registry
589
+ </h4>
590
+ <p className="text-sm text-theme-text-secondary text-center max-w-md mb-2">
591
+ The connection failed while fetching this image from <span className="inline-code">{registry}</span>. If your nodes pull images through a mirror or an internal copy of this registry, Radar doesn't use it, so it can't open this image.
592
+ </p>
593
+ <p className="text-xs text-theme-text-tertiary text-center max-w-md mb-2">
594
+ If <span className="inline-code">{registry}</span> should be reachable from where Radar runs, check the connection and retry.
595
+ </p>
596
+ {liveFiles}
597
+ <button
598
+ onClick={onRetry}
599
+ className="flex items-center gap-2 px-4 py-2 mt-4 text-sm btn-brand rounded-lg"
600
+ >
601
+ <RefreshCw className="w-4 h-4" />
602
+ Retry
603
+ </button>
604
+ </div>
605
+ )
606
+ }
607
+
516
608
  function formatAuthMethod(method: string): string {
517
609
  switch (method) {
518
610
  case 'google': return 'Google Cloud'
@@ -0,0 +1,150 @@
1
+ import { Link } from 'react-router-dom'
2
+ import { Upload, Loader2 } from 'lucide-react'
3
+ import { AlertBanner } from '@skyhook-io/k8s-ui'
4
+ import { formatBytes } from '../../utils/format'
5
+ import { resourcePath } from '../../utils/navigation'
6
+ import { Tooltip } from '../ui/Tooltip'
7
+ import { POD_FILE_PERSISTENCE_NOTE, type MountHint } from './pod-file-upload'
8
+
9
+ export type UploadState =
10
+ | { phase: 'idle' }
11
+ | { phase: 'confirm'; name: string; dir: string; size: number }
12
+ | { phase: 'uploading'; name: string; dir: string; sent: number; total: number }
13
+ | { phase: 'saving'; name: string; dir: string }
14
+ | { phase: 'saved'; path: string; replaced: boolean }
15
+ | { phase: 'error'; name: string; message: string }
16
+
17
+ export function isUploadBusy(state: UploadState): boolean {
18
+ return state.phase === 'uploading' || state.phase === 'saving' || state.phase === 'confirm'
19
+ }
20
+
21
+ interface UploadButtonProps {
22
+ blocked: MountHint | null
23
+ busy: boolean
24
+ /** The listing for the selected container is still loading. */
25
+ loading?: boolean
26
+ onClick: () => void
27
+ }
28
+
29
+ export function PodFileUploadButton({ blocked, busy, loading = false, onClick }: UploadButtonProps) {
30
+ const disabled = busy || loading || blocked !== null
31
+ const tip = blocked ? blocked.reason
32
+ : busy ? 'An upload is in progress'
33
+ : loading ? 'Loading the listing…'
34
+ : 'Upload a file into this directory (or drop one on the list)'
35
+ return (
36
+ <Tooltip content={tip}>
37
+ <button
38
+ type="button"
39
+ onClick={onClick}
40
+ disabled={disabled}
41
+ aria-disabled={disabled}
42
+ className="btn-brand inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium mr-2 disabled:opacity-50 disabled:pointer-events-none"
43
+ >
44
+ <Upload className="w-4 h-4" />
45
+ Upload
46
+ </button>
47
+ </Tooltip>
48
+ )
49
+ }
50
+
51
+ interface UploadNoticesProps {
52
+ namespace: string
53
+ blocked: MountHint | null
54
+ onNavigateAway: () => void
55
+ }
56
+
57
+ /** The persistence note, plus why uploads are off here when the pod spec says so. */
58
+ export function PodFileUploadNotices({ namespace, blocked, onNavigateAway }: UploadNoticesProps) {
59
+ return (
60
+ <>
61
+ <AlertBanner variant="info" title="Uploads change the live container" message={POD_FILE_PERSISTENCE_NOTE} className="mb-3" />
62
+ {blocked && (
63
+ <AlertBanner
64
+ variant="warning"
65
+ title="Uploads are off in this directory"
66
+ message={blocked.reason}
67
+ className="mb-3"
68
+ action={blocked.source ? (
69
+ <Link
70
+ to={resourcePath({ kind: blocked.source.kind, namespace, name: blocked.source.name })}
71
+ onClick={onNavigateAway}
72
+ className="text-xs text-accent hover:underline"
73
+ >
74
+ Open {blocked.source.kind} {blocked.source.name}
75
+ </Link>
76
+ ) : undefined}
77
+ />
78
+ )}
79
+ </>
80
+ )
81
+ }
82
+
83
+ interface UploadStatusProps {
84
+ state: UploadState
85
+ onConfirmReplace: () => void
86
+ onCancel: () => void
87
+ onDismiss: () => void
88
+ }
89
+
90
+ export function PodFileUploadStatus({ state, onConfirmReplace, onCancel, onDismiss }: UploadStatusProps) {
91
+ switch (state.phase) {
92
+ case 'idle':
93
+ return null
94
+ case 'confirm':
95
+ return (
96
+ <AlertBanner
97
+ variant="warning"
98
+ title={`Replace ${state.name}?`}
99
+ message={`${state.dir === '/' ? '' : state.dir}/${state.name} already exists. Uploading ${formatBytes(state.size)} replaces it in the running container; its owner and permissions are kept, but not ACLs or extended attributes.`}
100
+ className="mb-3"
101
+ >
102
+ <div className="flex gap-2 mt-2">
103
+ <button type="button" onClick={onConfirmReplace} className="btn-brand px-3 py-1 text-xs font-medium">Replace</button>
104
+ <button type="button" onClick={onCancel} className="px-3 py-1 text-xs rounded border border-theme-border text-theme-text-secondary hover:bg-theme-hover">Cancel</button>
105
+ </div>
106
+ </AlertBanner>
107
+ )
108
+ case 'uploading': {
109
+ const pct = state.total > 0 ? Math.min(100, Math.round((state.sent / state.total) * 100)) : 0
110
+ return (
111
+ <div className="mb-3 p-3 border border-theme-border rounded-lg bg-theme-surface" role="status">
112
+ <div className="flex items-center justify-between gap-3 text-sm">
113
+ <span className="min-w-0 truncate text-theme-text-primary">Uploading {state.name}</span>
114
+ <span className="shrink-0 text-xs text-theme-text-tertiary">{formatBytes(state.sent)} of {formatBytes(state.total)}</span>
115
+ <button type="button" onClick={onCancel} className="shrink-0 px-2 py-0.5 text-xs rounded border border-theme-border text-theme-text-secondary hover:bg-theme-hover">Cancel</button>
116
+ </div>
117
+ <div className="mt-2 h-1.5 rounded bg-theme-elevated overflow-hidden" role="progressbar" aria-valuemin={0} aria-valuemax={100} aria-valuenow={pct}>
118
+ <div className="h-full bg-accent" style={{ width: `${pct}%` }} />
119
+ </div>
120
+ </div>
121
+ )
122
+ }
123
+ case 'saving':
124
+ return (
125
+ <div className="mb-3 p-3 border border-theme-border rounded-lg bg-theme-surface flex items-center gap-2 text-sm text-theme-text-primary" role="status">
126
+ <Loader2 className="w-4 h-4 animate-spin shrink-0" />
127
+ <span className="truncate">Saving {state.name} in the container…</span>
128
+ </div>
129
+ )
130
+ case 'saved':
131
+ return (
132
+ <AlertBanner
133
+ variant="success"
134
+ title={state.replaced ? `Replaced ${state.path}` : `Saved ${state.path}`}
135
+ className="mb-3"
136
+ action={<button type="button" onClick={onDismiss} className="text-xs text-theme-text-secondary hover:underline">Dismiss</button>}
137
+ />
138
+ )
139
+ case 'error':
140
+ return (
141
+ <AlertBanner
142
+ variant="error"
143
+ title={`Could not upload ${state.name}`}
144
+ message={state.message}
145
+ className="mb-3"
146
+ action={<button type="button" onClick={onDismiss} className="text-xs text-theme-text-secondary hover:underline">Dismiss</button>}
147
+ />
148
+ )
149
+ }
150
+ }