@skyhook-io/radar-app 1.17.1 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +10 -11
- package/src/App.tsx +36 -36
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +396 -105
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
- package/src/components/diagnose/investigationEvidence/types.ts +26 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +28 -11
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +69 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +5 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +28 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +46 -69
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +21 -67
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +89 -14
- package/src/components/ui/RadarOmnibar.test.tsx +183 -0
- package/src/components/ui/RadarOmnibar.tsx +38 -4
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +2 -1
- package/src/components/ui/UpdateNotification.tsx +29 -5
- package/src/components/ui/omnibar-match.test.ts +37 -0
- package/src/components/ui/omnibar-match.ts +23 -0
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +43 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +2 -4
- package/src/index.ts +7 -0
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { UNKNOWN_SOURCE_LINE, uncheckedSourceLines } from './uncheckedSources'
|
|
3
|
+
|
|
4
|
+
describe('uncheckedSourceLines', () => {
|
|
5
|
+
it('names the kinds still loading', () => {
|
|
6
|
+
expect(uncheckedSourceLines([{
|
|
7
|
+
source: 'resources', reason: 'kind_sync_pending',
|
|
8
|
+
kinds: [{ group: 'autoscaling', kind: 'HorizontalPodAutoscaler' }, { kind: 'PersistentVolumeClaim' }],
|
|
9
|
+
}])).toEqual(['Still loading HorizontalPodAutoscalers and PersistentVolumeClaims, so their issues may be missing.'])
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('caps a long kind list', () => {
|
|
13
|
+
const kinds = ['Pod', 'Node', 'Service', 'Secret', 'ConfigMap'].map((kind) => ({ kind }))
|
|
14
|
+
expect(uncheckedSourceLines([{ source: 'resources', reason: 'kind_sync_failed', kinds }]))
|
|
15
|
+
.toEqual(["Pods, Nodes and 3 more couldn't be loaded, so their issues may be missing."])
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('says custom resources are loading when no kind can be named', () => {
|
|
19
|
+
expect(uncheckedSourceLines([{ source: 'custom_resources', reason: 'kind_sync_pending' }]))
|
|
20
|
+
.toEqual(['Custom resources are still loading, so failing ones may be missing.'])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('names the Helm namespaces that failed, so the rest reads as checked', () => {
|
|
24
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'read_failed', namespaces: ['payments'] }]))
|
|
25
|
+
.toEqual(["Helm releases in payments couldn't be checked, so failed or stuck releases there may be missing."])
|
|
26
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'read_failed', namespaces: ['a', 'b'] }]))
|
|
27
|
+
.toEqual(["Helm releases in 2 namespaces (a and b) couldn't be checked, so failed or stuck releases there may be missing."])
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("says when Radar's own service account is the problem", () => {
|
|
31
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'collector_access_denied' }]))
|
|
32
|
+
.toEqual(["Helm releases couldn't be checked because Radar's service account isn't allowed to impersonate users, so failed or stuck releases may be missing."])
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('falls back to the source line for a reason this version does not know', () => {
|
|
36
|
+
expect(uncheckedSourceLines([{ source: 'karpenter', reason: 'something_new' }]))
|
|
37
|
+
.toEqual(["Karpenter resources couldn't be checked, so NodePool and NodeClaim issues may be missing."])
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('keeps the generic line for an unknown source', () => {
|
|
41
|
+
expect(uncheckedSourceLines([{ source: 'brand_new', reason: 'read_failed' }])).toEqual([UNKNOWN_SOURCE_LINE])
|
|
42
|
+
})
|
|
43
|
+
})
|
|
@@ -1,20 +1,73 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { englishPlural } from "@skyhook-io/k8s-ui/utils/pluralize";
|
|
2
|
+
import type { IssuesResponse, UncheckedSource } from "../../api/client";
|
|
2
3
|
|
|
3
|
-
// The issue
|
|
4
|
-
//
|
|
4
|
+
// The line each issue source gets wherever Radar's issues would otherwise read
|
|
5
|
+
// as complete, when nothing more specific can be said about the gap.
|
|
5
6
|
const SOURCE_LINES: Record<string, string> = {
|
|
6
7
|
helm: "Helm releases couldn't be checked, so failed or stuck releases may be missing.",
|
|
8
|
+
resources: "Some resources couldn't be checked, so their issues may be missing.",
|
|
9
|
+
custom_resources: "Custom resources couldn't be checked, so failing ones may be missing.",
|
|
10
|
+
karpenter: "Karpenter resources couldn't be checked, so NodePool and NodeClaim issues may be missing.",
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
// For a source this version doesn't know, sent by a newer Radar.
|
|
10
14
|
export const UNKNOWN_SOURCE_LINE = "Some issue checks couldn't run, so issues may be missing.";
|
|
11
15
|
|
|
16
|
+
const NAMED_LIMIT = 3;
|
|
17
|
+
|
|
18
|
+
/** "A", "A and B", "A, B and C", "A, B and 4 more". */
|
|
19
|
+
function nameList(names: string[]): string {
|
|
20
|
+
if (names.length <= NAMED_LIMIT) {
|
|
21
|
+
return names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
22
|
+
}
|
|
23
|
+
return `${names.slice(0, NAMED_LIMIT - 1).join(", ")} and ${names.length - (NAMED_LIMIT - 1)} more`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function helmLine({ reason, namespaces }: UncheckedSource): string {
|
|
27
|
+
const where = namespaces?.length
|
|
28
|
+
? namespaces.length === 1
|
|
29
|
+
? `in ${namespaces[0]} `
|
|
30
|
+
: `in ${namespaces.length} namespaces (${nameList(namespaces)}) `
|
|
31
|
+
: "";
|
|
32
|
+
const missing = where ? "failed or stuck releases there may be missing" : "failed or stuck releases may be missing";
|
|
33
|
+
if (reason === "collector_access_denied") {
|
|
34
|
+
return `Helm releases ${where}couldn't be checked because Radar's service account isn't allowed to impersonate users, so ${missing}.`;
|
|
35
|
+
}
|
|
36
|
+
return `Helm releases ${where}couldn't be checked, so ${missing}.`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function kindsLine(source: UncheckedSource): string | undefined {
|
|
40
|
+
const kinds = [...new Set((source.kinds ?? []).map((k) => englishPlural(k.kind)))];
|
|
41
|
+
if (kinds.length === 0) {
|
|
42
|
+
if (source.source === "custom_resources" && source.reason === "kind_sync_pending") {
|
|
43
|
+
return "Custom resources are still loading, so failing ones may be missing.";
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const names = nameList(kinds);
|
|
48
|
+
switch (source.reason) {
|
|
49
|
+
case "kind_sync_pending":
|
|
50
|
+
return `Still loading ${names}, so their issues may be missing.`;
|
|
51
|
+
case "kind_sync_failed":
|
|
52
|
+
return `${names} couldn't be loaded, so their issues may be missing.`;
|
|
53
|
+
default:
|
|
54
|
+
return `${names} couldn't be checked, so their issues may be missing.`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function lineFor(source: UncheckedSource): string | undefined {
|
|
59
|
+
if (!Object.hasOwn(SOURCE_LINES, source.source)) return undefined;
|
|
60
|
+
if (source.source === "helm") return helmLine(source);
|
|
61
|
+
return kindsLine(source) ?? SOURCE_LINES[source.source];
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
/** One line per unchecked source, known sources first, without repeats. */
|
|
13
65
|
export function uncheckedSourceLines(sources: IssuesResponse["unchecked_sources"]): string[] {
|
|
14
66
|
const known = new Set<string>();
|
|
15
67
|
let unknown = false;
|
|
16
|
-
for (const
|
|
17
|
-
|
|
68
|
+
for (const source of sources ?? []) {
|
|
69
|
+
const line = lineFor(source);
|
|
70
|
+
if (line) known.add(line);
|
|
18
71
|
else unknown = true;
|
|
19
72
|
}
|
|
20
73
|
return unknown ? [...known, UNKNOWN_SOURCE_LINE] : [...known];
|
|
@@ -11,6 +11,8 @@ interface ScheduledWorkloadLogsViewerProps {
|
|
|
11
11
|
name: string
|
|
12
12
|
selectedRunKey?: string
|
|
13
13
|
onSelectRun?: (runKey: string) => void
|
|
14
|
+
/** The view's namespace selection; narrows a cluster-scoped template's runs. */
|
|
15
|
+
viewNamespaces?: string[]
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const EMPTY_RUNS: WorkloadRun[] = []
|
|
@@ -19,7 +21,7 @@ export function ScheduledWorkloadLogsViewer(props: ScheduledWorkloadLogsViewerPr
|
|
|
19
21
|
return <ScheduledWorkloadLogsContent key={JSON.stringify([props.kind, props.namespace, props.name])} {...props} />
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, onSelectRun }: ScheduledWorkloadLogsViewerProps) {
|
|
24
|
+
function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, onSelectRun, viewNamespaces }: ScheduledWorkloadLogsViewerProps) {
|
|
23
25
|
const clusterScoped = kind === 'ClusterWorkflowTemplate' || kind === 'clusterworkflowtemplates'
|
|
24
26
|
const jobSet = kind.toLowerCase() === 'jobset' || kind.toLowerCase() === 'jobsets'
|
|
25
27
|
const [localRunKey, setLocalRunKey] = useState('')
|
|
@@ -28,7 +30,7 @@ function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, o
|
|
|
28
30
|
const [scope, setScope] = useState('selected')
|
|
29
31
|
const [role, setRole] = useState('')
|
|
30
32
|
const rootQuery = useResource<any>('jobsets', namespace, name, 'jobset.x-k8s.io', { enabled: jobSet })
|
|
31
|
-
const runsQuery = useWorkloadRuns(kind, namespace, name, true, { clusterScoped, refetchActive: true, ...(jobSet ? { selected: effectiveRunKey } : {}) })
|
|
33
|
+
const runsQuery = useWorkloadRuns(kind, namespace, name, true, { clusterScoped, namespaces: viewNamespaces, refetchActive: true, ...(jobSet ? { selected: effectiveRunKey } : {}) })
|
|
32
34
|
const memberCollection = runsQuery.data?.collection === 'members'
|
|
33
35
|
const runs = runsQuery.data?.runs ?? EMPTY_RUNS
|
|
34
36
|
const selectedRunFromResponse = runsQuery.data?.selected
|
|
@@ -19,4 +19,49 @@ describe('Pod request and limit overlays', () => {
|
|
|
19
19
|
} } } }
|
|
20
20
|
expect(computeRequestLimitLines(resource, 'Deployment', 'cpu')![0].value).toBeCloseTo(1.2)
|
|
21
21
|
})
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
['1024000m', '2048000m'],
|
|
25
|
+
['1024000000u', '2048000000u'],
|
|
26
|
+
['1024000000000n', '2048000000000n'],
|
|
27
|
+
['1.024k', '2.048k'],
|
|
28
|
+
['1.024K', '2.048K'],
|
|
29
|
+
])('reads memory request %s and limit %s as bytes', (request, limit) => {
|
|
30
|
+
const resource = { spec: { containers: [
|
|
31
|
+
{ resources: { requests: { memory: request }, limits: { memory: limit } } },
|
|
32
|
+
] } }
|
|
33
|
+
expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toEqual([
|
|
34
|
+
{ value: 1024, label: 'request 1KiB', kind: 'request' },
|
|
35
|
+
{ value: 2048, label: 'limit 2KiB', kind: 'limit' },
|
|
36
|
+
])
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('sums binary and millibyte quantities across containers and native sidecars', () => {
|
|
40
|
+
const resource = { spec: { template: { spec: {
|
|
41
|
+
containers: [{ resources: { requests: { memory: '16Gi' }, limits: { memory: '16Gi' } } }],
|
|
42
|
+
initContainers: [{ restartPolicy: 'Always', resources: {
|
|
43
|
+
requests: { memory: '1181116006400m' }, limits: { memory: '1073741824000m' },
|
|
44
|
+
} }],
|
|
45
|
+
} } } }
|
|
46
|
+
const lines = computeRequestLimitLines(resource, 'Deployment', 'memory')!
|
|
47
|
+
expect(lines[0].value).toBeCloseTo(18360985190.4)
|
|
48
|
+
expect(lines[0].label).toBe('request 17.1GiB')
|
|
49
|
+
expect(lines[1]).toEqual({ value: 17 * 1024 ** 3, label: 'limit 17.0GiB', kind: 'limit' })
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it.each(['abcMi', 'abcm', 'abcu', 'abcn', '', undefined])('omits unreadable memory quantities: %s', (memory) => {
|
|
53
|
+
const resource = { spec: { containers: [
|
|
54
|
+
{ resources: { requests: { memory }, limits: { memory } } },
|
|
55
|
+
] } }
|
|
56
|
+
expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toBeUndefined()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('retains a genuine zero request while omitting a zero limit', () => {
|
|
60
|
+
const resource = { spec: { containers: [
|
|
61
|
+
{ resources: { requests: { memory: '0m' }, limits: { memory: '0m' } } },
|
|
62
|
+
] } }
|
|
63
|
+
expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toEqual([
|
|
64
|
+
{ value: 0, label: 'request 0KiB', kind: 'request' },
|
|
65
|
+
])
|
|
66
|
+
})
|
|
22
67
|
})
|
|
@@ -209,7 +209,7 @@ function collectRuntimeContainers(podSpec: any): any[] {
|
|
|
209
209
|
const CPU_SUFFIXES: Record<string, number> = { n: 1e-9, u: 1e-6, m: 1e-3 }
|
|
210
210
|
const MEMORY_SUFFIXES: Record<string, number> = {
|
|
211
211
|
Ki: 1024, Mi: 1024 ** 2, Gi: 1024 ** 3, Ti: 1024 ** 4, Pi: 1024 ** 5, Ei: 1024 ** 6,
|
|
212
|
-
K: 1e3, M: 1e6, G: 1e9, T: 1e12, P: 1e15, E: 1e18,
|
|
212
|
+
n: 1e-9, u: 1e-6, m: 1e-3, k: 1e3, K: 1e3, M: 1e6, G: 1e9, T: 1e12, P: 1e15, E: 1e18,
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// NOT a duplicate of @skyhook-io/k8s-ui/utils/format's parseCPUToNanocores /
|
|
@@ -232,7 +232,7 @@ function readQuantity(raw: unknown, category: 'cpu' | 'memory'): number | null {
|
|
|
232
232
|
for (const suffix of ['Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei']) {
|
|
233
233
|
if (s.endsWith(suffix)) return scaleOrNull(s, MEMORY_SUFFIXES[suffix])
|
|
234
234
|
}
|
|
235
|
-
for (const suffix of ['K', 'M', 'G', 'T', 'P', 'E']) {
|
|
235
|
+
for (const suffix of ['n', 'u', 'm', 'k', 'K', 'M', 'G', 'T', 'P', 'E']) {
|
|
236
236
|
if (s.endsWith(suffix)) return scaleOrNull(s, MEMORY_SUFFIXES[suffix])
|
|
237
237
|
}
|
|
238
238
|
const v = parseFloat(s)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
5
|
+
import { ImageFilesystemModal } from './ImageFilesystemModal'
|
|
6
|
+
import { ApiError } from '../../api/client'
|
|
7
|
+
|
|
8
|
+
const state = vi.hoisted(() => ({ authEnabled: false, showMetadata: false }))
|
|
9
|
+
vi.mock('../../contexts/CapabilitiesContext', () => ({ useIsAuthEnabled: () => state.authEnabled }))
|
|
10
|
+
vi.mock('../../api/client', () => ({
|
|
11
|
+
ApiError: class extends Error {
|
|
12
|
+
status = 401
|
|
13
|
+
data = { registryType: 'google' }
|
|
14
|
+
},
|
|
15
|
+
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() }),
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
22
|
+
let root: ReturnType<typeof createRoot>
|
|
23
|
+
|
|
24
|
+
afterEach(async () => {
|
|
25
|
+
await act(async () => root.unmount())
|
|
26
|
+
state.showMetadata = false
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it.each([true, false])('shows private-image guidance for authEnabled=%s', async (authEnabled) => {
|
|
30
|
+
state.authEnabled = authEnabled
|
|
31
|
+
root = createRoot(document.createElement('div'))
|
|
32
|
+
await act(async () => {
|
|
33
|
+
root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} />)
|
|
34
|
+
})
|
|
35
|
+
const text = document.body.textContent || ''
|
|
36
|
+
expect(text).toContain('Authentication Required')
|
|
37
|
+
if (authEnabled) {
|
|
38
|
+
expect(text).toContain("Private images need exec access to the Pod, or read access to its imagePullSecrets. Exec access also lets Radar use its own registry credentials.")
|
|
39
|
+
expect(text).not.toContain('~/.docker/config.json')
|
|
40
|
+
expect(text).not.toContain('Run this command to authenticate')
|
|
41
|
+
expect(text).not.toContain('gcloud')
|
|
42
|
+
} else {
|
|
43
|
+
expect(text).toContain('~/.docker/config.json')
|
|
44
|
+
expect(text).toContain('Run this command to authenticate')
|
|
45
|
+
expect(text).toContain('gcloud')
|
|
46
|
+
expect(text).not.toContain("Private images are read with the Pod's imagePullSecrets")
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it.each([true, false])('shows download confirmation for authEnabled=%s', async (authEnabled) => {
|
|
51
|
+
state.authEnabled = authEnabled
|
|
52
|
+
state.showMetadata = true
|
|
53
|
+
root = createRoot(document.createElement('div'))
|
|
54
|
+
await act(async () => {
|
|
55
|
+
root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} />)
|
|
56
|
+
})
|
|
57
|
+
const text = document.body.textContent || ''
|
|
58
|
+
expect(text).toContain('Download Image Layers?')
|
|
59
|
+
expect(text).toContain('Download & View')
|
|
60
|
+
if (authEnabled) {
|
|
61
|
+
expect(text).not.toContain('Authentication Command')
|
|
62
|
+
expect(text).not.toContain('gcloud')
|
|
63
|
+
expect(text).not.toContain('Run this command')
|
|
64
|
+
} else {
|
|
65
|
+
expect(text).toContain('Authentication Command')
|
|
66
|
+
expect(text).toContain('gcloud')
|
|
67
|
+
}
|
|
68
|
+
})
|
|
@@ -12,6 +12,7 @@ import { Tooltip } from '../ui/Tooltip'
|
|
|
12
12
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
13
13
|
import { readErrorBody } from '../../api/httpErrors'
|
|
14
14
|
import { Input } from '@skyhook-io/k8s-ui'
|
|
15
|
+
import { useIsAuthEnabled } from '../../contexts/CapabilitiesContext'
|
|
15
16
|
|
|
16
17
|
const radarLoadingIconUrl = assetUrl(radarLoadingIcon)
|
|
17
18
|
|
|
@@ -293,8 +294,9 @@ interface DownloadConfirmationProps {
|
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
function DownloadConfirmation({ metadata, onConfirm, onCancel }: DownloadConfirmationProps) {
|
|
297
|
+
const authEnabled = useIsAuthEnabled()
|
|
296
298
|
const isPublic = metadata.authMethod === 'anonymous'
|
|
297
|
-
const authCommand = !isPublic ? getAuthCommand(metadata.authMethod, metadata.image) : null
|
|
299
|
+
const authCommand = !authEnabled && !isPublic ? getAuthCommand(metadata.authMethod, metadata.image) : null
|
|
298
300
|
const [copied, setCopied] = useState(false)
|
|
299
301
|
|
|
300
302
|
const handleCopy = async () => {
|
|
@@ -417,11 +419,12 @@ interface AuthenticationHelpProps {
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
function AuthenticationHelp({ image, registryType, onRetry }: AuthenticationHelpProps) {
|
|
422
|
+
const authEnabled = useIsAuthEnabled()
|
|
420
423
|
const [copied, setCopied] = useState(false)
|
|
421
424
|
const [retrying, setRetrying] = useState(false)
|
|
422
425
|
const registry = getRegistryHost(image)
|
|
423
426
|
const authMethod = registryType || 'generic'
|
|
424
|
-
const authCommand = getAuthCommand(authMethod, image)
|
|
427
|
+
const authCommand = authEnabled ? null : getAuthCommand(authMethod, image)
|
|
425
428
|
|
|
426
429
|
const handleCopy = async () => {
|
|
427
430
|
if (!authCommand) return
|
|
@@ -489,8 +492,12 @@ function AuthenticationHelp({ image, registryType, onRetry }: AuthenticationHelp
|
|
|
489
492
|
|
|
490
493
|
{/* Explanation */}
|
|
491
494
|
<p className="text-xs text-theme-text-tertiary text-center max-w-md mb-6">
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
{authEnabled ? (
|
|
496
|
+
<>Private images need exec access to the Pod, or read access to its imagePullSecrets. Exec access also lets Radar use its own registry credentials.</>
|
|
497
|
+
) : (
|
|
498
|
+
<>Radar uses your local Docker credentials (<span className="font-mono">~/.docker/config.json</span>).
|
|
499
|
+
Run the command above in your terminal, then click Retry.</>
|
|
500
|
+
)}
|
|
494
501
|
</p>
|
|
495
502
|
|
|
496
503
|
{/* Retry button */}
|
|
@@ -127,7 +127,7 @@ interface PodFilesystemModalProps {
|
|
|
127
127
|
podName: string
|
|
128
128
|
containers: string[]
|
|
129
129
|
initialContainer?: string
|
|
130
|
-
onSwitchToImageFiles?: () => void
|
|
130
|
+
onSwitchToImageFiles?: (containerName: string) => void
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export function PodFilesystemModal({
|
|
@@ -389,7 +389,7 @@ export function PodFilesystemModal({
|
|
|
389
389
|
)}
|
|
390
390
|
{onSwitchToImageFiles && (
|
|
391
391
|
<button
|
|
392
|
-
onClick={() => { onClose(); onSwitchToImageFiles() }}
|
|
392
|
+
onClick={() => { onClose(); onSwitchToImageFiles(selectedContainer) }}
|
|
393
393
|
className="ml-auto text-blue-400 hover:text-blue-300 hover:underline"
|
|
394
394
|
>
|
|
395
395
|
Browse static image from registry →
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import { ResourcesView } from './ResourcesView'
|
|
8
|
+
|
|
9
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected', context: 'test' } }) }))
|
|
10
|
+
vi.mock('../dock', () => ({ useOpenLogs: () => () => {}, useOpenWorkloadLogs: () => () => {} }))
|
|
11
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
12
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
13
|
+
|
|
14
|
+
const requested: URL[] = []
|
|
15
|
+
let root: ReturnType<typeof createRoot>
|
|
16
|
+
let client: QueryClient
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
requested.length = 0
|
|
20
|
+
vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: () => {}, removeEventListener: () => {} }))
|
|
21
|
+
vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL) => {
|
|
22
|
+
requested.push(new URL(String(input), 'http://radar.invalid'))
|
|
23
|
+
return new Promise<Response>(() => {})
|
|
24
|
+
}))
|
|
25
|
+
root = createRoot(document.createElement('div'))
|
|
26
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterEach(async () => {
|
|
30
|
+
await act(async () => root.unmount())
|
|
31
|
+
client.clear()
|
|
32
|
+
vi.unstubAllGlobals()
|
|
33
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
async function certExpiryScope(namespaces: string[]) {
|
|
37
|
+
await act(async () => {
|
|
38
|
+
root.render(
|
|
39
|
+
<QueryClientProvider client={client}>
|
|
40
|
+
<MemoryRouter initialEntries={['/resources/secrets']}>
|
|
41
|
+
<ResourcesView namespaces={namespaces} selectedResource={null} onResourceClick={() => {}} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
</QueryClientProvider>,
|
|
44
|
+
)
|
|
45
|
+
})
|
|
46
|
+
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
|
|
47
|
+
const certExpiry = requested.filter((url) => url.pathname.endsWith('/secrets/certificate-expiry'))
|
|
48
|
+
if (certExpiry.length === 0) throw new Error(`no certificate-expiry request: ${requested.map(String).join(', ')}`)
|
|
49
|
+
return certExpiry.map((url) => url.searchParams.get('namespaces'))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
it('scopes certificate expiry to the namespaces in view', async () => {
|
|
53
|
+
expect(await certExpiryScope(['team-a', 'team-b'])).toEqual(['team-a,team-b'])
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('asks for every namespace when the view covers all', async () => {
|
|
57
|
+
expect(await certExpiryScope([])).toEqual([null])
|
|
58
|
+
})
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback } from 'react'
|
|
2
2
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
3
3
|
import { useQuery } from '@tanstack/react-query'
|
|
4
|
-
import {
|
|
4
|
+
import { fetchJSON, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAudit, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError } from '../../api/client'
|
|
5
5
|
import { isBadgeWorthy } from '../../utils/auditBadges'
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ISSUE_SEVERITY_RANK } from '@skyhook-io/k8s-ui'
|
|
7
|
+
import type { Issue, AuditBadgeMessage } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import { stripBasename } from '../../api/config'
|
|
9
|
+
import { createListRefetchInterval, type ResourceListResult } from '../../api/resourceLists'
|
|
9
10
|
import { useAPIResources } from '../../api/apiResources'
|
|
10
11
|
import { useConnection } from '../../context/ConnectionContext'
|
|
11
12
|
import { getSecretStoreProviderType } from '@skyhook-io/k8s-ui'
|
|
@@ -21,9 +22,8 @@ import {
|
|
|
21
22
|
CORE_RESOURCES,
|
|
22
23
|
intersectWorkloadWrites,
|
|
23
24
|
hasCuratedColumns,
|
|
24
|
-
sanitizePrinterTable,
|
|
25
25
|
} from '@skyhook-io/k8s-ui'
|
|
26
|
-
import type { Capabilities,
|
|
26
|
+
import type { Capabilities, ResourceQueryResult, WorkloadWritePermissions } from '@skyhook-io/k8s-ui'
|
|
27
27
|
import type { SelectedResource } from '../../types'
|
|
28
28
|
import { apiVersionToGroup, kindToPluralWithGroup, type NavigateToResource } from '../../utils/navigation'
|
|
29
29
|
import { CreateResourceDialog } from '../shared/CreateResourceDialog'
|
|
@@ -111,6 +111,18 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
111
111
|
|
|
112
112
|
// Track the selected kind from the k8s-ui component
|
|
113
113
|
const [selectedKind, setSelectedKind] = useState<SelectedKindInfo>(null)
|
|
114
|
+
const { data: issuesData } = useIssues(namespaces, selectedKind?.group === 'batch' && selectedKind?.name === 'cronjobs', 'CronJob')
|
|
115
|
+
const operationalIssues = useMemo(() => {
|
|
116
|
+
const result: Record<string, Issue> = {}
|
|
117
|
+
for (const issue of issuesData?.issues ?? []) {
|
|
118
|
+
if (issue.kind !== 'CronJob' || issue.group !== 'batch') continue
|
|
119
|
+
const key = `${issue.namespace ?? ''}/${issue.name}`
|
|
120
|
+
const previous = result[key]
|
|
121
|
+
if (!previous || ISSUE_SEVERITY_RANK[issue.severity] > ISSUE_SEVERITY_RANK[previous.severity] ||
|
|
122
|
+
(issue.severity === previous.severity && issue.id < previous.id)) result[key] = issue
|
|
123
|
+
}
|
|
124
|
+
return result
|
|
125
|
+
}, [issuesData])
|
|
114
126
|
const cnpgSidebarWorkspace = useCNPGSidebarWorkspace({ apiResources, namespaces, withMetrics: selectedKind?.group === 'postgresql.cnpg.io' })
|
|
115
127
|
const workloadWrites = namespaces.length === 0
|
|
116
128
|
? capabilities?.workloadWrites
|
|
@@ -121,7 +133,6 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
121
133
|
const canBulkScaleSelectedKind = useMemo(() => canBulkScaleKind(selectedKind, workloadWrites), [selectedKind, workloadWrites])
|
|
122
134
|
|
|
123
135
|
// Lightweight resource counts for sidebar badges (~2KB instead of ~608MB)
|
|
124
|
-
const namespacesParam = namespaces.join(',')
|
|
125
136
|
const { data: countsData, isError: countsIsError } = useResourceCounts(namespaces)
|
|
126
137
|
|
|
127
138
|
// Determine if selected kind is a CRD (only CRDs should send ?group= to backend)
|
|
@@ -183,23 +194,17 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
183
194
|
// unguarded on exactly the clusters the guard protects. Counts arrive
|
|
184
195
|
// right after 'connected' and settle the guard then.
|
|
185
196
|
const syncShellActive = connection.state === 'connecting'
|
|
186
|
-
// A
|
|
187
|
-
// the
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
selectedCountUnavailable && countsData?.reasons?.[selectedCountKey] === 'kind_sync_failed'
|
|
192
|
-
// A guarded kind whose informer hasn't finished reports unavailable with a
|
|
193
|
-
// kind_sync_pending reason — "count not known YET", so keep the loading
|
|
194
|
-
// state. Keyed on the reason, not on connection.state: deferred kinds sync
|
|
195
|
-
// after connect. Reasonless unavailable stays a real verification failure
|
|
196
|
-
// and blocks the view as before.
|
|
197
|
+
// A reasoned unavailable count must reach the list endpoint, which supplies
|
|
198
|
+
// the collector error without materializing an unchecked large payload.
|
|
199
|
+
const selectedCountReadFailure = selectedCountUnavailable &&
|
|
200
|
+
Boolean(countsData?.reasons?.[selectedCountKey]) &&
|
|
201
|
+
countsData?.reasons?.[selectedCountKey] !== 'kind_sync_pending'
|
|
197
202
|
const selectedCountPendingSync =
|
|
198
203
|
(selectedCountUnavailable && countsData?.reasons?.[selectedCountKey] === 'kind_sync_pending') ||
|
|
199
|
-
(syncShellActive && selectedCountUnavailable && !
|
|
204
|
+
(syncShellActive && selectedCountUnavailable && !selectedCountReadFailure)
|
|
200
205
|
const waitingForGuardCount = isSelectedKindGuarded &&
|
|
201
206
|
((!countsData && (!countsIsError || syncShellActive)) || selectedCountPendingSync)
|
|
202
|
-
const largeListBlocked = isSelectedKindGuarded && countsData != null && !selectedCountPendingSync && !
|
|
207
|
+
const largeListBlocked = isSelectedKindGuarded && countsData != null && !selectedCountPendingSync && !selectedCountReadFailure &&
|
|
203
208
|
(selectedCountUnavailable || (selectedCountKnown && (selectedCount ?? 0) > selectedKindRowLimit))
|
|
204
209
|
const selectedKindQueryBlocked = waitingForGuardCount || largeListBlocked
|
|
205
210
|
const podCount = countsData?.counts.Pod
|
|
@@ -227,64 +232,30 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
227
232
|
}
|
|
228
233
|
: null
|
|
229
234
|
|
|
235
|
+
const loadingInterval = useMemo(() => createListRefetchInterval(120000), [])
|
|
236
|
+
|
|
230
237
|
// Fetch full data only for the selected kind
|
|
231
238
|
const selectedKindQuery = useQuery({
|
|
232
239
|
queryKey: ['resources', selectedKind?.name, isSelectedCrd ? selectedKind?.group : '', namespaces],
|
|
233
|
-
queryFn: async (): Promise<
|
|
234
|
-
if (!selectedKind) return { items: [], printerTable: null }
|
|
235
|
-
const params = new URLSearchParams()
|
|
236
|
-
if (namespaces.length > 0) params.set('namespaces', namespacesParam)
|
|
237
|
-
if (isSelectedCrd && selectedKind.group) params.set('group', selectedKind.group)
|
|
238
|
-
if (selectedKindSummaryServed) params.set('include', 'summary')
|
|
240
|
+
queryFn: async ({ signal }): Promise<ResourceListResult<any>> => {
|
|
241
|
+
if (!selectedKind) return { items: [], coverage: { status: 'unknown' }, printerTable: null }
|
|
239
242
|
// Only CRDs can declare printer columns, and a curated kind discards the
|
|
240
243
|
// result — so table mode is requested from exactly the kinds that can use
|
|
241
244
|
// it. Resolving a table costs the server a CRD read per request; doing
|
|
242
245
|
// that for a kind whose columns are hand-curated is pure waste.
|
|
243
|
-
const wantsTable = isSelectedCrd && !!selectedKind.group &&
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
debugNamespaceLog('resources:selected-kind-fetch-start', {
|
|
248
|
-
kind: selectedKind.name,
|
|
249
|
-
group: isSelectedCrd ? selectedKind.group : '',
|
|
250
|
-
namespaces,
|
|
251
|
-
params: params.toString(),
|
|
252
|
-
})
|
|
253
|
-
const res = await fetch(apiUrl(`/resources/${selectedKind.name}?${params}`), {
|
|
254
|
-
credentials: getCredentialsMode(),
|
|
255
|
-
headers: getAuthHeaders(),
|
|
246
|
+
const wantsTable = isSelectedCrd && !!selectedKind.group && !hasCuratedColumns(selectedKind.name, selectedKind.group)
|
|
247
|
+
return fetchResourceList(selectedKind.name, {
|
|
248
|
+
namespaces, group: isSelectedCrd ? selectedKind.group : undefined,
|
|
249
|
+
summary: selectedKindSummaryServed, table: wantsTable, signal,
|
|
256
250
|
})
|
|
257
|
-
debugNamespaceLog('resources:selected-kind-fetch-response', {
|
|
258
|
-
kind: selectedKind.name,
|
|
259
|
-
group: isSelectedCrd ? selectedKind.group : '',
|
|
260
|
-
namespaces,
|
|
261
|
-
params: params.toString(),
|
|
262
|
-
status: res.status,
|
|
263
|
-
durationMs: Math.round(performance.now() - startedAt),
|
|
264
|
-
})
|
|
265
|
-
if (!res.ok) {
|
|
266
|
-
const errorData = await readErrorBody(res)
|
|
267
|
-
throw new ApiError(errorData.error || `Failed to fetch ${selectedKind.name}`, res.status, errorData)
|
|
268
|
-
}
|
|
269
|
-
const body = await res.json()
|
|
270
|
-
// Both branches are current shapes, not a guess at a legacy one: a Radar
|
|
271
|
-
// backend that predates `table` ignores the parameter and answers with
|
|
272
|
-
// the bare array. @skyhook-io/radar-app is versioned independently of the
|
|
273
|
-
// backend it points at, so a consumer can pair a new frontend with an
|
|
274
|
-
// older Radar — and reading that array as a missing envelope would render
|
|
275
|
-
// every CRD list empty. Items and columns still come from one response,
|
|
276
|
-
// so a row can never render against another fetch's cells.
|
|
277
|
-
if (!wantsTable || Array.isArray(body)) return { items: body as any[], printerTable: null }
|
|
278
|
-
return {
|
|
279
|
-
items: Array.isArray(body?.items) ? body.items as any[] : [],
|
|
280
|
-
printerTable: sanitizePrinterTable(body),
|
|
281
|
-
}
|
|
282
251
|
},
|
|
283
252
|
enabled: !!selectedKind && !selectedKindQueryBlocked && resourceKindListMode(selectedKind, hostFeatures, capabilitiesPending) === 'table',
|
|
284
253
|
staleTime: 30000,
|
|
285
|
-
|
|
254
|
+
// Safety net — SSE k8s_event drives near-real-time invalidation. A list
|
|
255
|
+
// whose namespaces are still loading is re-read until they finish.
|
|
256
|
+
refetchInterval: loadingInterval,
|
|
286
257
|
retry: (failureCount: number, error: Error) => {
|
|
287
|
-
if (isForbiddenError(error) || isKindSyncFailed(error)) return false
|
|
258
|
+
if (isForbiddenError(error) || isKindSyncFailed(error) || isUnretryableReadError(error)) return false
|
|
288
259
|
// Cluster still connecting, or this kind's informer still completing
|
|
289
260
|
// its initial sync: keep the query in its loading state and retry —
|
|
290
261
|
// the header's sync-progress label explains the wait.
|
|
@@ -301,20 +272,21 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
301
272
|
return {
|
|
302
273
|
resourceName: selectedKind.name,
|
|
303
274
|
group: selectedKind.group,
|
|
275
|
+
coverage: selectedKindQuery.data?.coverage,
|
|
304
276
|
data: selectedKindQueryBlocked ? [] : selectedKindQuery.data?.items,
|
|
305
277
|
isLoading: waitingForGuardCount || selectedKindQuery.isLoading,
|
|
306
278
|
error: selectedKindQueryBlocked ? undefined : selectedKindQuery.error,
|
|
307
279
|
refetch: selectedKindQuery.refetch,
|
|
308
280
|
dataUpdatedAt: selectedKindQuery.dataUpdatedAt,
|
|
309
281
|
}
|
|
310
|
-
}, [selectedKind, selectedKindQueryBlocked, waitingForGuardCount, selectedKindQuery.data?.items, selectedKindQuery.isLoading, selectedKindQuery.error, selectedKindQuery.refetch, selectedKindQuery.dataUpdatedAt])
|
|
282
|
+
}, [selectedKind, selectedKindQueryBlocked, waitingForGuardCount, selectedKindQuery.data?.items, selectedKindQuery.data?.coverage, selectedKindQuery.isLoading, selectedKindQuery.error, selectedKindQuery.refetch, selectedKindQuery.dataUpdatedAt])
|
|
311
283
|
|
|
312
284
|
// Metrics
|
|
313
285
|
const { data: topPodMetrics } = useTopPodMetrics({ enabled: topPodMetricsEnabled, namespaces })
|
|
314
286
|
const { data: topNodeMetrics } = useTopNodeMetrics({ enabled: topNodeMetricsEnabled })
|
|
315
287
|
|
|
316
288
|
// Certificate expiry
|
|
317
|
-
const { data: certExpiry, isError: certExpiryError } = useSecretCertExpiry()
|
|
289
|
+
const { data: certExpiry, isError: certExpiryError } = useSecretCertExpiry(namespaces)
|
|
318
290
|
|
|
319
291
|
// An ExternalSecret names a store; only the store says which backend it reads
|
|
320
292
|
// from. Two list calls per page beat one lookup per row, and the column shows
|
|
@@ -412,13 +384,16 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
412
384
|
apiResources={apiResources}
|
|
413
385
|
// Lightweight counts for sidebar (replaces 233 parallel queries)
|
|
414
386
|
resourceCounts={countsData?.counts ?? EMPTY_RESOURCE_COUNTS}
|
|
387
|
+
resourceCoverage={countsData?.coverage}
|
|
415
388
|
resourceForbidden={countsData?.forbidden}
|
|
416
389
|
resourceReasons={countsData?.reasons}
|
|
417
390
|
resourceUnavailable={countsData?.unavailable}
|
|
418
391
|
selectedKindQuery={selectedKindQueryResult}
|
|
419
392
|
printerTable={selectedKindQueryBlocked ? null : selectedKindQuery.data?.printerTable ?? null}
|
|
420
393
|
connectionState={connection.state === 'connecting' && connection.syncStatus ? 'syncing' : connection.state}
|
|
421
|
-
largeListGuard={
|
|
394
|
+
largeListGuard={selectedKind && isListTooLargeError(selectedKindQuery.error)
|
|
395
|
+
? { kind: selectedKind.name, reason: 'too-many', count: typeof selectedKindQuery.error.data?.count === 'number' ? selectedKindQuery.error.data.count : undefined, limit: selectedKindRowLimit, namespaces }
|
|
396
|
+
: largeListGuard}
|
|
422
397
|
onSelectedKindChange={setSelectedKind}
|
|
423
398
|
sidebarCategoryWorkspaces={cnpgSidebarWorkspace}
|
|
424
399
|
topPodMetrics={topPodMetrics}
|
|
@@ -426,6 +401,8 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
426
401
|
certExpiry={certExpiry}
|
|
427
402
|
storeProviders={storeProviders}
|
|
428
403
|
certExpiryError={certExpiryError}
|
|
404
|
+
operationalIssues={operationalIssues}
|
|
405
|
+
operationalIssuesIncomplete={Boolean(issuesData && (issuesData.total_matched ?? issuesData.total ?? issuesData.issues.length) > issuesData.issues.length)}
|
|
429
406
|
auditBadges={auditBadges}
|
|
430
407
|
// Pinned kinds
|
|
431
408
|
pinned={pinned}
|