@skyhook-io/radar-app 1.16.3 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/App.tsx +14 -7
- package/src/RadarApp.tsx +27 -17
- package/src/api/client.goneResource.test.ts +49 -0
- package/src/api/client.ts +115 -8
- package/src/api/diagnose.test.ts +40 -0
- package/src/api/diagnose.ts +12 -1
- package/src/api/radarFeatures.render.test.tsx +19 -1
- package/src/api/radarFeatures.ts +3 -0
- package/src/api/traffic.sources.test.ts +55 -0
- package/src/api/traffic.ts +173 -14
- package/src/components/applications/ApplicationsView.tsx +3 -0
- package/src/components/capacity/CapacityPoolDetail.tsx +18 -7
- package/src/components/capacity/CapacityView.test.tsx +31 -1
- package/src/components/capacity/shared.tsx +12 -21
- package/src/components/cnpg/CNPGProtection.tsx +2 -2
- package/src/components/diagnose/AgentSetupNotice.test.tsx +58 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +142 -51
- package/src/components/diagnose/ApplyDialog.ack.test.tsx +47 -0
- package/src/components/diagnose/ApplyDialog.test.tsx +59 -6
- package/src/components/diagnose/ApplyDialog.tsx +26 -28
- package/src/components/diagnose/DiagnoseContext.test.ts +43 -0
- package/src/components/diagnose/DiagnoseContext.tsx +136 -54
- package/src/components/diagnose/DiagnoseSurface.tsx +16 -3
- package/src/components/diagnose/InvestigationView.tsx +39 -2
- package/src/components/diagnose/LocalDiagnoseAction.tsx +40 -20
- package/src/components/diagnose/agentCatalog.ts +2 -2
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/dock/TrafficFlowListTab.tsx +27 -6
- package/src/components/execution/BatchExecutionView.tsx +11 -11
- package/src/components/helm/ChartBrowser.tsx +3 -3
- package/src/components/helm/RevisionHistory.tsx +3 -2
- package/src/components/home/ClusterHealthCard.tsx +7 -0
- package/src/components/home/mcpToolCatalog.ts +1 -1
- package/src/components/resources/renderers/KyvernoPolicyQueued.tsx +2 -1
- package/src/components/resources/renderers/NodeRenderer.tsx +7 -1
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +81 -0
- package/src/components/resources/renderers/ServiceRenderer.tsx +19 -14
- package/src/components/settings/SettingsDialog.tsx +122 -19
- package/src/components/shared/LargeClusterNamespacePicker.tsx +11 -5
- package/src/components/timeline/TimelineList.tsx +3 -0
- package/src/components/timeline/TimelineRetentionNote.test.tsx +49 -0
- package/src/components/timeline/TimelineRetentionNote.tsx +20 -0
- package/src/components/timeline/TimelineView.tsx +7 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +144 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +22 -1
- package/src/components/traffic/TrafficFlowListContext.tsx +12 -4
- package/src/components/traffic/TrafficFocusSearch.tsx +172 -0
- package/src/components/traffic/TrafficGraph.tsx +109 -26
- package/src/components/traffic/TrafficGraphTooLarge.tsx +150 -0
- package/src/components/traffic/TrafficView.tsx +582 -149
- package/src/components/traffic/trafficFilters.test.ts +398 -1
- package/src/components/traffic/trafficFilters.ts +408 -0
- package/src/components/workload/WorkloadView.test.ts +2 -1
- package/src/components/workload/WorkloadView.tsx +135 -290
- package/src/context/TimelineCustomization.tsx +15 -0
- package/src/hooks/useGitOpsWriteGuard.test.tsx +457 -0
- package/src/hooks/useGitOpsWriteGuard.ts +193 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +256 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
getGitOpsResourceStatus,
|
|
4
|
+
gitOpsOwnerFromRelationships,
|
|
5
|
+
type GitOpsOwnerRef,
|
|
6
|
+
type GitOpsStatus,
|
|
7
|
+
type HelmOwnerRef,
|
|
8
|
+
} from '@skyhook-io/k8s-ui'
|
|
9
|
+
import type { Relationships, ResourceRef } from '../types'
|
|
10
|
+
import { kindToPluralWithGroup } from '../utils/navigation'
|
|
11
|
+
import { useResource, useResourceWithRelationships, useResources } from '../api/client'
|
|
12
|
+
|
|
13
|
+
export interface ResolvedGitOpsOwner {
|
|
14
|
+
/** GitOps owner, with an Argo Application's namespace filled in when the
|
|
15
|
+
* tracking label omitted it and exactly one Application matches. */
|
|
16
|
+
owner: GitOpsOwnerRef | null
|
|
17
|
+
/** Owner as reported by relationships, before namespace resolution. */
|
|
18
|
+
rawOwner: GitOpsOwnerRef | null
|
|
19
|
+
/** The owner CR (Application / Kustomization / HelmRelease). */
|
|
20
|
+
ownerObject: any
|
|
21
|
+
ownerPending: boolean
|
|
22
|
+
ownerVerified: boolean
|
|
23
|
+
/** The Argo CD tracking label named no namespace and Radar filled it in
|
|
24
|
+
* from a single Application of that name. */
|
|
25
|
+
ownerMatchedByName: boolean
|
|
26
|
+
ownerStatus: GitOpsStatus | null
|
|
27
|
+
/** The label/annotation that ties the object to its owner. */
|
|
28
|
+
ownerSource: string | null
|
|
29
|
+
helmOwner: HelmOwnerRef | null
|
|
30
|
+
helmSource: string | null
|
|
31
|
+
/** A parent (e.g. the Deployment of a ReplicaSet) consulted when the
|
|
32
|
+
* object carries no GitOps ownership itself. */
|
|
33
|
+
inheritedLookupRef: ResourceRef | null
|
|
34
|
+
lookupPending: boolean
|
|
35
|
+
lookupError: boolean
|
|
36
|
+
/** The parent was read but the server sent no relationships for it (its
|
|
37
|
+
* topology isn't built yet), so an inherited owner is unknown, not absent. */
|
|
38
|
+
relationshipsUnavailable: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Resolves who manages a resource: its own GitOps/Helm tracking metadata or,
|
|
42
|
+
// failing that, the metadata of the workload that owns it.
|
|
43
|
+
export function useResolvedGitOpsOwner({
|
|
44
|
+
kind,
|
|
45
|
+
group,
|
|
46
|
+
namespace,
|
|
47
|
+
name,
|
|
48
|
+
relationships,
|
|
49
|
+
resource,
|
|
50
|
+
enabled = true,
|
|
51
|
+
cacheScope,
|
|
52
|
+
}: {
|
|
53
|
+
kind: string
|
|
54
|
+
group?: string
|
|
55
|
+
namespace: string
|
|
56
|
+
name: string
|
|
57
|
+
relationships: Relationships | undefined
|
|
58
|
+
resource: any
|
|
59
|
+
enabled?: boolean
|
|
60
|
+
/** Keeps these reads apart from the shared resource cache (see useResource). */
|
|
61
|
+
cacheScope?: string
|
|
62
|
+
}): ResolvedGitOpsOwner {
|
|
63
|
+
const active = enabled && Boolean(relationships)
|
|
64
|
+
const relationshipGitopsOwner = useMemo(
|
|
65
|
+
() => (active ? gitOpsOwnerFromRelationships(relationships) : null),
|
|
66
|
+
[active, relationships],
|
|
67
|
+
)
|
|
68
|
+
const inheritedLookupRef = useMemo(
|
|
69
|
+
() =>
|
|
70
|
+
active
|
|
71
|
+
? findInheritedGitOpsLookupRef(relationships, relationshipGitopsOwner, { kind, namespace, name, group })
|
|
72
|
+
: null,
|
|
73
|
+
[active, relationships, relationshipGitopsOwner, kind, namespace, name, group],
|
|
74
|
+
)
|
|
75
|
+
const inherited = useResourceWithRelationships<any>(
|
|
76
|
+
inheritedLookupRef ? kindToPluralWithGroup(inheritedLookupRef.kind, inheritedLookupRef.group ?? '') : '',
|
|
77
|
+
inheritedLookupRef?.namespace ?? '',
|
|
78
|
+
inheritedLookupRef?.name ?? '',
|
|
79
|
+
inheritedLookupRef?.group,
|
|
80
|
+
{ cacheScope },
|
|
81
|
+
)
|
|
82
|
+
const inheritedGitopsOwner = useMemo(
|
|
83
|
+
() => (inheritedLookupRef ? gitOpsOwnerFromRelationships(inherited.data?.relationships) : null),
|
|
84
|
+
[inheritedLookupRef, inherited.data?.relationships],
|
|
85
|
+
)
|
|
86
|
+
const relationshipHelmOwner = useMemo(
|
|
87
|
+
() => (active ? nativeHelmOwnerFromRelationships(relationships, resource?.metadata?.namespace ?? namespace) : null),
|
|
88
|
+
[active, relationships, resource?.metadata?.namespace, namespace],
|
|
89
|
+
)
|
|
90
|
+
const inheritedHelmOwner = useMemo(
|
|
91
|
+
() =>
|
|
92
|
+
inheritedLookupRef
|
|
93
|
+
? nativeHelmOwnerFromRelationships(
|
|
94
|
+
inherited.data?.relationships,
|
|
95
|
+
inherited.data?.resource?.metadata?.namespace ?? namespace,
|
|
96
|
+
)
|
|
97
|
+
: null,
|
|
98
|
+
[inheritedLookupRef, inherited.data?.relationships, inherited.data?.resource?.metadata?.namespace, namespace],
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const rawOwner = relationshipGitopsOwner ?? inheritedGitopsOwner
|
|
102
|
+
const gitOpsSourceResource = relationshipGitopsOwner ? resource : inherited.data?.resource
|
|
103
|
+
const helmOwner = relationshipHelmOwner ?? inheritedHelmOwner
|
|
104
|
+
const helmSourceResource = relationshipHelmOwner ? resource : inherited.data?.resource
|
|
105
|
+
|
|
106
|
+
const shouldResolveArgoNamespace = rawOwner?.tool === 'argocd' && !rawOwner.namespace
|
|
107
|
+
const argoQuery = useResources<any>('applications', undefined, 'argoproj.io', {
|
|
108
|
+
enabled: shouldResolveArgoNamespace,
|
|
109
|
+
cacheScope,
|
|
110
|
+
})
|
|
111
|
+
const argoApplications = argoQuery.data
|
|
112
|
+
const owner = useMemo(() => resolveGitOpsOwner(rawOwner, argoApplications), [rawOwner, argoApplications])
|
|
113
|
+
|
|
114
|
+
const ownerGroup = owner ? gitOpsOwnerGroup(owner) : ''
|
|
115
|
+
const shouldFetchOwner = Boolean(owner?.namespace)
|
|
116
|
+
const ownerQuery = useResource<any>(
|
|
117
|
+
shouldFetchOwner ? owner!.kind : '',
|
|
118
|
+
owner?.namespace ?? '',
|
|
119
|
+
owner?.name ?? '',
|
|
120
|
+
ownerGroup,
|
|
121
|
+
{ enabled: shouldFetchOwner, cacheScope },
|
|
122
|
+
)
|
|
123
|
+
const ownerObject = shouldFetchOwner ? ownerQuery.data : undefined
|
|
124
|
+
|
|
125
|
+
const ownerStatus = useMemo(() => deriveGitOpsOwnerStatus(owner, ownerObject), [owner, ownerObject])
|
|
126
|
+
const ownerSource = useMemo(
|
|
127
|
+
() => describeGitOpsOwnerSource(rawOwner, gitOpsSourceResource),
|
|
128
|
+
[rawOwner, gitOpsSourceResource],
|
|
129
|
+
)
|
|
130
|
+
const helmSource = useMemo(() => describeHelmOwnerSource(helmOwner, helmSourceResource), [helmOwner, helmSourceResource])
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
owner,
|
|
134
|
+
rawOwner,
|
|
135
|
+
ownerObject,
|
|
136
|
+
ownerPending: Boolean(shouldFetchOwner && ownerQuery.isLoading && !ownerQuery.data),
|
|
137
|
+
ownerVerified: Boolean(shouldFetchOwner && ownerQuery.data),
|
|
138
|
+
ownerMatchedByName: Boolean(shouldResolveArgoNamespace && owner?.namespace),
|
|
139
|
+
ownerStatus,
|
|
140
|
+
ownerSource,
|
|
141
|
+
helmOwner,
|
|
142
|
+
helmSource,
|
|
143
|
+
inheritedLookupRef,
|
|
144
|
+
lookupPending: Boolean((inheritedLookupRef && inherited.isPending) || (shouldResolveArgoNamespace && argoQuery.isPending)),
|
|
145
|
+
lookupError: Boolean(inheritedLookupRef && inherited.isError),
|
|
146
|
+
relationshipsUnavailable: Boolean(inheritedLookupRef && inherited.data && !inherited.data.relationships),
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function gitOpsOwnerGroup(owner: GitOpsOwnerRef): string {
|
|
151
|
+
if (owner.tool === 'argocd') return 'argoproj.io'
|
|
152
|
+
if (owner.kind === 'kustomizations') return 'kustomize.toolkit.fluxcd.io'
|
|
153
|
+
return 'helm.toolkit.fluxcd.io'
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The owner as the singular Kind + group the server's APIs take. */
|
|
157
|
+
export function gitOpsOwnerKindRef(owner: GitOpsOwnerRef): { kind: string; group: string } {
|
|
158
|
+
if (owner.tool === 'argocd') return { kind: 'Application', group: 'argoproj.io' }
|
|
159
|
+
if (owner.kind === 'kustomizations') return { kind: 'Kustomization', group: 'kustomize.toolkit.fluxcd.io' }
|
|
160
|
+
return { kind: 'HelmRelease', group: 'helm.toolkit.fluxcd.io' }
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function resolveGitOpsOwner(owner: GitOpsOwnerRef | null, argoApplications: any[] | undefined): GitOpsOwnerRef | null {
|
|
164
|
+
if (!owner || owner.namespace || owner.tool !== 'argocd') return owner
|
|
165
|
+
const matches = (argoApplications ?? []).filter((app) => app?.metadata?.name === owner.name)
|
|
166
|
+
if (matches.length !== 1) return owner
|
|
167
|
+
const namespace = matches[0]?.metadata?.namespace
|
|
168
|
+
return namespace ? { ...owner, namespace } : owner
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function findInheritedGitOpsLookupRef(
|
|
172
|
+
relationships: Relationships | undefined,
|
|
173
|
+
directOwner: GitOpsOwnerRef | null,
|
|
174
|
+
current: ResourceRef,
|
|
175
|
+
): ResourceRef | null {
|
|
176
|
+
if (directOwner) return null
|
|
177
|
+
const inheritedManagerRefs = (relationships?.managedBy ?? []).filter(
|
|
178
|
+
(ref) => !gitOpsOwnerFromRelationships({ managedBy: [ref] }) && !isNativeHelmManager(ref),
|
|
179
|
+
)
|
|
180
|
+
const candidates = [relationships?.deployment, ...inheritedManagerRefs, relationships?.owner].filter(
|
|
181
|
+
Boolean,
|
|
182
|
+
) as ResourceRef[]
|
|
183
|
+
|
|
184
|
+
return candidates.find((ref) => !isCurrentResource(ref, current)) ?? null
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function nativeHelmOwnerFromRelationships(
|
|
188
|
+
relationships: Relationships | undefined,
|
|
189
|
+
fallbackNamespace: string,
|
|
190
|
+
): HelmOwnerRef | null {
|
|
191
|
+
const ref = relationships?.managedBy?.[0]
|
|
192
|
+
if (!ref || !isNativeHelmManager(ref)) return null
|
|
193
|
+
return {
|
|
194
|
+
namespace: ref.namespace || fallbackNamespace,
|
|
195
|
+
name: ref.name,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isCurrentResource(ref: ResourceRef, current: ResourceRef): boolean {
|
|
200
|
+
return (
|
|
201
|
+
kindToPluralWithGroup(ref.kind, ref.group ?? '') === kindToPluralWithGroup(current.kind, current.group ?? '') &&
|
|
202
|
+
ref.namespace === current.namespace &&
|
|
203
|
+
ref.name === current.name &&
|
|
204
|
+
(ref.group ?? '') === (current.group ?? '')
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function isNativeHelmManager(ref: ResourceRef): boolean {
|
|
209
|
+
return ref.kind === 'HelmRelease' && ref.group !== 'helm.toolkit.fluxcd.io'
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function describeGitOpsOwnerSource(owner: GitOpsOwnerRef | null, resource: any): string | null {
|
|
213
|
+
if (!owner || !resource) return null
|
|
214
|
+
const labels = resource.metadata?.labels ?? {}
|
|
215
|
+
const annotations = resource.metadata?.annotations ?? {}
|
|
216
|
+
|
|
217
|
+
if (owner.tool === 'fluxcd') {
|
|
218
|
+
const nameKey = owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/name' : 'kustomize.toolkit.fluxcd.io/name'
|
|
219
|
+
const nsKey =
|
|
220
|
+
owner.kind === 'helmreleases' ? 'helm.toolkit.fluxcd.io/namespace' : 'kustomize.toolkit.fluxcd.io/namespace'
|
|
221
|
+
if (labels[nameKey] || labels[nsKey]) {
|
|
222
|
+
return `${nameKey}=${labels[nameKey] ?? ''}, ${nsKey}=${labels[nsKey] ?? ''}`
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const trackingID = annotations['argocd.argoproj.io/tracking-id']
|
|
227
|
+
if (trackingID) return `argocd.argoproj.io/tracking-id=${trackingID}`
|
|
228
|
+
const argoInstance = labels['argocd.argoproj.io/instance']
|
|
229
|
+
if (argoInstance) return `argocd.argoproj.io/instance=${argoInstance}`
|
|
230
|
+
return null
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function describeHelmOwnerSource(owner: HelmOwnerRef | null, resource: any): string | null {
|
|
234
|
+
if (!owner || !resource) return null
|
|
235
|
+
const annotations = resource.metadata?.annotations ?? {}
|
|
236
|
+
const releaseName = annotations['meta.helm.sh/release-name']
|
|
237
|
+
const releaseNamespace = annotations['meta.helm.sh/release-namespace']
|
|
238
|
+
if (releaseName || releaseNamespace) {
|
|
239
|
+
return `meta.helm.sh/release-name=${releaseName ?? ''}, meta.helm.sh/release-namespace=${releaseNamespace ?? ''}`
|
|
240
|
+
}
|
|
241
|
+
return null
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function deriveGitOpsOwnerStatus(owner: GitOpsOwnerRef | null, resource: any): GitOpsStatus | null {
|
|
245
|
+
if (!owner || !resource || !hasGitOpsStatusPayload(owner, resource)) return null
|
|
246
|
+
return getGitOpsResourceStatus(owner.kind, resource)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function hasGitOpsStatusPayload(owner: GitOpsOwnerRef, resource: any): boolean {
|
|
250
|
+
if (owner.kind === 'applications') {
|
|
251
|
+
const status = resource.status ?? {}
|
|
252
|
+
return Boolean(status.sync?.status || status.health?.status || status.operationState?.phase)
|
|
253
|
+
}
|
|
254
|
+
if (resource.spec?.suspend === true) return true
|
|
255
|
+
return Array.isArray(resource.status?.conditions) && resource.status.conditions.length > 0
|
|
256
|
+
}
|