@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
package/src/api/client.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { createListRefetchInterval, normalizeResourceList, type ResourceListBody, type ResourceListResult } from './resourceLists'
|
|
1
2
|
import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
|
|
3
|
+
import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
|
|
2
4
|
import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
|
|
3
5
|
import { useEffect, useRef, useCallback, useMemo } from 'react'
|
|
4
6
|
import type { KueueAdmissionResponse } from '@skyhook-io/k8s-ui/types/scheduling'
|
|
7
|
+
import { canonicalReadCode, readActionFor } from '@skyhook-io/k8s-ui/utils/read-actions'
|
|
8
|
+
import type { SearchCoverage } from '@skyhook-io/k8s-ui/types/read-coverage'
|
|
5
9
|
import type { GitOpsWriteEvidence } from '@skyhook-io/k8s-ui/utils/gitops-write-guard'
|
|
6
10
|
import type {
|
|
7
11
|
AppHistory,
|
|
@@ -22,7 +26,7 @@ import type {
|
|
|
22
26
|
YamlSchemaLoadResult,
|
|
23
27
|
} from '@skyhook-io/k8s-ui'
|
|
24
28
|
import { useQuery, useMutation, useQueryClient, skipToken, type QueryClient } from '@tanstack/react-query'
|
|
25
|
-
import { showApiError, showApiSuccess } from '../components/ui/Toast'
|
|
29
|
+
import { showApiError, showApiSuccess, showApiNotice } from '../components/ui/Toast'
|
|
26
30
|
import { useIsAuthEnabled, useNamespacedCapabilities } from '../contexts/CapabilitiesContext'
|
|
27
31
|
import type {
|
|
28
32
|
Topology,
|
|
@@ -43,6 +47,7 @@ import type {
|
|
|
43
47
|
UpgradeInfo,
|
|
44
48
|
BatchUpgradeInfo,
|
|
45
49
|
ChartSourceCandidate,
|
|
50
|
+
SourceUpgradeSelection,
|
|
46
51
|
ChartSourceStatus,
|
|
47
52
|
ValuesDiff,
|
|
48
53
|
ValuesPreviewResponse,
|
|
@@ -289,13 +294,14 @@ export function isStillLoadingError(error: unknown): boolean {
|
|
|
289
294
|
return isKindSyncPending(error) || isClusterConnecting(error);
|
|
290
295
|
}
|
|
291
296
|
|
|
292
|
-
// isKindSyncFailed matches
|
|
293
|
-
//
|
|
297
|
+
// isKindSyncFailed matches a kind that missed its sync deadline. Radar keeps
|
|
298
|
+
// loading it, so a later reload may succeed, but retrying at once won't —
|
|
299
|
+
// show the error. Older Radars spelled the code kind_sync_failed.
|
|
294
300
|
export function isKindSyncFailed(error: unknown): boolean {
|
|
295
301
|
return (
|
|
296
302
|
error instanceof ApiError &&
|
|
297
303
|
error.status === 503 &&
|
|
298
|
-
error.data?.error_code === "
|
|
304
|
+
canonicalReadCode(error.data?.error_code) === "kind_sync_timed_out"
|
|
299
305
|
);
|
|
300
306
|
}
|
|
301
307
|
|
|
@@ -755,22 +761,43 @@ export interface IssuesResponse {
|
|
|
755
761
|
recent_changes_reason?: string
|
|
756
762
|
recent_changes_guidance?: string
|
|
757
763
|
recent_changes_truncated?: boolean
|
|
764
|
+
// Present when the recent-changes window starts before the history Radar
|
|
765
|
+
// holds; complete_since is sent only to callers who can read every namespace.
|
|
766
|
+
recent_changes_history_coverage?: {
|
|
767
|
+
incomplete: boolean
|
|
768
|
+
complete_since?: string
|
|
769
|
+
reasons: string[]
|
|
770
|
+
}
|
|
758
771
|
// Present only when RBAC visibility is incomplete (absent = full access).
|
|
759
772
|
// state 'degraded' means core workload reads are denied, so an empty list may
|
|
760
773
|
// mean "can't see" rather than "nothing broken" — the UI must say so.
|
|
761
774
|
visibility?: { state?: string; impact?: string };
|
|
762
775
|
// Issue sources Radar couldn't check, so their issues may be missing: an
|
|
763
|
-
// empty list is not an all-clear.
|
|
764
|
-
//
|
|
765
|
-
|
|
776
|
+
// empty list is not an all-clear. A newer Radar may send sources and
|
|
777
|
+
// reasons this version doesn't know. Absent when every source was checked,
|
|
778
|
+
// and from older Radars.
|
|
779
|
+
unchecked_sources?: UncheckedSource[];
|
|
766
780
|
}
|
|
767
781
|
|
|
768
|
-
export
|
|
769
|
-
|
|
770
|
-
|
|
782
|
+
export interface UncheckedSource {
|
|
783
|
+
source: string;
|
|
784
|
+
reason: string;
|
|
785
|
+
// The kinds within the source that went unchecked; absent means the whole
|
|
786
|
+
// source, or that Radar couldn't tell which kinds.
|
|
787
|
+
kinds?: { group?: string; kind: string }[];
|
|
788
|
+
// The namespaces whose read failed while the others were read; absent
|
|
789
|
+
// means the gap isn't limited to particular namespaces.
|
|
790
|
+
namespaces?: string[];
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
export function useIssues(namespaces: string[] = [], enabled = true, kind?: string) {
|
|
794
|
+
const params = new URLSearchParams();
|
|
795
|
+
if (namespaces.length) params.set('namespaces', namespaces.join(','));
|
|
796
|
+
if (kind) { params.set('kind', kind); params.set('limit', '1000'); }
|
|
797
|
+
const query = params.toString();
|
|
771
798
|
return useQuery<IssuesResponse>({
|
|
772
|
-
queryKey: ["issues", namespaces],
|
|
773
|
-
queryFn: () => fetchJSON(`/issues${
|
|
799
|
+
queryKey: kind ? ["issues", namespaces, kind] : ["issues", namespaces],
|
|
800
|
+
queryFn: () => fetchJSON(`/issues${query ? `?${query}` : ''}`),
|
|
774
801
|
staleTime: 30000,
|
|
775
802
|
refetchInterval: ISSUES_REFRESH_INTERVAL_MS,
|
|
776
803
|
enabled,
|
|
@@ -828,7 +855,19 @@ export function useResourceIssues(
|
|
|
828
855
|
// The Issues page narrowed to one subject: the same per-resource lookup with
|
|
829
856
|
// ?coverage=1, which also says whether Radar reads the subject's kind and what
|
|
830
857
|
// the caller's RBAC withheld. Polls like the page list.
|
|
858
|
+
export interface CronJobSchedulingEvidence {
|
|
859
|
+
uid: string;
|
|
860
|
+
event_id?: string;
|
|
861
|
+
state: 'reported' | 'configuration_changed' | 'history_incomplete';
|
|
862
|
+
reason: string;
|
|
863
|
+
message: string;
|
|
864
|
+
last_reported_at: string;
|
|
865
|
+
configuration_changed_at?: string;
|
|
866
|
+
history_incomplete?: boolean;
|
|
867
|
+
}
|
|
868
|
+
|
|
831
869
|
export interface SubjectIssuesResponse {
|
|
870
|
+
scheduling_report?: CronJobSchedulingEvidence;
|
|
832
871
|
issues: Issue[];
|
|
833
872
|
coverage: "ok" | "syncing" | "notWatched" | "unknownKind";
|
|
834
873
|
withheld?: { issues: number };
|
|
@@ -836,7 +875,7 @@ export interface SubjectIssuesResponse {
|
|
|
836
875
|
}
|
|
837
876
|
|
|
838
877
|
export function useSubjectIssues(
|
|
839
|
-
subject: { kind: string; group: string; namespace: string; name: string } | null,
|
|
878
|
+
subject: { kind: string; group: string; namespace: string; name: string; uid?: string } | null,
|
|
840
879
|
enabled: boolean,
|
|
841
880
|
) {
|
|
842
881
|
const capabilities = useCapabilities();
|
|
@@ -845,7 +884,7 @@ export function useSubjectIssues(
|
|
|
845
884
|
const params = new URLSearchParams({ coverage: "1" });
|
|
846
885
|
if (subject?.group) params.set("group", subject.group);
|
|
847
886
|
return useQuery<SubjectIssuesResponse>({
|
|
848
|
-
queryKey: ["issues", "subject", subject?.kind ?? "", subject?.group ?? "", subject?.namespace ?? "", subject?.name ?? "", support, ...gatedKey],
|
|
887
|
+
queryKey: ["issues", "subject", subject?.kind ?? "", subject?.group ?? "", subject?.namespace ?? "", subject?.name ?? "", subject?.uid ?? "", support, ...gatedKey],
|
|
849
888
|
queryFn: () => {
|
|
850
889
|
if (!capabilities.data && capabilities.error) throw capabilities.error;
|
|
851
890
|
return guard(() => fetchJSON<SubjectIssuesResponse>(`/issues/resource/${encodeURIComponent(subject!.kind)}/${pathNs}/${encodeURIComponent(subject!.name)}?${params}`));
|
|
@@ -1101,12 +1140,14 @@ function costRefetchInterval(
|
|
|
1101
1140
|
};
|
|
1102
1141
|
}
|
|
1103
1142
|
|
|
1104
|
-
export function useOpenCostSummary(enabled = true) {
|
|
1143
|
+
export function useOpenCostSummary(enabled = true, namespaces: string[] = []) {
|
|
1105
1144
|
const clusterInfo = useClusterInfo();
|
|
1145
|
+
const params =
|
|
1146
|
+
namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
|
|
1106
1147
|
return useQuery<OpenCostSummary>({
|
|
1107
|
-
queryKey: ["opencost-summary"],
|
|
1148
|
+
queryKey: ["opencost-summary", namespaces],
|
|
1108
1149
|
enabled,
|
|
1109
|
-
queryFn: () => fetchJSON(
|
|
1150
|
+
queryFn: () => fetchJSON(`/opencost/summary${params}`),
|
|
1110
1151
|
refetchInterval: costRefetchInterval(
|
|
1111
1152
|
COST_REFRESH_INTERVAL_MS,
|
|
1112
1153
|
clusterInfo.data?.context,
|
|
@@ -1749,6 +1790,7 @@ export async function markWhatsNewSeen(version: string): Promise<void> {
|
|
|
1749
1790
|
|
|
1750
1791
|
export interface VersionInfo {
|
|
1751
1792
|
currentVersion: string;
|
|
1793
|
+
buildChannel?: 'stable' | 'prerelease' | 'custom' | 'development';
|
|
1752
1794
|
latestVersion?: string;
|
|
1753
1795
|
updateAvailable: boolean;
|
|
1754
1796
|
releaseUrl?: string;
|
|
@@ -1967,6 +2009,12 @@ export interface SearchResult {
|
|
|
1967
2009
|
total: number;
|
|
1968
2010
|
searched: number;
|
|
1969
2011
|
total_matched: number;
|
|
2012
|
+
/** From Radars that predate search coverage: "time_limit" when scan report findings were only partly searched. */
|
|
2013
|
+
incomplete_findings?: string;
|
|
2014
|
+
/** From Radars that predate search coverage: some namespaces' scan reports were left out, access not confirmed yet. */
|
|
2015
|
+
access_incomplete?: boolean;
|
|
2016
|
+
/** Absent from Radars that predate search coverage, which say nothing about it. */
|
|
2017
|
+
coverage?: SearchCoverage;
|
|
1970
2018
|
}
|
|
1971
2019
|
|
|
1972
2020
|
const SEARCH_MIN_QUERY = 2;
|
|
@@ -1984,15 +2032,16 @@ export function useSearch(
|
|
|
1984
2032
|
context?: "summary" | "none";
|
|
1985
2033
|
enabled?: boolean;
|
|
1986
2034
|
globalNs?: boolean;
|
|
2035
|
+
/** Re-query on an interval decided from the latest response. */
|
|
2036
|
+
refetchInterval?: (data: SearchResult | undefined) => number | false;
|
|
1987
2037
|
},
|
|
1988
2038
|
) {
|
|
1989
2039
|
const trimmed = query.trim();
|
|
1990
2040
|
const enabled = (opts?.enabled ?? true) && trimmed.length >= SEARCH_MIN_QUERY;
|
|
1991
2041
|
const limit = opts?.limit ?? 20;
|
|
1992
2042
|
const context = opts?.context ?? "summary";
|
|
1993
|
-
//
|
|
1994
|
-
//
|
|
1995
|
-
// tokens). The omnibar opts in so ⌘K is a genuinely global lookup.
|
|
2043
|
+
// Searches always ignore the saved namespace pick. Keep globalNs as the
|
|
2044
|
+
// explicit global-search marker used by the omnibar and embedded hosts.
|
|
1996
2045
|
const globalNs = opts?.globalNs ?? false;
|
|
1997
2046
|
return useQuery<SearchResult>({
|
|
1998
2047
|
queryKey: ["search", trimmed, limit, context, globalNs],
|
|
@@ -2003,6 +2052,7 @@ export function useSearch(
|
|
|
2003
2052
|
),
|
|
2004
2053
|
enabled,
|
|
2005
2054
|
staleTime: 2000,
|
|
2055
|
+
refetchInterval: (q) => opts?.refetchInterval?.(q.state.data) ?? false,
|
|
2006
2056
|
placeholderData: (prev) => prev, // keepPreviousData
|
|
2007
2057
|
});
|
|
2008
2058
|
}
|
|
@@ -2517,9 +2567,37 @@ export function useApplicationHistory(
|
|
|
2517
2567
|
}
|
|
2518
2568
|
|
|
2519
2569
|
// How often a page asks again while Radar is still connecting to argocd-server,
|
|
2520
|
-
// and while it retries a
|
|
2570
|
+
// and while it retries after a failure. Radar re-checks a failed connection at
|
|
2571
|
+
// most every 30s, so asking more often while retrying adds requests without
|
|
2572
|
+
// making the server reconnect sooner.
|
|
2573
|
+
// A page whose last fetch failed and was waiting on something keeps asking at
|
|
2574
|
+
// the slow rate, so a Radar or proxy outage doesn't strand it. It stops when
|
|
2575
|
+
// Radar answered that the object is gone or the caller can't read it, since
|
|
2576
|
+
// asking again won't change that answer.
|
|
2521
2577
|
const ARGO_CONNECTING_POLL_MS = 2000;
|
|
2522
|
-
const ARGO_RETRYING_POLL_MS =
|
|
2578
|
+
const ARGO_RETRYING_POLL_MS = 30_000;
|
|
2579
|
+
|
|
2580
|
+
type PollState<T> = {
|
|
2581
|
+
state: { status: string; data?: T; error?: unknown };
|
|
2582
|
+
};
|
|
2583
|
+
|
|
2584
|
+
function afterFailedFetch(error: unknown, wanted: number | false): number | false {
|
|
2585
|
+
if (wanted === false) return false;
|
|
2586
|
+
if (error instanceof ApiError && [401, 403, 404].includes(error.status)) return false;
|
|
2587
|
+
return ARGO_RETRYING_POLL_MS;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
export function gitopsTreeRefetchInterval(
|
|
2591
|
+
query: PollState<Pick<GitOpsResourceTree, "healthApiPending" | "healthApiRetrying">>,
|
|
2592
|
+
): number | false {
|
|
2593
|
+
const data = query.state.data;
|
|
2594
|
+
const wanted = data?.healthApiPending
|
|
2595
|
+
? ARGO_CONNECTING_POLL_MS
|
|
2596
|
+
: data?.healthApiRetrying
|
|
2597
|
+
? ARGO_RETRYING_POLL_MS
|
|
2598
|
+
: false;
|
|
2599
|
+
return query.state.status === "error" ? afterFailedFetch(query.state.error, wanted) : wanted;
|
|
2600
|
+
}
|
|
2523
2601
|
|
|
2524
2602
|
export function useGitOpsTree(
|
|
2525
2603
|
kind: string,
|
|
@@ -2545,12 +2623,7 @@ export function useGitOpsTree(
|
|
|
2545
2623
|
staleTime: 5000,
|
|
2546
2624
|
// Radar answers at once while it connects to argocd-server; ask again
|
|
2547
2625
|
// until Argo's per-resource health is in.
|
|
2548
|
-
refetchInterval:
|
|
2549
|
-
query.state.data?.healthApiPending
|
|
2550
|
-
? ARGO_CONNECTING_POLL_MS
|
|
2551
|
-
: query.state.data?.healthApiRetrying
|
|
2552
|
-
? ARGO_RETRYING_POLL_MS
|
|
2553
|
-
: false,
|
|
2626
|
+
refetchInterval: gitopsTreeRefetchInterval,
|
|
2554
2627
|
});
|
|
2555
2628
|
}
|
|
2556
2629
|
|
|
@@ -2560,6 +2633,27 @@ export function useGitOpsTree(
|
|
|
2560
2633
|
// auto-quiesces on completion.
|
|
2561
2634
|
const INSIGHTS_RUNNING_POLL_MS = 2000;
|
|
2562
2635
|
|
|
2636
|
+
export function gitopsInsightsRefetchInterval(
|
|
2637
|
+
query: PollState<{
|
|
2638
|
+
summary?: Partial<
|
|
2639
|
+
Pick<GitOpsInsight["summary"], "operationPhase" | "resourceHealthApiPending" | "resourceHealthApiRetrying">
|
|
2640
|
+
>;
|
|
2641
|
+
capabilities?: Pick<NonNullable<GitOpsInsight["capabilities"]>, "argoConnecting" | "argoRetrying">;
|
|
2642
|
+
}>,
|
|
2643
|
+
): number | false {
|
|
2644
|
+
const data = query.state.data;
|
|
2645
|
+
const phase = data?.summary?.operationPhase;
|
|
2646
|
+
let wanted: number | false = false;
|
|
2647
|
+
if (phase === "Running" || phase === "Terminating") {
|
|
2648
|
+
wanted = INSIGHTS_RUNNING_POLL_MS;
|
|
2649
|
+
} else if (data?.summary?.resourceHealthApiPending || data?.capabilities?.argoConnecting) {
|
|
2650
|
+
wanted = ARGO_CONNECTING_POLL_MS;
|
|
2651
|
+
} else if (data?.summary?.resourceHealthApiRetrying || data?.capabilities?.argoRetrying) {
|
|
2652
|
+
wanted = ARGO_RETRYING_POLL_MS;
|
|
2653
|
+
}
|
|
2654
|
+
return query.state.status === "error" ? afterFailedFetch(query.state.error, wanted) : wanted;
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2563
2657
|
export function useGitOpsInsights(
|
|
2564
2658
|
kind: string,
|
|
2565
2659
|
namespace: string,
|
|
@@ -2581,19 +2675,7 @@ export function useGitOpsInsights(
|
|
|
2581
2675
|
),
|
|
2582
2676
|
enabled: Boolean(kind && name),
|
|
2583
2677
|
staleTime: 5000,
|
|
2584
|
-
refetchInterval:
|
|
2585
|
-
const phase = query.state.data?.summary?.operationPhase;
|
|
2586
|
-
if (phase === "Running" || phase === "Terminating") {
|
|
2587
|
-
return INSIGHTS_RUNNING_POLL_MS;
|
|
2588
|
-
}
|
|
2589
|
-
const summary = query.state.data?.summary;
|
|
2590
|
-
if (summary?.resourceHealthApiPending || query.state.data?.capabilities?.argoConnecting) {
|
|
2591
|
-
return ARGO_CONNECTING_POLL_MS;
|
|
2592
|
-
}
|
|
2593
|
-
return summary?.resourceHealthApiRetrying || query.state.data?.capabilities?.argoRetrying
|
|
2594
|
-
? ARGO_RETRYING_POLL_MS
|
|
2595
|
-
: false;
|
|
2596
|
-
},
|
|
2678
|
+
refetchInterval: gitopsInsightsRefetchInterval,
|
|
2597
2679
|
});
|
|
2598
2680
|
}
|
|
2599
2681
|
|
|
@@ -2774,6 +2856,32 @@ export function useResource<T>(
|
|
|
2774
2856
|
};
|
|
2775
2857
|
}
|
|
2776
2858
|
|
|
2859
|
+
// Availability checks return headers only, without downloading Secret values.
|
|
2860
|
+
export async function fetchResourceAvailability(
|
|
2861
|
+
kind: string,
|
|
2862
|
+
namespace: string,
|
|
2863
|
+
name: string,
|
|
2864
|
+
): Promise<"present" | "missing" | "unchecked"> {
|
|
2865
|
+
const response = await apiFetch(`${getApiBase()}/resources/${encodeURIComponent(kind)}/${encodeURIComponent(namespace || "_")}/${encodeURIComponent(name)}`, { method: "HEAD" });
|
|
2866
|
+
const resourceLookup = response.headers.get("X-Radar-Resource-Read") === "true";
|
|
2867
|
+
if (resourceLookup && response.ok) return "present";
|
|
2868
|
+
if (resourceLookup && response.status === 404) return "missing";
|
|
2869
|
+
// Older Radar versions do not serve HEAD lookups. Keep their existing
|
|
2870
|
+
// navigation without claiming that availability was verified.
|
|
2871
|
+
if (response.status === 405 || response.ok) return "unchecked";
|
|
2872
|
+
throw new ApiError(httpStatusMessage(response.status, response.statusText), response.status);
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
export function useResourceAvailability(kind: string, namespace: string, name: string) {
|
|
2876
|
+
return useQuery({
|
|
2877
|
+
queryKey: ["resource", kind, namespace, name, undefined, "availability"],
|
|
2878
|
+
queryFn: () => fetchResourceAvailability(kind, namespace, name),
|
|
2879
|
+
enabled: Boolean(kind && name),
|
|
2880
|
+
refetchInterval: GONE_RECHECK_MS,
|
|
2881
|
+
retry: (failureCount, error) => !isForbiddenError(error) && failureCount < 1,
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2777
2885
|
// Hook that returns full response with relationships explicitly
|
|
2778
2886
|
export function useResourceWithRelationships<T>(
|
|
2779
2887
|
kind: string,
|
|
@@ -2799,6 +2907,38 @@ export function useResourceWithRelationships<T>(
|
|
|
2799
2907
|
});
|
|
2800
2908
|
}
|
|
2801
2909
|
|
|
2910
|
+
export interface ResourceListOptions {
|
|
2911
|
+
namespaces?: string[]
|
|
2912
|
+
group?: string
|
|
2913
|
+
table?: boolean
|
|
2914
|
+
summary?: boolean
|
|
2915
|
+
signal?: AbortSignal
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
export async function fetchResourceList<T>(kind: string, options: ResourceListOptions = {}): Promise<ResourceListResult<T>> {
|
|
2919
|
+
const params = new URLSearchParams()
|
|
2920
|
+
if (options.namespaces?.length) params.set('namespaces', options.namespaces.join(','))
|
|
2921
|
+
if (options.group) params.set('group', options.group)
|
|
2922
|
+
if (options.table) params.set('table', '1')
|
|
2923
|
+
if (options.summary) params.set('include', 'summary')
|
|
2924
|
+
// A Radar that predates the list budget ignores the parameter.
|
|
2925
|
+
params.set('maxItems', options.summary ? '50000' : '25000')
|
|
2926
|
+
const body = await fetchJSON<ResourceListBody<T>>(`/resources/${encodeURIComponent(kind)}?${params}`, options.signal)
|
|
2927
|
+
return normalizeResourceList<T>(body)
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
// A read failure no retry can answer: the request, the caller's access or
|
|
2931
|
+
// Radar's collection has to change first (too large, outside the collector, a
|
|
2932
|
+
// denial), so it is shown at once.
|
|
2933
|
+
export function isUnretryableReadError(error: unknown): boolean {
|
|
2934
|
+
return error instanceof ApiError && !['retry', undefined].includes(readActionFor(error.data?.error_code))
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
// The list is over the request's size budget; the body carries `count` and `limit`.
|
|
2938
|
+
export function isListTooLargeError(error: unknown): error is ApiError {
|
|
2939
|
+
return error instanceof ApiError && error.data?.error_code === 'list_too_large'
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2802
2942
|
// List resources - queryKey includes group for cache sharing with ResourcesView
|
|
2803
2943
|
export function useResources<T>(
|
|
2804
2944
|
kind: string,
|
|
@@ -2806,29 +2946,26 @@ export function useResources<T>(
|
|
|
2806
2946
|
group?: string,
|
|
2807
2947
|
options?: { enabled?: boolean; refetchInterval?: number | false; cacheScope?: string },
|
|
2808
2948
|
) {
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2811
|
-
if (group) params.set("group", group);
|
|
2812
|
-
const queryString = params.toString();
|
|
2813
|
-
|
|
2814
|
-
return useQuery<T[]>({
|
|
2949
|
+
const loadingInterval = useMemo(() => createListRefetchInterval(options?.refetchInterval), [options?.refetchInterval])
|
|
2950
|
+
const query = useQuery<ResourceListResult<T>>({
|
|
2815
2951
|
queryKey: ["resources", kind, group, namespace, ...(options?.cacheScope ? [options.cacheScope] : [])],
|
|
2816
|
-
queryFn: () =>
|
|
2817
|
-
fetchJSON(`/resources/${kind}${queryString ? `?${queryString}` : ""}`),
|
|
2952
|
+
queryFn: ({ signal }) => fetchResourceList<T>(kind, { namespaces: namespace ? [namespace] : [], group, signal }),
|
|
2818
2953
|
enabled: (options?.enabled ?? true) && Boolean(kind),
|
|
2819
2954
|
staleTime: 30000, // 30 seconds - matches refetchInterval in ResourcesView
|
|
2820
|
-
refetchInterval:
|
|
2955
|
+
refetchInterval: loadingInterval,
|
|
2821
2956
|
// Kind still completing its initial sync (progressive shell, or a
|
|
2822
2957
|
// deferred kind shortly after connect): keep polling instead of
|
|
2823
2958
|
// surfacing an error.
|
|
2824
2959
|
retry: (failureCount, error) => {
|
|
2825
2960
|
if (isStillLoadingError(error)) return true;
|
|
2826
2961
|
if (isKindSyncFailed(error)) return false;
|
|
2962
|
+
if (isUnretryableReadError(error)) return false;
|
|
2827
2963
|
return failureCount < 1; // one retry, 4xx included, unlike the QueryClient default
|
|
2828
2964
|
},
|
|
2829
2965
|
retryDelay: (failureCount, error) =>
|
|
2830
2966
|
isStillLoadingError(error) ? 2000 : Math.min(1000 * 2 ** failureCount, 30000),
|
|
2831
2967
|
});
|
|
2968
|
+
return { ...query, data: query.data?.items, coverage: query.data?.coverage };
|
|
2832
2969
|
}
|
|
2833
2970
|
|
|
2834
2971
|
// Timeline changes (unified view of changes + K8s events)
|
|
@@ -5543,10 +5680,46 @@ export function useNodeRemovalPlan(name: string | undefined, enabled: boolean) {
|
|
|
5543
5680
|
})
|
|
5544
5681
|
}
|
|
5545
5682
|
|
|
5546
|
-
export
|
|
5683
|
+
export type NodeDrainActivity = {
|
|
5684
|
+
requestId: number;
|
|
5685
|
+
startedAt: number;
|
|
5686
|
+
timeoutSeconds: number;
|
|
5687
|
+
contextName?: string;
|
|
5688
|
+
} & ({ status: "pending" } | {
|
|
5689
|
+
status: "finished";
|
|
5690
|
+
finishedAt: number;
|
|
5691
|
+
summary: ReturnType<typeof describeDrainResult>;
|
|
5692
|
+
});
|
|
5693
|
+
|
|
5694
|
+
export function nodeDrainActivityKey(apiBase: string, name: string, nodeUID: string) {
|
|
5695
|
+
return ["node-drain-activity", apiBase, name, nodeUID] as const;
|
|
5696
|
+
}
|
|
5697
|
+
|
|
5698
|
+
export function useNodeDrainActivity(name: string, nodeUID: string) {
|
|
5699
|
+
const queryClient = useQueryClient();
|
|
5700
|
+
const queryKey = nodeDrainActivityKey(getApiBase(), nodeUID ? name : "", nodeUID);
|
|
5701
|
+
const { data } = useQuery<NodeDrainActivity | null>({
|
|
5702
|
+
queryKey,
|
|
5703
|
+
queryFn: () => null,
|
|
5704
|
+
initialData: null,
|
|
5705
|
+
enabled: false,
|
|
5706
|
+
staleTime: Infinity,
|
|
5707
|
+
gcTime: Infinity,
|
|
5708
|
+
});
|
|
5709
|
+
return {
|
|
5710
|
+
activity: nodeUID ? data : null,
|
|
5711
|
+
dismiss: () => queryClient.setQueryData(queryKey, null),
|
|
5712
|
+
};
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
let nextNodeDrainRequestId = 0;
|
|
5716
|
+
|
|
5717
|
+
export function useDrainNode(nodeUID = "") {
|
|
5547
5718
|
const queryClient = useQueryClient();
|
|
5719
|
+
const apiBase = getApiBase();
|
|
5548
5720
|
|
|
5549
5721
|
return useMutation({
|
|
5722
|
+
retry: false,
|
|
5550
5723
|
mutationFn: async ({
|
|
5551
5724
|
name,
|
|
5552
5725
|
options,
|
|
@@ -5554,7 +5727,7 @@ export function useDrainNode() {
|
|
|
5554
5727
|
name: string;
|
|
5555
5728
|
options?: DrainNodeOptions;
|
|
5556
5729
|
}) => {
|
|
5557
|
-
const response = await apiFetch(
|
|
5730
|
+
const response = await apiFetch(apiUrl(`/nodes/${encodeURIComponent(name)}/drain`, apiBase), {
|
|
5558
5731
|
method: "POST",
|
|
5559
5732
|
headers: options ? { "Content-Type": "application/json" } : {},
|
|
5560
5733
|
body: options ? JSON.stringify(options) : undefined,
|
|
@@ -5565,6 +5738,37 @@ export function useDrainNode() {
|
|
|
5565
5738
|
}
|
|
5566
5739
|
return response.json();
|
|
5567
5740
|
},
|
|
5741
|
+
onMutate: ({ name }) => {
|
|
5742
|
+
const contextName = queryClient.getQueryData<ClusterInfo>(["cluster-info"])?.context
|
|
5743
|
+
?? queryClient.getQueryData<{ context: string }>(["connection-status"])?.context;
|
|
5744
|
+
const activity: NodeDrainActivity = {
|
|
5745
|
+
status: "pending",
|
|
5746
|
+
requestId: ++nextNodeDrainRequestId,
|
|
5747
|
+
startedAt: Date.now(),
|
|
5748
|
+
timeoutSeconds: 120,
|
|
5749
|
+
contextName,
|
|
5750
|
+
};
|
|
5751
|
+
const queryKey = nodeDrainActivityKey(apiBase, name, nodeUID);
|
|
5752
|
+
if (nodeUID) queryClient.setQueryData(queryKey, activity);
|
|
5753
|
+
return { queryKey, activity, tracked: Boolean(nodeUID), contextName };
|
|
5754
|
+
},
|
|
5755
|
+
onError: (error, _variables, context) => {
|
|
5756
|
+
if (!context?.tracked) return;
|
|
5757
|
+
queryClient.setQueryData<NodeDrainActivity | null>(context.queryKey, (previous) =>
|
|
5758
|
+
previous?.requestId === context.activity.requestId ? {
|
|
5759
|
+
...context.activity,
|
|
5760
|
+
status: "finished",
|
|
5761
|
+
finishedAt: Date.now(),
|
|
5762
|
+
summary: {
|
|
5763
|
+
title: "Could not confirm drain completion",
|
|
5764
|
+
detail: `${error.message}\nCheck the node's pods before retrying or taking it down. A failed request does not confirm whether evictions ran.`,
|
|
5765
|
+
type: "warning",
|
|
5766
|
+
failed: true,
|
|
5767
|
+
outcome: "unconfirmed",
|
|
5768
|
+
},
|
|
5769
|
+
} : previous,
|
|
5770
|
+
);
|
|
5771
|
+
},
|
|
5568
5772
|
meta: {
|
|
5569
5773
|
errorMessage: "Failed to drain node",
|
|
5570
5774
|
// No static successMessage — handled in onSuccess to distinguish partial failures
|
|
@@ -5574,20 +5778,41 @@ export function useDrainNode() {
|
|
|
5574
5778
|
evictedPods?: string[];
|
|
5575
5779
|
skippedPods?: DrainPlanPod[];
|
|
5576
5780
|
errors?: string[];
|
|
5781
|
+
pendingPods?: string[];
|
|
5782
|
+
waitedForDeletion?: boolean;
|
|
5783
|
+
outcome?: DrainCompletionOutcome;
|
|
5784
|
+
unconfirmedPods?: string[];
|
|
5785
|
+
verificationError?: string;
|
|
5577
5786
|
},
|
|
5578
5787
|
variables,
|
|
5788
|
+
context,
|
|
5579
5789
|
) => {
|
|
5790
|
+
const currentContext = queryClient.getQueryData<ClusterInfo>(["cluster-info"])?.context;
|
|
5791
|
+
if (context?.tracked && queryClient.getQueryData<NodeDrainActivity | null>(context.queryKey)?.requestId !== context.activity.requestId) return;
|
|
5792
|
+
const { title, detail, type } = describeDrainResult(data);
|
|
5793
|
+
if (context?.tracked) {
|
|
5794
|
+
queryClient.setQueryData<NodeDrainActivity | null>(context.queryKey, (previous) =>
|
|
5795
|
+
previous?.requestId === context.activity.requestId ? {
|
|
5796
|
+
...context.activity,
|
|
5797
|
+
status: "finished",
|
|
5798
|
+
finishedAt: Date.now(),
|
|
5799
|
+
summary: describeDrainResult(data, { recorded: true }),
|
|
5800
|
+
} : previous,
|
|
5801
|
+
);
|
|
5802
|
+
}
|
|
5803
|
+
if (context && (context.queryKey[1] !== getApiBase() ||
|
|
5804
|
+
(context.contextName && currentContext && context.contextName !== currentContext))) return;
|
|
5580
5805
|
queryClient.invalidateQueries({ queryKey: ["resources", "nodes"] });
|
|
5581
5806
|
queryClient.invalidateQueries({
|
|
5582
5807
|
queryKey: ["resource", "nodes", "", variables.name],
|
|
5583
5808
|
});
|
|
5584
5809
|
queryClient.invalidateQueries({ queryKey: ["topology"] });
|
|
5585
|
-
|
|
5586
|
-
const { title, detail, failed } = describeDrainResult(data);
|
|
5587
|
-
if (failed) {
|
|
5810
|
+
if (type === "error") {
|
|
5588
5811
|
showApiError(title, detail);
|
|
5589
|
-
} else {
|
|
5812
|
+
} else if (type === "success") {
|
|
5590
5813
|
showApiSuccess(title, detail);
|
|
5814
|
+
} else {
|
|
5815
|
+
showApiNotice(title, detail, type);
|
|
5591
5816
|
}
|
|
5592
5817
|
},
|
|
5593
5818
|
});
|
|
@@ -5601,47 +5826,86 @@ function listWithOverflow(items: string[]): string {
|
|
|
5601
5826
|
return rest > 0 ? `${shown.join("; ")}; +${rest} more` : shown.join("; ");
|
|
5602
5827
|
}
|
|
5603
5828
|
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
*/
|
|
5608
|
-
export function describeDrainResult(data: {
|
|
5829
|
+
export type DrainCompletionOutcome = "complete" | "incomplete" | "unconfirmed" | "started";
|
|
5830
|
+
|
|
5831
|
+
interface DrainResultData {
|
|
5609
5832
|
evictedPods?: string[];
|
|
5610
5833
|
skippedPods?: DrainPlanPod[];
|
|
5611
5834
|
errors?: string[];
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5835
|
+
pendingPods?: string[];
|
|
5836
|
+
unconfirmedPods?: string[];
|
|
5837
|
+
verificationError?: string;
|
|
5838
|
+
waitedForDeletion?: boolean;
|
|
5839
|
+
outcome?: DrainCompletionOutcome;
|
|
5840
|
+
}
|
|
5841
|
+
|
|
5842
|
+
export function describeDrainResult(data: DrainResultData, { recorded = false }: { recorded?: boolean } = {}): {
|
|
5843
|
+
title: string;
|
|
5844
|
+
detail: string;
|
|
5845
|
+
failed: boolean;
|
|
5846
|
+
type: "success" | "error" | "warning" | "info";
|
|
5847
|
+
outcome: DrainCompletionOutcome;
|
|
5848
|
+
} {
|
|
5849
|
+
const evicted = data.evictedPods?.length ?? 0;
|
|
5850
|
+
const skipped = data.skippedPods ?? [];
|
|
5851
|
+
const errors = data.errors ?? [];
|
|
5852
|
+
const pending = data.pendingPods ?? [];
|
|
5853
|
+
const unconfirmed = data.unconfirmedPods ?? [];
|
|
5854
|
+
const blocking = skipped.filter((pod) => pod.expectedSkip === false);
|
|
5855
|
+
const unknownSkips = skipped.filter((pod) => pod.expectedSkip === undefined);
|
|
5856
|
+
const expected = skipped.filter((pod) => pod.expectedSkip);
|
|
5857
|
+
// Older backends have no completion outcome or expected-skip metadata.
|
|
5858
|
+
const outcome = data.outcome ?? (
|
|
5859
|
+
errors.length > 0 || pending.length > 0 || blocking.length > 0 ? "incomplete" :
|
|
5860
|
+
unconfirmed.length > 0 || data.verificationError ? "unconfirmed" :
|
|
5861
|
+
evicted > 0 && !data.waitedForDeletion ? "started" :
|
|
5862
|
+
unknownSkips.length > 0 ? "unconfirmed" : "complete"
|
|
5863
|
+
);
|
|
5616
5864
|
const parts: string[] = [];
|
|
5617
|
-
if (skipped.length > 0) {
|
|
5618
|
-
parts.push(
|
|
5619
|
-
`Skipped ${skipped.length}: ${listWithOverflow(
|
|
5620
|
-
skipped.map((p) => `${p.namespace}/${p.name} (${p.reason})`),
|
|
5621
|
-
)}`,
|
|
5622
|
-
);
|
|
5623
|
-
}
|
|
5624
5865
|
if (errors.length > 0) {
|
|
5625
|
-
parts.push(`Failed ${errors.length}: ${listWithOverflow(errors)}`);
|
|
5866
|
+
parts.push(`Failed evictions ${errors.length}: ${listWithOverflow(errors)}`);
|
|
5626
5867
|
}
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
? "Evictions were accepted; those pods may still be terminating. The node remains cordoned."
|
|
5630
|
-
: "The node remains cordoned.",
|
|
5631
|
-
);
|
|
5632
|
-
const detail = parts.join("\n");
|
|
5633
|
-
if (errors.length > 0) {
|
|
5634
|
-
return {
|
|
5635
|
-
title: `Drain finished with ${errors.length} failed eviction(s): ${evicted} evicted, ${skipped.length} skipped`,
|
|
5636
|
-
detail,
|
|
5637
|
-
failed: true,
|
|
5638
|
-
};
|
|
5868
|
+
if (pending.length > 0) {
|
|
5869
|
+
parts.push(`Still on the node ${pending.length}: ${listWithOverflow(pending)}`);
|
|
5639
5870
|
}
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5871
|
+
const describePod = (pod: DrainPlanPod) => `${pod.namespace}/${pod.name} (${pod.reason})`;
|
|
5872
|
+
if (blocking.length > 0) {
|
|
5873
|
+
parts.push(`Skipped pods requiring attention ${blocking.length}: ${listWithOverflow(blocking.map(describePod))}`);
|
|
5874
|
+
}
|
|
5875
|
+
if (unknownSkips.length > 0) {
|
|
5876
|
+
parts.push(`Skipped pods requiring review ${unknownSkips.length}: ${listWithOverflow(unknownSkips.map(describePod))}`);
|
|
5877
|
+
}
|
|
5878
|
+
if (unconfirmed.length > 0) {
|
|
5879
|
+
parts.push(`Deletion unconfirmed ${unconfirmed.length}: ${listWithOverflow(unconfirmed)}`);
|
|
5880
|
+
}
|
|
5881
|
+
if (data.verificationError) {
|
|
5882
|
+
parts.push(`Could not verify pod deletion: ${data.verificationError}`);
|
|
5883
|
+
}
|
|
5884
|
+
if (outcome === "started") {
|
|
5885
|
+
parts.push("Eviction requests were accepted; pod deletion has not been confirmed.");
|
|
5886
|
+
} else if (data.waitedForDeletion && evicted > 0 && pending.length === 0 && unconfirmed.length === 0 && !data.verificationError) {
|
|
5887
|
+
parts.push("All evicted pods have left the node.");
|
|
5888
|
+
}
|
|
5889
|
+
if (expected.length > 0) {
|
|
5890
|
+
parts.push(`Left in place by design: ${pluralize(expected.length, "pod")}.`);
|
|
5891
|
+
}
|
|
5892
|
+
parts.push(recorded ? "The node was left cordoned." : "The node remains cordoned.");
|
|
5893
|
+
if (outcome === "incomplete" || outcome === "unconfirmed") {
|
|
5894
|
+
if (blocking.length > 0) parts.push("Review the skipped workloads and drain options before retrying.");
|
|
5895
|
+
if (pending.length > 0) parts.push("Check the remaining pods before retrying.");
|
|
5896
|
+
if (errors.length > 0) parts.push("Resolve the failed evictions before retrying.");
|
|
5897
|
+
if (unconfirmed.length > 0 || data.verificationError || unknownSkips.length > 0) parts.push("Check the node's pods to confirm what remains.");
|
|
5898
|
+
parts.push("Do not take the node down until required workloads are removed.");
|
|
5899
|
+
}
|
|
5900
|
+
const titles: Record<DrainCompletionOutcome, string> = {
|
|
5901
|
+
complete: evicted > 0 ? `Drain complete: ${pluralize(evicted, "pod")} removed` : "Nothing to evict",
|
|
5902
|
+
incomplete: errors.length > 0 ? `Drain incomplete: ${pluralize(errors.length, "failed eviction")}` :
|
|
5903
|
+
`Drain incomplete: ${pluralize(pending.length + blocking.length, "pod")} left on the node`,
|
|
5904
|
+
unconfirmed: "Could not confirm drain completion",
|
|
5905
|
+
started: `Evictions started: ${evicted} accepted`,
|
|
5644
5906
|
};
|
|
5907
|
+
const type = outcome === "complete" ? "success" : outcome === "started" ? "info" : errors.length > 0 ? "error" : "warning";
|
|
5908
|
+
return { title: titles[outcome], detail: parts.join("\n"), failed: outcome === "incomplete" || outcome === "unconfirmed", type, outcome };
|
|
5645
5909
|
}
|
|
5646
5910
|
|
|
5647
5911
|
// ============================================================================
|
|
@@ -5988,6 +6252,8 @@ export function useHelmUninstall() {
|
|
|
5988
6252
|
});
|
|
5989
6253
|
}
|
|
5990
6254
|
|
|
6255
|
+
export class HelmSourceSelectionError extends Error {}
|
|
6256
|
+
|
|
5991
6257
|
// Stream SSE progress events from a Helm operation endpoint.
|
|
5992
6258
|
// Resolves on 'complete', rejects on 'error'. Returns the complete event data for install (which includes release).
|
|
5993
6259
|
function streamHelmProgress(
|
|
@@ -6037,7 +6303,7 @@ function streamHelmProgress(
|
|
|
6037
6303
|
resolve(data);
|
|
6038
6304
|
return;
|
|
6039
6305
|
} else if (data.type === "error") {
|
|
6040
|
-
reject(new Error(data.message || failureLabel));
|
|
6306
|
+
reject(data.errorCode === 'chart_source_changed' || data.errorCode === 'chart_source_required' ? new HelmSourceSelectionError(data.message || failureLabel) : new Error(data.message || failureLabel));
|
|
6041
6307
|
return;
|
|
6042
6308
|
}
|
|
6043
6309
|
} catch (err) {
|
|
@@ -6067,18 +6333,19 @@ export function upgradeWithProgress(
|
|
|
6067
6333
|
repositoryName: string | undefined,
|
|
6068
6334
|
onProgress: (event: InstallProgressEvent) => void,
|
|
6069
6335
|
values?: Record<string, unknown>,
|
|
6336
|
+
sourceUpgrade?: SourceUpgradeSelection,
|
|
6070
6337
|
): Promise<void> {
|
|
6071
6338
|
const params = new URLSearchParams({ version });
|
|
6072
6339
|
if (repositoryName) params.set("repository", repositoryName);
|
|
6073
|
-
const options: RequestInit = values
|
|
6340
|
+
const options: RequestInit = values || sourceUpgrade
|
|
6074
6341
|
? {
|
|
6075
6342
|
method: "POST",
|
|
6076
6343
|
headers: { "Content-Type": "application/json" },
|
|
6077
|
-
body: JSON.stringify({ values }),
|
|
6344
|
+
body: JSON.stringify({ values, sourceUpgrade }),
|
|
6078
6345
|
}
|
|
6079
6346
|
: { method: "POST" };
|
|
6080
6347
|
return streamHelmProgress(
|
|
6081
|
-
`${getApiBase()}/helm/releases/${namespace}/${name}/upgrade-stream?${params.toString()}`,
|
|
6348
|
+
`${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/upgrade-stream" : "upgrade-stream"}?${params.toString()}`,
|
|
6082
6349
|
options,
|
|
6083
6350
|
onProgress,
|
|
6084
6351
|
"Upgrade failed",
|
|
@@ -6112,20 +6379,21 @@ export function useHelmPreviewValues() {
|
|
|
6112
6379
|
values: Record<string, unknown>;
|
|
6113
6380
|
version?: string;
|
|
6114
6381
|
repository?: string;
|
|
6382
|
+
sourceUpgrade?: SourceUpgradeSelection;
|
|
6115
6383
|
}
|
|
6116
6384
|
>({
|
|
6117
|
-
mutationFn: async ({ namespace, name, values, version, repository }) => {
|
|
6385
|
+
mutationFn: async ({ namespace, name, values, version, repository, sourceUpgrade }) => {
|
|
6118
6386
|
const response = await apiFetch(
|
|
6119
|
-
`${getApiBase()}/helm/releases/${namespace}/${name}/values/preview`,
|
|
6387
|
+
`${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/preview" : "values/preview"}`,
|
|
6120
6388
|
{
|
|
6121
6389
|
method: "POST",
|
|
6122
6390
|
headers: { "Content-Type": "application/json" },
|
|
6123
|
-
body: JSON.stringify({ values, version, repository }),
|
|
6391
|
+
body: JSON.stringify({ values, version, repository, sourceUpgrade }),
|
|
6124
6392
|
},
|
|
6125
6393
|
);
|
|
6126
6394
|
if (!response.ok) {
|
|
6127
6395
|
const error = await readErrorBody(response);
|
|
6128
|
-
throw new Error(error.error || `HTTP ${response.status}`);
|
|
6396
|
+
throw error.errorCode === 'chart_source_changed' || error.errorCode === 'chart_source_required' ? new HelmSourceSelectionError(error.error || 'Source changed; select it again') : new Error(error.error || `HTTP ${response.status}`);
|
|
6129
6397
|
}
|
|
6130
6398
|
return response.json();
|
|
6131
6399
|
},
|
|
@@ -6256,6 +6524,20 @@ export function useHelmSourceStatus(namespace: string, releaseName: string, enab
|
|
|
6256
6524
|
});
|
|
6257
6525
|
}
|
|
6258
6526
|
|
|
6527
|
+
export function useHelmSourceVersions(namespace: string, releaseName: string, selection: SourceUpgradeSelection | null, enabled: boolean) {
|
|
6528
|
+
const { support, gatedKey, guard } = useRadarFeature('helmSourceIdentity')
|
|
6529
|
+
return useQuery<string[]>({
|
|
6530
|
+
queryKey: ['helm-source-versions', namespace, releaseName, selection, gatedKey],
|
|
6531
|
+
enabled: enabled && selection !== null && support === 'supported',
|
|
6532
|
+
queryFn: () => guard(() => {
|
|
6533
|
+
if (!selection) throw new Error('Select a chart source')
|
|
6534
|
+
const params = new URLSearchParams({type: selection.source.type, reference: selection.source.reference})
|
|
6535
|
+
if (selection.source.url) params.set('url', selection.source.url)
|
|
6536
|
+
return fetchJSON(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source/versions?${params}`)
|
|
6537
|
+
}),
|
|
6538
|
+
})
|
|
6539
|
+
}
|
|
6540
|
+
|
|
6259
6541
|
async function mutateHelmSource(namespace: string, releaseName: string, source: ChartSourceCandidate): Promise<void> {
|
|
6260
6542
|
const response = await apiFetch(apiUrl(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source`), {
|
|
6261
6543
|
method: "PUT",
|
|
@@ -6275,6 +6557,7 @@ export function useSetHelmSource(namespace: string, releaseName: string) {
|
|
|
6275
6557
|
meta: { errorMessage: "Failed to associate chart source", successMessage: "Chart source associated" },
|
|
6276
6558
|
onSuccess: () => {
|
|
6277
6559
|
queryClient.invalidateQueries({ queryKey: ["helm-source-status", namespace, releaseName] });
|
|
6560
|
+
queryClient.invalidateQueries({ queryKey: ["helm-source-versions", namespace, releaseName] });
|
|
6278
6561
|
queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] });
|
|
6279
6562
|
queryClient.invalidateQueries({ queryKey: ["helm-release-versions"] });
|
|
6280
6563
|
queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] });
|
|
@@ -6436,6 +6719,7 @@ export function useInstallChart() {
|
|
|
6436
6719
|
|
|
6437
6720
|
// Install progress event types
|
|
6438
6721
|
export interface InstallProgressEvent {
|
|
6722
|
+
errorCode?: string;
|
|
6439
6723
|
type: "progress" | "complete" | "error";
|
|
6440
6724
|
phase?: string;
|
|
6441
6725
|
message?: string;
|
|
@@ -6846,10 +7130,11 @@ export function useContexts() {
|
|
|
6846
7130
|
|
|
6847
7131
|
// Where a remote Argo Application or Flux object (spec.kubeConfig) deploys:
|
|
6848
7132
|
// the destination's host for display, and the kubeconfig contexts that reach it.
|
|
6849
|
-
export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean) {
|
|
7133
|
+
export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean, group?: string) {
|
|
7134
|
+
const queryString = group ? `?group=${encodeURIComponent(group)}` : "";
|
|
6850
7135
|
return useQuery<{ server: string; contexts: string[] }>({
|
|
6851
|
-
queryKey: ["gitops-destination", kind, namespace, name],
|
|
6852
|
-
queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`),
|
|
7136
|
+
queryKey: ["gitops-destination", kind, namespace, name, group ?? ""],
|
|
7137
|
+
queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}${queryString}`),
|
|
6853
7138
|
enabled,
|
|
6854
7139
|
staleTime: 60000,
|
|
6855
7140
|
retry: false,
|
|
@@ -7099,7 +7384,7 @@ export function useSetActiveNamespace() {
|
|
|
7099
7384
|
});
|
|
7100
7385
|
if (scope.cacheScoped) {
|
|
7101
7386
|
queryClient.removeQueries({
|
|
7102
|
-
predicate: (query) => query.queryKey[0] !== "namespace-scope",
|
|
7387
|
+
predicate: (query) => query.queryKey[0] !== "namespace-scope" && query.queryKey[0] !== "node-drain-activity",
|
|
7103
7388
|
});
|
|
7104
7389
|
}
|
|
7105
7390
|
queryClient.setQueryData<NamespaceScope>(["namespace-scope"], scope);
|
|
@@ -7297,21 +7582,25 @@ export function useWorkloadRuns(
|
|
|
7297
7582
|
namespace: string,
|
|
7298
7583
|
name: string,
|
|
7299
7584
|
enabled = true,
|
|
7300
|
-
options?: { refetchActive?: boolean; clusterScoped?: boolean; role?: string; search?: string; state?: string; selected?: string },
|
|
7585
|
+
options?: { refetchActive?: boolean; clusterScoped?: boolean; namespaces?: string[]; role?: string; search?: string; state?: string; selected?: string; ownerUID?: string },
|
|
7301
7586
|
) {
|
|
7302
7587
|
const clusterScoped = options?.clusterScoped ?? false;
|
|
7303
7588
|
const ns = clusterScoped ? "_" : namespace;
|
|
7589
|
+
// A cluster-scoped template's runs live in many namespaces; the view's
|
|
7590
|
+
// namespace selection narrows them, as it does every other list.
|
|
7591
|
+
const viewNamespaces = clusterScoped ? (options?.namespaces ?? []).join(",") : "";
|
|
7304
7592
|
const params = new URLSearchParams();
|
|
7305
7593
|
if (clusterScoped) params.set("clusterScoped", "true");
|
|
7594
|
+
if (viewNamespaces) params.set("namespaces", viewNamespaces);
|
|
7306
7595
|
for (const key of ["role", "search", "state", "selected"] as const) { if (options?.[key]) params.set(key, options[key]); }
|
|
7307
7596
|
const queryString = params.toString();
|
|
7308
7597
|
|
|
7309
7598
|
return useQuery<WorkloadRunsResponse>({
|
|
7310
|
-
queryKey: ["workload-runs", kind, namespace, name, clusterScoped, options?.role ?? '', options?.search ?? '', options?.state ?? '', options?.selected ?? ''],
|
|
7599
|
+
queryKey: ["workload-runs", kind, namespace, name, clusterScoped, viewNamespaces, options?.role ?? '', options?.search ?? '', options?.state ?? '', options?.selected ?? '', options?.ownerUID ?? ''],
|
|
7311
7600
|
placeholderData: (previous, query) => {
|
|
7312
7601
|
if (previous?.collection !== 'members') return undefined
|
|
7313
|
-
const identity = ["workload-runs", kind, namespace, name, clusterScoped, options?.role ?? '', options?.search ?? '', options?.state ?? '']
|
|
7314
|
-
return identity.every((value, index) => query?.queryKey[index] === value) ? previous : undefined
|
|
7602
|
+
const identity = ["workload-runs", kind, namespace, name, clusterScoped, viewNamespaces, options?.role ?? '', options?.search ?? '', options?.state ?? '']
|
|
7603
|
+
return identity.every((value, index) => query?.queryKey[index] === value) && query?.queryKey[10] === (options?.ownerUID ?? '') ? previous : undefined
|
|
7315
7604
|
},
|
|
7316
7605
|
queryFn: () =>
|
|
7317
7606
|
fetchJSON(
|
|
@@ -7623,6 +7912,8 @@ export interface DiagnosticsSnapshot {
|
|
|
7623
7912
|
historyLimit: number;
|
|
7624
7913
|
debugEvents: boolean;
|
|
7625
7914
|
mcpEnabled: boolean;
|
|
7915
|
+
mcpReadOnly: boolean;
|
|
7916
|
+
pprof?: boolean;
|
|
7626
7917
|
hasPrometheusURL: boolean;
|
|
7627
7918
|
hasPrometheusHeaders: boolean;
|
|
7628
7919
|
};
|