@skyhook-io/radar-app 1.21.7 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/App.tsx +26 -3
  4. package/src/api/client.ts +16 -3
  5. package/src/api/radarFeatures.ts +4 -0
  6. package/src/api/traefik.ts +33 -0
  7. package/src/api/traffic.ts +1 -0
  8. package/src/components/CloudFunnelButton.test.tsx +39 -1
  9. package/src/components/CloudFunnelButton.tsx +10 -3
  10. package/src/components/NamespaceSwitcher.tsx +6 -2
  11. package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
  12. package/src/components/applications/ApplicationsView.tsx +71 -142
  13. package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
  14. package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
  15. package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
  16. package/src/components/cnpg/CNPGOverview.tsx +62 -4
  17. package/src/components/home/HomeView.tsx +9 -1
  18. package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
  19. package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
  20. package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
  21. package/src/components/issues/IssuesPane.render.test.tsx +78 -2
  22. package/src/components/issues/IssuesPane.tsx +38 -6
  23. package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
  24. package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
  25. package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
  26. package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
  27. package/src/components/settings/FormSaveActions.tsx +6 -2
  28. package/src/components/settings/MetricsBackendSwitch.tsx +13 -15
  29. package/src/components/settings/OpenObserveSetup.test.tsx +68 -27
  30. package/src/components/settings/OpenObserveSetup.tsx +93 -123
  31. package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
  32. package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
  33. package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
  34. package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
  35. package/src/components/traffic/TrafficFlowList.tsx +5 -5
  36. package/src/components/traffic/TrafficGraph.test.tsx +11 -0
  37. package/src/components/traffic/TrafficGraph.tsx +31 -19
  38. package/src/components/traffic/TrafficView.tsx +17 -6
  39. package/src/components/traffic/traffic-export.test.ts +8 -0
  40. package/src/components/traffic/traffic-export.ts +7 -4
  41. package/src/components/traffic/trafficFilters.test.ts +51 -1
  42. package/src/components/traffic/trafficFilters.ts +39 -11
  43. package/src/components/ui/command-items-crd.test.tsx +23 -8
  44. package/src/components/whats-new/releaseNotes.ts +75 -1
  45. package/src/components/workload/WorkloadView.tsx +8 -6
  46. package/src/components/workspace/WorkspaceConditions.tsx +56 -0
  47. package/src/components/workspace/layout.test.tsx +20 -0
  48. package/src/components/workspace/layout.tsx +1 -1
  49. package/src/contexts/CapabilitiesContext.tsx +2 -0
  50. package/src/integrations/resourceHosts.test.tsx +1 -1
  51. package/src/integrations/resourceHosts.tsx +3 -0
  52. package/src/utils/page-links.ts +15 -1
@@ -108,9 +108,10 @@ describe('Metrics backend choice', () => {
108
108
  expect(container.querySelector('[data-testid="prometheus-form"]')?.closest('.hidden')).toBeNull()
109
109
  })
110
110
 
111
- it('switches views without saving, and offers to release a matched cluster from the Prometheus view', async () => {
111
+ it('switches views without saving, and releases a matched cluster from the Prometheus view without a confirmation', async () => {
112
112
  const onChanged = vi.fn()
113
113
  await mount(matched(), { onChanged })
114
+ expect(button('Use Prometheus for this cluster')).toBeUndefined()
114
115
  await click(radio('Prometheus-compatible'))
115
116
  expect(calls.filter((c) => c.method !== 'GET')).toHaveLength(0)
116
117
  expect(container.textContent).toContain('This cluster still reads from OpenObserve.')
@@ -118,6 +119,7 @@ describe('Metrics backend choice', () => {
118
119
  await click(button('Use Prometheus for this cluster'))
119
120
  expect(calls.at(-1)).toMatchObject({ method: 'DELETE', path: '/integrations/openobserve/cluster?clusterUid=uid-123' })
120
121
  expect(onChanged).toHaveBeenCalled()
122
+ expect(radio('Prometheus-compatible').getAttribute('aria-checked')).toBe('true')
121
123
  expect(container.textContent).not.toContain('This cluster still reads from OpenObserve.')
122
124
  })
123
125
 
@@ -156,7 +158,9 @@ describe('OpenObserve setup', () => {
156
158
  const link = Array.from(container.querySelectorAll('a')).find((a) => a.textContent?.includes('Create a service account in OpenObserve'))!
157
159
  expect(link.target).toBe('_blank')
158
160
  expect(link.rel).toContain('noopener')
159
- expect(field('Organization').value).toBe('default')
161
+ expect(field('Organization').value).toBe('')
162
+ expect(field('Organization').placeholder).toBe('2Zp8kQ1vXcR7mN4tLwYb9HsA3eD')
163
+ type(field('Organization'), 'team')
160
164
  type(field('Address'), 'https://oo.example.com')
161
165
  type(field('User or service account email'), 'radar@example.com')
162
166
  type(field('Token'), 'secret')
@@ -164,9 +168,9 @@ describe('OpenObserve setup', () => {
164
168
  expect(onDirtyChange).toHaveBeenLastCalledWith(true)
165
169
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', clusterUid: 'uid-123', notes: { collector: true, missing: ['cpu', 'hpa'] } } })
166
170
  replies['GET /integrations/openobserve'] = [{ body: matched() }]
167
- await click(button('Test and save'))
171
+ await click(button('Save changes'))
168
172
  expect(posts()[0].body).toEqual({
169
- baseUrl: 'https://oo.example.com', org: 'default', user: 'radar@example.com', token: 'secret', caCertFile: '', clusterLabel: '', clusterUid: 'uid-123',
173
+ baseUrl: 'https://oo.example.com', org: 'team', user: 'radar@example.com', token: 'secret', caCertFile: '', clusterLabel: '', clusterUid: 'uid-123',
170
174
  })
171
175
  expect(onChanged).toHaveBeenCalled()
172
176
  expect(container.textContent).toContain('Data comes from the OpenObserve collector.')
@@ -186,7 +190,7 @@ describe('OpenObserve setup', () => {
186
190
  { body: { outcome: 'confirm', reason: 'Found only by name.', suggestion: { label: 'k8s_cluster', value: 'prod' }, clusterUid: 'uid-123' } },
187
191
  { body: { outcome: 'saved', clusterUid: 'uid-123', notes: {} } })
188
192
  replies['GET /integrations/openobserve'] = [{ body: matched() }]
189
- await click(button('Test and save'))
193
+ await click(button('Save changes'))
190
194
  expect(container.textContent).toContain('Found only by name.')
191
195
  await click(button("Confirm 'prod' and save"))
192
196
  expect(posts()).toHaveLength(2)
@@ -204,14 +208,14 @@ describe('OpenObserve setup', () => {
204
208
  outcome: 'not_found', reason: 'No metrics for this cluster.', clusterUid: 'uid-123',
205
209
  clusterNames: [{ label: 'k8s_cluster', value: 'staging' }, { label: 'k8s_cluster', value: 'dev' }],
206
210
  } })
207
- await click(button('Test and save'))
211
+ await click(button('Save changes'))
208
212
  const text = container.textContent!
209
213
  expect(text).toContain('No metrics for this cluster.')
210
214
  expect(text).toContain('OpenObserve has metrics for: k8s_cluster=staging, k8s_cluster=dev.')
211
215
  expect(text).toContain('If OpenObserve names clusters with another label, set it under Advanced.')
212
216
  expect(text).toContain('radar_cluster_uid=uid-123')
213
217
  expect(text).not.toContain('Matched by')
214
- expect(button('Test and save')).toBeTruthy()
218
+ expect(button('Save changes')).toBeTruthy()
215
219
  expect(field('Token').value).toBe('secret')
216
220
  expect(onChanged).not.toHaveBeenCalled()
217
221
  expect(calls.map((c) => c.method)).toEqual(['GET', 'POST'])
@@ -227,7 +231,7 @@ describe('OpenObserve setup', () => {
227
231
  outcome: 'not_found', clusterUid: 'uid-123', clusterNames: [],
228
232
  reason: '3 sampled Pods from namespace demo are in OpenObserve, but carry none of the cluster labels cluster.',
229
233
  } })
230
- await click(button('Test and save'))
234
+ await click(button('Save changes'))
231
235
  const text = container.textContent!
232
236
  expect(text).toContain('carry none of the cluster labels')
233
237
  expect(text).not.toContain('OpenObserve has no cluster metrics yet.')
@@ -241,7 +245,7 @@ describe('OpenObserve setup', () => {
241
245
  type(field('User or service account email'), 'radar@example.com')
242
246
  type(field('Token'), 'secret')
243
247
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'not_found', clusterUid: 'uid-123', clusterNames: [] } })
244
- await click(button('Test and save'))
248
+ await click(button('Save changes'))
245
249
  expect(container.textContent).toContain('OpenObserve has no cluster metrics yet.')
246
250
  })
247
251
 
@@ -250,7 +254,7 @@ describe('OpenObserve setup', () => {
250
254
  await click(radio('OpenObserve'))
251
255
  type(field('Address'), 'https://oo.example.com')
252
256
  reply('POST /integrations/openobserve/setup', { status: 400, body: { error: 'Login failed: 401 Unauthorized' } })
253
- await click(button('Test and save'))
257
+ await click(button('Save changes'))
254
258
  expect(container.querySelector('[role="alert"]')?.textContent).toBe('Login failed: 401 Unauthorized')
255
259
  expect(field('Address').value).toBe('https://oo.example.com')
256
260
  })
@@ -268,59 +272,80 @@ describe('OpenObserve setup', () => {
268
272
  it('offers the saved connection to an unmatched cluster', async () => {
269
273
  await mount({ connection: connection(), cluster: { uid: 'uid-123' } })
270
274
  await click(radio('OpenObserve'))
271
- expect(container.textContent).toContain('Use the saved OpenObserve connection (https://oo.example.com, user radar@example.com)')
275
+ expect(field('Address').value).toBe('https://oo.example.com')
272
276
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', notes: {} } })
273
277
  replies['GET /integrations/openobserve'] = [{ body: matched() }]
274
- await click(button('Test and save'))
278
+ await click(button('Use for this cluster'))
275
279
  expect(posts()[0].body).toEqual({ useSaved: true, clusterUid: 'uid-123' })
276
280
  })
277
281
 
278
- it('uses Prometheus for this cluster without a confirmation', async () => {
279
- await mount(matched())
282
+ it('drops the Saved note once this cluster switches back to Prometheus', async () => {
283
+ await mount({ connection: connection(), cluster: { uid: 'uid-123' } })
284
+ await click(radio('OpenObserve'))
285
+ reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', notes: { collector: true } } })
286
+ replies['GET /integrations/openobserve'] = [{ body: matched() }]
287
+ await click(button('Use for this cluster'))
288
+ expect(container.textContent).toContain('Data comes from the OpenObserve collector.')
289
+ await click(radio('Prometheus-compatible'))
280
290
  reply('DELETE /integrations/openobserve/cluster?clusterUid=uid-123', { body: { connection: connection(), cluster: { uid: 'uid-123' } } })
281
291
  await click(button('Use Prometheus for this cluster'))
282
- expect(calls.at(-1)).toMatchObject({ method: 'DELETE', path: '/integrations/openobserve/cluster?clusterUid=uid-123' })
283
- expect(radio('Prometheus-compatible').getAttribute('aria-checked')).toBe('true')
292
+ await click(radio('OpenObserve'))
293
+ expect(container.textContent).not.toContain('Data comes from the OpenObserve collector.')
294
+ expect(Array.from(container.querySelectorAll('[role="status"]')).some((el) => el.textContent?.trim() === 'Saved')).toBe(false)
284
295
  })
285
296
 
286
297
  it('asks before removing the saved connection, listing the clusters that use it', async () => {
287
298
  await mount(matched({ clusters: [{ context: 'kind-oo-b', by: 'id' }, { context: 'kind-oo-c', by: 'name' }] }))
288
- await click(button('Remove saved OpenObserve connection'))
299
+ await click(button('Remove OpenObserve connection'))
289
300
  expect(calls.some((c) => c.method === 'DELETE')).toBe(false)
290
301
  const dialog = document.body.textContent!
291
302
  expect(dialog).toContain('Remove the saved OpenObserve connection?')
292
- expect(dialog).toContain('These clusters go back to their own Prometheus: kind-oo-b, kind-oo-c.')
303
+ expect(dialog).toContain('These clusters go back to their Prometheus settings: kind-oo-b, kind-oo-c. Nothing is deleted in OpenObserve or Kubernetes.')
293
304
  reply('DELETE /integrations/openobserve', { body: unmatched })
294
- await click(button('Remove'))
305
+ await click(button('Remove connection'))
295
306
  expect(calls.at(-1)).toMatchObject({ method: 'DELETE', path: '/integrations/openobserve' })
296
307
  expect(field('Address').value).toBe('')
308
+ expect(radio('Prometheus-compatible').getAttribute('aria-checked')).toBe('true')
309
+ expect(container.querySelector('[data-testid="prometheus-form"]')?.textContent).toContain('Status block')
310
+ })
311
+
312
+ it('shows the live status only with the source metrics come from', async () => {
313
+ await mount(unmatched)
314
+ await click(radio('OpenObserve'))
315
+ expect(container.querySelector('fieldset[aria-label="OpenObserve connection settings"]')?.textContent).not.toContain('Status block')
316
+ expect(container.querySelector('[data-testid="prometheus-form"]')?.textContent).toContain('Status block')
317
+ act(() => root.unmount())
318
+ root = createRoot(container)
319
+ replies = {}
320
+ await mount(matched())
321
+ await click(radio('Prometheus-compatible'))
322
+ expect(container.querySelector('[data-testid="prometheus-form"]')?.textContent).not.toContain('Status block')
323
+ expect(container.querySelector('fieldset[aria-label="OpenObserve connection settings"]')?.textContent).toContain('Status block')
297
324
  })
298
325
 
299
326
  it('shows an environment token read-only and never sends a token for it', async () => {
300
327
  await mount({ connection: connection({ tokenSource: 'env', tokenEnv: 'RADAR_OO_TOKEN' }), cluster: { uid: 'uid-123' } })
301
328
  await click(radio('OpenObserve'))
302
- await click(button('Edit connection'))
303
329
  expect(container.textContent).toContain('Token from $RADAR_OO_TOKEN')
304
330
  expect(container.querySelector('input[type="password"]')).toBeNull()
305
- expect(field('Address').value).toBe('https://oo.example.com')
331
+ type(field('Organization'), 'team')
306
332
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', notes: {} } })
307
333
  replies['GET /integrations/openobserve'] = [{ body: matched({ tokenSource: 'env', tokenEnv: 'RADAR_OO_TOKEN' }) }]
308
- await click(button('Test and save'))
334
+ await click(button('Save changes'))
309
335
  expect(posts()[0].body).not.toHaveProperty('token')
310
- expect(posts()[0].body).toMatchObject({ baseUrl: 'https://oo.example.com', user: 'radar@example.com' })
336
+ expect(posts()[0].body).toMatchObject({ baseUrl: 'https://oo.example.com', org: 'team', user: 'radar@example.com' })
311
337
  })
312
338
 
313
339
  it('asks for a new token when an environment-token connection points at another user', async () => {
314
340
  await mount({ connection: connection({ tokenSource: 'env', tokenEnv: 'RADAR_OO_TOKEN' }), cluster: { uid: 'uid-123' } })
315
341
  await click(radio('OpenObserve'))
316
- await click(button('Edit connection'))
317
342
  type(field('User or service account email'), 'other@example.com')
318
343
  expect(container.textContent).not.toContain('Token from $RADAR_OO_TOKEN')
319
344
  expect(container.textContent).toContain('A new address, organization or user needs its own token.')
320
345
  type(field('Token'), 'new-secret')
321
346
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', notes: {} } })
322
347
  replies['GET /integrations/openobserve'] = [{ body: matched() }]
323
- await click(button('Test and save'))
348
+ await click(button('Save changes'))
324
349
  expect(posts()[0].body).toMatchObject({ user: 'other@example.com', token: 'new-secret', clusterUid: 'uid-123' })
325
350
  })
326
351
 
@@ -329,15 +354,31 @@ describe('OpenObserve setup', () => {
329
354
  await click(radio('OpenObserve'))
330
355
  reply('POST /integrations/openobserve/setup', { body: { outcome: 'saved', notes: {} } })
331
356
  replies['GET /integrations/openobserve'] = [{ status: 500, body: { error: 'boom' } }]
332
- await click(button('Test and save'))
357
+ await click(button('Use for this cluster'))
333
358
  expect(container.textContent).toContain("Saved, but Radar couldn't reload this page.")
334
359
  expect(container.textContent).not.toContain('boom')
335
360
  })
336
361
 
337
362
  it('keeps a saved token when editing without typing one', async () => {
338
363
  await mount(matched())
339
- await click(button('Edit connection'))
340
364
  expect(field('Token').placeholder).toBe('Saved — leave empty to keep')
341
365
  expect(field('Token').value).toBe('')
342
366
  })
367
+ it('shows a saved connection filled in, saving only after a change, and discards back to it', async () => {
368
+ const onDirtyChange = vi.fn()
369
+ await mount(matched(), { onDirtyChange })
370
+ expect(field('Address').value).toBe('https://oo.example.com')
371
+ expect(field('User or service account email').value).toBe('radar@example.com')
372
+ expect(button('Edit connection')).toBeUndefined()
373
+ expect(button('Save changes')!.disabled).toBe(true)
374
+ expect(button('Discard')).toBeUndefined()
375
+ type(field('Address'), 'https://oo2.example.com')
376
+ expect(button('Save changes')!.disabled).toBe(false)
377
+ expect(container.textContent).toContain('Unsaved changes')
378
+ expect(onDirtyChange).toHaveBeenLastCalledWith(true)
379
+ await click(button('Discard'))
380
+ expect(field('Address').value).toBe('https://oo.example.com')
381
+ expect(button('Save changes')!.disabled).toBe(true)
382
+ expect(onDirtyChange).toHaveBeenLastCalledWith(false)
383
+ })
343
384
  })
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'
2
2
  import { Collapse, ConfirmDialog, Disclosure, Input } from '@skyhook-io/k8s-ui'
3
- import { Check, ExternalLink } from 'lucide-react'
3
+ import { ExternalLink } from 'lucide-react'
4
4
  import {
5
5
  getOpenObserveState,
6
6
  removeOpenObserveConnection,
@@ -13,8 +13,9 @@ import {
13
13
  type OpenObserveState,
14
14
  } from '../../api/openobserveSetup'
15
15
  import { missingFamiliesNote } from './openobserveStatus'
16
+ import { FormSaveActions } from './FormSaveActions'
16
17
 
17
- const SERVICE_ACCOUNT_DOCS = 'https://openobserve.ai/docs/user-guide/identity-and-access-management/service-accounts/'
18
+ const SERVICE_ACCOUNT_DOCS = 'https://openobserve.ai/docs/user-guide/account-administration/identity-and-access-management/service-accounts/'
18
19
  const inputClass = 'block w-full min-w-0 px-3 py-2 text-sm bg-theme-elevated border border-theme-border rounded-md text-theme-text-primary placeholder:text-theme-text-tertiary focus:outline-none focus:border-skyhook-500'
19
20
 
20
21
  interface Draft {
@@ -28,7 +29,7 @@ interface Draft {
28
29
 
29
30
  const draftFrom = (connection: OpenObserveConnection | null): Draft => ({
30
31
  baseUrl: connection?.baseUrl ?? '',
31
- org: connection?.org ?? 'default',
32
+ org: connection?.org ?? '',
32
33
  user: connection?.user ?? '',
33
34
  token: '',
34
35
  caCertFile: connection?.caCertFile ?? '',
@@ -61,7 +62,6 @@ export function OpenObserveSetup({
61
62
  status,
62
63
  onStateChange,
63
64
  onChanged,
64
- onUsePrometheus,
65
65
  onDirtyChange,
66
66
  onBusyChange,
67
67
  }: {
@@ -70,14 +70,12 @@ export function OpenObserveSetup({
70
70
  status?: ReactNode
71
71
  onStateChange: (state: OpenObserveState) => void
72
72
  onChanged: () => void
73
- onUsePrometheus: () => Promise<void>
74
73
  onDirtyChange?: (dirty: boolean) => void
75
74
  onBusyChange?: (busy: boolean) => void
76
75
  }) {
77
76
  const id = useId()
78
77
  const { connection, cluster } = state
79
78
  const match = cluster.match
80
- const [editing, setEditing] = useState(false)
81
79
  const baseline = useMemo(() => draftFrom(connection), [connection])
82
80
  const [draft, setDraft] = useState<Draft>(baseline)
83
81
  const [busy, setBusy] = useState(false)
@@ -89,11 +87,10 @@ export function OpenObserveSetup({
89
87
  return () => { mounted.current = false }
90
88
  }, [])
91
89
 
92
- const showForm = !locked && (!connection || editing)
93
90
  // A token from an environment variable is kept only for the same address,
94
91
  // organization and user; the server never sends a saved secret elsewhere.
95
92
  const envToken = !!connection && connection.tokenSource === 'env' && sameTarget(draft, baseline)
96
- const dirty = showForm && !sameDraft(draft, baseline)
93
+ const dirty = !locked && !sameDraft(draft, baseline)
97
94
  useEffect(() => onDirtyChange?.(dirty), [dirty, onDirtyChange])
98
95
  useEffect(() => onBusyChange?.(busy), [busy, onBusyChange])
99
96
  useEffect(() => () => {
@@ -101,6 +98,16 @@ export function OpenObserveSetup({
101
98
  onBusyChange?.(false)
102
99
  }, [onDirtyChange, onBusyChange])
103
100
 
101
+ // Switching this cluster back to Prometheus happens outside this form.
102
+ useEffect(() => {
103
+ if (!match) setResult((current) => current?.kind === 'saved' ? null : current)
104
+ }, [match])
105
+
106
+ // Switching this cluster back to Prometheus happens outside this form.
107
+ useEffect(() => {
108
+ if (!match) setResult((current) => current?.kind === 'saved' ? null : current)
109
+ }, [match])
110
+
104
111
  const update = (changes: Partial<Draft>) => {
105
112
  setDraft((value) => ({ ...value, ...changes }))
106
113
  if (result?.kind === 'confirm') setResult(null)
@@ -132,7 +139,6 @@ export function OpenObserveSetup({
132
139
  if (!mounted.current) return
133
140
  if (response.outcome === 'saved') {
134
141
  setResult({ kind: 'saved', notes: response.notes })
135
- setEditing(false)
136
142
  onChanged()
137
143
  let next: OpenObserveState
138
144
  try {
@@ -153,7 +159,7 @@ export function OpenObserveSetup({
153
159
 
154
160
  const testAndSave = () => {
155
161
  if (result?.kind === 'confirm') void submit({ ...result.body, confirm: result.suggestion })
156
- else void submit(showForm ? formBody() : { useSaved: true })
162
+ else void submit(dirty || !connection ? formBody() : { useSaved: true })
157
163
  }
158
164
 
159
165
  const removeAll = () => {
@@ -162,22 +168,15 @@ export function OpenObserveSetup({
162
168
  setResult(null)
163
169
  const next = await removeOpenObserveConnection()
164
170
  if (!mounted.current) return
165
- setEditing(false)
166
171
  setDraft(draftFrom(next.connection))
167
172
  onStateChange(next)
168
173
  onChanged()
169
174
  })
170
175
  }
171
176
 
172
- const startEditing = () => {
177
+ const discard = () => {
173
178
  setDraft(baseline)
174
179
  setResult(null)
175
- setEditing(true)
176
- }
177
- const cancelEditing = () => {
178
- setDraft(baseline)
179
- setResult(null)
180
- setEditing(false)
181
180
  }
182
181
 
183
182
  const shared = connection && connection.clusters.length > 1
@@ -209,10 +208,8 @@ export function OpenObserveSetup({
209
208
  result.reloadFailed && "Saved, but Radar couldn't reload this page. Reopen Settings to see the match.",
210
209
  ].filter((note): note is string => !!note) : []
211
210
 
212
- const outcome = result && result.kind !== 'saved' ? (
213
- result.kind === 'error' ? (
214
- <p role="alert" className="text-xs text-semantic-error">{result.message}</p>
215
- ) : result.kind === 'confirm' ? (
211
+ const outcome = result && result.kind !== 'saved' && result.kind !== 'error' ? (
212
+ result.kind === 'confirm' ? (
216
213
  <p role="status" className="text-xs text-warning-text">
217
214
  {result.reason ?? `OpenObserve has metrics for ${pair(result.suggestion)}, matched only by name.`}
218
215
  </p>
@@ -229,115 +226,89 @@ export function OpenObserveSetup({
229
226
  )
230
227
  ) : null
231
228
 
232
- const saveButton = (
233
- <button type="button" onClick={testAndSave} disabled={busy} className="btn-brand min-w-28 px-3 py-2 text-xs">
234
- {busy ? 'Testing…' : result?.kind === 'confirm' ? `Confirm '${result.suggestion.value}' and save` : 'Test and save'}
235
- </button>
236
- )
237
-
238
229
  return (
239
230
  <fieldset disabled={busy} aria-label="OpenObserve connection settings" className="min-w-0 space-y-4">
240
231
  {statusRow}
241
232
  {cluster.error && <p className="text-xs text-warning-text">{cluster.error}</p>}
242
- {showForm ? (
243
- <div className="space-y-4">
244
- {shared}
245
- <div className="space-y-1">
246
- <label htmlFor={`${id}-url`} className="block text-sm font-medium text-theme-text-primary">Address</label>
247
- <Input id={`${id}-url`} value={draft.baseUrl} onChange={(e) => update({ baseUrl: e.target.value })} placeholder="https://openobserve.example.com" spellCheck={false} className={inputClass} />
248
- </div>
249
- <div className="space-y-1">
250
- <label htmlFor={`${id}-org`} className="block text-sm font-medium text-theme-text-primary">Organization</label>
251
- <Input id={`${id}-org`} value={draft.org} onChange={(e) => update({ org: e.target.value })} spellCheck={false} className={inputClass} />
252
- </div>
253
- <div className="space-y-1">
254
- <label htmlFor={`${id}-user`} className="block text-sm font-medium text-theme-text-primary">User or service account email</label>
255
- <Input id={`${id}-user`} value={draft.user} onChange={(e) => update({ user: e.target.value })} autoComplete="off" spellCheck={false} className={inputClass} />
256
- <a href={SERVICE_ACCOUNT_DOCS} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
257
- Create a service account in OpenObserve
258
- <ExternalLink aria-hidden="true" className="h-3 w-3" />
259
- </a>
260
- </div>
261
- <div className="space-y-1">
262
- <label htmlFor={`${id}-token`} className="block text-sm font-medium text-theme-text-primary">Token</label>
263
- {envToken ? (
264
- <p id={`${id}-token`} className="text-sm text-theme-text-secondary">Token from ${connection.tokenEnv}</p>
265
- ) : (
266
- <Input
267
- id={`${id}-token`}
268
- type="password"
269
- autoComplete="new-password"
270
- spellCheck={false}
271
- value={draft.token}
272
- onChange={(e) => update({ token: e.target.value })}
273
- placeholder={connection?.tokenSource === 'saved' && sameTarget(draft, baseline) ? 'Saved — leave empty to keep' : undefined}
274
- className={inputClass}
275
- />
276
- )}
277
- {connection && connection.tokenSource !== 'none' && !sameTarget(draft, baseline) && (
278
- <p className="text-xs text-theme-text-secondary">A new address, organization or user needs its own token.</p>
279
- )}
280
- <p className="text-xs text-theme-text-tertiary">Saved in ~/.radar/config.json, readable only by you.</p>
281
- </div>
282
- <Disclosure
283
- summary="Advanced"
284
- summaryClassName="text-sm font-medium text-theme-text-secondary"
285
- defaultOpen={!!(baseline.caCertFile || baseline.clusterLabel)}
286
- >
287
- <div className="space-y-4 pt-3">
288
- <div className="space-y-1">
289
- <label htmlFor={`${id}-ca`} className="block text-sm font-medium text-theme-text-primary">CA certificate file</label>
290
- <Input id={`${id}-ca`} value={draft.caCertFile} onChange={(e) => update({ caCertFile: e.target.value })} placeholder="/path/to/ca.pem" spellCheck={false} className={inputClass} />
291
- </div>
292
- <div className="space-y-1">
293
- <label htmlFor={`${id}-label`} className="block text-sm font-medium text-theme-text-primary">Cluster label</label>
294
- <p className="text-xs text-theme-text-tertiary">Only when OpenObserve names clusters with a label Radar doesn’t know.</p>
295
- <Input id={`${id}-label`} value={draft.clusterLabel} onChange={(e) => update({ clusterLabel: e.target.value })} spellCheck={false} className={inputClass} />
296
- </div>
297
- </div>
298
- </Disclosure>
233
+ {match && <p className="text-sm text-theme-text-primary">{matchSummary(match)}</p>}
234
+ {shared}
235
+ <div className="space-y-4">
236
+ <div className="space-y-1">
237
+ <label htmlFor={`${id}-url`} className="block text-sm font-medium text-theme-text-primary">Address</label>
238
+ <Input id={`${id}-url`} value={draft.baseUrl} onChange={(e) => update({ baseUrl: e.target.value })} placeholder="https://openobserve.example.com" spellCheck={false} className={inputClass} />
299
239
  </div>
300
- ) : match && connection ? (
301
- <div className="card-inner-lg space-y-2">
302
- <p className="text-sm text-theme-text-primary">{matchSummary(match)}</p>
303
- <p className="break-words text-xs text-theme-text-secondary">{connectionLine(connection)}</p>
304
- {shared}
240
+ <div className="space-y-1">
241
+ <label htmlFor={`${id}-org`} className="block text-sm font-medium text-theme-text-primary">Organization</label>
242
+ <Input id={`${id}-org`} value={draft.org} onChange={(e) => update({ org: e.target.value })} placeholder="2Zp8kQ1vXcR7mN4tLwYb9HsA3eD" spellCheck={false} className={inputClass} />
243
+ <p className="text-xs text-theme-text-tertiary">The organization ID from OpenObserve. Leave empty for default.</p>
305
244
  </div>
306
- ) : connection ? (
307
- <p className="break-words text-sm text-theme-text-secondary">
308
- Use the saved OpenObserve connection ({connection.baseUrl}, user {connection.user})
309
- </p>
310
- ) : null}
311
- <div className="space-y-2 border-t border-theme-border pt-4">
312
- <div className="flex min-h-8 flex-wrap items-center gap-3">
313
- {(showForm || !match) && saveButton}
314
- {connection && !editing && (
315
- <button type="button" onClick={startEditing} className="text-xs font-medium text-accent-text hover:underline">Edit connection</button>
316
- )}
317
- {editing && (
318
- <button type="button" onClick={cancelEditing} className="text-xs text-theme-text-secondary hover:underline">Cancel</button>
319
- )}
320
- {match && !editing && (
321
- <button type="button" onClick={() => void run(async () => { setResult(null); await onUsePrometheus() })} className="text-xs font-medium text-accent-text hover:underline">
322
- Use Prometheus for this cluster
323
- </button>
245
+ <div className="space-y-1">
246
+ <label htmlFor={`${id}-user`} className="block text-sm font-medium text-theme-text-primary">User or service account email</label>
247
+ <Input id={`${id}-user`} value={draft.user} onChange={(e) => update({ user: e.target.value })} autoComplete="off" spellCheck={false} className={inputClass} />
248
+ <a href={SERVICE_ACCOUNT_DOCS} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
249
+ Create a service account in OpenObserve
250
+ <ExternalLink aria-hidden="true" className="h-3 w-3" />
251
+ </a>
252
+ </div>
253
+ <div className="space-y-1">
254
+ <label htmlFor={`${id}-token`} className="block text-sm font-medium text-theme-text-primary">Token</label>
255
+ {envToken ? (
256
+ <p id={`${id}-token`} className="text-sm text-theme-text-secondary">Token from ${connection.tokenEnv}</p>
257
+ ) : (
258
+ <Input
259
+ id={`${id}-token`}
260
+ type="password"
261
+ autoComplete="new-password"
262
+ spellCheck={false}
263
+ value={draft.token}
264
+ onChange={(e) => update({ token: e.target.value })}
265
+ placeholder={connection?.tokenSource === 'saved' && sameTarget(draft, baseline) ? 'Saved — leave empty to keep' : undefined}
266
+ className={inputClass}
267
+ />
324
268
  )}
325
- {result?.kind === 'saved' && (
326
- <span role="status" className="flex items-center gap-1.5 text-xs text-theme-text-secondary">
327
- <Check aria-hidden="true" className="h-3.5 w-3.5 text-[var(--color-success-dark)] dark:text-[var(--color-success-light)]" />
328
- Saved
329
- </span>
269
+ {connection && connection.tokenSource !== 'none' && !sameTarget(draft, baseline) && (
270
+ <p className="text-xs text-theme-text-secondary">A new address, organization or user needs its own token.</p>
330
271
  )}
272
+ <p className="text-xs text-theme-text-tertiary">Saved in ~/.radar/config.json, readable only by you.</p>
331
273
  </div>
274
+ <Disclosure
275
+ summary="Advanced"
276
+ summaryClassName="text-sm font-medium text-theme-text-secondary"
277
+ defaultOpen={!!(baseline.caCertFile || baseline.clusterLabel)}
278
+ >
279
+ <div className="space-y-4 pt-3">
280
+ <div className="space-y-1">
281
+ <label htmlFor={`${id}-ca`} className="block text-sm font-medium text-theme-text-primary">CA certificate file</label>
282
+ <Input id={`${id}-ca`} value={draft.caCertFile} onChange={(e) => update({ caCertFile: e.target.value })} placeholder="/path/to/ca.pem" spellCheck={false} className={inputClass} />
283
+ </div>
284
+ <div className="space-y-1">
285
+ <label htmlFor={`${id}-label`} className="block text-sm font-medium text-theme-text-primary">Cluster label</label>
286
+ <p className="text-xs text-theme-text-tertiary">Only when OpenObserve names clusters with a label Radar doesn’t know.</p>
287
+ <Input id={`${id}-label`} value={draft.clusterLabel} onChange={(e) => update({ clusterLabel: e.target.value })} spellCheck={false} className={inputClass} />
288
+ </div>
289
+ </div>
290
+ </Disclosure>
291
+ </div>
292
+ <div>
293
+ <FormSaveActions
294
+ dirty={dirty}
295
+ busy={busy}
296
+ canSave={dirty || result?.kind === 'confirm' || (!!connection && !match)}
297
+ saveLabel={result?.kind === 'confirm' ? `Confirm '${result.suggestion.value}' and save` : !dirty && connection && !match ? 'Use for this cluster' : 'Save changes'}
298
+ onSave={testAndSave}
299
+ onDiscard={discard}
300
+ feedback={result?.kind === 'saved' ? { tone: 'success', message: 'Saved' } : undefined}
301
+ error={result?.kind === 'error' ? result.message : undefined}
302
+ />
332
303
  <Collapse open={notes.length > 0}>
333
- <ul className="space-y-0.5 text-xs text-theme-text-secondary">
304
+ <ul className="space-y-0.5 pt-2 text-xs text-theme-text-secondary">
334
305
  {notes.map((note) => <li key={note}>{note}</li>)}
335
306
  </ul>
336
307
  </Collapse>
337
- <Collapse open={!!outcome}>{outcome}</Collapse>
338
- {connection && !editing && (
339
- <button type="button" onClick={() => setConfirmingRemove(true)} className="self-start text-xs font-medium text-semantic-error hover:underline">
340
- Remove saved OpenObserve connection
308
+ <Collapse open={!!outcome}><div className="pt-2">{outcome}</div></Collapse>
309
+ {connection && (
310
+ <button type="button" onClick={() => setConfirmingRemove(true)} className="mt-3 text-xs text-accent-text hover:underline">
311
+ Remove OpenObserve connection
341
312
  </button>
342
313
  )}
343
314
  </div>
@@ -346,11 +317,10 @@ export function OpenObserveSetup({
346
317
  onClose={() => setConfirmingRemove(false)}
347
318
  onConfirm={removeAll}
348
319
  title="Remove the saved OpenObserve connection?"
349
- message={contexts.length
350
- ? `These clusters go back to their own Prometheus: ${contexts.join(', ')}.`
351
- : 'No cluster reads from it yet.'}
352
- confirmLabel="Remove"
353
- variant="warning"
320
+ message={`${contexts.length
321
+ ? `These clusters go back to their Prometheus settings: ${contexts.join(', ')}.`
322
+ : 'No cluster reads from it yet.'} Nothing is deleted in OpenObserve or Kubernetes.`}
323
+ confirmLabel="Remove connection"
354
324
  showWarning={false}
355
325
  />
356
326
  </fieldset>
@@ -76,6 +76,16 @@ describe('TrafficConnectionsTable', () => {
76
76
  })
77
77
  })
78
78
 
79
+ describe('TrafficConnectionsTable ports taken from a Service', () => {
80
+ it('says the port was taken from the Service, not observed', () => {
81
+ const props = { isRateBased: false, selection: null, onSelect: vi.fn(), onFocus: vi.fn() }
82
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[{ ...tcp, portSource: 'service' }]} />))
83
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('5432 (from Service)')
84
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[{ ...tcp, port: 0, portSource: 'serviceMultiple' }]} />))
85
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('multiple (from Service)')
86
+ })
87
+ })
88
+
79
89
  describe('TrafficConnectionsTable protocol data', () => {
80
90
  it('renders compact protocol figures without their mixed sum', () => {
81
91
  const mixed = { ...tcp, bytesSent: 38668, bytesRecv: 652404, bytesByProtocol: {
@@ -92,3 +102,16 @@ describe('TrafficConnectionsTable protocol data', () => {
92
102
  expect(container.textContent).not.toMatch(/674\.9 KB|691,?072/)
93
103
  })
94
104
  })
105
+
106
+ describe('TrafficConnectionsTable likely overlay', () => {
107
+ it('selects the overlay row apart from the other traffic between the same nodes', () => {
108
+ const other = { ...tcp, source: { name: 'node-a', namespace: '', kind: 'Pod' }, destination: { name: 'node-b', namespace: '', kind: 'Pod' }, port: 0 }
109
+ const overlay = { ...other, protocol: 'udp', likelyOverlay: true }
110
+ const onSelect = vi.fn()
111
+ const props = { flows: [other, overlay], isRateBased: false, onSelect, onFocus: vi.fn() }
112
+ act(() => root.render(<TrafficConnectionsTable {...props} selection={null} />))
113
+ act(() => container.querySelectorAll<HTMLElement>('[role="row"]')[1].click())
114
+ act(() => root.render(<TrafficConnectionsTable {...props} selection={onSelect.mock.calls[0][0]} />))
115
+ expect([...container.querySelectorAll('[role="row"]')].map(r => r.getAttribute('aria-selected'))).toEqual(['false', 'true'])
116
+ })
117
+ })
@@ -8,7 +8,7 @@ import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
8
8
  import { Tooltip } from '../ui/Tooltip'
9
9
  import type { TrafficGraphSelection } from './TrafficGraph'
10
10
  import {
11
- dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
11
+ dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind, portLabel,
12
12
  type GraphFlow, type TrafficFocus,
13
13
  } from './trafficFilters'
14
14
 
@@ -40,6 +40,7 @@ function rowSelection(flow: AggregatedFlow): TrafficGraphSelection {
40
40
  destId: graphEndpointId(flow.destination),
41
41
  port: flow.port,
42
42
  directionUnknown: !!flow.directionUnknown,
43
+ ...(flow.likelyOverlay && { likelyOverlay: true }),
43
44
  }
44
45
  }
45
46
 
@@ -47,7 +48,7 @@ function selectedRows(rows: GraphFlow[], selection: TrafficGraphSelection | null
47
48
  if (selection?.type !== 'edge' || selection.port === undefined) return new Set()
48
49
  const between = rows.filter(flow =>
49
50
  graphEndpointId(flow.source) === selection.sourceId && graphEndpointId(flow.destination) === selection.destId &&
50
- !!flow.directionUnknown === !!selection.directionUnknown)
51
+ !!flow.directionUnknown === !!selection.directionUnknown && !!flow.likelyOverlay === !!selection.likelyOverlay)
51
52
  return new Set(edgesOnPort(between, f => f, selection.port))
52
53
  }
53
54
 
@@ -106,7 +107,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
106
107
  <Virtuoso
107
108
  className="flex-1"
108
109
  data={rows}
109
- computeItemKey={(_, flow) => `${graphEndpointId(flow.source)}->${graphEndpointId(flow.destination)}:${flow.port}${flow.directionUnknown ? ':u' : ''}`}
110
+ computeItemKey={(_, flow) => `${graphEndpointId(flow.source)}->${graphEndpointId(flow.destination)}:${flow.port}${flow.directionUnknown ? ':u' : ''}${flow.likelyOverlay ? ':v' : ''}`}
110
111
  itemContent={(_, flow) => {
111
112
  const sel = rowSelection(flow)
112
113
  const isSelected = selected.has(flow)
@@ -129,7 +130,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
129
130
  : <ArrowRight className="h-3 w-3 text-theme-text-tertiary" />}
130
131
  {endpoint(flow.destination)}
131
132
  <span className="truncate text-theme-text-secondary tabular-nums">
132
- {flow.port > 0 ? flow.port : '—'}
133
+ {portLabel(flow.port, flow.portSource) ?? '—'}
133
134
  {(flow.l7Protocol || flow.protocol) && (
134
135
  <span className="ml-1 text-theme-text-tertiary">{flow.l7Protocol || flow.protocol.toUpperCase()}</span>
135
136
  )}