@skyhook-io/radar-app 1.21.6 → 1.21.7
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 +1 -1
- package/package.json +7 -7
- package/src/App.tsx +19 -1
- package/src/RadarApp.tsx +8 -2
- package/src/api/client.discoverMetrics.test.tsx +69 -0
- package/src/api/client.issueCorrelation.test.tsx +244 -0
- package/src/api/client.issueRowChanges.test.tsx +129 -0
- package/src/api/client.pendingOwnership.test.tsx +197 -0
- package/src/api/client.prometheusStatus.test.ts +4 -0
- package/src/api/client.restartError.test.ts +36 -1
- package/src/api/client.stopWorkflow.test.tsx +133 -0
- package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
- package/src/api/client.ts +572 -111
- package/src/api/connectionBinding.test.tsx +3 -1
- package/src/api/connectionBinding.ts +14 -2
- package/src/api/gitOpsPermissions.render.test.tsx +155 -0
- package/src/api/gitOpsPermissions.test.ts +90 -0
- package/src/api/gitOpsPermissions.ts +51 -0
- package/src/api/httpErrors.test.ts +30 -1
- package/src/api/httpErrors.ts +17 -0
- package/src/api/openobserveSetup.ts +85 -0
- package/src/api/podDebug.test.tsx +137 -0
- package/src/api/podDebug.ts +82 -0
- package/src/api/prometheusCharts.test.ts +23 -0
- package/src/api/prometheusCharts.ts +25 -0
- package/src/api/radarFeatures.render.test.tsx +43 -2
- package/src/api/radarFeatures.test.ts +18 -1
- package/src/api/radarFeatures.ts +17 -4
- package/src/api/reviewedActionMutation.ts +9 -2
- package/src/api/workloadMetrics.ts +2 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
- package/src/components/applications/ApplicationsView.tsx +56 -31
- package/src/components/cnpg/host.test.tsx +1 -1
- package/src/components/cnpg/host.tsx +0 -2
- package/src/components/dock/BottomDock.tsx +7 -3
- package/src/components/dock/MissingShellDebug.test.tsx +193 -0
- package/src/components/dock/MissingShellDebug.tsx +114 -0
- package/src/components/dock/PodDebugSession.test.tsx +60 -0
- package/src/components/dock/PodDebugSession.tsx +96 -0
- package/src/components/dock/TerminalTab.test.tsx +48 -4
- package/src/components/dock/TerminalTab.tsx +47 -25
- package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
- package/src/components/dock/WorkloadLogsTab.tsx +16 -0
- package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
- package/src/components/execution/BatchExecutionView.tsx +88 -5
- package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
- package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
- package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
- package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
- package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
- package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
- package/src/components/gitops/GitOpsView.tsx +93 -32
- package/src/components/helm/OwnedResources.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +1 -0
- package/src/components/issues/IssuesPane.render.test.tsx +1 -1
- package/src/components/issues/IssuesPane.tsx +11 -0
- package/src/components/issues/useIssueExpansion.ts +91 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
- package/src/components/resource/MetricsNotConnected.tsx +114 -0
- package/src/components/resource/PVCUsageBar.tsx +2 -1
- package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
- package/src/components/resource/PrometheusCharts.tsx +14 -2
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
- package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
- package/src/components/resource/RestartChart.tsx +4 -3
- package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
- package/src/components/resource/RightsizingStrip.tsx +5 -3
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
- package/src/components/resource/nameMatchedScope.ts +9 -3
- package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
- package/src/components/resources/PodDebugAction.test.tsx +157 -0
- package/src/components/resources/PodDebugAction.tsx +207 -0
- package/src/components/resources/PodDebugPermission.tsx +21 -0
- package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
- package/src/components/resources/ResourcesView.tsx +39 -5
- package/src/components/resources/namespaceHint.test.ts +34 -0
- package/src/components/resources/namespaceHint.ts +19 -0
- package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
- package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
- package/src/components/resources/renderers/PodRenderer.tsx +12 -5
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
- package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
- package/src/components/settings/MetricsBackendSwitch.tsx +167 -0
- package/src/components/settings/OpenObserveSetup.test.tsx +343 -0
- package/src/components/settings/OpenObserveSetup.tsx +358 -0
- package/src/components/settings/SettingsDialog.tsx +21 -7
- package/src/components/settings/openobserveStatus.test.ts +34 -0
- package/src/components/settings/openobserveStatus.ts +55 -0
- package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
- package/src/components/timeline/TimelineList.test.ts +18 -0
- package/src/components/timeline/TimelineList.tsx +19 -5
- package/src/components/timeline/TimelineView.tsx +2 -0
- package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
- package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +95 -10
- package/src/context/TimelineNavigation.test.ts +59 -0
- package/src/context/TimelineNavigation.tsx +86 -0
- package/src/contexts/CapabilitiesContext.tsx +3 -1
- package/src/hooks/useResourceCounts.ts +2 -1
- package/src/hooks/useWorkflowStopAction.ts +31 -0
- package/src/index.css +1 -0
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +4 -2
- package/src/k8s-ui-exports.test.ts +10 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResourceCoverage } from '@skyhook-io/k8s-ui'
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
3
3
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
4
4
|
import { useQuery } from '@tanstack/react-query'
|
|
5
5
|
import yaml from 'yaml'
|
|
@@ -57,6 +57,8 @@ import {
|
|
|
57
57
|
type GitOpsTreePreset,
|
|
58
58
|
type SelectedResource,
|
|
59
59
|
} from '@skyhook-io/k8s-ui'
|
|
60
|
+
import { GitOpsActionError } from '../../api/httpErrors'
|
|
61
|
+
import { GitOpsPermissionRowActions } from './GitOpsPermissionRowActions'
|
|
60
62
|
import { useToast } from '../ui/Toast'
|
|
61
63
|
import { useContextSwitchFlow } from '../useContextSwitchFlow'
|
|
62
64
|
import { FluxOperatorCard } from './FluxOperatorCard'
|
|
@@ -75,6 +77,7 @@ import {
|
|
|
75
77
|
useArgoRollback,
|
|
76
78
|
useArgoSuspend,
|
|
77
79
|
useArgoSync,
|
|
80
|
+
useGitOpsActionCapabilities,
|
|
78
81
|
useArgoTerminate,
|
|
79
82
|
useFluxReconcile,
|
|
80
83
|
useFluxResume,
|
|
@@ -86,6 +89,8 @@ import {
|
|
|
86
89
|
useResource,
|
|
87
90
|
} from '../../api/client'
|
|
88
91
|
import { useAPIResources, GITOPS_KINDS } from '../../api/apiResources'
|
|
92
|
+
import { getApiBase } from '../../api/config'
|
|
93
|
+
import { connectionHeaderValue } from '../../api/connectionBinding'
|
|
89
94
|
import { combinedListStatus, lowerBound } from '../../api/resourceLists'
|
|
90
95
|
import { useConnection } from '../../context/ConnectionContext'
|
|
91
96
|
import { useRegisterShortcut } from '../../hooks/useKeyboardShortcuts'
|
|
@@ -102,6 +107,15 @@ type ArgoSyncDialogTarget =
|
|
|
102
107
|
| { scope: 'application' }
|
|
103
108
|
| { scope: 'resource'; resource: GitOpsInsightRef }
|
|
104
109
|
|
|
110
|
+
function useActiveSyncDialog<T>(dialog: T | null) {
|
|
111
|
+
const active = useRef<T | null>(null)
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
active.current = dialog
|
|
114
|
+
return () => { active.current = null }
|
|
115
|
+
}, [dialog])
|
|
116
|
+
return active
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
const KIND_BY_NAME = new Map(GITOPS_KINDS.map((k) => [k.name, k]))
|
|
106
120
|
|
|
107
121
|
// Fallback poll for the rows; SSE changes to row kinds refetch them within 15s (App.tsx slow tier).
|
|
@@ -150,7 +164,10 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
150
164
|
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
151
165
|
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
152
166
|
|
|
153
|
-
const
|
|
167
|
+
const clusterKey = JSON.stringify([getApiBase(), connection.context])
|
|
168
|
+
const [syncSelection, setSyncSelection] = useState<{ rowId: string; clusterKey: string } | null>(null)
|
|
169
|
+
if (syncSelection && syncSelection.clusterKey !== clusterKey) setSyncSelection(null)
|
|
170
|
+
const syncDialogRowId = syncSelection?.clusterKey === clusterKey ? syncSelection.rowId : null
|
|
154
171
|
const [pendingActions, setPendingActions] = useState<Map<string, Set<GitOpsRowAction>>>(new Map())
|
|
155
172
|
|
|
156
173
|
// Mark an action as in-flight (or done) for a given row. Cloning the
|
|
@@ -250,8 +267,12 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
250
267
|
})
|
|
251
268
|
|
|
252
269
|
const syncDialogRow = rowsQuery.data?.rows.find((row) => row.id === syncDialogRowId)
|
|
270
|
+
const activeSyncDialog = useActiveSyncDialog(syncDialogRow ? syncSelection : null)
|
|
271
|
+
const { disabledReasons: syncDialogDisabledReasons } = useGitOpsActionCapabilities(
|
|
272
|
+
syncDialogRow?.kindName ?? '', syncDialogRow?.group, syncDialogRow?.namespace ?? '', syncDialogRow?.name ?? '', !!syncDialogRow,
|
|
273
|
+
)
|
|
253
274
|
useEffect(() => {
|
|
254
|
-
if (syncDialogRowId && !syncDialogRow)
|
|
275
|
+
if (syncDialogRowId && !syncDialogRow) setSyncSelection(null)
|
|
255
276
|
}, [syncDialogRowId, syncDialogRow])
|
|
256
277
|
|
|
257
278
|
// Row mutations invalidate granular keys (['resource', …], ['gitops-tree', …])
|
|
@@ -304,7 +325,8 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
304
325
|
// detail page uses. The mutation fires from onConfirm; clear the
|
|
305
326
|
// in-flight flag here since the dialog now owns the lifecycle.
|
|
306
327
|
markAction(id, action, false)
|
|
307
|
-
|
|
328
|
+
argoSync.reset()
|
|
329
|
+
setSyncSelection({ rowId: id, clusterKey })
|
|
308
330
|
return
|
|
309
331
|
case 'refresh':
|
|
310
332
|
argoRefresh.mutate({ namespace, name, hard: false }, settle)
|
|
@@ -361,6 +383,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
361
383
|
params.set('apiGroup', row.group)
|
|
362
384
|
navigate({ pathname: gitOpsDetailPath(row.kindName, ns, row.name), search: params.toString() })
|
|
363
385
|
}}
|
|
386
|
+
renderRowActions={(row, items) => <GitOpsPermissionRowActions row={row} items={items} />}
|
|
364
387
|
onRowAction={handleRowAction}
|
|
365
388
|
pendingRowActions={pendingActions}
|
|
366
389
|
argoResumeUpgrade={argoResumeUpgrade}
|
|
@@ -371,6 +394,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
371
394
|
/>
|
|
372
395
|
<SyncOptionsDialog
|
|
373
396
|
open={!!syncDialogRow}
|
|
397
|
+
disabledReason={syncDialogDisabledReasons.sync}
|
|
374
398
|
appLabel={syncDialogRow ? `${syncDialogRow.namespace}/${syncDialogRow.name}` : ''}
|
|
375
399
|
multiSource={isArgoMultiSource(syncDialogRow?.raw)}
|
|
376
400
|
comparedRevision={syncDialogRow?.raw?.status?.sync?.revision}
|
|
@@ -378,16 +402,22 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
378
402
|
applicationSyncOptions={argoApplicationSyncOptions(syncDialogRow?.raw)}
|
|
379
403
|
autoSyncEnabled={!!syncDialogRow && isArgoAutoSyncEnabled(syncDialogRow.raw)}
|
|
380
404
|
pending={argoSync.isPending}
|
|
381
|
-
|
|
405
|
+
syncError={argoSync.error?.message}
|
|
406
|
+
syncRawError={argoSync.error?.rawDetail}
|
|
407
|
+
onCancel={() => setSyncSelection(null)}
|
|
382
408
|
onConfirm={(opts) => {
|
|
383
|
-
if (!syncDialogRow) return
|
|
409
|
+
if (!syncDialogRow || syncDialogDisabledReasons.sync) return
|
|
384
410
|
const { namespace, name } = syncDialogRow
|
|
385
411
|
argoSync.mutate(
|
|
386
|
-
{
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
412
|
+
{
|
|
413
|
+
namespace, name, ...opts,
|
|
414
|
+
applicationSyncOptions: argoApplicationSyncOptions(syncDialogRow.raw),
|
|
415
|
+
isErrorShownInline: () => activeSyncDialog.current === syncSelection,
|
|
416
|
+
},
|
|
417
|
+
{ onSuccess: () => {
|
|
418
|
+
refetchTableAfterMutation()
|
|
419
|
+
setSyncSelection(null)
|
|
420
|
+
} },
|
|
391
421
|
)
|
|
392
422
|
}}
|
|
393
423
|
/>
|
|
@@ -398,6 +428,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
398
428
|
function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOpsViewProps) {
|
|
399
429
|
const location = useLocation()
|
|
400
430
|
const navigate = useNavigate()
|
|
431
|
+
const { connection } = useConnection()
|
|
401
432
|
const { showError, showSuccess, showToast } = useToast()
|
|
402
433
|
const parts = location.pathname.split('/').filter(Boolean)
|
|
403
434
|
const kind = parts[2] || 'applications'
|
|
@@ -490,7 +521,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
490
521
|
const [graphFullscreen, setGraphFullscreen] = useState(false)
|
|
491
522
|
const [helmValuesOpen, setHelmValuesOpen] = useState(false)
|
|
492
523
|
|
|
524
|
+
const { permissions: actionPermissions, disabledReasons: actionDisabledReasons, permissionCheckUnavailable } = useGitOpsActionCapabilities(kind, effectiveGroup, namespace, name)
|
|
493
525
|
const argoSync = useArgoSync()
|
|
526
|
+
const remediationSync = useArgoSync({ reportErrors: false })
|
|
494
527
|
const argoResourceValidation = useArgoResourceValidation()
|
|
495
528
|
const argoRefresh = useArgoRefresh()
|
|
496
529
|
const argoTerminate = useArgoTerminate()
|
|
@@ -507,7 +540,12 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
507
540
|
const fluxSuspend = useFluxSuspend()
|
|
508
541
|
const fluxResume = useFluxResume()
|
|
509
542
|
|
|
510
|
-
const [
|
|
543
|
+
const appKey = JSON.stringify([getApiBase(), connection.context, kind, effectiveGroup, namespace, name])
|
|
544
|
+
const [syncDialog, setSyncDialog] = useState<{ appKey: string; target: ArgoSyncDialogTarget } | null>(null)
|
|
545
|
+
if (syncDialog && syncDialog.appKey !== appKey) setSyncDialog(null)
|
|
546
|
+
const syncDialogTarget = syncDialog?.appKey === appKey ? syncDialog.target : null
|
|
547
|
+
const activeSyncDialog = useActiveSyncDialog(syncDialogTarget ? syncDialog : null)
|
|
548
|
+
const argoSyncBusy = argoSync.isPending || remediationSync.isPending || applyResource.isPending
|
|
511
549
|
const [validatedTargetKey, setValidatedTargetKey] = useState<string | null>(null)
|
|
512
550
|
const validationStale = validatedTargetKey !== null && validatedTargetKey !== deployTargetKey
|
|
513
551
|
// Doubles as the "open" flag (truthy = dialog open) and the data carrier
|
|
@@ -517,13 +555,15 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
517
555
|
const [refreshKind, setRefreshKind] = useState<'normal' | 'hard'>('normal')
|
|
518
556
|
|
|
519
557
|
function openArgoSyncDialog(target: ArgoSyncDialogTarget) {
|
|
558
|
+
if (argoSyncBusy) return
|
|
559
|
+
argoSync.reset()
|
|
520
560
|
argoResourceValidation.reset()
|
|
521
|
-
|
|
561
|
+
setSyncDialog({ appKey, target })
|
|
522
562
|
}
|
|
523
563
|
|
|
524
564
|
function closeArgoSyncDialog() {
|
|
525
565
|
argoResourceValidation.reset()
|
|
526
|
-
|
|
566
|
+
setSyncDialog(null)
|
|
527
567
|
}
|
|
528
568
|
|
|
529
569
|
const detailRow = tool && resourceQ.data ? normalizeDetailResource(kind, effectiveGroup, tool, resourceQ.data) : null
|
|
@@ -631,11 +671,13 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
631
671
|
category: 'GitOps',
|
|
632
672
|
scope: 'gitops',
|
|
633
673
|
handler: () => {
|
|
674
|
+
const reason = actionDisabledReasons[isArgoApp ? 'sync' : 'reconcile']
|
|
675
|
+
if (reason) { showToast(reason, { type: 'info', id: `gitops-denied:${reason}` }); return }
|
|
634
676
|
if (effectiveSuspended || terminating || operationInProgress) return
|
|
635
677
|
if (isArgoApp) openArgoSyncDialog({ scope: 'application' })
|
|
636
678
|
else if (isFlux) fluxReconcile.mutate({ kind, namespace, name })
|
|
637
679
|
},
|
|
638
|
-
enabled: shortcutsEnabled && (isArgoApp || isFlux) && !effectiveSuspended && !terminating && !(isArgoApp && operationInProgress),
|
|
680
|
+
enabled: shortcutsEnabled && (isArgoApp || isFlux) && !effectiveSuspended && !terminating && !(isArgoApp && (operationInProgress || argoSyncBusy)),
|
|
639
681
|
})
|
|
640
682
|
useRegisterShortcut({
|
|
641
683
|
id: 'gitops-detail-refresh',
|
|
@@ -645,6 +687,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
645
687
|
scope: 'gitops',
|
|
646
688
|
handler: () => {
|
|
647
689
|
if (!isArgoApp) return
|
|
690
|
+
if (actionDisabledReasons.refresh) { showToast(actionDisabledReasons.refresh, { type: 'info', id: `gitops-denied:${actionDisabledReasons.refresh}` }); return }
|
|
648
691
|
setRefreshKind('normal')
|
|
649
692
|
argoRefresh.mutate({ namespace, name, hard: false })
|
|
650
693
|
},
|
|
@@ -658,6 +701,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
658
701
|
scope: 'gitops',
|
|
659
702
|
handler: () => {
|
|
660
703
|
if (!isArgoApp) return
|
|
704
|
+
if (actionDisabledReasons.refresh) { showToast(actionDisabledReasons.refresh, { type: 'info', id: `gitops-denied:${actionDisabledReasons.refresh}` }); return }
|
|
661
705
|
setRefreshKind('hard')
|
|
662
706
|
argoRefresh.mutate({ namespace, name, hard: true })
|
|
663
707
|
},
|
|
@@ -670,6 +714,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
670
714
|
category: 'GitOps',
|
|
671
715
|
scope: 'gitops',
|
|
672
716
|
handler: () => {
|
|
717
|
+
if (actionDisabledReasons.terminate) { showToast(actionDisabledReasons.terminate, { type: 'info', id: `gitops-denied:${actionDisabledReasons.terminate}` }); return }
|
|
673
718
|
if (isArgoApp && isRunning) argoTerminate.mutate({ namespace, name })
|
|
674
719
|
},
|
|
675
720
|
enabled: shortcutsEnabled && isArgoApp && isRunning,
|
|
@@ -707,7 +752,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
707
752
|
if (isArgoAutoSyncSwitchedOff(resourceQ.data) && (argoResumeUpgrade || argoResumeBlockedReason)) return
|
|
708
753
|
argoResume.mutate({ namespace, name })
|
|
709
754
|
},
|
|
710
|
-
syncing:
|
|
755
|
+
syncing: argoSyncBusy,
|
|
711
756
|
refreshing: argoRefresh.isPending,
|
|
712
757
|
refreshingKind: refreshKind,
|
|
713
758
|
terminating: argoTerminate.isPending,
|
|
@@ -775,10 +820,12 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
775
820
|
// away and back.
|
|
776
821
|
window.setTimeout(() => setChangesFocusKey(null), 4000)
|
|
777
822
|
}}
|
|
778
|
-
remediationPending={
|
|
823
|
+
remediationPending={argoSyncBusy}
|
|
779
824
|
onRemediate={(remediation) => {
|
|
780
825
|
if (remediation.kind === 'create-namespace' && remediation.target) {
|
|
781
826
|
const nsName = remediation.target
|
|
827
|
+
const apiBase = getApiBase()
|
|
828
|
+
const expectedConnection = { apiBase, connectionId: connectionHeaderValue(apiBase) }
|
|
782
829
|
const yamlManifest = `apiVersion: v1\nkind: Namespace\nmetadata:\n name: ${nsName}\n`
|
|
783
830
|
applyResource.mutate(
|
|
784
831
|
{ yaml: yamlManifest, mode: 'apply' },
|
|
@@ -788,15 +835,15 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
788
835
|
// sync was triggered, so a successful create-namespace + sync
|
|
789
836
|
// failure doesn't yield a misleading "sync triggered" toast.
|
|
790
837
|
if (isArgoApp) {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
{
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
838
|
+
void remediationSync.mutateAsync({ namespace, name, applicationSyncOptions: appSyncOptions, expectedConnection }).then(
|
|
839
|
+
() => showSuccess(`Created namespace ${nsName}`, 'Sync triggered to retry the apply.'),
|
|
840
|
+
(error: Error) => {
|
|
841
|
+
const title = `Created namespace ${nsName}, but sync failed`
|
|
842
|
+
if (error instanceof GitOpsActionError) {
|
|
843
|
+
showError(title, `${error.notificationDetail}\nCheck the application’s status before retrying Sync.`, error.rawDetail)
|
|
844
|
+
} else {
|
|
845
|
+
showError(title, error.message)
|
|
846
|
+
}
|
|
800
847
|
},
|
|
801
848
|
)
|
|
802
849
|
} else {
|
|
@@ -823,6 +870,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
823
870
|
isArgoApp={isArgoApp}
|
|
824
871
|
isFlux={isFlux}
|
|
825
872
|
isFluxWorkload={isFluxWorkload}
|
|
873
|
+
actionDisabledReasons={actionDisabledReasons}
|
|
874
|
+
actionPermissions={actionPermissions}
|
|
875
|
+
permissionCheckUnavailable={permissionCheckUnavailable}
|
|
826
876
|
argo={argoHandlers}
|
|
827
877
|
flux={fluxHandlers}
|
|
828
878
|
activeTab={appView}
|
|
@@ -868,6 +918,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
868
918
|
<GitOpsActivityInsightView
|
|
869
919
|
insight={insightsQ.data}
|
|
870
920
|
error={insightsQ.error as Error | null}
|
|
921
|
+
rollbackDisabledReason={actionDisabledReasons.rollback}
|
|
871
922
|
onRollback={isArgoApp && !operationInProgress ? (item) => {
|
|
872
923
|
if (argoRollbackUpgrade || argoRollbackBlockedReason || parseArgoRollbackID(item.id) == null) return
|
|
873
924
|
setRollbackTarget(item)
|
|
@@ -889,9 +940,9 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
889
940
|
? terminatingActionTooltip
|
|
890
941
|
: effectiveSuspended
|
|
891
942
|
? 'Resume the Application before syncing a resource.'
|
|
892
|
-
: operationInProgress ||
|
|
943
|
+
: operationInProgress || argoSyncBusy
|
|
893
944
|
? 'Wait for the current sync operation to finish.'
|
|
894
|
-
:
|
|
945
|
+
: actionDisabledReasons.sync
|
|
895
946
|
) : undefined}
|
|
896
947
|
focusKey={changesFocusKey}
|
|
897
948
|
tree={tree}
|
|
@@ -952,6 +1003,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
952
1003
|
multiSource={isArgoMultiSource(resourceQ.data)}
|
|
953
1004
|
pinsComparedRevision={argoInheritanceSupport === 'supported' && argoComparedRevisionCurrent(resourceQ.data)}
|
|
954
1005
|
resource={syncDialogTarget?.scope === 'resource' ? syncDialogTarget.resource : undefined}
|
|
1006
|
+
disabledReason={actionDisabledReasons.sync}
|
|
955
1007
|
comparedRevision={resourceQ.data?.status?.sync?.revision}
|
|
956
1008
|
applicationSyncOptions={appSyncOptions}
|
|
957
1009
|
pending={argoSync.isPending}
|
|
@@ -960,20 +1012,27 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
960
1012
|
operationInProgress={operationInProgress}
|
|
961
1013
|
validationResult={validationStale ? null : argoResourceValidation.data}
|
|
962
1014
|
validationError={validationStale ? undefined : argoResourceValidation.error?.message}
|
|
1015
|
+
validationRawError={validationStale ? undefined : argoResourceValidation.error?.rawDetail}
|
|
1016
|
+
syncError={argoSync.error?.message}
|
|
1017
|
+
syncRawError={argoSync.error?.rawDetail}
|
|
963
1018
|
onCancel={closeArgoSyncDialog}
|
|
964
1019
|
onValidationReset={() => argoResourceValidation.reset()}
|
|
965
1020
|
onValidate={syncDialogTarget?.scope === 'resource' ? (opts) => {
|
|
1021
|
+
if (actionDisabledReasons.validate) return
|
|
1022
|
+
argoSync.reset()
|
|
966
1023
|
setValidatedTargetKey(deployTargetKey)
|
|
967
1024
|
argoResourceValidation.mutate(buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions))
|
|
968
1025
|
} : undefined}
|
|
969
1026
|
onConfirm={(opts) => {
|
|
970
|
-
if (!syncDialogTarget) return
|
|
1027
|
+
if (!syncDialogTarget || actionDisabledReasons.sync) return
|
|
1028
|
+
if (argoResourceValidation.isError) argoResourceValidation.reset()
|
|
971
1029
|
const variables = syncDialogTarget.scope === 'resource'
|
|
972
1030
|
? buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions)
|
|
973
1031
|
: { namespace, name, ...opts, applicationSyncOptions: appSyncOptions }
|
|
974
|
-
argoSync.mutate(
|
|
975
|
-
|
|
976
|
-
|
|
1032
|
+
argoSync.mutate({
|
|
1033
|
+
...variables,
|
|
1034
|
+
isErrorShownInline: () => activeSyncDialog.current === syncDialog,
|
|
1035
|
+
}, { onSuccess: closeArgoSyncDialog })
|
|
977
1036
|
}}
|
|
978
1037
|
/>
|
|
979
1038
|
<RollbackDialog
|
|
@@ -981,6 +1040,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
981
1040
|
appLabel={`${namespace}/${name}`}
|
|
982
1041
|
revision={rollbackTarget?.revision || ''}
|
|
983
1042
|
historyId={rollbackTarget?.id}
|
|
1043
|
+
disabledReason={actionDisabledReasons.rollback}
|
|
984
1044
|
source={rollbackTarget?.source}
|
|
985
1045
|
multiSourceWarning={rollbackTarget?.rollbackMultiSourceWarning}
|
|
986
1046
|
pending={argoRollback.isPending}
|
|
@@ -992,6 +1052,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
992
1052
|
setRollbackTarget(null)
|
|
993
1053
|
return
|
|
994
1054
|
}
|
|
1055
|
+
if (actionDisabledReasons.rollback) return
|
|
995
1056
|
const id = parseArgoRollbackID(rollbackTarget?.id)
|
|
996
1057
|
if (id == null) {
|
|
997
1058
|
showError('Rollback target became invalid', 'The history entry changed while the dialog was open. Reselect a target and try again.')
|
|
@@ -414,6 +414,7 @@ function PodQuickActions({ namespace, podName, isRunning }: PodQuickActionsProps
|
|
|
414
414
|
const containers = data.resource?.spec?.containers || []
|
|
415
415
|
if (containers.length > 0) {
|
|
416
416
|
openTerminal({
|
|
417
|
+
podUID: data.resource?.metadata?.uid,
|
|
417
418
|
namespace,
|
|
418
419
|
podName,
|
|
419
420
|
containerName: containers[0].name,
|
|
@@ -61,6 +61,7 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
61
61
|
{ arg: 'group', desc: 'API group when the kind is ambiguous (e.g. serving.knative.dev for Knative Service vs core Service)' },
|
|
62
62
|
{ arg: 'include', desc: 'events, metrics, changes, issues, drain-plan (Node pod/PDB estimate), revisions (rollback targets for Deployment/StatefulSet/DaemonSet/Rollout)' },
|
|
63
63
|
{ arg: 'context', desc: 'resourceContext tier: basic (default) or none' },
|
|
64
|
+
{ arg: 'relationship', desc: 'one relationship field a partial-preview warning named (e.g. dependents), returned with up to 200 entries' },
|
|
64
65
|
],
|
|
65
66
|
},
|
|
66
67
|
{
|
|
@@ -8,7 +8,7 @@ const state = vi.hoisted(() => ({
|
|
|
8
8
|
fleet: { data: undefined as IssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
|
|
9
9
|
subject: { data: undefined as SubjectIssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
|
|
10
10
|
}))
|
|
11
|
-
vi.mock('../../api/client', () => ({ useIssues: () => state.fleet, useSubjectIssues: () => state.subject }))
|
|
11
|
+
vi.mock('../../api/client', () => ({ useIssues: () => state.fleet, useSubjectIssues: () => state.subject, useIssueCorrelation: () => ({ data: undefined, error: null, isFetching: false, dataUpdatedAt: 0, refetch: vi.fn() }), useIssueRowChanges: () => undefined }))
|
|
12
12
|
vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: undefined }), karpenterCapacityAvailable: () => false }))
|
|
13
13
|
vi.mock('../../contexts/CapabilitiesContext', () => ({ useCapabilitiesContext: () => ({}) }))
|
|
14
14
|
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
@@ -28,6 +28,7 @@ import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
|
|
|
28
28
|
import { recordUsageEvent } from "../../api/usage-data";
|
|
29
29
|
import { uncheckedSourceLines, uncheckedSubjectWhy } from "./uncheckedSources";
|
|
30
30
|
import { UncheckedSourceHelp } from "./UncheckedSourceHelp";
|
|
31
|
+
import { useIssueExpansion, useIssueRowNotes } from "./useIssueExpansion";
|
|
31
32
|
|
|
32
33
|
// A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
|
|
33
34
|
// always single-cluster (unlike Argo hub-and-spoke), so the issue and the
|
|
@@ -201,6 +202,11 @@ export function IssuesPane({
|
|
|
201
202
|
const subjectHidden =
|
|
202
203
|
!!subject?.namespace && namespaces.length > 0 && !namespaces.includes(subject.namespace);
|
|
203
204
|
const related = useSubjectIssues(subject, !subjectHidden);
|
|
205
|
+
const expansion = useIssueExpansion(() => {
|
|
206
|
+
if (subject) void related.refetch();
|
|
207
|
+
else void refetch();
|
|
208
|
+
});
|
|
209
|
+
const rowNotes = useIssueRowNotes();
|
|
204
210
|
const subjectState = subject
|
|
205
211
|
? issueSubjectState(subject, namespaces, related)
|
|
206
212
|
: null;
|
|
@@ -424,6 +430,11 @@ export function IssuesPane({
|
|
|
424
430
|
issues={shown}
|
|
425
431
|
anyData={subject ? !!related.data : !!data}
|
|
426
432
|
onResourceClick={onResourceClick}
|
|
433
|
+
onOpenIssueChange={expansion.onOpenIssueChange}
|
|
434
|
+
expandedIssue={expansion.expandedIssue}
|
|
435
|
+
timelineLinks={expansion.timelineLinks}
|
|
436
|
+
rowChanges={rowNotes.rowChanges}
|
|
437
|
+
onVisibleIssuesChange={rowNotes.onVisibleIssuesChange}
|
|
427
438
|
renderActions={({ issue }) => {
|
|
428
439
|
const capacityHref = capacityHrefForIssue(issue, hasKarpenter);
|
|
429
440
|
return (
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { issueRowKey, type Issue, type IssueExpansion } from "@skyhook-io/k8s-ui";
|
|
3
|
+
import { useIssueCorrelation, useIssueRowChanges, type CorrelatedIssuesResponse } from "../../api/client";
|
|
4
|
+
import { RadarFeatureUnsupportedError } from "../../api/radarFeatures";
|
|
5
|
+
import { useTimelineEventLinks } from "../../context/TimelineNavigation";
|
|
6
|
+
|
|
7
|
+
interface CorrelationQuery {
|
|
8
|
+
data: CorrelatedIssuesResponse | undefined;
|
|
9
|
+
error: unknown;
|
|
10
|
+
isFetching: boolean;
|
|
11
|
+
dataUpdatedAt: number;
|
|
12
|
+
refetch: () => unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Maps the correlation request for the open issue onto what the row renders.
|
|
16
|
+
* Data wins over a later refresh error: the row keeps the last answer and says
|
|
17
|
+
* the refresh failed and when that answer arrived. */
|
|
18
|
+
export function issueExpansionFromQuery(issue: Issue, query: CorrelationQuery): IssueExpansion {
|
|
19
|
+
const onRetry = () => { void query.refetch(); };
|
|
20
|
+
const retrying = query.isFetching;
|
|
21
|
+
if (query.data) {
|
|
22
|
+
const status = query.data.correlation_status;
|
|
23
|
+
if (status === "user_forbidden" || status === "read_error") {
|
|
24
|
+
return { recentChanges: { status: "unavailable", reason: status }, onRetry, retrying };
|
|
25
|
+
}
|
|
26
|
+
// An issue Radar doesn't correlate comes back unchanged, with no
|
|
27
|
+
// correlation and no status; the row then shows no Recent changes section.
|
|
28
|
+
const fresh = status === "not_found"
|
|
29
|
+
? undefined
|
|
30
|
+
: query.data.issues?.find((candidate) => candidate.id === issue.id);
|
|
31
|
+
if (!fresh) return { recentChanges: { status: "not_found" } };
|
|
32
|
+
// An ineligible issue comes back as the list has it. Overriding the row with
|
|
33
|
+
// it would only freeze the row on that copy once later refreshes fail.
|
|
34
|
+
if (!fresh.correlation && !fresh.correlated_changes && !fresh.no_recent_changes) {
|
|
35
|
+
return { recentChanges: { status: "loaded" } };
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
issue: fresh,
|
|
39
|
+
recentChanges: { status: "loaded" },
|
|
40
|
+
onRetry,
|
|
41
|
+
retrying,
|
|
42
|
+
...(query.error ? { refreshFailed: { fetchedAt: query.dataUpdatedAt } } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (query.error instanceof RadarFeatureUnsupportedError) {
|
|
46
|
+
return { recentChanges: { status: "unsupported", upgrade: query.error.radarUpgrade } };
|
|
47
|
+
}
|
|
48
|
+
if (query.error) return { recentChanges: { status: "failed" }, onRetry, retrying };
|
|
49
|
+
return { recentChanges: { status: "loading" } };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Wires a host's issue list (IssuesView or ResourceIssuesSection) to the
|
|
54
|
+
* correlation request: the list reports its open row, this fetches for that
|
|
55
|
+
* one issue, and the open row renders the fresh answer. `onNotFound` refreshes
|
|
56
|
+
* the host's list when the open issue is no longer in the subject's answer.
|
|
57
|
+
*/
|
|
58
|
+
export function useIssueExpansion(onNotFound?: () => void) {
|
|
59
|
+
const [openIssue, setOpenIssue] = useState<Issue | null>(null);
|
|
60
|
+
const query = useIssueCorrelation(openIssue, openIssue !== null);
|
|
61
|
+
const { data, error, isFetching, refetch, dataUpdatedAt } = query;
|
|
62
|
+
const expansion = useMemo(
|
|
63
|
+
() => (openIssue ? issueExpansionFromQuery(openIssue, { data, error, isFetching, dataUpdatedAt, refetch }) : undefined),
|
|
64
|
+
[openIssue, data, error, isFetching, dataUpdatedAt, refetch],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const notFoundRef = useRef(onNotFound);
|
|
68
|
+
notFoundRef.current = onNotFound;
|
|
69
|
+
const notFound = expansion?.recentChanges.status === "not_found";
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (notFound) notFoundRef.current?.();
|
|
72
|
+
}, [notFound, dataUpdatedAt]);
|
|
73
|
+
|
|
74
|
+
const openKey = openIssue ? issueRowKey(openIssue) : null;
|
|
75
|
+
const expandedIssue = useCallback(
|
|
76
|
+
(issue: Issue) => (openKey !== null && issueRowKey(issue) === openKey ? expansion : undefined),
|
|
77
|
+
[openKey, expansion],
|
|
78
|
+
);
|
|
79
|
+
const timelineLinks = useTimelineEventLinks();
|
|
80
|
+
return { onOpenIssueChange: setOpenIssue, expandedIssue, timelineLinks };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Wires a host's issue list to the batched row lookup: the list reports the
|
|
85
|
+
* rows on screen, this fetches the one change each of them names.
|
|
86
|
+
*/
|
|
87
|
+
export function useIssueRowNotes() {
|
|
88
|
+
const [visible, setVisible] = useState<Issue[]>([]);
|
|
89
|
+
const rowChanges = useIssueRowChanges(visible);
|
|
90
|
+
return { rowChanges, onVisibleIssuesChange: setVisible };
|
|
91
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { expect, it, vi } from 'vitest'
|
|
6
|
+
import type { PrometheusStatus } from '../../api/client'
|
|
7
|
+
import { NavCustomizationProvider } from '../../context/NavCustomization'
|
|
8
|
+
vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({ metrics: false }) }))
|
|
9
|
+
|
|
10
|
+
const { MetricsNotConnected, OpenObserveUnavailable } = await import('./MetricsNotConnected')
|
|
11
|
+
|
|
12
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
13
|
+
|
|
14
|
+
it('drops a discovery result once the metrics source changes', async () => {
|
|
15
|
+
vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input) => String(input).includes('/prometheus/connect')
|
|
16
|
+
? new Response(JSON.stringify({ error: 'Prometheus connection failed' }), { status: 502 })
|
|
17
|
+
: new Response(JSON.stringify({ detected: false }))))
|
|
18
|
+
const client = new QueryClient({ defaultOptions: { mutations: { retry: false }, queries: { retry: false } } })
|
|
19
|
+
const container = document.createElement('div')
|
|
20
|
+
const root = createRoot(container)
|
|
21
|
+
const render = (status: PrometheusStatus) => root.render(
|
|
22
|
+
<QueryClientProvider client={client}><NavCustomizationProvider value={{}}>
|
|
23
|
+
<MetricsNotConnected status={status} isWorkload={false} />
|
|
24
|
+
</NavCustomizationProvider></QueryClientProvider>,
|
|
25
|
+
)
|
|
26
|
+
const before: PrometheusStatus = { available: false, connected: false, openobserve: 'local' }
|
|
27
|
+
await act(async () => render(before))
|
|
28
|
+
const discover = () => [...container.querySelectorAll('button')].find((b) => b.textContent === 'Discover metrics')
|
|
29
|
+
await act(async () => discover()!.click())
|
|
30
|
+
expect(container.querySelector('[role="status"]')?.textContent).toBe('No metrics source found.')
|
|
31
|
+
expect(discover()).toBeUndefined()
|
|
32
|
+
|
|
33
|
+
await act(async () => render({ ...before, source: { kind: 'openobserve', via: 'local', warning: 'Checking…', pending: true } }))
|
|
34
|
+
expect(container.querySelector('[role="status"]')).toBeNull()
|
|
35
|
+
expect(discover()).toBeDefined()
|
|
36
|
+
act(() => root.unmount())
|
|
37
|
+
vi.unstubAllGlobals()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('says OpenObserve unavailable once', async () => {
|
|
41
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
42
|
+
const container = document.createElement('div')
|
|
43
|
+
const root = createRoot(container)
|
|
44
|
+
const status: PrometheusStatus = { available: false, connected: true, source: { kind: 'openobserve', via: 'hub', unavailable: true, error: 'OpenObserve unavailable: Radar Hub could not be reached' } }
|
|
45
|
+
await act(async () => root.render(<NavCustomizationProvider value={{}}><OpenObserveUnavailable status={status} /></NavCustomizationProvider>))
|
|
46
|
+
expect(container.textContent?.match(/OpenObserve unavailable/g)).toHaveLength(1)
|
|
47
|
+
expect(container.textContent).toContain('Radar Hub could not be reached')
|
|
48
|
+
act(() => root.unmount())
|
|
49
|
+
vi.unstubAllGlobals()
|
|
50
|
+
})
|