@skyhook-io/radar-app 1.20.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/package.json +1 -1
- package/src/App.tsx +6 -4
- package/src/api/client.ts +69 -10
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.ts +2 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/investigationCase.test.tsx +41 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -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.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +38 -12
- package/src/components/home/MCPSetupDialog.tsx +5 -2
- package/src/components/home/mcpToolCatalog.ts +44 -4
- package/src/components/issues/uncheckedSources.test.ts +2 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- 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/whats-new/releaseNotes.ts +1 -1
- package/src/contexts/CapabilitiesContext.tsx +2 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +5 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -821,7 +821,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
821
821
|
navigate({ pathname: `/resources/${pluralKind}`, search: newParams.toString() })
|
|
822
822
|
}, [searchParams, navigate])
|
|
823
823
|
|
|
824
|
-
const navigateToHelmRelease = useCallback((namespace: string, name: string, storageNamespace?: string, investigationRunID?: string | null) => {
|
|
824
|
+
const navigateToHelmRelease = useCallback((namespace: string, name: string, storageNamespace?: string, investigationRunID?: string | null, observed?: boolean) => {
|
|
825
825
|
const newParams = new URLSearchParams()
|
|
826
826
|
const globalNamespaces = searchParams.get('namespaces')
|
|
827
827
|
if (globalNamespaces) {
|
|
@@ -832,7 +832,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
832
832
|
newParams.set('releaseStorage', storageNamespace)
|
|
833
833
|
}
|
|
834
834
|
if (investigationRunID) newParams.set('ai-run', investigationRunID)
|
|
835
|
-
setSelectedHelmRelease({ namespace, name, storageNamespace })
|
|
835
|
+
setSelectedHelmRelease({ namespace, name, storageNamespace, observed })
|
|
836
836
|
if (mainView === 'helm') {
|
|
837
837
|
setSearchParams(newParams, { replace: true })
|
|
838
838
|
return
|
|
@@ -1642,7 +1642,9 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
1642
1642
|
if (slashIdx > 0) {
|
|
1643
1643
|
const ns = releaseParam.slice(0, slashIdx)
|
|
1644
1644
|
const name = releaseParam.slice(slashIdx + 1)
|
|
1645
|
-
|
|
1645
|
+
const storageNamespace = searchParams.get('releaseStorage') || undefined
|
|
1646
|
+
// Keep what a row click knows about the release; the URL doesn't carry it.
|
|
1647
|
+
setSelectedHelmRelease(prev => (prev?.namespace === ns && prev.name === name && prev.storageNamespace === storageNamespace ? prev : { namespace: ns, name, storageNamespace }))
|
|
1646
1648
|
}
|
|
1647
1649
|
}
|
|
1648
1650
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- run only when searchParams change; namespacesKey/namespaceScope are read for that transition
|
|
@@ -2349,7 +2351,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
|
|
|
2349
2351
|
<HelmView
|
|
2350
2352
|
namespaces={namespaces}
|
|
2351
2353
|
selectedRelease={selectedHelmRelease}
|
|
2352
|
-
onReleaseClick={navigateToHelmRelease}
|
|
2354
|
+
onReleaseClick={(namespace, name, storageNamespace, observed) => navigateToHelmRelease(namespace, name, storageNamespace, undefined, observed)}
|
|
2353
2355
|
/>
|
|
2354
2356
|
)}
|
|
2355
2357
|
|
package/src/api/client.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createListRefetchInterval, normalizeResourceList, type ResourceListBody
|
|
|
2
2
|
import type { CascadeDetail } from '@skyhook-io/k8s-ui/components/ui/ForceDeleteConfirmDialog'
|
|
3
3
|
import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
|
|
4
4
|
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
5
|
-
import type { ReadGap } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
5
|
+
import type { ReadGap, ReadGapSet } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
6
6
|
import type { WorkloadHistoryCoverage } from '@skyhook-io/k8s-ui/utils/workload-history-notes'
|
|
7
7
|
import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
8
8
|
import { useEffect, useRef, useCallback, useMemo } from 'react'
|
|
@@ -44,8 +44,10 @@ import type {
|
|
|
44
44
|
TimelineEvent,
|
|
45
45
|
TimeRange,
|
|
46
46
|
ResourceWithRelationships,
|
|
47
|
+
HelmInventory,
|
|
47
48
|
HelmRelease,
|
|
48
49
|
HelmReleaseDetail,
|
|
50
|
+
ObservedHelmReleaseDetail,
|
|
49
51
|
HelmValues,
|
|
50
52
|
ManifestDiff,
|
|
51
53
|
NotesDiff,
|
|
@@ -529,13 +531,20 @@ export interface DashboardHelmRelease {
|
|
|
529
531
|
export interface DashboardHelmSummary {
|
|
530
532
|
total: number;
|
|
531
533
|
releases: DashboardHelmRelease[];
|
|
532
|
-
|
|
534
|
+
// True when no Helm records could be read and the caller was refused. A
|
|
535
|
+
// refusal in only some namespaces leaves it false and fills unreadNamespaces.
|
|
536
|
+
restricted?: boolean;
|
|
533
537
|
// error + errorCode populated when the Helm read failed for a non-RBAC
|
|
534
538
|
// reason (client not initialized, unconfigured, network). Surfaced
|
|
535
539
|
// via the dashboard widget so empty results aren't mistaken for
|
|
536
540
|
// "this cluster has zero releases."
|
|
537
541
|
error?: string;
|
|
538
542
|
errorCode?: string;
|
|
543
|
+
// Namespaces whose Helm records weren't read: refused, or the permission
|
|
544
|
+
// check behind that went unanswered. Their releases are missing from total
|
|
545
|
+
// and releases. Absent when everything in scope was read, on a restricted or
|
|
546
|
+
// failed answer, and from an older Radar.
|
|
547
|
+
unreadNamespaces?: ReadGapSet<string>;
|
|
539
548
|
}
|
|
540
549
|
|
|
541
550
|
export interface DashboardCRDCount {
|
|
@@ -801,8 +810,10 @@ export interface UncheckedSource {
|
|
|
801
810
|
// The kinds within the source that went unchecked; absent means the whole
|
|
802
811
|
// source, or that Radar couldn't tell which kinds.
|
|
803
812
|
kinds?: { group?: string; kind: string }[];
|
|
804
|
-
// The namespaces
|
|
805
|
-
//
|
|
813
|
+
// The namespaces this entry's gap is limited to: the source was checked in
|
|
814
|
+
// the others, and these weren't (the read failed or was refused there, or
|
|
815
|
+
// Radar didn't read there because the caller can't). Absent means the gap
|
|
816
|
+
// isn't limited to particular namespaces.
|
|
806
817
|
namespaces?: string[];
|
|
807
818
|
}
|
|
808
819
|
|
|
@@ -6121,13 +6132,59 @@ function helmNamespaceParams(namespaces: string[] = []) {
|
|
|
6121
6132
|
return namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
|
|
6122
6133
|
}
|
|
6123
6134
|
|
|
6124
|
-
//
|
|
6125
|
-
|
|
6135
|
+
// Objects still loading clear on their own, so the list shouldn't wait for a
|
|
6136
|
+
// manual refresh to fill in. Some gaps outlast any quick retry, such as
|
|
6137
|
+
// permission checks spread over many namespaces, so polling slows rather than
|
|
6138
|
+
// repeating a full object read every few seconds.
|
|
6139
|
+
const HELM_INVENTORY_FAST_POLLS = 24;
|
|
6140
|
+
|
|
6141
|
+
export function helmInventoryRefetchInterval(inventory: Pick<HelmInventory, "objectCoverage"> | undefined, updates: number): number | false {
|
|
6142
|
+
const settling = inventory?.objectCoverage?.gaps.some((gap) => gap.action === "retry" || gap.action === "wait");
|
|
6143
|
+
if (!settling) return false;
|
|
6144
|
+
return updates < HELM_INVENTORY_FAST_POLLS ? 5000 : 60000;
|
|
6145
|
+
}
|
|
6146
|
+
|
|
6147
|
+
// The Helm list as far as the caller's access reaches. An older Radar has no
|
|
6148
|
+
// inventory route: its list is the whole answer, and a denial stays a 403.
|
|
6149
|
+
export function useHelmInventory(namespaces: string[] = []) {
|
|
6126
6150
|
const params = helmNamespaceParams(namespaces);
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6151
|
+
const { isPending: capabilitiesPending } = useCapabilities();
|
|
6152
|
+
const { support } = useRadarFeature("helmInventory");
|
|
6153
|
+
const hasInventory = support === "supported";
|
|
6154
|
+
return useQuery<HelmInventory>({
|
|
6155
|
+
queryKey: ["helm-releases", namespaces, hasInventory],
|
|
6156
|
+
queryFn: async () =>
|
|
6157
|
+
hasInventory
|
|
6158
|
+
? fetchJSON<HelmInventory>(`/helm/inventory${params}`)
|
|
6159
|
+
: { releases: await fetchJSON<HelmRelease[]>(`/helm/releases${params}`), observed: [] },
|
|
6160
|
+
enabled: !capabilitiesPending,
|
|
6130
6161
|
staleTime: 30000, // 30 seconds
|
|
6162
|
+
refetchInterval: (query) => helmInventoryRefetchInterval(query.state.data, query.state.dataUpdateCount),
|
|
6163
|
+
});
|
|
6164
|
+
}
|
|
6165
|
+
|
|
6166
|
+
// Kubernetes refused the caller's own read of Helm's storage. Other 403s on the
|
|
6167
|
+
// same route mean something else, and a Radar without inventory sends no code.
|
|
6168
|
+
export function isHelmReleaseReadDenied(error: unknown): boolean {
|
|
6169
|
+
return isForbiddenError(error) && (error as ApiError).data?.error_code === "release_read_denied";
|
|
6170
|
+
}
|
|
6171
|
+
|
|
6172
|
+
// Each observed read walks every object the caller can see, so an open drawer
|
|
6173
|
+
// follows the list's schedule while objects settle and otherwise refreshes
|
|
6174
|
+
// once a minute. A retryable error retries sooner.
|
|
6175
|
+
export function observedHelmReleaseRefetchInterval(detail: ObservedHelmReleaseDetail | undefined, updates: number, error: unknown): number | false {
|
|
6176
|
+
if (error) return isStableClientError(error) ? false : 15000
|
|
6177
|
+
return helmInventoryRefetchInterval(detail, updates) || 60000
|
|
6178
|
+
}
|
|
6179
|
+
|
|
6180
|
+
// One release built from the stamps on its objects, for a caller who can't read
|
|
6181
|
+
// Helm's storage.
|
|
6182
|
+
export function useObservedHelmRelease(namespace: string, name: string) {
|
|
6183
|
+
return useQuery<ObservedHelmReleaseDetail>({
|
|
6184
|
+
queryKey: ["helm-observed-release", namespace, name],
|
|
6185
|
+
queryFn: () => fetchJSON(`/helm/inventory/${namespace}/${name}`),
|
|
6186
|
+
staleTime: 5000,
|
|
6187
|
+
refetchInterval: (query) => observedHelmReleaseRefetchInterval(query.state.data, query.state.dataUpdateCount, query.state.error),
|
|
6131
6188
|
});
|
|
6132
6189
|
}
|
|
6133
6190
|
|
|
@@ -6142,7 +6199,9 @@ export function useHelmRelease(
|
|
|
6142
6199
|
queryFn: () => fetchJSON(`/helm/releases/${namespace}/${name}`),
|
|
6143
6200
|
enabled: Boolean(namespace && name) && (options?.enabled ?? true),
|
|
6144
6201
|
staleTime: 5000,
|
|
6145
|
-
|
|
6202
|
+
// Poll for live resource status updates (post-upgrade/rollback); a refusal
|
|
6203
|
+
// would only repeat.
|
|
6204
|
+
refetchInterval: (query) => (isForbiddenError(query.state.error) ? false : 10000),
|
|
6146
6205
|
});
|
|
6147
6206
|
}
|
|
6148
6207
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { ApiError, helmInventoryRefetchInterval, observedHelmReleaseRefetchInterval, useHelmInventory } from './client'
|
|
7
|
+
import type { HelmInventory, ObservedHelmReleaseDetail } from '../types'
|
|
8
|
+
|
|
9
|
+
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
10
|
+
|
|
11
|
+
vi.mock('../context/ConnectionContext', () => ({ useClusterConnected: () => true, useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
12
|
+
|
|
13
|
+
type Seen = { data?: HelmInventory; error: unknown }
|
|
14
|
+
|
|
15
|
+
const json = (status: number, body: unknown) => new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } })
|
|
16
|
+
|
|
17
|
+
let root: Root | undefined
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root?.unmount())
|
|
21
|
+
root = undefined
|
|
22
|
+
vi.unstubAllGlobals()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
async function readInventory(features: Record<string, boolean>, routes: Record<string, () => Response>) {
|
|
26
|
+
const paths: string[] = []
|
|
27
|
+
vi.stubGlobal('fetch', vi.fn(async (input: RequestInfo | URL) => {
|
|
28
|
+
const path = new URL(String(input), 'http://radar.test').pathname
|
|
29
|
+
paths.push(path)
|
|
30
|
+
if (path.endsWith('/capabilities')) return json(200, { features })
|
|
31
|
+
const route = Object.keys(routes).find((key) => path.endsWith(key))
|
|
32
|
+
return route ? routes[route]() : json(200, {})
|
|
33
|
+
}))
|
|
34
|
+
const seen: Seen = { error: null }
|
|
35
|
+
function Probe() {
|
|
36
|
+
const { data, error } = useHelmInventory([])
|
|
37
|
+
seen.data = data
|
|
38
|
+
seen.error = error
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
42
|
+
root = createRoot(document.createElement('div'))
|
|
43
|
+
await act(async () => {
|
|
44
|
+
root!.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>)
|
|
45
|
+
})
|
|
46
|
+
await vi.waitFor(() => expect(seen.data !== undefined || seen.error !== null).toBe(true))
|
|
47
|
+
return { seen, paths }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('useHelmInventory', () => {
|
|
51
|
+
it('reads the inventory from a Radar that advertises it', async () => {
|
|
52
|
+
const inventory: HelmInventory = { releases: [], observed: [{ name: 'api', namespace: 'apps', resourceCount: 1 }], storageDenied: { extent: 'all' } }
|
|
53
|
+
const { seen, paths } = await readInventory({ helmInventory: true }, { '/helm/inventory': () => json(200, inventory) })
|
|
54
|
+
expect(seen.data).toEqual(inventory)
|
|
55
|
+
expect(paths.some((path) => path.endsWith('/helm/releases'))).toBe(false)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('reads the release list from an older Radar, which is the whole answer', async () => {
|
|
59
|
+
const release = { name: 'api', namespace: 'apps', chart: 'c', chartVersion: '1', appVersion: '1', status: 'deployed', revision: 1, updated: '2026-01-01T00:00:00Z' }
|
|
60
|
+
const { seen, paths } = await readInventory({}, { '/helm/releases': () => json(200, [release]) })
|
|
61
|
+
expect(seen.data).toEqual({ releases: [release], observed: [] })
|
|
62
|
+
expect(paths.some((path) => path.includes('/helm/inventory'))).toBe(false)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('keeps an older Radar’s denial an error', async () => {
|
|
66
|
+
const { seen } = await readInventory({}, { '/helm/releases': () => json(403, { error: 'insufficient permissions to list Helm releases' }) })
|
|
67
|
+
expect(seen.data).toBeUndefined()
|
|
68
|
+
expect((seen.error as { status?: number }).status).toBe(403)
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
describe('helmInventoryRefetchInterval', () => {
|
|
73
|
+
const withGap = (action: string): HelmInventory => ({ releases: [], observed: [], objectCoverage: { gaps: [{ code: 'x', action }] } as unknown as HelmInventory['objectCoverage'] })
|
|
74
|
+
|
|
75
|
+
it('leaves a settled list alone', () => {
|
|
76
|
+
expect(helmInventoryRefetchInterval(undefined, 0)).toBe(false)
|
|
77
|
+
expect(helmInventoryRefetchInterval({}, 0)).toBe(false)
|
|
78
|
+
expect(helmInventoryRefetchInterval(withGap('grant_access'), 0)).toBe(false)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('follows both gaps that can clear by themselves', () => {
|
|
82
|
+
expect(helmInventoryRefetchInterval(withGap('retry'), 0)).toBe(5000)
|
|
83
|
+
expect(helmInventoryRefetchInterval(withGap('wait'), 0)).toBe(5000)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('slows down, without stopping, once a gap outlasts the quick retries', () => {
|
|
87
|
+
expect(helmInventoryRefetchInterval(withGap('retry'), 24)).toBe(60000)
|
|
88
|
+
expect(helmInventoryRefetchInterval(withGap('wait'), 500)).toBe(60000)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
describe('observedHelmReleaseRefetchInterval', () => {
|
|
93
|
+
const detail = (action?: string) =>
|
|
94
|
+
({ name: 'web', namespace: 'apps', resourceCount: 1, objectCoverage: { gaps: action ? [{ code: 'x', action }] : [] } }) as unknown as ObservedHelmReleaseDetail
|
|
95
|
+
|
|
96
|
+
it('rereads a settled drawer only once a minute, since each read walks every object', () => {
|
|
97
|
+
expect(observedHelmReleaseRefetchInterval(detail(), 3, null)).toBe(60000)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('follows the list while objects settle', () => {
|
|
101
|
+
expect(observedHelmReleaseRefetchInterval(detail('retry'), 0, null)).toBe(5000)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('retries a retryable error and stops on a stable one', () => {
|
|
105
|
+
expect(observedHelmReleaseRefetchInterval(undefined, 0, new ApiError('busy', 503))).toBe(15000)
|
|
106
|
+
expect(observedHelmReleaseRefetchInterval(undefined, 0, new ApiError('gone', 404))).toBe(false)
|
|
107
|
+
})
|
|
108
|
+
})
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -66,6 +66,8 @@ export const RADAR_FEATURES = {
|
|
|
66
66
|
// turns it on.
|
|
67
67
|
argoEnableSelfHealOff: { label: 'Auto-sync that starts without self-heal', flag: 'argoEnableSelfHealOff', flagShippedWithEndpoint: true },
|
|
68
68
|
helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
|
|
69
|
+
// Never blocks a control: on an older Radar the Helm view reads /helm/releases.
|
|
70
|
+
helmInventory: { label: 'Helm releases without Secret access', flag: 'helmInventory', flagShippedWithEndpoint: true },
|
|
69
71
|
agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
|
|
70
72
|
} as const satisfies Record<string, RadarFeatureSpec>
|
|
71
73
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { expect, it } from 'vitest'
|
|
3
|
+
import { ServicePortCards } from '@skyhook-io/k8s-ui/components/resources/renderers/ServiceRenderer'
|
|
4
|
+
import { CurlButton, isHttpishPort } from './ServiceCurlButton'
|
|
5
|
+
|
|
6
|
+
// The UI keeps Curl for every Service shape, including headless, ExternalName
|
|
7
|
+
// and selector-less ones; only MCP's curl_service is narrower.
|
|
8
|
+
it.each([
|
|
9
|
+
['ClusterIP', '10.0.0.8', { app: 'demo' }],
|
|
10
|
+
['LoadBalancer', '10.0.0.8', { app: 'demo' }],
|
|
11
|
+
['ClusterIP', 'None', { app: 'demo' }],
|
|
12
|
+
['ClusterIP', undefined, { app: 'demo' }],
|
|
13
|
+
['ClusterIP', '10.0.0.8', {}],
|
|
14
|
+
['ExternalName', undefined, {}],
|
|
15
|
+
] as const)('preserves UI Service requests through the shared workload port cards: %s %s', (type, clusterIP, selector) => {
|
|
16
|
+
const service = { metadata: { namespace: 'team', name: 'app' }, spec: { type, clusterIP, selector, ports: [{ port: 80, protocol: 'TCP' }] } }
|
|
17
|
+
const html = renderToStaticMarkup(<ServicePortCards service={service} renderPortAction={() => <CurlButton active={false} onClick={() => {}} />} />)
|
|
18
|
+
expect(html).toContain('aria-expanded')
|
|
19
|
+
// Port information remains available even when the HTTP action is unsupported.
|
|
20
|
+
expect(html).toContain('80')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
['TCP', true],
|
|
25
|
+
[undefined, true],
|
|
26
|
+
['tcp', true],
|
|
27
|
+
['UDP', false],
|
|
28
|
+
['SCTP', false],
|
|
29
|
+
] as const)('offers Curl only on TCP ports (HTTP rides TCP): protocol %s', (protocol, offered) => {
|
|
30
|
+
// Port 8080 and name http would otherwise read as HTTP.
|
|
31
|
+
expect(isHttpishPort(8080, 'http', undefined, protocol)).toBe(offered)
|
|
32
|
+
})
|
|
@@ -36,8 +36,8 @@ export function defaultPathForPort(port: number, name?: string, appProtocol?: st
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function isHttpishPort(port: number, name?: string, appProtocol?: string, protocol?: string): boolean {
|
|
39
|
-
// HTTP rides TCP —
|
|
40
|
-
if (
|
|
39
|
+
// HTTP rides TCP — UDP and SCTP ports are never GET targets (e.g. statsd "metrics-udp").
|
|
40
|
+
if (protocol && protocol.toUpperCase() !== 'TCP') return false
|
|
41
41
|
const proto = (appProtocol || '').toLowerCase()
|
|
42
42
|
if (proto === 'http' || proto === 'https' || proto === 'http2') return true
|
|
43
43
|
if (proto && proto !== 'tcp') {
|
|
@@ -841,6 +841,47 @@ describe("agent case placement (D-1, D-1b)", () => {
|
|
|
841
841
|
expect(resolved.items[0].placement).toBe("card");
|
|
842
842
|
});
|
|
843
843
|
|
|
844
|
+
it("places a citation of an observed Helm release stored in another namespace", () => {
|
|
845
|
+
const helmRef = evidenceRef("h", "o");
|
|
846
|
+
const projection = project(
|
|
847
|
+
tool("diag", "diagnose", diagnoseBundle, { evidenceRef: ref }),
|
|
848
|
+
tool(
|
|
849
|
+
"helm",
|
|
850
|
+
"get_helm_release",
|
|
851
|
+
{
|
|
852
|
+
summary: "Observed: Helm's release Secrets can't be read here.",
|
|
853
|
+
observed: {
|
|
854
|
+
name: "shop",
|
|
855
|
+
namespace: "shop",
|
|
856
|
+
storageNamespace: "flux-system",
|
|
857
|
+
chart: "shop",
|
|
858
|
+
chartVersion: "1.4.2",
|
|
859
|
+
resourceCount: 3,
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
evidenceRef: helmRef,
|
|
864
|
+
summary: JSON.stringify({ namespace: "flux-system", name: "shop" }),
|
|
865
|
+
},
|
|
866
|
+
),
|
|
867
|
+
);
|
|
868
|
+
const resolved = resolveInvestigationCase(
|
|
869
|
+
projection,
|
|
870
|
+
{
|
|
871
|
+
evidence: [
|
|
872
|
+
linked(helmRef, "context", "The release's chart is shop 1.4.2.", {
|
|
873
|
+
kind: "HelmRelease",
|
|
874
|
+
namespace: "shop",
|
|
875
|
+
name: "shop",
|
|
876
|
+
observation: "resource",
|
|
877
|
+
}),
|
|
878
|
+
],
|
|
879
|
+
},
|
|
880
|
+
0,
|
|
881
|
+
);
|
|
882
|
+
expect(resolved.items[0].placement).toBe("card");
|
|
883
|
+
});
|
|
884
|
+
|
|
844
885
|
it("keeps an ordinary listing's held entry to the listing's namespace", () => {
|
|
845
886
|
const listRef = evidenceRef("c", "e");
|
|
846
887
|
const projection = project(
|
|
@@ -457,6 +457,22 @@ describe("listing cards (helm releases, packages, search)", () => {
|
|
|
457
457
|
]);
|
|
458
458
|
});
|
|
459
459
|
|
|
460
|
+
it.each([[[]], [[{ name: "shop", namespace: "shop", chart: "shop" }]]])(
|
|
461
|
+
"keeps a partial Helm read's limits with its rows: %j",
|
|
462
|
+
(observed) => {
|
|
463
|
+
const summary = "Partial: 0 releases read from Helm and 1 observed.";
|
|
464
|
+
const projection = project([
|
|
465
|
+
tool("helm", "list_helm_releases", { summary, releases: [], observed }),
|
|
466
|
+
]);
|
|
467
|
+
expect(projection.limitations).toEqual(
|
|
468
|
+
expect.arrayContaining([
|
|
469
|
+
expect.objectContaining({ source: "Helm releases", kind: "unknown" }),
|
|
470
|
+
]),
|
|
471
|
+
);
|
|
472
|
+
expect(JSON.stringify(projection.limitations)).toContain(summary);
|
|
473
|
+
},
|
|
474
|
+
);
|
|
475
|
+
|
|
460
476
|
it("lists Helm releases with their status and chart", () => {
|
|
461
477
|
const projection = project([
|
|
462
478
|
tool(
|
|
@@ -497,6 +513,62 @@ describe("listing cards (helm releases, packages, search)", () => {
|
|
|
497
513
|
expect(data.resources[1].issue).toBe("0/1 pods ready");
|
|
498
514
|
});
|
|
499
515
|
|
|
516
|
+
it("lists observed Helm releases without a status of their own", () => {
|
|
517
|
+
const projection = project([
|
|
518
|
+
tool("helm", "list_helm_releases", {
|
|
519
|
+
summary: "Partial: 1 releases read from Helm and 1 observed.",
|
|
520
|
+
releases: [{ name: "podinfo", namespace: "shop", chart: "podinfo", chartVersion: "6.15.0", status: "failed", revision: 3 }],
|
|
521
|
+
observed: [{ name: "redis", namespace: "team-b", chart: "redis", chartVersion: "19.0.1", resourceCount: 2, healthIssue: "ImagePullBackOff" }],
|
|
522
|
+
storageDenied: { count: 1, names: ["team-b"] },
|
|
523
|
+
}),
|
|
524
|
+
]);
|
|
525
|
+
const [group] = groupsOf(projection.groups, "inventory");
|
|
526
|
+
const data = group.latest.data;
|
|
527
|
+
if (data.type !== "inventory") throw new Error("expected inventory");
|
|
528
|
+
expect(data.resources.map((row) => row.status)).toEqual([
|
|
529
|
+
"failed · podinfo 6.15.0",
|
|
530
|
+
"status unknown · redis 19.0.1",
|
|
531
|
+
]);
|
|
532
|
+
expect(data.resources[1].issue).toBe("ImagePullBackOff");
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("shows an observed get_helm_release as an observed row with its limits", () => {
|
|
536
|
+
const summary = "Observed: Helm's release Secrets can't be read here.";
|
|
537
|
+
const projection = project([
|
|
538
|
+
tool("helm", "get_helm_release", {
|
|
539
|
+
summary,
|
|
540
|
+
observed: { name: "redis", namespace: "team-b", chart: "redis", chartVersion: "19.0.1", resourceCount: 2, resources: [] },
|
|
541
|
+
}),
|
|
542
|
+
]);
|
|
543
|
+
const [group] = groupsOf(projection.groups, "inventory");
|
|
544
|
+
const data = group.latest.data;
|
|
545
|
+
if (data.type !== "inventory") throw new Error("expected inventory");
|
|
546
|
+
expect(data.resources.map((row) => row.status)).toEqual(["status unknown · redis 19.0.1"]);
|
|
547
|
+
expect(JSON.stringify(projection.limitations)).toContain(summary);
|
|
548
|
+
expect(JSON.stringify(projection.limitations)).not.toContain("couldn't summarize");
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it.each([
|
|
552
|
+
["owns the target", "api", "producer-related"],
|
|
553
|
+
["doesn't own it", "worker", "broader"],
|
|
554
|
+
])("ranks an observed Helm release by whether it %s", (_, name, relevance) => {
|
|
555
|
+
const projection = project([
|
|
556
|
+
tool("diag", "diagnose", targetBundle),
|
|
557
|
+
tool("helm", "get_helm_release", {
|
|
558
|
+
summary: "Observed: Helm's release Secrets can't be read here.",
|
|
559
|
+
observed: {
|
|
560
|
+
name: "shop",
|
|
561
|
+
namespace: "shop",
|
|
562
|
+
chart: "shop",
|
|
563
|
+
resourceCount: 1,
|
|
564
|
+
resources: [{ kind: "Deployment", apiVersion: "apps/v1", namespace: "shop", name }],
|
|
565
|
+
},
|
|
566
|
+
}),
|
|
567
|
+
]);
|
|
568
|
+
const [group] = groupsOf(projection.groups, "inventory");
|
|
569
|
+
expect(group.latest.relevance).toBe(relevance);
|
|
570
|
+
});
|
|
571
|
+
|
|
500
572
|
it("lists packages with their version and sources", () => {
|
|
501
573
|
const projection = project([
|
|
502
574
|
tool(
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
InvestigationHelmRevision,
|
|
16
16
|
InvestigationHelmHook,
|
|
17
17
|
} from "../types";
|
|
18
|
+
import { adaptListHelmReleases } from "./listings";
|
|
18
19
|
|
|
19
20
|
function helmOwnedResource(
|
|
20
21
|
value: unknown,
|
|
@@ -124,12 +125,61 @@ function helmOperation(value: unknown): InvestigationHelmOperation | undefined {
|
|
|
124
125
|
return undefined;
|
|
125
126
|
return candidate as unknown as InvestigationHelmOperation;
|
|
126
127
|
}
|
|
128
|
+
// The release manages the target when the target is among the resources
|
|
129
|
+
// Helm rendered for it; a release is never the investigated object itself.
|
|
130
|
+
// Without an API version the owned row cannot tell colliding kinds apart
|
|
131
|
+
// (CNPG vs CAPI Cluster), so it establishes nothing.
|
|
132
|
+
function releaseRelevance(
|
|
133
|
+
builder: ProjectionBuilder,
|
|
134
|
+
resources: readonly InvestigationHelmOwnedResource[],
|
|
135
|
+
): InvestigationEvidenceRelevance {
|
|
136
|
+
return resources.some(
|
|
137
|
+
(owned) =>
|
|
138
|
+
owned.apiVersion !== undefined &&
|
|
139
|
+
resourceMatchesTarget(builder.target, {
|
|
140
|
+
kind: owned.kind,
|
|
141
|
+
group: apiVersionToGroup(owned.apiVersion),
|
|
142
|
+
namespace: owned.namespace || undefined,
|
|
143
|
+
name: owned.name,
|
|
144
|
+
}),
|
|
145
|
+
)
|
|
146
|
+
? "producer-related"
|
|
147
|
+
: "broader";
|
|
148
|
+
}
|
|
149
|
+
|
|
127
150
|
export function adaptHelmRelease(
|
|
128
151
|
builder: ProjectionBuilder,
|
|
129
152
|
source: InvestigationEvidenceSource,
|
|
130
153
|
payload: unknown,
|
|
131
154
|
): void {
|
|
132
155
|
const value = record(payload);
|
|
156
|
+
// Without Helm's Secrets the release comes from its objects, with no status
|
|
157
|
+
// or history: it reads as list_helm_releases' observed rows do. The call's
|
|
158
|
+
// namespace is where Helm stores the release, which a Flux HelmRelease can
|
|
159
|
+
// set apart from the release's own, so the card is scoped to the release.
|
|
160
|
+
const observed = record(value?.observed);
|
|
161
|
+
if (value && observed && nonEmptyString(value.summary)) {
|
|
162
|
+
adaptListHelmReleases(
|
|
163
|
+
builder,
|
|
164
|
+
{
|
|
165
|
+
...source,
|
|
166
|
+
args: JSON.stringify({
|
|
167
|
+
namespace: observed.namespace,
|
|
168
|
+
name: observed.name,
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
{ summary: value.summary, releases: [], observed: [observed] },
|
|
172
|
+
releaseRelevance(
|
|
173
|
+
builder,
|
|
174
|
+
(Array.isArray(observed.resources) ? observed.resources : [])
|
|
175
|
+
.map(helmOwnedResource)
|
|
176
|
+
.filter((item): item is InvestigationHelmOwnedResource =>
|
|
177
|
+
Boolean(item),
|
|
178
|
+
),
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
133
183
|
if (
|
|
134
184
|
!value ||
|
|
135
185
|
!nonEmptyString(value.name) ||
|
|
@@ -207,22 +257,7 @@ export function adaptHelmRelease(
|
|
|
207
257
|
...(hooks ? { hooks } : {}),
|
|
208
258
|
...(values ? { values } : {}),
|
|
209
259
|
};
|
|
210
|
-
|
|
211
|
-
// Helm rendered for it; a release is never the investigated object itself.
|
|
212
|
-
// Without an API version the owned row cannot tell colliding kinds apart
|
|
213
|
-
// (CNPG vs CAPI Cluster), so it establishes nothing.
|
|
214
|
-
const relevance: InvestigationEvidenceRelevance = resources.some(
|
|
215
|
-
(owned) =>
|
|
216
|
-
owned.apiVersion !== undefined &&
|
|
217
|
-
resourceMatchesTarget(builder.target, {
|
|
218
|
-
kind: owned.kind,
|
|
219
|
-
group: apiVersionToGroup(owned.apiVersion),
|
|
220
|
-
namespace: owned.namespace || undefined,
|
|
221
|
-
name: owned.name,
|
|
222
|
-
}),
|
|
223
|
-
)
|
|
224
|
-
? "producer-related"
|
|
225
|
-
: "broader";
|
|
260
|
+
const relevance = releaseRelevance(builder, resources);
|
|
226
261
|
const status = release.status.toLowerCase();
|
|
227
262
|
const operationFailed =
|
|
228
263
|
lastOperation?.status === "failed" ||
|
|
@@ -1,24 +1,51 @@
|
|
|
1
1
|
import { adaptListResources } from "./resource";
|
|
2
2
|
import { nonEmptyString, parseJSON, record, stringArray } from "../parse";
|
|
3
3
|
import { invalidPayload, type ProjectionBuilder } from "../observations";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
InvestigationEvidenceRelevance,
|
|
6
|
+
InvestigationEvidenceSource,
|
|
7
|
+
} from "../types";
|
|
5
8
|
|
|
6
9
|
// Helm releases, installed packages and search hits are inventories: rows
|
|
7
10
|
// with a kind, a name and a namespace, one line of status, and for a hit
|
|
8
11
|
// the text that matched. They render on the inventory card so a citation
|
|
9
12
|
// can name a row the way it names a resource in a listing.
|
|
10
13
|
|
|
14
|
+
// A caller who can't read all of Helm's storage gets an object, whose observed
|
|
15
|
+
// rows have no status of their own; the card must not read as though they did.
|
|
16
|
+
function helmReleaseRows(payload: unknown): unknown[] | undefined {
|
|
17
|
+
if (Array.isArray(payload)) return payload;
|
|
18
|
+
const value = record(payload);
|
|
19
|
+
if (!value || !Array.isArray(value.releases) || !Array.isArray(value.observed)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return [
|
|
23
|
+
...value.releases,
|
|
24
|
+
...value.observed.map((entry) => {
|
|
25
|
+
const item = record(entry);
|
|
26
|
+
return item ? { ...item, status: "status unknown" } : entry;
|
|
27
|
+
}),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
|
|
11
31
|
export function adaptListHelmReleases(
|
|
12
32
|
builder: ProjectionBuilder,
|
|
13
33
|
source: InvestigationEvidenceSource,
|
|
14
34
|
payload: unknown,
|
|
35
|
+
relevance?: InvestigationEvidenceRelevance,
|
|
15
36
|
): void {
|
|
16
37
|
// Retained runs may contain the Helm producer's nil-slice encoding.
|
|
17
38
|
if (payload === null) payload = [];
|
|
18
|
-
|
|
39
|
+
const rows = helmReleaseRows(payload);
|
|
40
|
+
if (!rows) {
|
|
19
41
|
invalidPayload(builder, source);
|
|
20
42
|
return;
|
|
21
43
|
}
|
|
44
|
+
// A partial read can miss releases, which its rows can't show.
|
|
45
|
+
const partial = record(payload)?.summary;
|
|
46
|
+
if (nonEmptyString(partial)) {
|
|
47
|
+
builder.limit(source, "Helm releases", partial, "unknown");
|
|
48
|
+
}
|
|
22
49
|
const args = record(parseJSON(source.args ?? ""));
|
|
23
50
|
const namespace = nonEmptyString(args?.namespace)
|
|
24
51
|
? args.namespace
|
|
@@ -26,7 +53,7 @@ export function adaptListHelmReleases(
|
|
|
26
53
|
adaptListResources(
|
|
27
54
|
builder,
|
|
28
55
|
source,
|
|
29
|
-
|
|
56
|
+
rows.map((entry) => {
|
|
30
57
|
const item = record(entry);
|
|
31
58
|
if (!item) return entry;
|
|
32
59
|
const chart = [item.chart, item.chartVersion]
|
|
@@ -44,7 +71,10 @@ export function adaptListHelmReleases(
|
|
|
44
71
|
: {}),
|
|
45
72
|
};
|
|
46
73
|
}),
|
|
47
|
-
{
|
|
74
|
+
{
|
|
75
|
+
title: namespace ? `Helm releases in ${namespace}` : "Helm releases",
|
|
76
|
+
relevance,
|
|
77
|
+
},
|
|
48
78
|
);
|
|
49
79
|
}
|
|
50
80
|
|