@skyhook-io/k8s-ui 1.8.10 → 1.8.12
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 +7 -6
- package/src/assets/gitops/argocd.png +0 -0
- package/src/assets/gitops/flux.svg +7 -0
- package/src/components/applications/AppChips.tsx +10 -0
- package/src/components/applications/ApplicationDetail.test.tsx +697 -0
- package/src/components/applications/ApplicationDetail.tsx +3269 -474
- package/src/components/applications/ApplicationsView.tsx +62 -10
- package/src/components/applications/applications-view.test.tsx +47 -0
- package/src/components/applications/index.ts +1 -1
- package/src/components/audit/AuditAlerts.tsx +14 -10
- package/src/components/checks/ChecksView.tsx +2 -3
- package/src/components/checks/severity.ts +14 -10
- package/src/components/cluster-switcher/ClusterSwitcher.tsx +2 -2
- package/src/components/compare/CompareResourcePicker.tsx +2 -2
- package/src/components/gitops/GitOpsDetailLayout.tsx +13 -3
- package/src/components/gitops/GitOpsGraphFilterRail.tsx +2 -1
- package/src/components/gitops/GitOpsTableView.tsx +13 -6
- package/src/components/gitops/ManagedResourcesList.tsx +8 -11
- package/src/components/gitops/SyncCountdown.tsx +26 -17
- package/src/components/gitops/SyncOptionsDialog.test.ts +48 -0
- package/src/components/gitops/SyncOptionsDialog.tsx +190 -46
- package/src/components/gitops/insights/ArgoResourceDiff.tsx +172 -0
- package/src/components/gitops/insights/GitOpsInsightViews.tsx +474 -121
- package/src/components/gitops/insights/index.ts +1 -0
- package/src/components/gitops/insights/insights-helpers.test.ts +102 -1
- package/src/components/gitops/insights/insights-helpers.ts +74 -1
- package/src/components/gitops/tree/GitOpsTreeGraph.tsx +10 -2
- package/src/components/issues/IssuesView.tsx +91 -52
- package/src/components/issues/ResourceIssuesSection.test.tsx +39 -6
- package/src/components/issues/ResourceIssuesSection.tsx +46 -144
- package/src/components/issues/index.ts +3 -0
- package/src/components/issues/issue-timing.ts +53 -0
- package/src/components/issues/issues.test.ts +102 -1
- package/src/components/issues/severity.ts +3 -0
- package/src/components/logs/LogCore.tsx +14 -4
- package/src/components/logs/WorkloadLogsViewer.tsx +31 -6
- package/src/components/logs/useLogStream.ts +8 -1
- package/src/components/namespace-switcher/NamespacePicker.tsx +86 -107
- package/src/components/resources/ResourcesSidebar.test.tsx +71 -0
- package/src/components/resources/ResourcesSidebar.tsx +46 -46
- package/src/components/resources/ResourcesView.selected-kind.test.ts +143 -0
- package/src/components/resources/ResourcesView.tsx +233 -51
- package/src/components/resources/renderers/AWSMachineRenderer.tsx +3 -2
- package/src/components/resources/renderers/AWSManagedClusterRenderer.tsx +3 -2
- package/src/components/resources/renderers/AWSManagedControlPlaneRenderer.tsx +3 -2
- package/src/components/resources/renderers/AWSManagedMachinePoolRenderer.tsx +3 -2
- package/src/components/resources/renderers/AzureMachineRenderer.tsx +3 -2
- package/src/components/resources/renderers/AzureManagedControlPlaneRenderer.tsx +3 -2
- package/src/components/resources/renderers/AzureManagedMachinePoolRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIClusterRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIKubeadmControlPlaneRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIMachineDeploymentRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIMachineHealthCheckRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIMachinePoolRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIMachineRenderer.tsx +3 -2
- package/src/components/resources/renderers/CAPIMachineSetRenderer.tsx +3 -2
- package/src/components/resources/renderers/CertificateRenderer.tsx +3 -2
- package/src/components/resources/renderers/CertificateRequestRenderer.tsx +3 -2
- package/src/components/resources/renderers/ClusterComplianceReportRenderer.tsx +2 -2
- package/src/components/resources/renderers/CompositeRenderer.tsx +3 -2
- package/src/components/resources/renderers/CronWorkflowRenderer.tsx +99 -0
- package/src/components/resources/renderers/ExternalSecretRenderer.tsx +3 -2
- package/src/components/resources/renderers/GCPMachineRenderer.tsx +3 -2
- package/src/components/resources/renderers/GCPManagedControlPlaneRenderer.tsx +3 -2
- package/src/components/resources/renderers/GCPManagedMachinePoolRenderer.tsx +3 -2
- package/src/components/resources/renderers/GRPCRouteRenderer.tsx +7 -3
- package/src/components/resources/renderers/GatewayClassRenderer.tsx +3 -2
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +7 -3
- package/src/components/resources/renderers/JobRenderer.tsx +3 -1
- package/src/components/resources/renderers/KarpenterEC2NodeClassRenderer.tsx +3 -2
- package/src/components/resources/renderers/KarpenterNodeClaimRenderer.tsx +3 -2
- package/src/components/resources/renderers/KarpenterNodePoolRenderer.tsx +3 -2
- package/src/components/resources/renderers/KedaScaledJobRenderer.tsx +3 -2
- package/src/components/resources/renderers/KedaScaledObjectRenderer.tsx +3 -2
- package/src/components/resources/renderers/ManagedResourceRenderer.tsx +3 -2
- package/src/components/resources/renderers/PVCRenderer.tsx +3 -2
- package/src/components/resources/renderers/PrometheusRuleRenderer.tsx +2 -2
- package/src/components/resources/renderers/SbomReportRenderer.tsx +2 -2
- package/src/components/resources/renderers/SealedSecretRenderer.tsx +3 -2
- package/src/components/resources/renderers/SecretRenderer.tsx +2 -0
- package/src/components/resources/renderers/SecretStoreRenderer.tsx +3 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +58 -40
- package/src/components/resources/renderers/SimpleRouteRenderer.tsx +7 -3
- package/src/components/resources/renderers/VulnerabilityReportRenderer.tsx +2 -2
- package/src/components/resources/renderers/WorkflowRenderer.test.tsx +43 -0
- package/src/components/resources/renderers/WorkflowRenderer.tsx +60 -78
- package/src/components/resources/renderers/index.ts +1 -0
- package/src/components/resources/resource-utils-argo.test.ts +18 -1
- package/src/components/resources/resource-utils-argo.ts +8 -0
- package/src/components/resources/resource-utils-capi.ts +1 -1
- package/src/components/resources/resource-utils.ts +31 -0
- package/src/components/shared/DetailShell.tsx +2 -2
- package/src/components/shared/ResourceActionsBar.tsx +142 -111
- package/src/components/shared/ResourceRendererDispatch.tsx +33 -4
- package/src/components/shared/UnifiedDiff.tsx +51 -0
- package/src/components/shared/index.ts +1 -0
- package/src/components/timeline/TimelineList.tsx +375 -354
- package/src/components/timeline/TimelineStrip.test.tsx +194 -0
- package/src/components/timeline/TimelineStrip.tsx +836 -0
- package/src/components/timeline/TimelineSwimlanes.test.tsx +1028 -0
- package/src/components/timeline/TimelineSwimlanes.tsx +2498 -593
- package/src/components/timeline/TimelineToolbar.test.tsx +320 -0
- package/src/components/timeline/TimelineToolbar.tsx +759 -0
- package/src/components/timeline/TimelineToolbarState.test.tsx +88 -0
- package/src/components/timeline/index.ts +23 -0
- package/src/components/timeline/scrubber-math.test.ts +235 -0
- package/src/components/timeline/scrubber-math.ts +249 -0
- package/src/components/timeline/shared.test.tsx +219 -0
- package/src/components/timeline/shared.tsx +232 -447
- package/src/components/timeline/timeline-filters.test.ts +196 -0
- package/src/components/timeline/timeline-filters.ts +180 -0
- package/src/components/timeline/timeline-lane-sort.test.ts +97 -0
- package/src/components/timeline/timeline-lane-sort.ts +77 -0
- package/src/components/timeline/timeline-live.test.ts +131 -0
- package/src/components/timeline/timeline-live.ts +77 -0
- package/src/components/topology/GroupNode.tsx +9 -2
- package/src/components/topology/K8sResourceNode.test.ts +11 -0
- package/src/components/topology/K8sResourceNode.tsx +387 -243
- package/src/components/topology/TopologyBreadcrumb.tsx +30 -0
- package/src/components/topology/TopologyControls.tsx +3 -1
- package/src/components/topology/TopologyFilterSidebar.tsx +9 -0
- package/src/components/topology/TopologyGraph.tsx +149 -90
- package/src/components/topology/TopologyOverlayBar.tsx +30 -0
- package/src/components/topology/TopologySearch.tsx +25 -17
- package/src/components/topology/index.ts +2 -0
- package/src/components/topology/layout.ts +10 -2
- package/src/components/topology/topology.css +0 -92
- package/src/components/ui/Badge.tsx +6 -1
- package/src/components/ui/CodeViewer.tsx +2 -2
- package/src/components/ui/Collapse.tsx +59 -0
- package/src/components/ui/ConfirmDialog.tsx +7 -3
- package/src/components/ui/DialogPortal.tsx +31 -9
- package/src/components/ui/Input.tsx +24 -0
- package/src/components/ui/MultiSelectPicker.test.tsx +101 -0
- package/src/components/ui/MultiSelectPicker.tsx +167 -0
- package/src/components/ui/PaneLoader.tsx +10 -2
- package/src/components/ui/ResourceBar.tsx +68 -25
- package/src/components/ui/SearchBox.tsx +18 -4
- package/src/components/ui/SearchPillInput.tsx +2 -2
- package/src/components/ui/SelectMenu.tsx +81 -0
- package/src/components/ui/drawer-components.tsx +48 -32
- package/src/components/ui/index.ts +6 -0
- package/src/components/ui/severity-tone.ts +11 -4
- package/src/components/workload/ResourceDetailDrawer.tsx +6 -2
- package/src/components/workload/WorkloadView.tsx +2706 -475
- package/src/components/workload/index.ts +1 -1
- package/src/theme/tailwind-theme.css +1 -0
- package/src/theme/variables.css +2 -1
- package/src/types/core.ts +57 -4
- package/src/types/gitops-insights.ts +69 -1
- package/src/types/gitops.ts +3 -3
- package/src/utils/application-history.test.ts +538 -0
- package/src/utils/application-history.ts +257 -0
- package/src/utils/application-topology.test.ts +198 -0
- package/src/utils/application-topology.ts +261 -0
- package/src/utils/applications.test.ts +201 -1
- package/src/utils/applications.ts +1182 -393
- package/src/utils/index.ts +3 -0
- package/src/utils/navigation.test.ts +32 -1
- package/src/utils/navigation.ts +70 -0
- package/src/utils/resource-hierarchy.test.ts +1024 -1
- package/src/utils/resource-hierarchy.ts +925 -267
- package/src/utils/resource-icons.ts +2 -0
- package/src/utils/topology-neighborhood.test.ts +202 -1
- package/src/utils/topology-neighborhood.ts +194 -13
- package/src/utils/workflow-execution.test.ts +556 -0
- package/src/utils/workflow-execution.ts +814 -0
- package/src/utils/workload-colors.ts +2 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useMemo, useEffect, useRef, useCallback, type ReactNode } from 'react'
|
|
1
|
+
import { useState, useMemo, useEffect, useRef, useCallback, type ComponentType, type ReactNode } from 'react'
|
|
2
2
|
import { flushSync } from 'react-dom'
|
|
3
3
|
import { useRefreshAnimation } from '../../hooks/useRefreshAnimation'
|
|
4
4
|
import { startViewTransitionSafe } from '../../utils/view-transition'
|
|
@@ -11,18 +11,27 @@ import {
|
|
|
11
11
|
ArrowRight,
|
|
12
12
|
RefreshCw,
|
|
13
13
|
Activity,
|
|
14
|
+
AlertTriangle,
|
|
14
15
|
Terminal,
|
|
15
16
|
Layers,
|
|
16
17
|
FileText,
|
|
17
18
|
Copy,
|
|
18
19
|
Check,
|
|
20
|
+
CheckCircle2,
|
|
21
|
+
Clock3,
|
|
22
|
+
Boxes,
|
|
23
|
+
ExternalLink,
|
|
24
|
+
GitBranch,
|
|
19
25
|
Minimize2,
|
|
20
26
|
Maximize2,
|
|
27
|
+
Scale,
|
|
28
|
+
Server,
|
|
21
29
|
X,
|
|
22
30
|
BarChart3,
|
|
23
31
|
Network,
|
|
32
|
+
DollarSign,
|
|
24
33
|
} from 'lucide-react'
|
|
25
|
-
import type { TimelineEvent, ResourceRef, Relationships, SelectedResource, ResolvedEnvFrom, Topology, TopologyNode, HPADiagnosis } from '../../types'
|
|
34
|
+
import type { TimelineEvent, ResourceRef, Relationships, SelectedResource, ResolvedEnvFrom, Topology, TopologyNode, HPADiagnosis, WorkloadPodInfo } from '../../types'
|
|
26
35
|
import type { GitOpsStatus } from '../../types/gitops'
|
|
27
36
|
import type { NavigateToResource } from '../../utils/navigation'
|
|
28
37
|
import { refToSelectedResource, pluralToKind, kindToPlural, apiVersionToGroup } from '../../utils/navigation'
|
|
@@ -30,34 +39,50 @@ import { neighborhoodFor, seedNodeIds } from '../../utils/topology-neighborhood'
|
|
|
30
39
|
import { TopologyGraph } from '../topology/TopologyGraph'
|
|
31
40
|
import { gitOpsOwnerFromRelationships, type GitOpsOwnerRef } from '../../utils/gitops-owner'
|
|
32
41
|
import { gitOpsRouteForResource } from '../../utils/gitops-route'
|
|
33
|
-
import { isChangeEvent, isHistoricalEvent } from '../../types'
|
|
34
|
-
import { getKindBadgeColor, getHealthBadgeColor } from '../../utils/badge-colors'
|
|
35
42
|
import { buildResourceHierarchy, getAllEventsFromHierarchy, isProblematicEvent, type ResourceLane } from '../../utils/resource-hierarchy'
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
type ZoomLevel,
|
|
39
|
-
formatAxisTime,
|
|
40
|
-
EventMarker,
|
|
41
|
-
EventDotLegend,
|
|
42
|
-
HealthSpanLegend,
|
|
43
|
-
HealthSpan,
|
|
44
|
-
ZoomControls,
|
|
45
|
-
buildHealthSpans,
|
|
46
|
-
timeToX,
|
|
47
|
-
calculateTimeRange,
|
|
48
|
-
} from '../timeline/shared'
|
|
43
|
+
import { TimelineSwimlanes, type TimeWindow } from '../timeline/TimelineSwimlanes'
|
|
44
|
+
import { TimelineList } from '../timeline/TimelineList'
|
|
49
45
|
import { ResourceActionsBar } from '../shared/ResourceActionsBar'
|
|
50
46
|
import { EditableYamlView, SaveSuccessAnimation } from '../shared/EditableYamlView'
|
|
51
|
-
import { ResourceRendererDispatch, getResourceStatus, type RendererOverrides } from '../shared/ResourceRendererDispatch'
|
|
47
|
+
import { ResourceRendererDispatch, getResourceStatus, diagnoseHealthHint, type DiagnoseHealthHint, type RendererOverrides } from '../shared/ResourceRendererDispatch'
|
|
52
48
|
import type { ScalerDiagnosis } from '../resources/renderers/WorkloadRenderer'
|
|
53
49
|
import { DetailShell, type DetailShellTab } from '../shared/DetailShell'
|
|
54
50
|
import { HelmManagedByChip, ManagedByChip, type HelmOwnerRef } from '../shared/ManagedByChip'
|
|
55
|
-
import { getKindColorOutline, displayKindName, OperationalIssuesShownContext } from '../ui/drawer-components'
|
|
51
|
+
import { getKindColorOutline, displayKindName, OperationalIssuesShownContext, ResourceRefBadge } from '../ui/drawer-components'
|
|
52
|
+
import { Badge, type BadgeSeverity } from '../ui/Badge'
|
|
53
|
+
import { Tooltip } from '../ui/Tooltip'
|
|
56
54
|
import { midTruncate } from '../../utils/format'
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
import { hpaStateLabel } from '../resources/resource-utils-hpa'
|
|
56
|
+
import {
|
|
57
|
+
cronToHuman,
|
|
58
|
+
formatAge,
|
|
59
|
+
formatDuration,
|
|
60
|
+
getGatewayAddresses,
|
|
61
|
+
getGatewayListeners,
|
|
62
|
+
getIngressAddress,
|
|
63
|
+
getIngressHosts,
|
|
64
|
+
getServiceExternalIP,
|
|
65
|
+
} from '../resources/resource-utils'
|
|
66
|
+
import { ServicePortCards, type ServicePortRenderProps } from '../resources/renderers/ServiceRenderer'
|
|
67
|
+
|
|
68
|
+
export type WorkloadTabType = 'overview' | 'topology' | 'timeline' | 'logs' | 'metrics' | 'cost' | 'yaml'
|
|
59
69
|
type TabType = WorkloadTabType
|
|
60
70
|
|
|
71
|
+
export interface ResourceOwnershipContext {
|
|
72
|
+
application?: {
|
|
73
|
+
key: string
|
|
74
|
+
name: string
|
|
75
|
+
}
|
|
76
|
+
workload: ResourceRef
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ServingResourceDetail {
|
|
80
|
+
ref: ResourceRef
|
|
81
|
+
resource?: any
|
|
82
|
+
loading?: boolean
|
|
83
|
+
error?: Error | null
|
|
84
|
+
}
|
|
85
|
+
|
|
61
86
|
// ============================================================================
|
|
62
87
|
// MAIN WORKLOAD VIEW — presentation only, data injected via props
|
|
63
88
|
// ============================================================================
|
|
@@ -105,6 +130,10 @@ interface WorkloadViewProps {
|
|
|
105
130
|
scopeControls?: ReactNode
|
|
106
131
|
/** Hide WorkloadView's own breadcrumb/identity header when a host page owns that chrome. */
|
|
107
132
|
compactHeader?: boolean
|
|
133
|
+
/** High-confidence containment context for resources whose controller ownership is reliable, currently Pods. */
|
|
134
|
+
ownershipContext?: ResourceOwnershipContext
|
|
135
|
+
/** Open the application wrapper for ownership breadcrumbs. */
|
|
136
|
+
onOpenApplication?: (appKey: string) => void
|
|
108
137
|
|
|
109
138
|
// ── Data (injected by wrapper) ──────────────────────────────────────────
|
|
110
139
|
/** The resource data object */
|
|
@@ -117,6 +146,17 @@ interface WorkloadViewProps {
|
|
|
117
146
|
hpaDiagnosis?: HPADiagnosis
|
|
118
147
|
/** Compact diagnosis for autoscalers controlling this workload */
|
|
119
148
|
scalerDiagnostics?: ScalerDiagnosis[]
|
|
149
|
+
/** Pod readiness data from the host's workload-pods endpoint. Optional so
|
|
150
|
+
* shared consumers can still render from relationships when they do not wire
|
|
151
|
+
* Radar-specific data hooks. */
|
|
152
|
+
workloadPods?: WorkloadPodInfo[]
|
|
153
|
+
workloadPodsLoading?: boolean
|
|
154
|
+
workloadPodsError?: Error | null
|
|
155
|
+
/** Full objects for service/route refs related to this workload. Optional;
|
|
156
|
+
* overview falls back to relationship refs when hosts do not fetch them. */
|
|
157
|
+
servingResources?: ServingResourceDetail[]
|
|
158
|
+
renderServicePortAction?: (props: ServicePortRenderProps) => ReactNode
|
|
159
|
+
renderServicePortPanel?: (props: ServicePortRenderProps) => ReactNode
|
|
120
160
|
/** Whether the resource is loading */
|
|
121
161
|
isLoading?: boolean
|
|
122
162
|
/** Fetch error for the resource (preserves status + message so the
|
|
@@ -128,6 +168,8 @@ interface WorkloadViewProps {
|
|
|
128
168
|
// ── Timeline data ────────────────────────────────────────────────────────
|
|
129
169
|
/** All timeline events for this resource's namespace */
|
|
130
170
|
allEvents?: TimelineEvent[]
|
|
171
|
+
/** Persisted lifecycle events reconstructed for resources related to this workload. */
|
|
172
|
+
relatedTimelineEvents?: TimelineEvent[]
|
|
131
173
|
/** Whether timeline events are loading */
|
|
132
174
|
eventsLoading?: boolean
|
|
133
175
|
/** Topology data for hierarchy building + the Topology tab's neighborhood. */
|
|
@@ -156,7 +198,7 @@ interface WorkloadViewProps {
|
|
|
156
198
|
/** Controlled active tab. If not provided, managed internally. */
|
|
157
199
|
activeTab?: TabType
|
|
158
200
|
/** Called when tab changes (for URL sync etc.) */
|
|
159
|
-
onTabChange?: (tab: TabType) => void
|
|
201
|
+
onTabChange?: (tab: TabType, opts?: { replace?: boolean }) => void
|
|
160
202
|
|
|
161
203
|
// ── GitOps navigation ─────────────────────────────────────────────────────
|
|
162
204
|
/**
|
|
@@ -206,8 +248,18 @@ interface WorkloadViewProps {
|
|
|
206
248
|
initialContainer: string | null
|
|
207
249
|
onConsumeInitialContainer: () => void
|
|
208
250
|
}) => ReactNode
|
|
251
|
+
/** Render a full replacement for the expanded Overview tab. */
|
|
252
|
+
renderExpandedOverview?: (props: {
|
|
253
|
+
kind: string
|
|
254
|
+
apiKind: string
|
|
255
|
+
namespace: string
|
|
256
|
+
name: string
|
|
257
|
+
resource: any
|
|
258
|
+
}) => ReactNode
|
|
209
259
|
/** Render the metrics tab content */
|
|
210
260
|
renderMetricsTab?: (props: { kind: string; namespace: string; name: string }) => ReactNode
|
|
261
|
+
/** Render the cost tab content */
|
|
262
|
+
renderCostTab?: (props: { kind: string; namespace: string; name: string }) => ReactNode
|
|
211
263
|
/** Render a read-only YAML view for a related object from the workload's
|
|
212
264
|
* neighborhood. Providing this turns the YAML tab into an object explorer
|
|
213
265
|
* (rail of the workload + its Services/config/policies/pods); omitting it
|
|
@@ -216,8 +268,12 @@ interface WorkloadViewProps {
|
|
|
216
268
|
renderRelatedYaml?: (ref: { kind: string; namespace: string; name: string; group?: string }) => ReactNode
|
|
217
269
|
/** Whether metrics are available for this resource kind */
|
|
218
270
|
isMetricsAvailable?: (kind: string, resource: any) => boolean
|
|
271
|
+
/** Whether cost is available for this resource kind */
|
|
272
|
+
isCostAvailable?: (kind: string, resource: any) => boolean
|
|
219
273
|
/** Render extra content at the bottom of the overview tab (e.g. audit findings) */
|
|
220
274
|
renderOverviewExtra?: (props: { kind: string; namespace: string; name: string }) => ReactNode
|
|
275
|
+
/** Render lightweight overview intro content before the default renderer. */
|
|
276
|
+
renderOverviewIntro?: (props: { kind: string; namespace: string; name: string }) => ReactNode
|
|
221
277
|
/** Render content at the TOP of the overview tab, above the renderer (e.g. live
|
|
222
278
|
* Operational Issues). Optional + additive — consumers that don't pass it are
|
|
223
279
|
* unaffected. Only rendered when `hasOperationalIssues` is true: the lead
|
|
@@ -229,6 +285,10 @@ interface WorkloadViewProps {
|
|
|
229
285
|
* live issues for this resource). Avoids showing the same failure twice.
|
|
230
286
|
* Also gates the `renderOverviewLead` wrapper (see above). */
|
|
231
287
|
hasOperationalIssues?: boolean
|
|
288
|
+
/** True while the live-issues fetch is still pending. Renderers suppress their
|
|
289
|
+
* banners during this window too — a banner whose failure the pipeline covers
|
|
290
|
+
* would otherwise flash on first paint before the issues arrive and hide it. */
|
|
291
|
+
operationalIssuesPending?: boolean
|
|
232
292
|
|
|
233
293
|
// ── Duplicate ────────────────────────────────────────────────────────────
|
|
234
294
|
/** Duplicate handler — opens create dialog with this resource's YAML */
|
|
@@ -266,17 +326,26 @@ export function WorkloadView({
|
|
|
266
326
|
hideBackButton,
|
|
267
327
|
scopeControls,
|
|
268
328
|
compactHeader,
|
|
329
|
+
ownershipContext,
|
|
330
|
+
onOpenApplication,
|
|
269
331
|
// Data
|
|
270
332
|
resource,
|
|
271
333
|
relationships,
|
|
272
334
|
certificateInfo,
|
|
273
335
|
hpaDiagnosis,
|
|
274
336
|
scalerDiagnostics,
|
|
337
|
+
workloadPods,
|
|
338
|
+
workloadPodsLoading = false,
|
|
339
|
+
workloadPodsError = null,
|
|
340
|
+
servingResources,
|
|
341
|
+
renderServicePortAction,
|
|
342
|
+
renderServicePortPanel,
|
|
275
343
|
isLoading: resourceLoading = false,
|
|
276
344
|
resourceError,
|
|
277
345
|
refetch: refetchProp,
|
|
278
346
|
// Timeline
|
|
279
347
|
allEvents,
|
|
348
|
+
relatedTimelineEvents = [],
|
|
280
349
|
eventsLoading = false,
|
|
281
350
|
topology,
|
|
282
351
|
resourceFocusedK8sEvents,
|
|
@@ -296,15 +365,20 @@ export function WorkloadView({
|
|
|
296
365
|
onTabChange,
|
|
297
366
|
// Render props
|
|
298
367
|
renderLogsTab,
|
|
368
|
+
renderExpandedOverview,
|
|
299
369
|
renderRelatedYaml,
|
|
300
370
|
renderMetricsTab,
|
|
371
|
+
renderCostTab,
|
|
301
372
|
isMetricsAvailable,
|
|
373
|
+
isCostAvailable,
|
|
302
374
|
// Duplicate
|
|
303
375
|
onDuplicate,
|
|
304
376
|
onDownload,
|
|
305
377
|
renderOverviewExtra,
|
|
378
|
+
renderOverviewIntro,
|
|
306
379
|
renderOverviewLead,
|
|
307
380
|
hasOperationalIssues,
|
|
381
|
+
operationalIssuesPending,
|
|
308
382
|
// Actions bar
|
|
309
383
|
actionsBarProps,
|
|
310
384
|
// Renderer overrides
|
|
@@ -349,7 +423,6 @@ export function WorkloadView({
|
|
|
349
423
|
}, [])
|
|
350
424
|
|
|
351
425
|
const [selectedEventId, setSelectedEventId] = useState<string | null>(null)
|
|
352
|
-
const [zoom, setZoom] = useState<ZoomLevel>(1)
|
|
353
426
|
const [selectedPod, setSelectedPod] = useState<string | null>(null)
|
|
354
427
|
const [initialContainer, setInitialContainer] = useState<string | null>(null)
|
|
355
428
|
const [copied, setCopied] = useState<string | null>(null)
|
|
@@ -386,7 +459,6 @@ export function WorkloadView({
|
|
|
386
459
|
// A deep-linked ?tab=topology that turns out unavailable falls back to
|
|
387
460
|
// overview instead of rendering an empty body under a hidden tab.
|
|
388
461
|
const topologyTabHidden = !!topology && (!neighborhood || neighborhood.nodes.length === 0)
|
|
389
|
-
const effectiveTab: TabType = activeTab === 'topology' && topologyTabHidden ? 'overview' : activeTab
|
|
390
462
|
|
|
391
463
|
// YAML tab object rail — the same neighborhood, as a manifest list: the
|
|
392
464
|
// workload first, then routing → config → policy/scaling → ownership.
|
|
@@ -433,8 +505,10 @@ export function WorkloadView({
|
|
|
433
505
|
|
|
434
506
|
// Flatten events from hierarchy
|
|
435
507
|
const resourceEvents = useMemo(() => {
|
|
436
|
-
|
|
437
|
-
|
|
508
|
+
const events = [...getAllEventsFromHierarchy(resourceLanes), ...relatedTimelineEvents]
|
|
509
|
+
const unique = new Map(events.map((event) => [event.id, event]))
|
|
510
|
+
return Array.from(unique.values()).sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp) || a.id.localeCompare(b.id))
|
|
511
|
+
}, [resourceLanes, relatedTimelineEvents])
|
|
438
512
|
const overviewEvents = resourceEvents.length > 0 ? resourceEvents : (resourceFocusedK8sEvents ?? [])
|
|
439
513
|
const overviewEventsLoading = resourceEvents.length > 0 ? eventsLoading : resourceFocusedEventsLoading
|
|
440
514
|
const overviewEventsError = resourceEvents.length > 0 ? undefined : resourceFocusedK8sError
|
|
@@ -462,6 +536,7 @@ export function WorkloadView({
|
|
|
462
536
|
const combined = [
|
|
463
537
|
...pods,
|
|
464
538
|
...childPods.map(p => ({ kind: 'Pod' as const, namespace: p.namespace, name: p.name })),
|
|
539
|
+
...(workloadPods ?? []).map(p => ({ kind: 'Pod' as const, namespace, name: p.name })),
|
|
465
540
|
]
|
|
466
541
|
const seen = new Set<string>()
|
|
467
542
|
return combined.filter(p => {
|
|
@@ -470,7 +545,7 @@ export function WorkloadView({
|
|
|
470
545
|
seen.add(key)
|
|
471
546
|
return true
|
|
472
547
|
})
|
|
473
|
-
}, [pods, childPods])
|
|
548
|
+
}, [pods, childPods, workloadPods, namespace])
|
|
474
549
|
|
|
475
550
|
// Metadata
|
|
476
551
|
const metadata = useMemo(() => extractMetadata(kind, resource), [kind, resource])
|
|
@@ -562,8 +637,32 @@ export function WorkloadView({
|
|
|
562
637
|
], [active, expanded, onBack, onClose, switchView]))
|
|
563
638
|
|
|
564
639
|
const status = getResourceStatus(apiKind, resource)
|
|
640
|
+
const showOwnershipHeading = kind === 'Pod' && Boolean(ownershipContext)
|
|
641
|
+
const headerImage = metadata.find(m => m.label === 'Image')?.value
|
|
642
|
+
|
|
643
|
+
// The AI/Diagnose action lives in the header chrome (next to expand/refresh/close),
|
|
644
|
+
// set apart from the imperative ops in the action bar — it's an invitation to
|
|
645
|
+
// understand the resource, not another verb to run on it. Adaptive by health:
|
|
646
|
+
// prominent "Diagnose" on a problem, a quiet icon when fine. Rendered via the host
|
|
647
|
+
// slot (DiagnoseCustomization); standalone Radar injects it, Hub overrides it.
|
|
648
|
+
const renderDiagnose = actionsBarProps?.renderDiagnose as
|
|
649
|
+
| ((ctx: { kind: string; namespace: string; name: string; health?: DiagnoseHealthHint }) => ReactNode)
|
|
650
|
+
| undefined
|
|
651
|
+
const diagnoseAction = renderDiagnose?.({
|
|
652
|
+
kind: apiKind,
|
|
653
|
+
namespace,
|
|
654
|
+
name,
|
|
655
|
+
health: diagnoseHealthHint(apiKind, resource),
|
|
656
|
+
})
|
|
565
657
|
|
|
566
658
|
const showMetricsTab = isMetricsAvailable ? isMetricsAvailable(kind, resource) : false
|
|
659
|
+
const showCostTab = isCostAvailable ? isCostAvailable(kind, resource) : false
|
|
660
|
+
const logsTabVisible = Boolean(renderLogsTab) && (allPods.length > 0 || LOGS_TAB_WITHOUT_PODS_KINDS.has(kindToPlural(kind).toLowerCase()))
|
|
661
|
+
const metricsTabVisible = Boolean(showMetricsTab && renderMetricsTab)
|
|
662
|
+
const costTabVisible = Boolean(showCostTab && renderCostTab)
|
|
663
|
+
const podEvidenceLoading = resourceLoading || workloadPodsLoading || eventsLoading
|
|
664
|
+
const logsFallbackReady = !renderLogsTab || (!logsTabVisible && !podEvidenceLoading)
|
|
665
|
+
const requestedTab: TabType = activeTab
|
|
567
666
|
const tabs: DetailShellTab<TabType>[] = [
|
|
568
667
|
{ id: 'overview', label: 'Overview', icon: <Layers className="w-4 h-4" /> },
|
|
569
668
|
{ id: 'topology', label: 'Topology', icon: <Network className="w-4 h-4" />, hidden: topologyTabHidden },
|
|
@@ -573,10 +672,27 @@ export function WorkloadView({
|
|
|
573
672
|
icon: <Activity className="w-4 h-4" />,
|
|
574
673
|
badge: resourceEvents.length > 0 ? <span className="ml-1 badge-sm bg-theme-elevated">{resourceEvents.length}</span> : undefined,
|
|
575
674
|
},
|
|
576
|
-
{ id: 'logs', label: 'Logs', icon: <Terminal className="w-4 h-4" />, hidden: !
|
|
577
|
-
{ id: 'metrics', label: 'Metrics', icon: <BarChart3 className="w-4 h-4" />, hidden: !
|
|
675
|
+
{ id: 'logs', label: 'Logs', icon: <Terminal className="w-4 h-4" />, hidden: !logsTabVisible },
|
|
676
|
+
{ id: 'metrics', label: 'Metrics', icon: <BarChart3 className="w-4 h-4" />, hidden: !metricsTabVisible },
|
|
677
|
+
{ id: 'cost', label: 'Cost', icon: <DollarSign className="w-4 h-4" />, hidden: !costTabVisible },
|
|
578
678
|
{ id: 'yaml', label: 'YAML', icon: <FileText className="w-4 h-4" /> },
|
|
579
679
|
]
|
|
680
|
+
const requestedTabAvailable = tabs.some((tab) => tab.id === requestedTab && !tab.hidden)
|
|
681
|
+
const effectiveTab: TabType = requestedTabAvailable ? requestedTab : 'overview'
|
|
682
|
+
const shouldCommitFallback =
|
|
683
|
+
requestedTab !== 'overview' &&
|
|
684
|
+
!requestedTabAvailable &&
|
|
685
|
+
(
|
|
686
|
+
(requestedTab === 'topology' && topologyTabHidden) ||
|
|
687
|
+
(requestedTab === 'metrics' && (!renderMetricsTab || (!!resource && !resourceLoading && !showMetricsTab))) ||
|
|
688
|
+
(requestedTab === 'cost' && (!renderCostTab || (!!resource && !resourceLoading && !showCostTab))) ||
|
|
689
|
+
(requestedTab === 'logs' && logsFallbackReady)
|
|
690
|
+
)
|
|
691
|
+
useEffect(() => {
|
|
692
|
+
if (shouldCommitFallback && activeTab !== 'overview') onTabChange?.('overview', { replace: true })
|
|
693
|
+
}, [activeTab, onTabChange, shouldCommitFallback])
|
|
694
|
+
const expandedOverview = expanded ? renderExpandedOverview?.({ kind, apiKind, namespace, name, resource }) : null
|
|
695
|
+
const overviewIntro = renderOverviewIntro?.({ kind, namespace, name })
|
|
580
696
|
|
|
581
697
|
// ── Collapsed (drawer) mode ──────────────────────────────────────────────
|
|
582
698
|
if (!expanded) {
|
|
@@ -596,39 +712,46 @@ export function WorkloadView({
|
|
|
596
712
|
</span>
|
|
597
713
|
)}
|
|
598
714
|
</div>
|
|
599
|
-
<div className="flex items-center gap-1">
|
|
715
|
+
<div className="flex items-center gap-1.5">
|
|
716
|
+
{diagnoseAction}
|
|
600
717
|
{onExpand && (
|
|
718
|
+
<Tooltip content="Open full view" delay={150} position="bottom">
|
|
719
|
+
<button
|
|
720
|
+
onClick={() => onExpand({ yaml: showYaml })}
|
|
721
|
+
// Pre-mount the fullscreen view on hover/press so the click starts
|
|
722
|
+
// the morph instantly (its heavy mount is already paid for).
|
|
723
|
+
onPointerEnter={onExpandIntent}
|
|
724
|
+
onPointerDown={onExpandIntent}
|
|
725
|
+
onPointerLeave={onCancelExpandIntent}
|
|
726
|
+
className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded"
|
|
727
|
+
aria-label="Open full view"
|
|
728
|
+
>
|
|
729
|
+
<Maximize2 className="w-4 h-4" />
|
|
730
|
+
</button>
|
|
731
|
+
</Tooltip>
|
|
732
|
+
)}
|
|
733
|
+
<Tooltip content="Refresh" delay={150} position="bottom">
|
|
601
734
|
<button
|
|
602
|
-
onClick={() =>
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
title="Open full view"
|
|
735
|
+
onClick={() => refetch()}
|
|
736
|
+
disabled={isRefreshAnimating}
|
|
737
|
+
className={clsx(
|
|
738
|
+
'p-1.5 hover:bg-theme-elevated rounded disabled:opacity-50 transition-colors duration-500',
|
|
739
|
+
refreshPhase === 'success' ? 'text-emerald-400' : 'text-theme-text-secondary hover:text-theme-text-primary'
|
|
740
|
+
)}
|
|
741
|
+
aria-label="Refresh"
|
|
610
742
|
>
|
|
611
|
-
|
|
743
|
+
{refreshPhase === 'success'
|
|
744
|
+
? <Check className="w-4 h-4 stroke-[2.5]" />
|
|
745
|
+
: <RefreshCw className={clsx('w-4 h-4', refreshPhase === 'spinning' && 'animate-spin')} />
|
|
746
|
+
}
|
|
612
747
|
</button>
|
|
613
|
-
|
|
614
|
-
<button
|
|
615
|
-
onClick={() => refetch()}
|
|
616
|
-
disabled={isRefreshAnimating}
|
|
617
|
-
className={clsx(
|
|
618
|
-
'p-1.5 hover:bg-theme-elevated rounded disabled:opacity-50 transition-colors duration-500',
|
|
619
|
-
refreshPhase === 'success' ? 'text-emerald-400' : 'text-theme-text-secondary hover:text-theme-text-primary'
|
|
620
|
-
)}
|
|
621
|
-
title="Refresh"
|
|
622
|
-
>
|
|
623
|
-
{refreshPhase === 'success'
|
|
624
|
-
? <Check className="w-4 h-4 stroke-[2.5]" />
|
|
625
|
-
: <RefreshCw className={clsx('w-4 h-4', refreshPhase === 'spinning' && 'animate-spin')} />
|
|
626
|
-
}
|
|
627
|
-
</button>
|
|
748
|
+
</Tooltip>
|
|
628
749
|
{onClose && (
|
|
629
|
-
<
|
|
630
|
-
<
|
|
631
|
-
|
|
750
|
+
<Tooltip content="Close (Esc)" delay={150} position="bottom">
|
|
751
|
+
<button onClick={onClose} className="p-1.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded" aria-label="Close">
|
|
752
|
+
<X className="w-4 h-4" />
|
|
753
|
+
</button>
|
|
754
|
+
</Tooltip>
|
|
632
755
|
)}
|
|
633
756
|
</div>
|
|
634
757
|
</div>
|
|
@@ -637,13 +760,15 @@ export function WorkloadView({
|
|
|
637
760
|
<div className="px-4 pb-3">
|
|
638
761
|
<div className="flex items-center gap-2">
|
|
639
762
|
<h2 className="text-lg font-semibold text-theme-text-primary truncate">{name}</h2>
|
|
640
|
-
<
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
763
|
+
<Tooltip content="Copy name" delay={150}>
|
|
764
|
+
<button
|
|
765
|
+
onClick={() => copyToClipboard(name, 'name')}
|
|
766
|
+
className="p-1 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded shrink-0"
|
|
767
|
+
aria-label="Copy name"
|
|
768
|
+
>
|
|
769
|
+
{copied === 'name' ? <Check className="w-3.5 h-3.5 text-green-400" /> : <Copy className="w-3.5 h-3.5" />}
|
|
770
|
+
</button>
|
|
771
|
+
</Tooltip>
|
|
647
772
|
</div>
|
|
648
773
|
<p className="text-sm text-theme-text-tertiary">{namespace}</p>
|
|
649
774
|
{(gitopsOwner || helmOwner || (gitOpsResourcePath && onNavigateGitOpsPath)) && (
|
|
@@ -685,7 +810,7 @@ export function WorkloadView({
|
|
|
685
810
|
onDownload={onDownload}
|
|
686
811
|
/>
|
|
687
812
|
) : (
|
|
688
|
-
<OperationalIssuesShownContext.Provider value={!!hasOperationalIssues}>
|
|
813
|
+
<OperationalIssuesShownContext.Provider value={!!hasOperationalIssues || !!operationalIssuesPending}>
|
|
689
814
|
{renderOverviewLead && hasOperationalIssues && (
|
|
690
815
|
<div className="px-4 pt-4">
|
|
691
816
|
{renderOverviewLead({ kind, namespace, name })}
|
|
@@ -711,12 +836,8 @@ export function WorkloadView({
|
|
|
711
836
|
updates={resourceFocusedUpdates}
|
|
712
837
|
eventsError={resourceFocusedK8sError}
|
|
713
838
|
updatesError={resourceFocusedUpdatesError}
|
|
839
|
+
mainFooter={renderOverviewExtra && renderOverviewExtra({ kind, namespace, name })}
|
|
714
840
|
/>
|
|
715
|
-
{renderOverviewExtra && (
|
|
716
|
-
<div className="px-4 pb-4">
|
|
717
|
-
{renderOverviewExtra({ kind, namespace, name })}
|
|
718
|
-
</div>
|
|
719
|
-
)}
|
|
720
841
|
</OperationalIssuesShownContext.Provider>
|
|
721
842
|
)}
|
|
722
843
|
</div>
|
|
@@ -726,32 +847,47 @@ export function WorkloadView({
|
|
|
726
847
|
|
|
727
848
|
// ── Expanded (full) mode ─────────────────────────────────────────────────
|
|
728
849
|
return (
|
|
729
|
-
<OperationalIssuesShownContext.Provider value={!!hasOperationalIssues}>
|
|
850
|
+
<OperationalIssuesShownContext.Provider value={!!hasOperationalIssues || !!operationalIssuesPending}>
|
|
730
851
|
<DetailShell
|
|
731
852
|
breadcrumb={breadcrumb}
|
|
732
853
|
nav={
|
|
733
854
|
breadcrumb || hideBackButton ? undefined : (
|
|
734
|
-
<
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
855
|
+
<Tooltip content="Go back (Esc)" delay={150} position="bottom">
|
|
856
|
+
<button
|
|
857
|
+
onClick={onBack}
|
|
858
|
+
className="p-1.5 mt-0.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded-lg transition-colors"
|
|
859
|
+
aria-label="Go back"
|
|
860
|
+
>
|
|
861
|
+
<ArrowLeft className="w-5 h-5" />
|
|
862
|
+
</button>
|
|
863
|
+
</Tooltip>
|
|
741
864
|
)
|
|
742
865
|
}
|
|
743
866
|
identity={
|
|
744
867
|
<>
|
|
745
|
-
|
|
746
|
-
<
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
{
|
|
753
|
-
|
|
754
|
-
|
|
868
|
+
{showOwnershipHeading && ownershipContext ? (
|
|
869
|
+
<OwnershipHeading
|
|
870
|
+
podName={name}
|
|
871
|
+
context={ownershipContext}
|
|
872
|
+
copied={copied === 'name'}
|
|
873
|
+
onCopy={() => copyToClipboard(name, 'name')}
|
|
874
|
+
onNavigateToResource={onNavigateToResource}
|
|
875
|
+
onOpenApplication={onOpenApplication}
|
|
876
|
+
/>
|
|
877
|
+
) : (
|
|
878
|
+
<div className="flex items-center gap-3 mb-1">
|
|
879
|
+
<h1 className="text-lg font-semibold text-theme-text-primary truncate">{name}</h1>
|
|
880
|
+
<Tooltip content="Copy name" delay={150}>
|
|
881
|
+
<button
|
|
882
|
+
onClick={() => copyToClipboard(name, 'name')}
|
|
883
|
+
className="p-1 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded shrink-0"
|
|
884
|
+
aria-label="Copy name"
|
|
885
|
+
>
|
|
886
|
+
{copied === 'name' ? <Check className="w-3.5 h-3.5 text-green-400" /> : <Copy className="w-3.5 h-3.5" />}
|
|
887
|
+
</button>
|
|
888
|
+
</Tooltip>
|
|
889
|
+
</div>
|
|
890
|
+
)}
|
|
755
891
|
<div className="flex items-center gap-3 text-sm text-theme-text-secondary">
|
|
756
892
|
<span className={clsx('badge', getKindColorOutline(apiKind))}>
|
|
757
893
|
{displayKindName(apiKind, resource?.kind)}
|
|
@@ -764,8 +900,12 @@ export function WorkloadView({
|
|
|
764
900
|
{namespace && namespace !== '_' && (
|
|
765
901
|
<span>Namespace: <span className="text-theme-text-primary">{namespace}</span></span>
|
|
766
902
|
)}
|
|
767
|
-
{
|
|
768
|
-
<
|
|
903
|
+
{headerImage && (
|
|
904
|
+
<Tooltip content={headerImage} delay={300} wrapperClassName="min-w-0 max-w-md">
|
|
905
|
+
<span className="truncate font-mono text-xs">
|
|
906
|
+
{midTruncate(headerImage, 72)}
|
|
907
|
+
</span>
|
|
908
|
+
</Tooltip>
|
|
769
909
|
)}
|
|
770
910
|
{gitopsOwner && (
|
|
771
911
|
<ManagedByChip owner={gitopsOwner} status={gitOpsOwnerStatus} verified={gitOpsOwnerVerified} pending={gitOpsOwnerPending} source={gitOpsOwnerSource} onOpen={onOpenGitOpsResource} variant="block" />
|
|
@@ -776,7 +916,7 @@ export function WorkloadView({
|
|
|
776
916
|
{gitOpsResourcePath && onNavigateGitOpsPath && (
|
|
777
917
|
<OpenInGitOpsChip onClick={() => onNavigateGitOpsPath(gitOpsResourcePath)} />
|
|
778
918
|
)}
|
|
779
|
-
{relationships?.owner && (
|
|
919
|
+
{relationships?.owner && !showOwnershipHeading && (
|
|
780
920
|
<span>Owner: <button onClick={() => onNavigateToResource?.(refToSelectedResource(relationships.owner!))} className="text-blue-500 hover:underline">{relationships.owner.name}</button></span>
|
|
781
921
|
)}
|
|
782
922
|
</div>
|
|
@@ -784,28 +924,33 @@ export function WorkloadView({
|
|
|
784
924
|
}
|
|
785
925
|
headerActions={
|
|
786
926
|
<>
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
disabled={isRefreshAnimating}
|
|
790
|
-
className={clsx(
|
|
791
|
-
'p-1.5 mt-0.5 hover:bg-theme-elevated rounded disabled:opacity-50 transition-colors duration-500',
|
|
792
|
-
refreshPhase === 'success' ? 'text-emerald-400' : 'text-theme-text-secondary hover:text-theme-text-primary'
|
|
793
|
-
)}
|
|
794
|
-
title="Refresh"
|
|
795
|
-
>
|
|
796
|
-
{refreshPhase === 'success'
|
|
797
|
-
? <Check className="w-5 h-5 stroke-[2.5]" />
|
|
798
|
-
: <RefreshCw className={clsx('w-5 h-5', refreshPhase === 'spinning' && 'animate-spin')} />
|
|
799
|
-
}
|
|
800
|
-
</button>
|
|
801
|
-
{onCollapseToDrawer && (
|
|
927
|
+
{diagnoseAction}
|
|
928
|
+
<Tooltip content="Refresh" delay={150} position="bottom">
|
|
802
929
|
<button
|
|
803
|
-
onClick={
|
|
804
|
-
|
|
805
|
-
|
|
930
|
+
onClick={() => refetch()}
|
|
931
|
+
disabled={isRefreshAnimating}
|
|
932
|
+
className={clsx(
|
|
933
|
+
'p-1.5 mt-0.5 hover:bg-theme-elevated rounded disabled:opacity-50 transition-colors duration-500',
|
|
934
|
+
refreshPhase === 'success' ? 'text-emerald-400' : 'text-theme-text-secondary hover:text-theme-text-primary'
|
|
935
|
+
)}
|
|
936
|
+
aria-label="Refresh"
|
|
806
937
|
>
|
|
807
|
-
|
|
938
|
+
{refreshPhase === 'success'
|
|
939
|
+
? <Check className="w-5 h-5 stroke-[2.5]" />
|
|
940
|
+
: <RefreshCw className={clsx('w-5 h-5', refreshPhase === 'spinning' && 'animate-spin')} />
|
|
941
|
+
}
|
|
808
942
|
</button>
|
|
943
|
+
</Tooltip>
|
|
944
|
+
{onCollapseToDrawer && (
|
|
945
|
+
<Tooltip content="Collapse to drawer" delay={150} position="bottom">
|
|
946
|
+
<button
|
|
947
|
+
onClick={onCollapseToDrawer}
|
|
948
|
+
className="p-1.5 mt-0.5 text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated rounded-lg transition-colors"
|
|
949
|
+
aria-label="Collapse to drawer"
|
|
950
|
+
>
|
|
951
|
+
<Minimize2 className="w-5 h-5" />
|
|
952
|
+
</button>
|
|
953
|
+
</Tooltip>
|
|
809
954
|
)}
|
|
810
955
|
</>
|
|
811
956
|
}
|
|
@@ -817,13 +962,29 @@ export function WorkloadView({
|
|
|
817
962
|
overlay={saveSuccess ? <SaveSuccessAnimation /> : null}
|
|
818
963
|
compactHeader={compactHeader}
|
|
819
964
|
>
|
|
820
|
-
{effectiveTab === 'overview' && (
|
|
965
|
+
{effectiveTab === 'overview' && expandedOverview ? (
|
|
966
|
+
<div className="h-full min-h-0">
|
|
967
|
+
{hasOperationalIssues && renderOverviewLead && (
|
|
968
|
+
<div className="px-4 pt-4">
|
|
969
|
+
{renderOverviewLead({ kind, namespace, name })}
|
|
970
|
+
</div>
|
|
971
|
+
)}
|
|
972
|
+
{expandedOverview}
|
|
973
|
+
</div>
|
|
974
|
+
) : effectiveTab === 'overview' && (
|
|
821
975
|
<InfoTab
|
|
822
976
|
resource={resource}
|
|
823
977
|
selectedResource={selectedResource}
|
|
824
978
|
relationships={relationships}
|
|
979
|
+
certificateInfo={certificateInfo}
|
|
825
980
|
hpaDiagnosis={hpaDiagnosis}
|
|
826
981
|
scalerDiagnostics={scalerDiagnostics}
|
|
982
|
+
workloadPods={workloadPods}
|
|
983
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
984
|
+
workloadPodsError={workloadPodsError}
|
|
985
|
+
servingResources={servingResources}
|
|
986
|
+
renderServicePortAction={renderServicePortAction}
|
|
987
|
+
renderServicePortPanel={renderServicePortPanel}
|
|
827
988
|
isLoading={resourceLoading}
|
|
828
989
|
error={resourceError}
|
|
829
990
|
onNavigate={onNavigateToResource}
|
|
@@ -833,6 +994,8 @@ export function WorkloadView({
|
|
|
833
994
|
isSavingSecret={isUpdatingResource}
|
|
834
995
|
onOpenLogs={handleOpenLogs}
|
|
835
996
|
onSwitchToTimeline={() => handleSetTab('timeline')}
|
|
997
|
+
onSwitchToLogs={logsTabVisible ? () => handleSetTab('logs') : undefined}
|
|
998
|
+
onSwitchToTopology={!topologyTabHidden ? () => handleSetTab('topology') : undefined}
|
|
836
999
|
rendererOverrides={rendererOverrides}
|
|
837
1000
|
resolvedEnvFrom={resolvedEnvFrom}
|
|
838
1001
|
events={overviewEvents}
|
|
@@ -841,6 +1004,7 @@ export function WorkloadView({
|
|
|
841
1004
|
eventsError={overviewEventsError}
|
|
842
1005
|
updatesError={resourceFocusedUpdatesError}
|
|
843
1006
|
extraContent={renderOverviewExtra && renderOverviewExtra({ kind, namespace, name })}
|
|
1007
|
+
introContent={overviewIntro}
|
|
844
1008
|
leadContent={hasOperationalIssues && renderOverviewLead ? renderOverviewLead({ kind, namespace, name }) : undefined}
|
|
845
1009
|
/>
|
|
846
1010
|
)}
|
|
@@ -864,14 +1028,11 @@ export function WorkloadView({
|
|
|
864
1028
|
{effectiveTab === 'timeline' && (
|
|
865
1029
|
<EventsTab
|
|
866
1030
|
events={resourceEvents}
|
|
867
|
-
resourceLanes={resourceLanes}
|
|
868
1031
|
isLoading={eventsLoading}
|
|
869
|
-
zoom={zoom}
|
|
870
|
-
onZoomChange={setZoom}
|
|
871
|
-
resourceKind={kind}
|
|
872
|
-
resourceName={name}
|
|
873
1032
|
selectedEventId={selectedEventId}
|
|
874
1033
|
onSelectEvent={setSelectedEventId}
|
|
1034
|
+
topology={topology}
|
|
1035
|
+
onResourceClick={onNavigateToResource}
|
|
875
1036
|
/>
|
|
876
1037
|
)}
|
|
877
1038
|
{effectiveTab === 'logs' && renderLogsTab && (
|
|
@@ -893,6 +1054,11 @@ export function WorkloadView({
|
|
|
893
1054
|
{renderMetricsTab({ kind: resource?.kind || kind, namespace, name })}
|
|
894
1055
|
</div>
|
|
895
1056
|
)}
|
|
1057
|
+
{effectiveTab === 'cost' && renderCostTab && (
|
|
1058
|
+
<div className="h-full overflow-auto p-4">
|
|
1059
|
+
{renderCostTab({ kind: resource?.kind || kind, namespace, name })}
|
|
1060
|
+
</div>
|
|
1061
|
+
)}
|
|
896
1062
|
{effectiveTab === 'yaml' && (
|
|
897
1063
|
<div className="flex h-full min-h-0">
|
|
898
1064
|
{renderRelatedYaml && yamlObjects.length > 1 && (
|
|
@@ -988,15 +1154,90 @@ function extractMetadata(kind: string, resource: any): { label: string; value: s
|
|
|
988
1154
|
|
|
989
1155
|
function OpenInGitOpsChip({ onClick }: { onClick: () => void }) {
|
|
990
1156
|
return (
|
|
991
|
-
<
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1157
|
+
<Tooltip content="Open this resource in the GitOps tab (tree + insights + ops)" delay={150}>
|
|
1158
|
+
<button
|
|
1159
|
+
type="button"
|
|
1160
|
+
onClick={onClick}
|
|
1161
|
+
className="inline-flex items-center gap-1 rounded border border-skyhook-500/40 bg-skyhook-500/10 px-1.5 py-0.5 text-[11px] font-medium text-skyhook-500 hover:bg-skyhook-500/20 transition-colors"
|
|
1162
|
+
>
|
|
1163
|
+
Open in GitOps
|
|
1164
|
+
<ArrowRight className="h-3 w-3 shrink-0" />
|
|
1165
|
+
</button>
|
|
1166
|
+
</Tooltip>
|
|
1167
|
+
)
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
function OwnershipHeading({
|
|
1171
|
+
podName,
|
|
1172
|
+
context,
|
|
1173
|
+
copied,
|
|
1174
|
+
onCopy,
|
|
1175
|
+
onNavigateToResource,
|
|
1176
|
+
onOpenApplication,
|
|
1177
|
+
}: {
|
|
1178
|
+
podName: string
|
|
1179
|
+
context: ResourceOwnershipContext
|
|
1180
|
+
copied: boolean
|
|
1181
|
+
onCopy: () => void
|
|
1182
|
+
onNavigateToResource?: NavigateToResource
|
|
1183
|
+
onOpenApplication?: (appKey: string) => void
|
|
1184
|
+
}) {
|
|
1185
|
+
const app = context.application
|
|
1186
|
+
const workload = context.workload
|
|
1187
|
+
const workloadLabel = `${displayKindName(kindToPlural(workload.kind), workload.kind)}/${workload.name}`
|
|
1188
|
+
return (
|
|
1189
|
+
<div className="mb-1 flex min-w-0 items-center gap-2">
|
|
1190
|
+
<div className="flex min-w-0 items-center gap-1.5 text-lg font-semibold text-theme-text-primary">
|
|
1191
|
+
{app ? (
|
|
1192
|
+
onOpenApplication ? (
|
|
1193
|
+
<Tooltip content={`Open application ${app.name}`} delay={150} wrapperClassName="min-w-0">
|
|
1194
|
+
<button
|
|
1195
|
+
type="button"
|
|
1196
|
+
onClick={() => onOpenApplication(app.key)}
|
|
1197
|
+
className="min-w-0 truncate rounded px-0.5 text-left hover:text-accent-text focus:outline-none focus:ring-2 focus:ring-accent"
|
|
1198
|
+
>
|
|
1199
|
+
{midTruncate(app.name, 32)}
|
|
1200
|
+
</button>
|
|
1201
|
+
</Tooltip>
|
|
1202
|
+
) : (
|
|
1203
|
+
<Tooltip content={app.name} delay={300} wrapperClassName="min-w-0">
|
|
1204
|
+
<span className="truncate">{midTruncate(app.name, 32)}</span>
|
|
1205
|
+
</Tooltip>
|
|
1206
|
+
)
|
|
1207
|
+
) : null}
|
|
1208
|
+
{app && <span className="shrink-0 text-theme-text-tertiary">/</span>}
|
|
1209
|
+
{onNavigateToResource ? (
|
|
1210
|
+
<Tooltip content={`Open workload ${workloadLabel}`} delay={150} wrapperClassName="min-w-0">
|
|
1211
|
+
<button
|
|
1212
|
+
type="button"
|
|
1213
|
+
onClick={() => onNavigateToResource(refToSelectedResource(workload))}
|
|
1214
|
+
className="min-w-0 truncate rounded px-0.5 text-left hover:text-accent-text focus:outline-none focus:ring-2 focus:ring-accent"
|
|
1215
|
+
>
|
|
1216
|
+
{midTruncate(workload.name, 32)}
|
|
1217
|
+
</button>
|
|
1218
|
+
</Tooltip>
|
|
1219
|
+
) : (
|
|
1220
|
+
<Tooltip content={workloadLabel} delay={300} wrapperClassName="min-w-0">
|
|
1221
|
+
<span className="truncate">{midTruncate(workload.name, 32)}</span>
|
|
1222
|
+
</Tooltip>
|
|
1223
|
+
)}
|
|
1224
|
+
<span className="shrink-0 text-theme-text-tertiary">/</span>
|
|
1225
|
+
<Tooltip content={podName} delay={300} wrapperClassName="min-w-0">
|
|
1226
|
+
<h1 className="truncate text-lg font-semibold text-theme-text-primary">
|
|
1227
|
+
{podName}
|
|
1228
|
+
</h1>
|
|
1229
|
+
</Tooltip>
|
|
1230
|
+
</div>
|
|
1231
|
+
<Tooltip content="Copy pod name" delay={150}>
|
|
1232
|
+
<button
|
|
1233
|
+
onClick={onCopy}
|
|
1234
|
+
className="shrink-0 rounded p-1 text-theme-text-secondary hover:bg-theme-elevated hover:text-theme-text-primary"
|
|
1235
|
+
aria-label="Copy pod name"
|
|
1236
|
+
>
|
|
1237
|
+
{copied ? <Check className="h-3.5 w-3.5 text-green-400" /> : <Copy className="h-3.5 w-3.5" />}
|
|
1238
|
+
</button>
|
|
1239
|
+
</Tooltip>
|
|
1240
|
+
</div>
|
|
1000
1241
|
)
|
|
1001
1242
|
}
|
|
1002
1243
|
|
|
@@ -1006,162 +1247,98 @@ function OpenInGitOpsChip({ onClick }: { onClick: () => void }) {
|
|
|
1006
1247
|
|
|
1007
1248
|
function EventsTab({
|
|
1008
1249
|
events,
|
|
1009
|
-
resourceLanes,
|
|
1010
1250
|
isLoading,
|
|
1011
|
-
zoom,
|
|
1012
|
-
onZoomChange,
|
|
1013
|
-
resourceKind,
|
|
1014
|
-
resourceName,
|
|
1015
1251
|
selectedEventId,
|
|
1016
1252
|
onSelectEvent,
|
|
1253
|
+
topology,
|
|
1254
|
+
onResourceClick,
|
|
1017
1255
|
}: {
|
|
1018
1256
|
events: TimelineEvent[]
|
|
1019
|
-
resourceLanes: ResourceLane[]
|
|
1020
1257
|
isLoading: boolean
|
|
1021
|
-
zoom: ZoomLevel
|
|
1022
|
-
onZoomChange: (zoom: ZoomLevel) => void
|
|
1023
|
-
resourceKind: string
|
|
1024
|
-
resourceName: string
|
|
1025
1258
|
selectedEventId: string | null
|
|
1026
1259
|
onSelectEvent: (id: string | null) => void
|
|
1260
|
+
topology?: Topology
|
|
1261
|
+
onResourceClick?: NavigateToResource
|
|
1027
1262
|
}) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
// Scroll to selected event
|
|
1034
|
-
useEffect(() => {
|
|
1035
|
-
if (selectedEventId) {
|
|
1036
|
-
const eventIndex = events.findIndex(e => e.id === selectedEventId)
|
|
1037
|
-
if (eventIndex >= 0) {
|
|
1038
|
-
const row = rowRefs.current.get(eventIndex)
|
|
1039
|
-
if (row) row.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
}, [selectedEventId, events])
|
|
1043
|
-
|
|
1044
|
-
// Track visible rows via IntersectionObserver
|
|
1263
|
+
// A ticking clock so the fitted window's right edge and the swimlane's Now line
|
|
1264
|
+
// track the present, not the mount time — the tab's events refresh (SSE + poll),
|
|
1265
|
+
// so a frozen "now" drifts left of the advancing edge and newer events land "in
|
|
1266
|
+
// the future" to its right.
|
|
1267
|
+
const [now, setNow] = useState(() => Date.now())
|
|
1045
1268
|
useEffect(() => {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
(entries) => {
|
|
1050
|
-
for (const entry of entries) {
|
|
1051
|
-
const idx = parseInt(entry.target.getAttribute('data-row-index') || '-1', 10)
|
|
1052
|
-
if (idx >= 0) {
|
|
1053
|
-
if (entry.isIntersecting) visibleIndices.add(idx)
|
|
1054
|
-
else visibleIndices.delete(idx)
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
if (visibleIndices.size > 0) {
|
|
1058
|
-
const indices = Array.from(visibleIndices)
|
|
1059
|
-
setVisibleRowRange({ first: Math.min(...indices), last: Math.max(...indices) })
|
|
1060
|
-
} else {
|
|
1061
|
-
setVisibleRowRange(null)
|
|
1062
|
-
}
|
|
1063
|
-
},
|
|
1064
|
-
{ root: tableContainerRef.current, threshold: 0.1 }
|
|
1065
|
-
)
|
|
1066
|
-
const timeoutId = setTimeout(() => {
|
|
1067
|
-
rowRefs.current.forEach((row) => observer.observe(row))
|
|
1068
|
-
}, 100)
|
|
1069
|
-
return () => { clearTimeout(timeoutId); observer.disconnect() }
|
|
1070
|
-
}, [events])
|
|
1071
|
-
|
|
1072
|
-
// Visible time range from visible rows
|
|
1073
|
-
const visibleTimeRangeFromRows = useMemo(() => {
|
|
1074
|
-
if (!visibleRowRange || events.length === 0) return null
|
|
1075
|
-
const visibleEvents = events.slice(visibleRowRange.first, visibleRowRange.last + 1)
|
|
1076
|
-
if (visibleEvents.length === 0) return null
|
|
1077
|
-
const timestamps = visibleEvents.map(e => new Date(e.timestamp).getTime())
|
|
1078
|
-
const start = Math.min(...timestamps)
|
|
1079
|
-
const end = Math.max(...timestamps)
|
|
1080
|
-
const timeSpan = end - start
|
|
1081
|
-
const padding = Math.max(timeSpan * 0.1, 60000)
|
|
1082
|
-
return { start: start - padding, end: end + padding }
|
|
1083
|
-
}, [events, visibleRowRange])
|
|
1084
|
-
|
|
1085
|
-
const now = Date.now()
|
|
1086
|
-
const { start: startTime, windowMs } = calculateTimeRange(zoom, now)
|
|
1087
|
-
const zoomIndex = ZOOM_LEVELS.indexOf(zoom)
|
|
1088
|
-
const canZoomIn = zoomIndex > 0
|
|
1089
|
-
const canZoomOut = zoomIndex < ZOOM_LEVELS.length - 1
|
|
1090
|
-
const handleZoomIn = () => { if (canZoomIn) onZoomChange(ZOOM_LEVELS[zoomIndex - 1]) }
|
|
1091
|
-
const handleZoomOut = () => { if (canZoomOut) onZoomChange(ZOOM_LEVELS[zoomIndex + 1]) }
|
|
1092
|
-
const localTimeToX = (ts: number) => timeToX(ts, startTime, windowMs)
|
|
1093
|
-
|
|
1094
|
-
// Build swimlanes
|
|
1095
|
-
const swimlanes = useMemo(() => {
|
|
1096
|
-
type SwimLane = {
|
|
1097
|
-
id: string; label: string
|
|
1098
|
-
spans: { start: number; end: number; health: string }[]
|
|
1099
|
-
events: TimelineEvent[]
|
|
1100
|
-
createdAt?: number; createdBeforeWindow: boolean
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
if (resourceLanes.length === 0) {
|
|
1104
|
-
const mainResourceEvents = events.filter(e => e.kind === resourceKind && e.name === resourceName)
|
|
1105
|
-
const healthResult = buildHealthSpans(mainResourceEvents.filter(e => isChangeEvent(e)), startTime, now, mainResourceEvents)
|
|
1106
|
-
return [{ id: 'main', label: `${resourceKind}: ${resourceName}`, spans: healthResult.spans, events: mainResourceEvents, createdAt: healthResult.createdAt, createdBeforeWindow: healthResult.createdBeforeWindow }]
|
|
1107
|
-
}
|
|
1269
|
+
const id = setInterval(() => setNow(Date.now()), 30_000)
|
|
1270
|
+
return () => clearInterval(id)
|
|
1271
|
+
}, [])
|
|
1108
1272
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1273
|
+
// Drop untimeable events once, at the source, so the swimlane, the list's date
|
|
1274
|
+
// grouping, and selection all agree. The Go/K8s zero time (0001-01-01) parses to
|
|
1275
|
+
// a valid-but-meaningless Date the swimlane can't place, but the list would
|
|
1276
|
+
// otherwise bucket it under a bogus "1/1/1" header (and selecting it strands the
|
|
1277
|
+
// pan). NaN / future timestamps are stripped for the same reason.
|
|
1278
|
+
const cleanEvents = useMemo(() => {
|
|
1279
|
+
const ceiling = Date.now() + 60_000
|
|
1280
|
+
return events.filter((e) => {
|
|
1281
|
+
const t = new Date(e.timestamp).getTime()
|
|
1282
|
+
return Number.isFinite(t) && t > 0 && t <= ceiling
|
|
1118
1283
|
})
|
|
1284
|
+
}, [events])
|
|
1119
1285
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1286
|
+
// Fit the swimlane's window to this resource's events. Uncontrolled, the
|
|
1287
|
+
// swimlane anchors to now and shows the last hour — but a resource's events can
|
|
1288
|
+
// be days old (a Deployment created last week), so that window is empty. Default
|
|
1289
|
+
// to the events' span; a user pan/zoom (userWindow) then takes over. Deriving the
|
|
1290
|
+
// default (not latching it in state) means it always tracks the current events —
|
|
1291
|
+
// latching once locked onto the pre-scoping event set and left the window wrong.
|
|
1292
|
+
const eventSpan = useMemo<TimeWindow | null>(() => {
|
|
1293
|
+
if (cleanEvents.length === 0) return null
|
|
1294
|
+
let lo = Infinity, hi = -Infinity
|
|
1295
|
+
for (const e of cleanEvents) {
|
|
1296
|
+
const t = new Date(e.timestamp).getTime()
|
|
1297
|
+
if (t < lo) lo = t
|
|
1298
|
+
if (t > hi) hi = t
|
|
1130
1299
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1300
|
+
const pad = Math.max((hi - lo) * 0.05, 60_000)
|
|
1301
|
+
// Never extend into the future: the right edge is the newest event or now,
|
|
1302
|
+
// whichever is earlier, so health bars stop at the Now line.
|
|
1303
|
+
return { fromMs: lo - pad, toMs: Math.min(hi + pad, now) }
|
|
1304
|
+
}, [cleanEvents, now])
|
|
1305
|
+
const [userWindow, setUserWindow] = useState<TimeWindow | null>(null)
|
|
1306
|
+
const viewWindow = userWindow ?? eventSpan
|
|
1307
|
+
|
|
1308
|
+
// Hard bounds for pan/zoom: the window can never leave [oldest event, now], so
|
|
1309
|
+
// scrolling back can't run off into empty/invalid-date territory and zoom-out
|
|
1310
|
+
// can't exceed the resource's actual lifespan.
|
|
1311
|
+
const bounds = useMemo<TimeWindow | null>(
|
|
1312
|
+
() => (eventSpan ? { fromMs: eventSpan.fromMs, toMs: now } : null),
|
|
1313
|
+
[eventSpan, now],
|
|
1314
|
+
)
|
|
1137
1315
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1316
|
+
// Selecting an event — from the list OR the swimlane — pans the swimlane window
|
|
1317
|
+
// to include it in the SAME update, THEN sets the shared selection. Panning
|
|
1318
|
+
// atomically is what prevents the flicker: the swimlane resolves selectedEventId
|
|
1319
|
+
// against the window on the same render, so an off-window event never briefly
|
|
1320
|
+
// resolves to null and oscillate against a separate pan effect. Refs read the
|
|
1321
|
+
// current window/events without making this callback churn.
|
|
1322
|
+
const selRefs = useRef({ viewWindow, events: cleanEvents, bounds })
|
|
1323
|
+
selRefs.current = { viewWindow, events: cleanEvents, bounds }
|
|
1324
|
+
const handleSelect = useCallback((id: string | null) => {
|
|
1325
|
+
if (id) {
|
|
1326
|
+
const { viewWindow: vw, events: evs, bounds: bd } = selRefs.current
|
|
1327
|
+
const evt = evs.find((e) => e.id === id)
|
|
1328
|
+
const t = evt ? new Date(evt.timestamp).getTime() : NaN
|
|
1329
|
+
if (vw && Number.isFinite(t) && (t < vw.fromMs || t > vw.toMs)) {
|
|
1330
|
+
const width = vw.toMs - vw.fromMs
|
|
1331
|
+
const now = Date.now()
|
|
1332
|
+
let fromMs = t - width / 2
|
|
1333
|
+
let toMs = t + width / 2
|
|
1334
|
+
if (toMs > now) { toMs = now; fromMs = now - width }
|
|
1335
|
+
const lo = bd?.fromMs
|
|
1336
|
+
if (lo != null && fromMs < lo) { fromMs = lo; toMs = lo + width }
|
|
1337
|
+
setUserWindow({ fromMs, toMs })
|
|
1338
|
+
}
|
|
1146
1339
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
}, [resourceLanes, events, resourceKind, resourceName, startTime, now])
|
|
1150
|
-
|
|
1151
|
-
// Time axis ticks
|
|
1152
|
-
const tickCount = 8
|
|
1153
|
-
const ticks = Array.from({ length: tickCount + 1 }, (_, i) => {
|
|
1154
|
-
const t = startTime + (windowMs * i) / tickCount
|
|
1155
|
-
return { time: t, label: formatAxisTime(new Date(t)) }
|
|
1156
|
-
})
|
|
1157
|
-
|
|
1158
|
-
const formatTimeRangeDisplay = () => {
|
|
1159
|
-
const start = new Date(startTime)
|
|
1160
|
-
const end = new Date(now)
|
|
1161
|
-
return `${start.toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })} → ${end.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
const nowX = localTimeToX(now)
|
|
1340
|
+
onSelectEvent(id)
|
|
1341
|
+
}, [onSelectEvent])
|
|
1165
1342
|
|
|
1166
1343
|
if (isLoading) {
|
|
1167
1344
|
return (
|
|
@@ -1174,191 +1351,80 @@ function EventsTab({
|
|
|
1174
1351
|
|
|
1175
1352
|
return (
|
|
1176
1353
|
<div className="h-full flex flex-col overflow-hidden">
|
|
1177
|
-
{/*
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
{lane.spans.map((span, i) => {
|
|
1215
|
-
const left = Math.max(0, localTimeToX(span.start))
|
|
1216
|
-
const right = Math.min(100, localTimeToX(span.end))
|
|
1217
|
-
const width = right - left
|
|
1218
|
-
const showCreatedBefore = i === 0 && lane.createdBeforeWindow && lane.createdAt
|
|
1219
|
-
return (
|
|
1220
|
-
<HealthSpan
|
|
1221
|
-
key={i}
|
|
1222
|
-
health={span.health}
|
|
1223
|
-
left={left}
|
|
1224
|
-
width={width}
|
|
1225
|
-
title={`${span.health} (${new Date(span.start).toLocaleTimeString()} - ${new Date(span.end).toLocaleTimeString()})`}
|
|
1226
|
-
createdBefore={showCreatedBefore ? new Date(lane.createdAt!) : undefined}
|
|
1227
|
-
/>
|
|
1228
|
-
)
|
|
1229
|
-
})}
|
|
1230
|
-
{lane.events.map((evt, i) => {
|
|
1231
|
-
const x = localTimeToX(new Date(evt.timestamp).getTime())
|
|
1232
|
-
if (x < 0 || x > 100) return null
|
|
1233
|
-
return (
|
|
1234
|
-
<EventMarker
|
|
1235
|
-
key={`${evt.id}-${i}`}
|
|
1236
|
-
event={evt}
|
|
1237
|
-
x={x}
|
|
1238
|
-
selected={selectedEventId === evt.id}
|
|
1239
|
-
onClick={() => onSelectEvent(selectedEventId === evt.id ? null : evt.id)}
|
|
1240
|
-
small
|
|
1241
|
-
/>
|
|
1242
|
-
)
|
|
1243
|
-
})}
|
|
1244
|
-
</div>
|
|
1245
|
-
</div>
|
|
1246
|
-
))}
|
|
1247
|
-
</div>
|
|
1248
|
-
|
|
1249
|
-
{/* Time axis */}
|
|
1250
|
-
<div className="flex">
|
|
1251
|
-
<div className="w-[280px] shrink-0 bg-theme-surface/50 border-r border-theme-border" />
|
|
1252
|
-
<div className="flex-1 relative h-5 bg-theme-elevated/30">
|
|
1253
|
-
{ticks.map((tick, i) => {
|
|
1254
|
-
const x = localTimeToX(tick.time)
|
|
1255
|
-
return (
|
|
1256
|
-
<div key={i} className="absolute top-0 flex flex-col items-center" style={{ left: `${x}%`, transform: 'translateX(-50%)' }}>
|
|
1257
|
-
<div className="h-1.5 w-px bg-theme-border" />
|
|
1258
|
-
<span className="text-[10px] text-theme-text-tertiary">{tick.label}</span>
|
|
1259
|
-
</div>
|
|
1260
|
-
)
|
|
1261
|
-
})}
|
|
1262
|
-
</div>
|
|
1263
|
-
</div>
|
|
1354
|
+
{/* Swimlane — the shared TimelineSwimlanes widget (kind chips, top axis with
|
|
1355
|
+
ticks + Now line, event clustering), flat + compact for a single subject.
|
|
1356
|
+
Its drawer is suppressed (compact); the list below is the detail surface. */}
|
|
1357
|
+
<div className="shrink-0 border-b border-theme-border">
|
|
1358
|
+
<TimelineSwimlanes
|
|
1359
|
+
events={cleanEvents}
|
|
1360
|
+
grouping="flat"
|
|
1361
|
+
compact
|
|
1362
|
+
topology={topology}
|
|
1363
|
+
onResourceClick={onResourceClick}
|
|
1364
|
+
viewWindow={viewWindow ?? undefined}
|
|
1365
|
+
bounds={bounds ?? undefined}
|
|
1366
|
+
nowMs={now}
|
|
1367
|
+
isLive={userWindow == null}
|
|
1368
|
+
onViewWindowChange={(w) => {
|
|
1369
|
+
const now = Date.now()
|
|
1370
|
+
const MIN = 15 * 60_000
|
|
1371
|
+
let { fromMs, toMs } = w
|
|
1372
|
+
// Floor zoom-in at ~15 min: a tiny empty sub-window strands the user
|
|
1373
|
+
// (the "move the strip above" hint has no strip here).
|
|
1374
|
+
if (toMs - fromMs < MIN) {
|
|
1375
|
+
const c = (fromMs + toMs) / 2
|
|
1376
|
+
fromMs = c - MIN / 2
|
|
1377
|
+
toMs = c + MIN / 2
|
|
1378
|
+
}
|
|
1379
|
+
// Never pan/zoom past now: shift the window back so its right edge is
|
|
1380
|
+
// at most the present (there's nothing in the future to show).
|
|
1381
|
+
if (toMs > now) {
|
|
1382
|
+
const width = toMs - fromMs
|
|
1383
|
+
toMs = now
|
|
1384
|
+
fromMs = now - width
|
|
1385
|
+
}
|
|
1386
|
+
setUserWindow({ fromMs, toMs })
|
|
1387
|
+
}}
|
|
1388
|
+
selectedEventId={selectedEventId}
|
|
1389
|
+
onSelectedEventChange={handleSelect}
|
|
1390
|
+
/>
|
|
1264
1391
|
</div>
|
|
1265
1392
|
|
|
1266
|
-
{/*
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
{events.length === 0 ? (
|
|
1280
|
-
<tr>
|
|
1281
|
-
<td colSpan={5} className="px-4 py-8 text-center text-theme-text-tertiary">
|
|
1282
|
-
No events in this time range
|
|
1283
|
-
</td>
|
|
1284
|
-
</tr>
|
|
1285
|
-
) : (
|
|
1286
|
-
events.map((evt, evtIdx) => {
|
|
1287
|
-
const isSelected = selectedEventId === evt.id
|
|
1288
|
-
const isHovered = hoveredEventId === evt.id
|
|
1289
|
-
const isWarning = isProblematicEvent(evt)
|
|
1290
|
-
return (
|
|
1291
|
-
<tr
|
|
1292
|
-
key={`${evt.id}-${evtIdx}`}
|
|
1293
|
-
ref={(el) => { if (el) rowRefs.current.set(evtIdx, el); else rowRefs.current.delete(evtIdx) }}
|
|
1294
|
-
data-row-index={evtIdx}
|
|
1295
|
-
onClick={() => onSelectEvent(isSelected ? null : evt.id)}
|
|
1296
|
-
onMouseEnter={() => setHoveredEventId(evt.id)}
|
|
1297
|
-
onMouseLeave={() => setHoveredEventId(null)}
|
|
1298
|
-
className={clsx(
|
|
1299
|
-
'cursor-pointer transition-colors',
|
|
1300
|
-
isSelected ? 'bg-blue-500/10' : isHovered ? 'bg-blue-500/5' : 'hover:bg-theme-surface/50'
|
|
1301
|
-
)}
|
|
1302
|
-
>
|
|
1303
|
-
<td className="px-4 py-3">
|
|
1304
|
-
<div className="flex items-center gap-2">
|
|
1305
|
-
<EventDot event={evt} />
|
|
1306
|
-
<span className={clsx('font-medium', isWarning ? 'text-amber-500' : 'text-theme-text-primary')}>
|
|
1307
|
-
{isHistoricalEvent(evt) && evt.reason ? evt.reason : isChangeEvent(evt) ? evt.eventType : evt.reason}
|
|
1308
|
-
</span>
|
|
1309
|
-
</div>
|
|
1310
|
-
</td>
|
|
1311
|
-
<td className="px-4 py-3 text-theme-text-secondary">
|
|
1312
|
-
{evt.message || evt.diff?.summary || '-'}
|
|
1313
|
-
</td>
|
|
1314
|
-
<td className="px-4 py-3 text-theme-text-tertiary">
|
|
1315
|
-
{new Date(evt.timestamp).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' })}
|
|
1316
|
-
</td>
|
|
1317
|
-
<td className="px-4 py-3">
|
|
1318
|
-
<span className={clsx('badge-sm', getKindBadgeColor(evt.kind))}>
|
|
1319
|
-
{evt.kind}
|
|
1320
|
-
</span>
|
|
1321
|
-
</td>
|
|
1322
|
-
<td className="px-4 py-3">
|
|
1323
|
-
{isWarning ? (
|
|
1324
|
-
<span className="badge status-degraded">Active</span>
|
|
1325
|
-
) : evt.healthState ? (
|
|
1326
|
-
<span className={clsx('badge', getHealthBadgeColor(evt.healthState))}>{evt.healthState}</span>
|
|
1327
|
-
) : null}
|
|
1328
|
-
</td>
|
|
1329
|
-
</tr>
|
|
1330
|
-
)
|
|
1331
|
-
})
|
|
1332
|
-
)}
|
|
1333
|
-
</tbody>
|
|
1334
|
-
</table>
|
|
1393
|
+
{/* Event list — the shared TimelineList: same event icons/colors as the
|
|
1394
|
+
swimlane, kind badge + resource link, namespace, message, and inline diff,
|
|
1395
|
+
all shown directly. compact drops its toolbar (the swimlane above owns the
|
|
1396
|
+
window). */}
|
|
1397
|
+
<div className="min-h-0 flex-1">
|
|
1398
|
+
<TimelineList
|
|
1399
|
+
compact
|
|
1400
|
+
events={cleanEvents}
|
|
1401
|
+
isLoading={false}
|
|
1402
|
+
onResourceClick={onResourceClick}
|
|
1403
|
+
selectedEventId={selectedEventId}
|
|
1404
|
+
onSelectEvent={handleSelect}
|
|
1405
|
+
/>
|
|
1335
1406
|
</div>
|
|
1336
1407
|
</div>
|
|
1337
1408
|
)
|
|
1338
1409
|
}
|
|
1339
1410
|
|
|
1340
|
-
function EventDot({ event }: { event: TimelineEvent }) {
|
|
1341
|
-
const isWarning = isProblematicEvent(event)
|
|
1342
|
-
const isDelete = event.eventType === 'delete'
|
|
1343
|
-
const isAdd = event.eventType === 'add'
|
|
1344
|
-
return (
|
|
1345
|
-
<div className={clsx(
|
|
1346
|
-
'w-3 h-3 rounded-full shrink-0',
|
|
1347
|
-
isWarning ? 'bg-amber-500' : isDelete ? 'bg-red-500' : isAdd ? 'bg-green-500' : 'bg-blue-500'
|
|
1348
|
-
)} />
|
|
1349
|
-
)
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
1411
|
// ============================================================================
|
|
1353
|
-
// INFO TAB —
|
|
1412
|
+
// INFO TAB — full-page workload triage overview
|
|
1354
1413
|
// ============================================================================
|
|
1355
1414
|
|
|
1356
1415
|
function InfoTab({
|
|
1357
1416
|
resource,
|
|
1358
1417
|
selectedResource,
|
|
1359
1418
|
relationships,
|
|
1419
|
+
certificateInfo,
|
|
1360
1420
|
hpaDiagnosis,
|
|
1361
1421
|
scalerDiagnostics,
|
|
1422
|
+
workloadPods,
|
|
1423
|
+
workloadPodsLoading,
|
|
1424
|
+
workloadPodsError,
|
|
1425
|
+
servingResources,
|
|
1426
|
+
renderServicePortAction,
|
|
1427
|
+
renderServicePortPanel,
|
|
1362
1428
|
isLoading,
|
|
1363
1429
|
error,
|
|
1364
1430
|
onNavigate,
|
|
@@ -1368,6 +1434,8 @@ function InfoTab({
|
|
|
1368
1434
|
isSavingSecret,
|
|
1369
1435
|
onOpenLogs,
|
|
1370
1436
|
onSwitchToTimeline,
|
|
1437
|
+
onSwitchToLogs,
|
|
1438
|
+
onSwitchToTopology,
|
|
1371
1439
|
rendererOverrides,
|
|
1372
1440
|
resolvedEnvFrom,
|
|
1373
1441
|
events,
|
|
@@ -1376,13 +1444,21 @@ function InfoTab({
|
|
|
1376
1444
|
eventsError,
|
|
1377
1445
|
updatesError,
|
|
1378
1446
|
extraContent,
|
|
1447
|
+
introContent,
|
|
1379
1448
|
leadContent,
|
|
1380
1449
|
}: {
|
|
1381
1450
|
resource: any
|
|
1382
1451
|
selectedResource: SelectedResource
|
|
1383
1452
|
relationships?: Relationships
|
|
1453
|
+
certificateInfo?: any
|
|
1384
1454
|
hpaDiagnosis?: HPADiagnosis
|
|
1385
1455
|
scalerDiagnostics?: ScalerDiagnosis[]
|
|
1456
|
+
workloadPods?: WorkloadPodInfo[]
|
|
1457
|
+
workloadPodsLoading?: boolean
|
|
1458
|
+
workloadPodsError?: Error | null
|
|
1459
|
+
servingResources?: ServingResourceDetail[]
|
|
1460
|
+
renderServicePortAction?: (props: ServicePortRenderProps) => ReactNode
|
|
1461
|
+
renderServicePortPanel?: (props: ServicePortRenderProps) => ReactNode
|
|
1386
1462
|
isLoading: boolean
|
|
1387
1463
|
error?: unknown
|
|
1388
1464
|
onNavigate?: NavigateToResource
|
|
@@ -1392,6 +1468,8 @@ function InfoTab({
|
|
|
1392
1468
|
isSavingSecret?: boolean
|
|
1393
1469
|
onOpenLogs?: (podName: string, containerName: string) => void
|
|
1394
1470
|
onSwitchToTimeline?: () => void
|
|
1471
|
+
onSwitchToLogs?: () => void
|
|
1472
|
+
onSwitchToTopology?: () => void
|
|
1395
1473
|
rendererOverrides?: RendererOverrides
|
|
1396
1474
|
resolvedEnvFrom?: ResolvedEnvFrom
|
|
1397
1475
|
events?: TimelineEvent[]
|
|
@@ -1400,61 +1478,2214 @@ function InfoTab({
|
|
|
1400
1478
|
eventsError?: Error | null
|
|
1401
1479
|
updatesError?: Error | null
|
|
1402
1480
|
extraContent?: ReactNode
|
|
1481
|
+
introContent?: ReactNode
|
|
1403
1482
|
leadContent?: ReactNode
|
|
1404
1483
|
}) {
|
|
1405
1484
|
if (!resource) {
|
|
1406
1485
|
return <FetchResult loading={isLoading} error={error} className="h-full" />
|
|
1407
1486
|
}
|
|
1408
1487
|
|
|
1488
|
+
if (!isRuntimeWorkloadOverviewKind(selectedResource.kind)) {
|
|
1489
|
+
return (
|
|
1490
|
+
<div className="h-full overflow-auto">
|
|
1491
|
+
{leadContent && (
|
|
1492
|
+
<div className="px-4 pt-4">
|
|
1493
|
+
{leadContent}
|
|
1494
|
+
</div>
|
|
1495
|
+
)}
|
|
1496
|
+
{introContent && (
|
|
1497
|
+
<div className="px-4 pt-4">
|
|
1498
|
+
{introContent}
|
|
1499
|
+
</div>
|
|
1500
|
+
)}
|
|
1501
|
+
<ResourceRendererDispatch
|
|
1502
|
+
resource={selectedResource}
|
|
1503
|
+
data={resource}
|
|
1504
|
+
relationships={relationships}
|
|
1505
|
+
certificateInfo={certificateInfo}
|
|
1506
|
+
hpaDiagnosis={hpaDiagnosis}
|
|
1507
|
+
scalerDiagnostics={scalerDiagnostics}
|
|
1508
|
+
onCopy={onCopy}
|
|
1509
|
+
copied={copied}
|
|
1510
|
+
onNavigate={onNavigate ? (ref) => onNavigate(refToSelectedResource(ref)) : undefined}
|
|
1511
|
+
onSaveSecretValue={onSaveSecretValue}
|
|
1512
|
+
isSavingSecret={isSavingSecret}
|
|
1513
|
+
showCommonSections={true}
|
|
1514
|
+
showMetrics={false}
|
|
1515
|
+
onOpenLogs={onOpenLogs}
|
|
1516
|
+
rendererOverrides={rendererOverrides}
|
|
1517
|
+
resolvedEnvFrom={resolvedEnvFrom}
|
|
1518
|
+
events={events}
|
|
1519
|
+
eventsLoading={eventsLoading}
|
|
1520
|
+
updates={updates}
|
|
1521
|
+
eventsError={eventsError}
|
|
1522
|
+
updatesError={updatesError}
|
|
1523
|
+
eventsHint={onSwitchToTimeline && (
|
|
1524
|
+
<button
|
|
1525
|
+
onClick={onSwitchToTimeline}
|
|
1526
|
+
className="text-xs text-theme-text-tertiary transition-colors hover:text-theme-text-secondary"
|
|
1527
|
+
>
|
|
1528
|
+
Showing recent events for this resource. Switch to the <span className="underline">Timeline</span> tab for full history and relationships.
|
|
1529
|
+
</button>
|
|
1530
|
+
)}
|
|
1531
|
+
renderSidebar={(sidebarSections) => (
|
|
1532
|
+
<div className="border-theme-border lg:w-[35%] lg:shrink-0 lg:border-l">
|
|
1533
|
+
<div className="space-y-4 p-4">
|
|
1534
|
+
{sidebarSections}
|
|
1535
|
+
</div>
|
|
1536
|
+
</div>
|
|
1537
|
+
)}
|
|
1538
|
+
mainFooter={extraContent}
|
|
1539
|
+
/>
|
|
1540
|
+
</div>
|
|
1541
|
+
)
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1409
1544
|
return (
|
|
1410
|
-
<
|
|
1411
|
-
{
|
|
1412
|
-
|
|
1545
|
+
<WorkloadOverviewTab
|
|
1546
|
+
resource={resource}
|
|
1547
|
+
selectedResource={selectedResource}
|
|
1548
|
+
relationships={relationships}
|
|
1549
|
+
hpaDiagnosis={hpaDiagnosis}
|
|
1550
|
+
scalerDiagnostics={scalerDiagnostics}
|
|
1551
|
+
workloadPods={workloadPods}
|
|
1552
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
1553
|
+
workloadPodsError={workloadPodsError}
|
|
1554
|
+
servingResources={servingResources}
|
|
1555
|
+
renderServicePortAction={renderServicePortAction}
|
|
1556
|
+
renderServicePortPanel={renderServicePortPanel}
|
|
1557
|
+
onNavigate={onNavigate}
|
|
1558
|
+
onSwitchToTimeline={onSwitchToTimeline}
|
|
1559
|
+
onSwitchToLogs={onSwitchToLogs}
|
|
1560
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1561
|
+
events={events}
|
|
1562
|
+
eventsLoading={eventsLoading}
|
|
1563
|
+
updates={updates}
|
|
1564
|
+
eventsError={eventsError}
|
|
1565
|
+
updatesError={updatesError}
|
|
1566
|
+
extraContent={extraContent}
|
|
1567
|
+
introContent={introContent}
|
|
1568
|
+
leadContent={leadContent}
|
|
1569
|
+
/>
|
|
1570
|
+
)
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
const POD_VISIBLE_LIMIT = 5
|
|
1574
|
+
const EVENT_VISIBLE_LIMIT = 5
|
|
1575
|
+
const RELATIONSHIP_GROUP_LIMIT = 5
|
|
1576
|
+
const RELATIONSHIP_REF_LIMIT = 5
|
|
1577
|
+
const LOGS_TAB_WITHOUT_PODS_KINDS = new Set([
|
|
1578
|
+
'jobs',
|
|
1579
|
+
'cronjobs',
|
|
1580
|
+
'workflows',
|
|
1581
|
+
'cronworkflows',
|
|
1582
|
+
'workflowtemplates',
|
|
1583
|
+
'clusterworkflowtemplates',
|
|
1584
|
+
'scaledjobs',
|
|
1585
|
+
])
|
|
1586
|
+
const RUNTIME_WORKLOAD_OVERVIEW_KINDS = new Set(['deployments', 'statefulsets', 'daemonsets', 'jobs', 'cronjobs'])
|
|
1587
|
+
type RuntimeOverviewShape = 'replicated' | 'job' | 'cronjob'
|
|
1588
|
+
|
|
1589
|
+
function isRuntimeWorkloadOverviewKind(kind: string) {
|
|
1590
|
+
return RUNTIME_WORKLOAD_OVERVIEW_KINDS.has(kindToPlural(kind).toLowerCase())
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
function runtimeOverviewShape(kind: string): RuntimeOverviewShape {
|
|
1594
|
+
const k = kindToPlural(kind).toLowerCase()
|
|
1595
|
+
if (k === 'jobs') return 'job'
|
|
1596
|
+
if (k === 'cronjobs') return 'cronjob'
|
|
1597
|
+
return 'replicated'
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
function WorkloadOverviewTab({
|
|
1601
|
+
resource,
|
|
1602
|
+
selectedResource,
|
|
1603
|
+
relationships,
|
|
1604
|
+
hpaDiagnosis,
|
|
1605
|
+
scalerDiagnostics,
|
|
1606
|
+
workloadPods,
|
|
1607
|
+
workloadPodsLoading,
|
|
1608
|
+
workloadPodsError,
|
|
1609
|
+
servingResources,
|
|
1610
|
+
renderServicePortAction,
|
|
1611
|
+
renderServicePortPanel,
|
|
1612
|
+
onNavigate,
|
|
1613
|
+
onSwitchToTimeline,
|
|
1614
|
+
onSwitchToLogs,
|
|
1615
|
+
onSwitchToTopology,
|
|
1616
|
+
events = [],
|
|
1617
|
+
updates = [],
|
|
1618
|
+
eventsLoading,
|
|
1619
|
+
eventsError,
|
|
1620
|
+
updatesError,
|
|
1621
|
+
extraContent,
|
|
1622
|
+
introContent,
|
|
1623
|
+
leadContent,
|
|
1624
|
+
}: {
|
|
1625
|
+
resource: any
|
|
1626
|
+
selectedResource: SelectedResource
|
|
1627
|
+
relationships?: Relationships
|
|
1628
|
+
hpaDiagnosis?: HPADiagnosis
|
|
1629
|
+
scalerDiagnostics?: ScalerDiagnosis[]
|
|
1630
|
+
workloadPods?: WorkloadPodInfo[]
|
|
1631
|
+
workloadPodsLoading?: boolean
|
|
1632
|
+
workloadPodsError?: Error | null
|
|
1633
|
+
servingResources?: ServingResourceDetail[]
|
|
1634
|
+
renderServicePortAction?: (props: ServicePortRenderProps) => ReactNode
|
|
1635
|
+
renderServicePortPanel?: (props: ServicePortRenderProps) => ReactNode
|
|
1636
|
+
onNavigate?: NavigateToResource
|
|
1637
|
+
onSwitchToTimeline?: () => void
|
|
1638
|
+
onSwitchToLogs?: () => void
|
|
1639
|
+
onSwitchToTopology?: () => void
|
|
1640
|
+
events?: TimelineEvent[]
|
|
1641
|
+
updates?: TimelineEvent[]
|
|
1642
|
+
eventsLoading?: boolean
|
|
1643
|
+
eventsError?: Error | null
|
|
1644
|
+
updatesError?: Error | null
|
|
1645
|
+
extraContent?: ReactNode
|
|
1646
|
+
introContent?: ReactNode
|
|
1647
|
+
leadContent?: ReactNode
|
|
1648
|
+
}) {
|
|
1649
|
+
const apiKind = kindToPlural(selectedResource.kind)
|
|
1650
|
+
const resourceKind = resource?.kind || displayKindName(apiKind, resource?.kind)
|
|
1651
|
+
const readiness = getReadinessSummary(resource, apiKind)
|
|
1652
|
+
const podSummary = getPodSummary(workloadPods, relationships, apiKind)
|
|
1653
|
+
const scaling = getScalingSummary(resource, apiKind, relationships, scalerDiagnostics, hpaDiagnosis)
|
|
1654
|
+
const controlSurface = runtimeControlSurface(apiKind)
|
|
1655
|
+
const overviewShape = runtimeOverviewShape(apiKind)
|
|
1656
|
+
const summaryMetrics = buildSummaryMetrics(resource, apiKind, resourceKind, readiness, podSummary, scaling)
|
|
1657
|
+
const relationshipGroups = buildRelationshipGroups(relationships)
|
|
1658
|
+
const servingRelationshipGroups = buildServingRelationshipGroups(relationships)
|
|
1659
|
+
const dependencyRelationshipGroups = buildDependencyRelationshipGroups(relationships)
|
|
1660
|
+
const showServingPath = servingRelationshipGroups.length > 0 && overviewShape !== 'job' && overviewShape !== 'cronjob'
|
|
1661
|
+
const secondaryRelationshipGroups = showServingPath ? dependencyRelationshipGroups : relationshipGroups
|
|
1662
|
+
const relationshipCardTitle =
|
|
1663
|
+
overviewShape === 'job' || overviewShape === 'cronjob'
|
|
1664
|
+
? 'Related resources'
|
|
1665
|
+
: showServingPath
|
|
1666
|
+
? 'Dependencies'
|
|
1667
|
+
: 'Related resources'
|
|
1668
|
+
|
|
1669
|
+
if (overviewShape === 'replicated') {
|
|
1670
|
+
const state = getReplicatedWorkloadState(resource, apiKind)
|
|
1671
|
+
const serviceAccountName = getPodTemplateSpec(resource, apiKind)?.serviceAccountName || 'default'
|
|
1672
|
+
return (
|
|
1673
|
+
<div className="h-full overflow-auto bg-theme-base">
|
|
1674
|
+
<div className="space-y-4 p-4">
|
|
1413
1675
|
{leadContent}
|
|
1676
|
+
{introContent}
|
|
1677
|
+
|
|
1678
|
+
<WorkloadStatusStrip
|
|
1679
|
+
state={state}
|
|
1680
|
+
readiness={readiness}
|
|
1681
|
+
podSummary={podSummary}
|
|
1682
|
+
servingSummary={showServingPath ? buildServingStripSummary(servingRelationshipGroups, servingResources) : undefined}
|
|
1683
|
+
/>
|
|
1684
|
+
|
|
1685
|
+
<div className="grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_360px] 2xl:grid-cols-[minmax(0,1fr)_400px]">
|
|
1686
|
+
<div className="space-y-4">
|
|
1687
|
+
<div className="grid items-start gap-4 2xl:grid-cols-[minmax(0,1fr)_minmax(320px,420px)]">
|
|
1688
|
+
<div className="space-y-4">
|
|
1689
|
+
{showServingPath && (
|
|
1690
|
+
<ServingConfigurationCard
|
|
1691
|
+
groups={servingRelationshipGroups}
|
|
1692
|
+
details={servingResources}
|
|
1693
|
+
renderPortAction={renderServicePortAction}
|
|
1694
|
+
renderPortPanel={renderServicePortPanel}
|
|
1695
|
+
onNavigate={onNavigate}
|
|
1696
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1697
|
+
/>
|
|
1698
|
+
)}
|
|
1699
|
+
<RuntimeCard
|
|
1700
|
+
resource={resource}
|
|
1701
|
+
apiKind={apiKind}
|
|
1702
|
+
state={state}
|
|
1703
|
+
readiness={readiness}
|
|
1704
|
+
scaling={scaling}
|
|
1705
|
+
namespace={selectedResource.namespace}
|
|
1706
|
+
workloadPods={workloadPods}
|
|
1707
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
1708
|
+
workloadPodsError={workloadPodsError}
|
|
1709
|
+
relationshipPods={relationships?.pods}
|
|
1710
|
+
scalerDiagnostics={scalerDiagnostics}
|
|
1711
|
+
hpaDiagnosis={hpaDiagnosis}
|
|
1712
|
+
relationships={relationships}
|
|
1713
|
+
onNavigate={onNavigate}
|
|
1714
|
+
onSwitchToLogs={onSwitchToLogs}
|
|
1715
|
+
/>
|
|
1716
|
+
</div>
|
|
1717
|
+
<div className="space-y-4">
|
|
1718
|
+
<ConfigurationInputsCard
|
|
1719
|
+
serviceAccountName={serviceAccountName}
|
|
1720
|
+
namespace={selectedResource.namespace}
|
|
1721
|
+
relationships={relationships}
|
|
1722
|
+
onNavigate={onNavigate}
|
|
1723
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1724
|
+
/>
|
|
1725
|
+
{extraContent}
|
|
1726
|
+
</div>
|
|
1727
|
+
</div>
|
|
1728
|
+
</div>
|
|
1729
|
+
|
|
1730
|
+
<div className="space-y-4">
|
|
1731
|
+
<ActivityCard
|
|
1732
|
+
events={events}
|
|
1733
|
+
updates={updates}
|
|
1734
|
+
loading={eventsLoading}
|
|
1735
|
+
eventsError={eventsError}
|
|
1736
|
+
updatesError={updatesError}
|
|
1737
|
+
onSwitchToTimeline={onSwitchToTimeline}
|
|
1738
|
+
/>
|
|
1739
|
+
</div>
|
|
1740
|
+
</div>
|
|
1414
1741
|
</div>
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
className="text-xs text-theme-text-tertiary hover:text-theme-text-secondary transition-colors"
|
|
1441
|
-
>
|
|
1442
|
-
Showing recent events across this workload. Switch to the <span className="underline">Timeline</span> tab for full history and resource relationships.
|
|
1443
|
-
</button>
|
|
1742
|
+
</div>
|
|
1743
|
+
)
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
return (
|
|
1747
|
+
<div className="h-full overflow-auto bg-theme-base">
|
|
1748
|
+
<div className="space-y-4 p-4">
|
|
1749
|
+
{leadContent}
|
|
1750
|
+
{introContent}
|
|
1751
|
+
|
|
1752
|
+
<div className="grid grid-cols-1 gap-3 md:grid-cols-2 2xl:grid-cols-4">
|
|
1753
|
+
{summaryMetrics.map((metric) => (
|
|
1754
|
+
<SummaryMetric key={metric.label} {...metric} />
|
|
1755
|
+
))}
|
|
1756
|
+
</div>
|
|
1757
|
+
|
|
1758
|
+
{showServingPath && (
|
|
1759
|
+
<ServingConfigurationCard
|
|
1760
|
+
groups={servingRelationshipGroups}
|
|
1761
|
+
details={servingResources}
|
|
1762
|
+
renderPortAction={renderServicePortAction}
|
|
1763
|
+
renderPortPanel={renderServicePortPanel}
|
|
1764
|
+
onNavigate={onNavigate}
|
|
1765
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1766
|
+
/>
|
|
1444
1767
|
)}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1768
|
+
|
|
1769
|
+
<div className="grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_360px] 2xl:grid-cols-[minmax(0,1fr)_400px]">
|
|
1770
|
+
<div className="space-y-4">
|
|
1771
|
+
<CurrentStateCard resource={resource} apiKind={apiKind} readiness={readiness} />
|
|
1772
|
+
<div className="grid items-start gap-4 2xl:grid-cols-2">
|
|
1773
|
+
{overviewShape === 'cronjob' ? (
|
|
1774
|
+
<CronJobRunsCard
|
|
1775
|
+
resource={resource}
|
|
1776
|
+
namespace={selectedResource.namespace}
|
|
1777
|
+
onNavigate={onNavigate}
|
|
1778
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1779
|
+
/>
|
|
1780
|
+
) : (
|
|
1781
|
+
<PodsAttentionCard
|
|
1782
|
+
namespace={selectedResource.namespace}
|
|
1783
|
+
emptyText={overviewShape === 'job' ? 'No Pods are currently retained for this Job.' : undefined}
|
|
1784
|
+
workloadPods={workloadPods}
|
|
1785
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
1786
|
+
workloadPodsError={workloadPodsError}
|
|
1787
|
+
relationshipPods={relationships?.pods}
|
|
1788
|
+
onNavigate={onNavigate}
|
|
1789
|
+
onSwitchToLogs={onSwitchToLogs}
|
|
1790
|
+
/>
|
|
1791
|
+
)}
|
|
1792
|
+
<ScalingCard
|
|
1793
|
+
title={controlSurface.cardTitle}
|
|
1794
|
+
icon={controlSurface.icon}
|
|
1795
|
+
scaling={scaling}
|
|
1796
|
+
scalerDiagnostics={scalerDiagnostics}
|
|
1797
|
+
hpaDiagnosis={hpaDiagnosis}
|
|
1798
|
+
relationships={relationships}
|
|
1799
|
+
onNavigate={onNavigate}
|
|
1800
|
+
/>
|
|
1449
1801
|
</div>
|
|
1802
|
+
{secondaryRelationshipGroups.length > 0 ? (
|
|
1803
|
+
<ServingDependenciesCard
|
|
1804
|
+
title={relationshipCardTitle}
|
|
1805
|
+
relationships={relationships}
|
|
1806
|
+
groups={secondaryRelationshipGroups}
|
|
1807
|
+
onNavigate={onNavigate}
|
|
1808
|
+
onSwitchToTopology={onSwitchToTopology}
|
|
1809
|
+
/>
|
|
1810
|
+
) : null}
|
|
1811
|
+
{extraContent && (
|
|
1812
|
+
<div className="grid items-start gap-4 2xl:grid-cols-2">
|
|
1813
|
+
{extraContent}
|
|
1814
|
+
</div>
|
|
1815
|
+
)}
|
|
1816
|
+
</div>
|
|
1817
|
+
|
|
1818
|
+
<div className="space-y-4">
|
|
1819
|
+
<ActivityCard
|
|
1820
|
+
events={events}
|
|
1821
|
+
updates={updates}
|
|
1822
|
+
loading={eventsLoading}
|
|
1823
|
+
eventsError={eventsError}
|
|
1824
|
+
updatesError={updatesError}
|
|
1825
|
+
onSwitchToTimeline={onSwitchToTimeline}
|
|
1826
|
+
/>
|
|
1450
1827
|
</div>
|
|
1451
|
-
)}
|
|
1452
|
-
/>
|
|
1453
|
-
{extraContent && (
|
|
1454
|
-
<div className="px-4 pb-4">
|
|
1455
|
-
{extraContent}
|
|
1456
1828
|
</div>
|
|
1829
|
+
|
|
1830
|
+
</div>
|
|
1831
|
+
</div>
|
|
1832
|
+
)
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
function OverviewCard({
|
|
1836
|
+
title,
|
|
1837
|
+
icon: Icon,
|
|
1838
|
+
action,
|
|
1839
|
+
children,
|
|
1840
|
+
}: {
|
|
1841
|
+
title: string
|
|
1842
|
+
icon: ComponentType<{ className?: string }>
|
|
1843
|
+
action?: ReactNode
|
|
1844
|
+
children: ReactNode
|
|
1845
|
+
}) {
|
|
1846
|
+
return (
|
|
1847
|
+
<section className="rounded-lg border border-theme-border bg-theme-surface p-4 shadow-theme-sm">
|
|
1848
|
+
<div className="mb-3 flex min-w-0 items-center justify-between gap-3">
|
|
1849
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
1850
|
+
<Icon className="h-4 w-4 shrink-0 text-theme-text-secondary" />
|
|
1851
|
+
<h2 className="truncate text-[11px] font-semibold uppercase tracking-wide text-theme-text-secondary">{title}</h2>
|
|
1852
|
+
</div>
|
|
1853
|
+
{action}
|
|
1854
|
+
</div>
|
|
1855
|
+
{children}
|
|
1856
|
+
</section>
|
|
1857
|
+
)
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
function SummaryMetric({
|
|
1861
|
+
label,
|
|
1862
|
+
value,
|
|
1863
|
+
detail,
|
|
1864
|
+
icon: Icon,
|
|
1865
|
+
mono,
|
|
1866
|
+
}: {
|
|
1867
|
+
label: string
|
|
1868
|
+
value: ReactNode
|
|
1869
|
+
detail?: ReactNode
|
|
1870
|
+
icon: ComponentType<{ className?: string }>
|
|
1871
|
+
mono?: boolean
|
|
1872
|
+
}) {
|
|
1873
|
+
return (
|
|
1874
|
+
<section className="min-w-0 rounded-lg border border-theme-border bg-theme-surface p-4 shadow-theme-sm">
|
|
1875
|
+
<div className="mb-3 flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-theme-text-secondary">
|
|
1876
|
+
<Icon className="h-4 w-4 shrink-0" />
|
|
1877
|
+
<span>{label}</span>
|
|
1878
|
+
</div>
|
|
1879
|
+
<div className={clsx('truncate text-lg font-semibold text-theme-text-primary', mono && 'font-mono')}>{value}</div>
|
|
1880
|
+
{detail && <div className="mt-1 truncate text-xs text-theme-text-tertiary">{detail}</div>}
|
|
1881
|
+
</section>
|
|
1882
|
+
)
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
interface ReplicatedWorkloadState {
|
|
1886
|
+
label: string
|
|
1887
|
+
detail: string
|
|
1888
|
+
badgeClass: string
|
|
1889
|
+
level: 'healthy' | 'neutral' | 'degraded' | 'unhealthy' | 'unknown'
|
|
1890
|
+
healthy: boolean
|
|
1891
|
+
needsAttention: boolean
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
function WorkloadStatusStrip({
|
|
1895
|
+
state,
|
|
1896
|
+
readiness,
|
|
1897
|
+
podSummary,
|
|
1898
|
+
servingSummary,
|
|
1899
|
+
}: {
|
|
1900
|
+
state: ReplicatedWorkloadState
|
|
1901
|
+
readiness: ReadinessSummary
|
|
1902
|
+
podSummary: ReturnType<typeof getPodSummary>
|
|
1903
|
+
servingSummary?: string
|
|
1904
|
+
}) {
|
|
1905
|
+
const servingMode = Boolean(servingSummary)
|
|
1906
|
+
const stateDetail = servingMode && state.healthy ? 'runtime health' : state.detail
|
|
1907
|
+
const podItem = servingMode && typeof podSummary.total === 'number'
|
|
1908
|
+
? {
|
|
1909
|
+
label: 'Pods',
|
|
1910
|
+
value: `${podSummary.total}`,
|
|
1911
|
+
detail: podSummary.total === 0
|
|
1912
|
+
? 'none running'
|
|
1913
|
+
: (podSummary.notReady ?? 0) > 0
|
|
1914
|
+
? `${podSummary.notReady} need attention`
|
|
1915
|
+
: 'runtime instances',
|
|
1916
|
+
}
|
|
1917
|
+
: { label: 'Pods', value: podSummary.label, detail: podSummary.detail }
|
|
1918
|
+
const items = [
|
|
1919
|
+
{ label: 'State', value: <span className={clsx('badge-sm', state.badgeClass)}>{state.label}</span>, detail: stateDetail },
|
|
1920
|
+
{ label: 'Ready', value: readiness.readyLabel, detail: readiness.detail },
|
|
1921
|
+
podItem,
|
|
1922
|
+
servingSummary ? { label: 'Exposure', value: servingSummary, detail: 'configured, not probed' } : null,
|
|
1923
|
+
].filter(Boolean) as Array<{ label: string; value: ReactNode; detail?: ReactNode }>
|
|
1924
|
+
|
|
1925
|
+
return (
|
|
1926
|
+
<section className="rounded-lg border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
|
|
1927
|
+
<div className="grid gap-3 sm:grid-cols-2 2xl:grid-cols-4">
|
|
1928
|
+
{items.map((item) => (
|
|
1929
|
+
<div key={item.label} className="min-w-0">
|
|
1930
|
+
<div className="text-[10px] font-semibold uppercase tracking-wide text-theme-text-tertiary">{item.label}</div>
|
|
1931
|
+
<div className="mt-1 truncate text-sm font-semibold text-theme-text-primary">{item.value}</div>
|
|
1932
|
+
{item.detail ? <div className="mt-0.5 truncate text-xs text-theme-text-tertiary">{item.detail}</div> : null}
|
|
1933
|
+
</div>
|
|
1934
|
+
))}
|
|
1935
|
+
</div>
|
|
1936
|
+
</section>
|
|
1937
|
+
)
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
function getReplicatedWorkloadState(resource: any, apiKind: string): ReplicatedWorkloadState {
|
|
1941
|
+
const status = resource?.status || {}
|
|
1942
|
+
const spec = resource?.spec || {}
|
|
1943
|
+
const metadata = resource?.metadata || {}
|
|
1944
|
+
const k = apiKind.toLowerCase()
|
|
1945
|
+
const generation = metadata.generation
|
|
1946
|
+
const observedGeneration = status.observedGeneration
|
|
1947
|
+
const controllerBehind =
|
|
1948
|
+
typeof generation === 'number' &&
|
|
1949
|
+
typeof observedGeneration === 'number' &&
|
|
1950
|
+
observedGeneration < generation
|
|
1951
|
+
|
|
1952
|
+
if (k === 'daemonsets') {
|
|
1953
|
+
const desired = status.desiredNumberScheduled ?? 0
|
|
1954
|
+
const ready = status.numberReady ?? 0
|
|
1955
|
+
const updated = status.updatedNumberScheduled ?? 0
|
|
1956
|
+
const unavailable = status.numberUnavailable ?? Math.max(0, desired - ready)
|
|
1957
|
+
if (desired === 0) return stateSummary('No targets', 'selector matches no nodes', 'status-neutral', 'neutral')
|
|
1958
|
+
if (controllerBehind) return stateSummary('Applying', 'controller has not observed latest spec', 'status-neutral', 'neutral')
|
|
1959
|
+
if (updated < desired) return stateSummary('Rolling out', `${updated}/${desired} updated`, 'status-neutral', 'neutral')
|
|
1960
|
+
if (ready === desired && unavailable === 0) return stateSummary('Healthy', `${ready}/${desired} ready`, 'status-healthy', 'healthy')
|
|
1961
|
+
if (ready > 0) return stateSummary('Degraded', `${ready}/${desired} ready`, 'status-degraded', 'degraded')
|
|
1962
|
+
return stateSummary('Unhealthy', 'no scheduled pods are ready', 'status-unhealthy', 'unhealthy')
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
const desired = spec.replicas ?? status.replicas ?? 0
|
|
1966
|
+
const ready = status.readyReplicas ?? 0
|
|
1967
|
+
const updated = status.updatedReplicas ?? 0
|
|
1968
|
+
const available = status.availableReplicas ?? ready
|
|
1969
|
+
const unavailable = status.unavailableReplicas ?? Math.max(0, desired - available)
|
|
1970
|
+
if (desired === 0) return stateSummary('Scaled to zero', 'no replicas requested', 'status-neutral', 'neutral')
|
|
1971
|
+
if (k === 'deployments' && spec.paused) return stateSummary('Paused', `${ready}/${desired} ready`, 'status-neutral', 'neutral')
|
|
1972
|
+
const progressCondition = Array.isArray(status.conditions)
|
|
1973
|
+
? status.conditions.find((condition: any) => condition.type === 'Progressing')
|
|
1974
|
+
: undefined
|
|
1975
|
+
if (progressCondition?.status === 'False' || progressCondition?.reason === 'ProgressDeadlineExceeded') {
|
|
1976
|
+
return stateSummary('Stalled', progressCondition.message || `${ready}/${desired} ready`, 'status-unhealthy', 'unhealthy')
|
|
1977
|
+
}
|
|
1978
|
+
if (controllerBehind) return stateSummary('Applying', 'controller has not observed latest spec', 'status-neutral', 'neutral')
|
|
1979
|
+
const statefulSetRolling = k === 'statefulsets' && status.updateRevision && status.currentRevision && status.updateRevision !== status.currentRevision
|
|
1980
|
+
if (updated < desired || statefulSetRolling) return stateSummary('Rolling out', `${updated}/${desired} updated`, 'status-neutral', 'neutral')
|
|
1981
|
+
if (ready === desired && available === desired && unavailable === 0) return stateSummary('Healthy', `${ready}/${desired} ready`, 'status-healthy', 'healthy')
|
|
1982
|
+
if (ready > 0) return stateSummary('Degraded', `${ready}/${desired} ready`, 'status-degraded', 'degraded')
|
|
1983
|
+
return stateSummary('Unhealthy', 'no replicas are ready', 'status-unhealthy', 'unhealthy')
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
function stateSummary(
|
|
1987
|
+
label: string,
|
|
1988
|
+
detail: string,
|
|
1989
|
+
badgeClass: string,
|
|
1990
|
+
level: ReplicatedWorkloadState['level'],
|
|
1991
|
+
): ReplicatedWorkloadState {
|
|
1992
|
+
return {
|
|
1993
|
+
label,
|
|
1994
|
+
detail,
|
|
1995
|
+
badgeClass,
|
|
1996
|
+
level,
|
|
1997
|
+
healthy: level === 'healthy',
|
|
1998
|
+
needsAttention: level === 'degraded' || level === 'unhealthy',
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
function buildServingStripSummary(groups: RelationshipGroup[], details?: ServingResourceDetail[]): string {
|
|
2003
|
+
const services = groups.find((group) => group.label === 'Services')?.refs ?? []
|
|
2004
|
+
const entrypoints = groups.find((group) => group.label === 'Entry points')?.refs ?? []
|
|
2005
|
+
const serviceResources = (details ?? [])
|
|
2006
|
+
.filter((detail) => services.some((ref) => resourceRefId(ref) === resourceRefId(detail.ref)))
|
|
2007
|
+
.map((detail) => detail.resource)
|
|
2008
|
+
.filter(Boolean)
|
|
2009
|
+
const serviceTypes = new Set(serviceResources.map((service) => service?.spec?.type || 'ClusterIP'))
|
|
2010
|
+
if (entrypoints.length > 0) return 'External entrypoint'
|
|
2011
|
+
if ([...serviceTypes].some((type) => ['LoadBalancer', 'NodePort', 'ExternalName'].includes(String(type)))) return 'External service'
|
|
2012
|
+
if (services.length > 0) return 'Internal service'
|
|
2013
|
+
return 'None'
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
interface SummaryMetricConfig {
|
|
2017
|
+
label: string
|
|
2018
|
+
value: ReactNode
|
|
2019
|
+
detail?: ReactNode
|
|
2020
|
+
icon: ComponentType<{ className?: string }>
|
|
2021
|
+
mono?: boolean
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
function buildSummaryMetrics(
|
|
2025
|
+
resource: any,
|
|
2026
|
+
apiKind: string,
|
|
2027
|
+
resourceKind: string,
|
|
2028
|
+
readiness: ReadinessSummary,
|
|
2029
|
+
podSummary: ReturnType<typeof getPodSummary>,
|
|
2030
|
+
scaling: ScalingSummary,
|
|
2031
|
+
): SummaryMetricConfig[] {
|
|
2032
|
+
const spec = resource?.spec || {}
|
|
2033
|
+
const status = resource?.status || {}
|
|
2034
|
+
const k = apiKind.toLowerCase()
|
|
2035
|
+
|
|
2036
|
+
if (k === 'jobs') {
|
|
2037
|
+
const duration = formatJobDuration(resource)
|
|
2038
|
+
return [
|
|
2039
|
+
{
|
|
2040
|
+
label: 'State',
|
|
2041
|
+
value: <span className={clsx('badge', readiness.healthBadge)}>{readiness.healthLabel}</span>,
|
|
2042
|
+
detail: resourceKind,
|
|
2043
|
+
icon: readiness.hasIssue ? AlertTriangle : Activity,
|
|
2044
|
+
},
|
|
2045
|
+
{
|
|
2046
|
+
label: 'Progress',
|
|
2047
|
+
value: readiness.readyLabel,
|
|
2048
|
+
detail: readiness.detail,
|
|
2049
|
+
icon: CheckCircle2,
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
label: 'Duration',
|
|
2053
|
+
value: duration || '-',
|
|
2054
|
+
detail: status.startTime ? (status.completionTime ? 'finished run' : 'current run') : 'not started',
|
|
2055
|
+
icon: Clock3,
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
label: 'Pods',
|
|
2059
|
+
value: podSummary.label,
|
|
2060
|
+
detail: podSummary.detail,
|
|
2061
|
+
icon: Boxes,
|
|
2062
|
+
},
|
|
2063
|
+
]
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
if (k === 'cronjobs') {
|
|
2067
|
+
const active = Array.isArray(status.active) ? status.active.length : 0
|
|
2068
|
+
return [
|
|
2069
|
+
{
|
|
2070
|
+
label: 'State',
|
|
2071
|
+
value: <span className={clsx('badge', readiness.healthBadge)}>{readiness.healthLabel}</span>,
|
|
2072
|
+
detail: spec.suspend ? 'schedule suspended' : active > 0 ? 'run in progress' : 'waiting for next run',
|
|
2073
|
+
icon: readiness.hasIssue ? AlertTriangle : Clock3,
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
label: 'Schedule',
|
|
2077
|
+
value: spec.schedule || '-',
|
|
2078
|
+
detail: spec.schedule ? cronToHuman(spec.schedule) : 'cron unavailable',
|
|
2079
|
+
icon: Clock3,
|
|
2080
|
+
mono: Boolean(spec.schedule),
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
label: 'Latest run',
|
|
2084
|
+
value: status.lastScheduleTime ? formatAge(status.lastScheduleTime) : 'Never',
|
|
2085
|
+
detail: status.lastSuccessfulTime ? `last success ${formatAge(status.lastSuccessfulTime)}` : 'no successful run recorded',
|
|
2086
|
+
icon: Activity,
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
label: 'Active jobs',
|
|
2090
|
+
value: active,
|
|
2091
|
+
detail: active > 0 ? 'currently running' : 'none running',
|
|
2092
|
+
icon: Boxes,
|
|
2093
|
+
},
|
|
2094
|
+
]
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
const control = runtimeControlSurface(apiKind)
|
|
2098
|
+
return [
|
|
2099
|
+
{
|
|
2100
|
+
label: 'State',
|
|
2101
|
+
value: <span className={clsx('badge', readiness.healthBadge)}>{readiness.healthLabel}</span>,
|
|
2102
|
+
detail: resourceKind,
|
|
2103
|
+
icon: readiness.hasIssue ? AlertTriangle : CheckCircle2,
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
label: 'Readiness',
|
|
2107
|
+
value: readiness.readyLabel,
|
|
2108
|
+
detail: readiness.detail,
|
|
2109
|
+
icon: Server,
|
|
2110
|
+
},
|
|
2111
|
+
{
|
|
2112
|
+
label: 'Pods',
|
|
2113
|
+
value: podSummary.label,
|
|
2114
|
+
detail: podSummary.detail,
|
|
2115
|
+
icon: Boxes,
|
|
2116
|
+
},
|
|
2117
|
+
{
|
|
2118
|
+
label: control.metricLabel,
|
|
2119
|
+
value: scaling.label,
|
|
2120
|
+
detail: scaling.detail,
|
|
2121
|
+
icon: control.icon,
|
|
2122
|
+
},
|
|
2123
|
+
]
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
interface ReadinessSummary {
|
|
2127
|
+
readyLabel: string
|
|
2128
|
+
detail: string
|
|
2129
|
+
healthLabel: string
|
|
2130
|
+
healthBadge: string
|
|
2131
|
+
hasIssue: boolean
|
|
2132
|
+
stats: Array<{ label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }>
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
function getReadinessSummary(resource: any, apiKind: string): ReadinessSummary {
|
|
2136
|
+
const status = resource?.status || {}
|
|
2137
|
+
const spec = resource?.spec || {}
|
|
2138
|
+
const k = apiKind.toLowerCase()
|
|
2139
|
+
|
|
2140
|
+
if (k === 'daemonsets') {
|
|
2141
|
+
const desired = status.desiredNumberScheduled ?? 0
|
|
2142
|
+
const ready = status.numberReady ?? 0
|
|
2143
|
+
const updated = status.updatedNumberScheduled ?? 0
|
|
2144
|
+
const available = status.numberAvailable ?? ready
|
|
2145
|
+
const unavailable = status.numberUnavailable ?? Math.max(0, desired - available)
|
|
2146
|
+
const noTargets = desired === 0
|
|
2147
|
+
const healthy = !noTargets && ready === desired && unavailable === 0
|
|
2148
|
+
return {
|
|
2149
|
+
readyLabel: `${ready}/${desired}`,
|
|
2150
|
+
detail: `${updated}/${desired} up-to-date`,
|
|
2151
|
+
healthLabel: noTargets ? 'No targets' : healthy ? 'Healthy' : 'Degraded',
|
|
2152
|
+
healthBadge: noTargets ? 'bg-theme-elevated text-theme-text-secondary' : healthy ? 'status-healthy' : 'status-degraded',
|
|
2153
|
+
hasIssue: !healthy && !noTargets,
|
|
2154
|
+
stats: [
|
|
2155
|
+
{ label: 'Desired', value: desired },
|
|
2156
|
+
{ label: 'Ready', value: ready, tone: ready === desired ? 'good' : 'warn' },
|
|
2157
|
+
{ label: 'Available', value: available },
|
|
2158
|
+
{ label: 'Unavailable', value: unavailable, tone: unavailable > 0 ? 'warn' : 'default' },
|
|
2159
|
+
],
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
if (k === 'jobs') {
|
|
2164
|
+
const desired = spec.completions ?? 1
|
|
2165
|
+
const succeeded = status.succeeded ?? 0
|
|
2166
|
+
const active = status.active ?? 0
|
|
2167
|
+
const failed = status.failed ?? 0
|
|
2168
|
+
const phase = jobPhase(resource)
|
|
2169
|
+
const complete = phase === 'Complete'
|
|
2170
|
+
return {
|
|
2171
|
+
readyLabel: `${succeeded}/${desired}`,
|
|
2172
|
+
detail: complete ? 'completed successfully' : phase === 'Failed' ? jobConditionMessage(resource) || `${failed} failed` : active > 0 ? `${active} active` : 'waiting for pods',
|
|
2173
|
+
healthLabel: phase,
|
|
2174
|
+
healthBadge: phase === 'Failed' ? 'status-unhealthy' : phase === 'Pending' ? 'status-degraded' : complete ? 'status-healthy' : 'status-neutral',
|
|
2175
|
+
hasIssue: phase === 'Failed',
|
|
2176
|
+
stats: [
|
|
2177
|
+
{ label: 'Completions', value: `${succeeded}/${desired}`, tone: complete ? 'good' : 'default' },
|
|
2178
|
+
{ label: 'Active', value: active },
|
|
2179
|
+
{ label: 'Failed attempts', value: failed, tone: phase === 'Failed' ? 'warn' : 'default' },
|
|
2180
|
+
{ label: 'Parallelism', value: spec.parallelism ?? '-' },
|
|
2181
|
+
],
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
if (k === 'cronjobs') {
|
|
2186
|
+
const active = Array.isArray(status.active) ? status.active.length : 0
|
|
2187
|
+
const suspended = !!spec.suspend
|
|
2188
|
+
const lastSchedule = status.lastScheduleTime ? Date.parse(status.lastScheduleTime) : 0
|
|
2189
|
+
const lastSuccess = status.lastSuccessfulTime ? Date.parse(status.lastSuccessfulTime) : 0
|
|
2190
|
+
const missingRecentSuccess = !suspended && active === 0 && lastSchedule > 0 && lastSchedule > lastSuccess
|
|
2191
|
+
return {
|
|
2192
|
+
readyLabel: active > 0 ? `${active} active` : 'Idle',
|
|
2193
|
+
detail: spec.schedule ? `schedule ${spec.schedule}` : 'scheduled job',
|
|
2194
|
+
healthLabel: missingRecentSuccess ? 'No recent success' : suspended ? 'Suspended' : active > 0 ? 'Active' : 'Scheduled',
|
|
2195
|
+
healthBadge: missingRecentSuccess ? 'status-degraded' : suspended ? 'status-neutral' : active > 0 ? 'status-neutral' : 'status-healthy',
|
|
2196
|
+
hasIssue: missingRecentSuccess,
|
|
2197
|
+
stats: [
|
|
2198
|
+
{ label: 'Schedule', value: spec.schedule || '-' },
|
|
2199
|
+
{ label: 'Active jobs', value: active, tone: active > 0 ? 'warn' : 'default' },
|
|
2200
|
+
{ label: 'Suspend', value: suspended ? 'Yes' : 'No', tone: suspended ? 'warn' : 'default' },
|
|
2201
|
+
{ label: 'Last schedule', value: status.lastScheduleTime ? formatAge(status.lastScheduleTime) : '-' },
|
|
2202
|
+
{ label: 'Last success', value: status.lastSuccessfulTime ? formatAge(status.lastSuccessfulTime) : '-' },
|
|
2203
|
+
],
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
const desired = spec.replicas ?? status.replicas ?? 0
|
|
2208
|
+
const current = status.replicas ?? desired
|
|
2209
|
+
const ready = status.readyReplicas ?? 0
|
|
2210
|
+
const updated = status.updatedReplicas ?? 0
|
|
2211
|
+
const available = status.availableReplicas ?? ready
|
|
2212
|
+
const unavailable = status.unavailableReplicas ?? Math.max(0, desired - available)
|
|
2213
|
+
const scaledToZero = desired === 0
|
|
2214
|
+
const healthy = !scaledToZero && ready === desired && unavailable === 0
|
|
2215
|
+
return {
|
|
2216
|
+
readyLabel: `${ready}/${desired}`,
|
|
2217
|
+
detail: `${updated}/${desired} updated · ${available} available`,
|
|
2218
|
+
healthLabel: scaledToZero ? 'Scaled to zero' : healthy ? 'Healthy' : 'Degraded',
|
|
2219
|
+
healthBadge: scaledToZero ? 'bg-theme-elevated text-theme-text-secondary' : healthy ? 'status-healthy' : 'status-degraded',
|
|
2220
|
+
hasIssue: !healthy && !scaledToZero,
|
|
2221
|
+
stats: [
|
|
2222
|
+
{ label: 'Desired', value: desired },
|
|
2223
|
+
{ label: 'Current', value: current },
|
|
2224
|
+
{ label: 'Ready', value: ready, tone: ready === desired ? 'good' : 'warn' },
|
|
2225
|
+
{ label: 'Updated', value: updated },
|
|
2226
|
+
{ label: 'Available', value: available },
|
|
2227
|
+
{ label: 'Unavailable', value: unavailable, tone: unavailable > 0 ? 'warn' : 'default' },
|
|
2228
|
+
],
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
function getPodSummary(workloadPods: WorkloadPodInfo[] | undefined, relationships: Relationships | undefined, apiKind?: string) {
|
|
2233
|
+
const k = apiKind?.toLowerCase()
|
|
2234
|
+
if (workloadPods) {
|
|
2235
|
+
const ready = workloadPods.filter((pod) => pod.ready).length
|
|
2236
|
+
const total = workloadPods.length
|
|
2237
|
+
const notReady = total - ready
|
|
2238
|
+
return {
|
|
2239
|
+
label: `${ready}/${total}`,
|
|
2240
|
+
detail: total === 0 ? (k === 'jobs' ? 'no pods retained' : 'no pods found') : notReady === 0 ? 'all ready' : `${notReady} need attention`,
|
|
2241
|
+
ready,
|
|
2242
|
+
total,
|
|
2243
|
+
notReady,
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
const count = relationships?.pods?.length ?? 0
|
|
2247
|
+
return {
|
|
2248
|
+
label: count ? String(count) : '-',
|
|
2249
|
+
detail: count ? 'status unavailable' : k === 'jobs' ? 'no pods retained' : 'no pod refs',
|
|
2250
|
+
ready: undefined,
|
|
2251
|
+
total: count || undefined,
|
|
2252
|
+
notReady: undefined,
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
interface ScalingSummary {
|
|
2257
|
+
label: string
|
|
2258
|
+
detail: string
|
|
2259
|
+
stats: Array<{ label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }>
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
function runtimeControlSurface(apiKind: string): { metricLabel: string; cardTitle: string; icon: ComponentType<{ className?: string }> } {
|
|
2263
|
+
const k = apiKind.toLowerCase()
|
|
2264
|
+
if (k === 'cronjobs') return { metricLabel: 'Schedule', cardTitle: 'Schedule', icon: Clock3 }
|
|
2265
|
+
if (k === 'jobs') return { metricLabel: 'Execution', cardTitle: 'Execution', icon: Activity }
|
|
2266
|
+
return { metricLabel: 'Scaling', cardTitle: 'Scaling', icon: Scale }
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
function getScalingSummary(
|
|
2270
|
+
resource: any,
|
|
2271
|
+
apiKind: string,
|
|
2272
|
+
relationships: Relationships | undefined,
|
|
2273
|
+
scalerDiagnostics: ScalerDiagnosis[] | undefined,
|
|
2274
|
+
hpaDiagnosis: HPADiagnosis | undefined,
|
|
2275
|
+
): ScalingSummary {
|
|
2276
|
+
const spec = resource?.spec || {}
|
|
2277
|
+
const status = resource?.status || {}
|
|
2278
|
+
const k = apiKind.toLowerCase()
|
|
2279
|
+
const scalers = relationships?.scalers ?? []
|
|
2280
|
+
const primaryDiagnosis = scalerDiagnostics?.find((entry) => entry.diagnosis)?.diagnosis ?? hpaDiagnosis
|
|
2281
|
+
|
|
2282
|
+
if (k === 'daemonsets') {
|
|
2283
|
+
return {
|
|
2284
|
+
label: 'Node scheduled',
|
|
2285
|
+
detail: `${status.desiredNumberScheduled ?? 0} desired nodes`,
|
|
2286
|
+
stats: [
|
|
2287
|
+
{ label: 'Controller', value: 'DaemonSet' },
|
|
2288
|
+
{ label: 'Desired nodes', value: status.desiredNumberScheduled ?? '-' },
|
|
2289
|
+
{ label: 'Misscheduled', value: status.numberMisscheduled ?? 0, tone: (status.numberMisscheduled ?? 0) > 0 ? 'warn' : 'default' },
|
|
2290
|
+
],
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
if (k === 'jobs') {
|
|
2295
|
+
const phase = jobPhase(resource)
|
|
2296
|
+
return {
|
|
2297
|
+
label: phase,
|
|
2298
|
+
detail: '',
|
|
2299
|
+
stats: [
|
|
2300
|
+
{ label: 'Started', value: status.startTime ? formatAge(status.startTime) : '-' },
|
|
2301
|
+
{ label: 'Finished', value: status.completionTime ? formatAge(status.completionTime) : phase === 'Running' ? 'Running' : '-' },
|
|
2302
|
+
{ label: 'Parallelism', value: spec.parallelism ?? 1 },
|
|
2303
|
+
{ label: 'Completions', value: spec.completions ?? 1 },
|
|
2304
|
+
{ label: 'Completion mode', value: spec.completionMode ?? 'NonIndexed' },
|
|
2305
|
+
{ label: 'Backoff limit', value: spec.backoffLimit ?? 6 },
|
|
2306
|
+
{ label: 'TTL after finish', value: spec.ttlSecondsAfterFinished != null ? `${spec.ttlSecondsAfterFinished}s` : 'None' },
|
|
2307
|
+
],
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
if (k === 'cronjobs') {
|
|
2312
|
+
return {
|
|
2313
|
+
label: spec.suspend ? 'Suspended' : 'Scheduled',
|
|
2314
|
+
detail: '',
|
|
2315
|
+
stats: [
|
|
2316
|
+
{ label: 'Schedule', value: spec.schedule ?? '-' },
|
|
2317
|
+
{ label: 'Human', value: spec.schedule ? cronToHuman(spec.schedule) : '-' },
|
|
2318
|
+
{ label: 'Concurrency', value: spec.concurrencyPolicy ?? 'Allow' },
|
|
2319
|
+
{ label: 'Starting deadline', value: spec.startingDeadlineSeconds ? `${spec.startingDeadlineSeconds}s` : 'None' },
|
|
2320
|
+
{ label: 'Success history', value: spec.successfulJobsHistoryLimit ?? 3 },
|
|
2321
|
+
{ label: 'Failed history', value: spec.failedJobsHistoryLimit ?? 1 },
|
|
2322
|
+
{ label: 'Suspend', value: spec.suspend ? 'Yes' : 'No', tone: spec.suspend ? 'warn' : 'default' },
|
|
2323
|
+
],
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
if (scalers.length > 0 || primaryDiagnosis) {
|
|
2328
|
+
return {
|
|
2329
|
+
label: scalers.length > 0 ? `${scalers.length} controller${scalers.length === 1 ? '' : 's'}` : hpaStateLabel(primaryDiagnosis!.state),
|
|
2330
|
+
detail: primaryDiagnosis ? hpaStateLabel(primaryDiagnosis.state) : 'replicas controlled externally',
|
|
2331
|
+
stats: [
|
|
2332
|
+
{ label: 'Desired', value: primaryDiagnosis?.bounds?.desired ?? spec.replicas ?? '-' },
|
|
2333
|
+
{ label: 'Current', value: primaryDiagnosis?.bounds?.current ?? status.replicas ?? '-' },
|
|
2334
|
+
{ label: 'Min', value: primaryDiagnosis?.bounds?.min ?? '-' },
|
|
2335
|
+
{ label: 'Max', value: primaryDiagnosis?.bounds?.max ?? '-' },
|
|
2336
|
+
],
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
return {
|
|
2341
|
+
label: spec.replicas !== undefined ? `${spec.replicas} replicas` : 'Manual',
|
|
2342
|
+
detail: 'replicas from workload spec',
|
|
2343
|
+
stats: [
|
|
2344
|
+
{ label: 'Desired', value: spec.replicas ?? '-' },
|
|
2345
|
+
{ label: 'Current', value: status.replicas ?? '-' },
|
|
2346
|
+
{ label: 'Strategy', value: spec.strategy?.type || spec.updateStrategy?.type || '-' },
|
|
2347
|
+
],
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
function CurrentStateCard({ resource, apiKind, readiness }: { resource: any; apiKind: string; readiness: ReadinessSummary }) {
|
|
2352
|
+
const metadata = resource?.metadata || {}
|
|
2353
|
+
const templateSpec = getPodTemplateSpec(resource, apiKind)
|
|
2354
|
+
const containers = templateSpec?.containers ?? []
|
|
2355
|
+
const image = containers[0]?.image
|
|
2356
|
+
const k = apiKind.toLowerCase()
|
|
2357
|
+
const title = k === 'jobs' ? 'Execution state' : k === 'cronjobs' ? 'Schedule state' : 'Current state'
|
|
2358
|
+
const generation = metadata.generation
|
|
2359
|
+
const observedGeneration = resource?.status?.observedGeneration
|
|
2360
|
+
const controllerBehind =
|
|
2361
|
+
typeof generation === 'number' &&
|
|
2362
|
+
typeof observedGeneration === 'number' &&
|
|
2363
|
+
observedGeneration < generation
|
|
2364
|
+
|
|
2365
|
+
return (
|
|
2366
|
+
<OverviewCard title={title} icon={k === 'jobs' ? Activity : k === 'cronjobs' ? Clock3 : Server}>
|
|
2367
|
+
<div className="grid gap-x-8 gap-y-3 sm:grid-cols-2 lg:grid-cols-3">
|
|
2368
|
+
{readiness.stats.map((stat) => (
|
|
2369
|
+
<OverviewStat key={String(stat.label)} label={stat.label} value={stat.value} tone={stat.tone} />
|
|
2370
|
+
))}
|
|
2371
|
+
{controllerBehind && (
|
|
2372
|
+
<>
|
|
2373
|
+
<OverviewStat label="Spec generation" value={generation} tone="warn" />
|
|
2374
|
+
<OverviewStat label="Controller seen" value={observedGeneration} tone="warn" />
|
|
2375
|
+
</>
|
|
2376
|
+
)}
|
|
2377
|
+
<OverviewStat label="Age" value={metadata.creationTimestamp ? formatAge(metadata.creationTimestamp) : '-'} />
|
|
2378
|
+
</div>
|
|
2379
|
+
<div className="mt-4 grid gap-2 border-t border-theme-border pt-3 text-sm sm:grid-cols-2">
|
|
2380
|
+
<InlineFact label="Kind" value={displayKindName(apiKind, resource?.kind)} />
|
|
2381
|
+
{templateSpec && <InlineFact label="Service account" value={templateSpec.serviceAccountName || 'default'} />}
|
|
2382
|
+
{image && <InlineFact label="Image" value={<span className="font-mono text-xs">{image}</span>} />}
|
|
2383
|
+
</div>
|
|
2384
|
+
</OverviewCard>
|
|
2385
|
+
)
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
function getPodTemplateSpec(resource: any, apiKind: string) {
|
|
2389
|
+
const spec = resource?.spec || {}
|
|
2390
|
+
return apiKind.toLowerCase() === 'cronjobs'
|
|
2391
|
+
? spec.jobTemplate?.spec?.template?.spec
|
|
2392
|
+
: spec.template?.spec
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
function jobPhase(job: any): 'Complete' | 'Failed' | 'Suspended' | 'Running' | 'Pending' {
|
|
2396
|
+
const status = job?.status || {}
|
|
2397
|
+
const spec = job?.spec || {}
|
|
2398
|
+
const conditions = Array.isArray(status.conditions) ? status.conditions : []
|
|
2399
|
+
if (conditions.some((condition: any) => condition.type === 'Failed' && condition.status === 'True')) return 'Failed'
|
|
2400
|
+
if (conditions.some((condition: any) => condition.type === 'Complete' && condition.status === 'True')) return 'Complete'
|
|
2401
|
+
if (spec.suspend) return 'Suspended'
|
|
2402
|
+
if ((status.active ?? 0) > 0) return 'Running'
|
|
2403
|
+
return 'Pending'
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
function jobConditionMessage(job: any): string {
|
|
2407
|
+
const conditions = Array.isArray(job?.status?.conditions) ? job.status.conditions : []
|
|
2408
|
+
const condition = conditions.find((entry: any) => (entry.type === 'Failed' || entry.type === 'Complete') && entry.status === 'True')
|
|
2409
|
+
return condition?.message || condition?.reason || ''
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
function formatJobDuration(job: any): string {
|
|
2413
|
+
const startTime = job?.status?.startTime
|
|
2414
|
+
if (!startTime) return ''
|
|
2415
|
+
const start = Date.parse(startTime)
|
|
2416
|
+
const endRaw = job?.status?.completionTime
|
|
2417
|
+
const end = endRaw ? Date.parse(endRaw) : Date.now()
|
|
2418
|
+
if (Number.isNaN(start) || Number.isNaN(end) || end < start) return ''
|
|
2419
|
+
return formatDuration(end - start, true)
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
function OverviewStat({ label, value, tone = 'default' }: { label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }) {
|
|
2423
|
+
return (
|
|
2424
|
+
<div className="min-w-0">
|
|
2425
|
+
<div className="text-[10px] font-semibold uppercase tracking-wide text-theme-text-tertiary">{label}</div>
|
|
2426
|
+
<div className={clsx(
|
|
2427
|
+
'mt-1 truncate text-sm font-semibold',
|
|
2428
|
+
tone === 'good' ? 'text-emerald-500' : tone === 'warn' ? 'text-amber-500' : 'text-theme-text-primary',
|
|
2429
|
+
)}>
|
|
2430
|
+
{value}
|
|
2431
|
+
</div>
|
|
2432
|
+
</div>
|
|
2433
|
+
)
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
function InlineFact({ label, value }: { label: string; value: ReactNode }) {
|
|
2437
|
+
return (
|
|
2438
|
+
<div className="min-w-0">
|
|
2439
|
+
<span className="text-theme-text-tertiary">{label}</span>
|
|
2440
|
+
<span className="mx-1 text-theme-text-tertiary">·</span>
|
|
2441
|
+
<span className="break-all text-theme-text-primary">{value}</span>
|
|
2442
|
+
</div>
|
|
2443
|
+
)
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
function RuntimeCard({
|
|
2447
|
+
resource,
|
|
2448
|
+
apiKind,
|
|
2449
|
+
state,
|
|
2450
|
+
readiness,
|
|
2451
|
+
scaling,
|
|
2452
|
+
namespace,
|
|
2453
|
+
workloadPods,
|
|
2454
|
+
workloadPodsLoading,
|
|
2455
|
+
workloadPodsError,
|
|
2456
|
+
relationshipPods,
|
|
2457
|
+
scalerDiagnostics,
|
|
2458
|
+
hpaDiagnosis,
|
|
2459
|
+
relationships,
|
|
2460
|
+
onNavigate,
|
|
2461
|
+
onSwitchToLogs,
|
|
2462
|
+
}: {
|
|
2463
|
+
resource: any
|
|
2464
|
+
apiKind: string
|
|
2465
|
+
state: ReplicatedWorkloadState
|
|
2466
|
+
readiness: ReadinessSummary
|
|
2467
|
+
scaling: ScalingSummary
|
|
2468
|
+
namespace: string
|
|
2469
|
+
workloadPods?: WorkloadPodInfo[]
|
|
2470
|
+
workloadPodsLoading?: boolean
|
|
2471
|
+
workloadPodsError?: Error | null
|
|
2472
|
+
relationshipPods?: ResourceRef[]
|
|
2473
|
+
scalerDiagnostics?: ScalerDiagnosis[]
|
|
2474
|
+
hpaDiagnosis?: HPADiagnosis
|
|
2475
|
+
relationships?: Relationships
|
|
2476
|
+
onNavigate?: NavigateToResource
|
|
2477
|
+
onSwitchToLogs?: () => void
|
|
2478
|
+
}) {
|
|
2479
|
+
const progress = rolloutProgress(resource, apiKind, state)
|
|
2480
|
+
const headline = rolloutHeadline(resource, apiKind, readiness, scaling)
|
|
2481
|
+
const facts = rolloutFacts(resource, apiKind, scaling, Boolean(progress))
|
|
2482
|
+
const scalerRefs = relationships?.scalers ?? []
|
|
2483
|
+
const navigateRef = onNavigate ? (ref: ResourceRef) => onNavigate(refToSelectedResource(ref)) : undefined
|
|
2484
|
+
|
|
2485
|
+
return (
|
|
2486
|
+
<OverviewCard
|
|
2487
|
+
title="Runtime"
|
|
2488
|
+
icon={Boxes}
|
|
2489
|
+
action={onSwitchToLogs && (
|
|
2490
|
+
<button type="button" onClick={onSwitchToLogs} className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
|
|
2491
|
+
<Terminal className="h-3.5 w-3.5" />
|
|
2492
|
+
Logs
|
|
2493
|
+
</button>
|
|
2494
|
+
)}
|
|
2495
|
+
>
|
|
2496
|
+
<div className="space-y-4">
|
|
2497
|
+
<div className="space-y-3">
|
|
2498
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
2499
|
+
<span className={clsx('h-2 w-2 shrink-0 rounded-full', rolloutStateDotClass(state.level))} />
|
|
2500
|
+
<div className="min-w-0 truncate text-sm font-medium text-theme-text-primary">{headline}</div>
|
|
2501
|
+
</div>
|
|
2502
|
+
|
|
2503
|
+
<div className="flex flex-wrap gap-1.5">
|
|
2504
|
+
{facts.map((fact) => (
|
|
2505
|
+
<RolloutFactChip key={String(fact.label)} label={fact.label} value={fact.value} tone={fact.tone} />
|
|
2506
|
+
))}
|
|
2507
|
+
</div>
|
|
2508
|
+
|
|
2509
|
+
{progress && <RolloutProgressBar progress={progress} state={state} />}
|
|
2510
|
+
|
|
2511
|
+
{scalerRefs.length > 0 ? (
|
|
2512
|
+
<div className="rounded-md border border-theme-border bg-theme-base px-3 py-2">
|
|
2513
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">Controlled by</div>
|
|
2514
|
+
<div className="flex flex-wrap gap-1.5">
|
|
2515
|
+
{scalerRefs.slice(0, RELATIONSHIP_REF_LIMIT).map((ref) => (
|
|
2516
|
+
<ResourceRefBadge key={`${ref.kind}/${ref.namespace}/${ref.name}`} resourceRef={ref} onClick={navigateRef} wrapAtSeparator />
|
|
2517
|
+
))}
|
|
2518
|
+
</div>
|
|
2519
|
+
{scalerDiagnostics?.map((entry) => (
|
|
2520
|
+
<div key={`${entry.ref.kind}/${entry.ref.namespace}/${entry.ref.name}`} className="mt-2 text-xs text-theme-text-secondary">
|
|
2521
|
+
{entry.loading ? 'Loading autoscaler diagnosis...' : entry.error ? 'Autoscaler diagnosis unavailable' : entry.diagnosis ? hpaStateLabel(entry.diagnosis.state) : 'Autoscaler status unavailable'}
|
|
2522
|
+
{entry.diagnosis?.summary && <span className="ml-1 text-theme-text-tertiary">{entry.diagnosis.summary}</span>}
|
|
2523
|
+
</div>
|
|
2524
|
+
))}
|
|
2525
|
+
</div>
|
|
2526
|
+
) : hpaDiagnosis ? (
|
|
2527
|
+
<div className="rounded-md border border-theme-border bg-theme-base px-3 py-2 text-xs text-theme-text-secondary">
|
|
2528
|
+
{hpaStateLabel(hpaDiagnosis.state)} <span className="text-theme-text-tertiary">{hpaDiagnosis.summary}</span>
|
|
2529
|
+
</div>
|
|
2530
|
+
) : null}
|
|
2531
|
+
</div>
|
|
2532
|
+
|
|
2533
|
+
<div className="border-t border-theme-border pt-3">
|
|
2534
|
+
<div className="mb-2 text-xs font-medium text-theme-text-tertiary">Pods</div>
|
|
2535
|
+
<PodsListContent
|
|
2536
|
+
namespace={namespace}
|
|
2537
|
+
workloadPods={workloadPods}
|
|
2538
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
2539
|
+
workloadPodsError={workloadPodsError}
|
|
2540
|
+
relationshipPods={relationshipPods}
|
|
2541
|
+
onNavigate={onNavigate}
|
|
2542
|
+
/>
|
|
2543
|
+
</div>
|
|
2544
|
+
</div>
|
|
2545
|
+
</OverviewCard>
|
|
2546
|
+
)
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
function PodsAttentionCard({
|
|
2550
|
+
namespace,
|
|
2551
|
+
emptyText,
|
|
2552
|
+
workloadPods,
|
|
2553
|
+
workloadPodsLoading,
|
|
2554
|
+
workloadPodsError,
|
|
2555
|
+
relationshipPods,
|
|
2556
|
+
onNavigate,
|
|
2557
|
+
onSwitchToLogs,
|
|
2558
|
+
}: {
|
|
2559
|
+
namespace: string
|
|
2560
|
+
emptyText?: string
|
|
2561
|
+
workloadPods?: WorkloadPodInfo[]
|
|
2562
|
+
workloadPodsLoading?: boolean
|
|
2563
|
+
workloadPodsError?: Error | null
|
|
2564
|
+
relationshipPods?: ResourceRef[]
|
|
2565
|
+
onNavigate?: NavigateToResource
|
|
2566
|
+
onSwitchToLogs?: () => void
|
|
2567
|
+
}) {
|
|
2568
|
+
return (
|
|
2569
|
+
<OverviewCard
|
|
2570
|
+
title="Pods"
|
|
2571
|
+
icon={Boxes}
|
|
2572
|
+
action={onSwitchToLogs && (
|
|
2573
|
+
<button type="button" onClick={onSwitchToLogs} className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
|
|
2574
|
+
<Terminal className="h-3.5 w-3.5" />
|
|
2575
|
+
Logs
|
|
2576
|
+
</button>
|
|
2577
|
+
)}
|
|
2578
|
+
>
|
|
2579
|
+
<PodsListContent
|
|
2580
|
+
namespace={namespace}
|
|
2581
|
+
emptyText={emptyText}
|
|
2582
|
+
workloadPods={workloadPods}
|
|
2583
|
+
workloadPodsLoading={workloadPodsLoading}
|
|
2584
|
+
workloadPodsError={workloadPodsError}
|
|
2585
|
+
relationshipPods={relationshipPods}
|
|
2586
|
+
onNavigate={onNavigate}
|
|
2587
|
+
/>
|
|
2588
|
+
</OverviewCard>
|
|
2589
|
+
)
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
function PodsListContent({
|
|
2593
|
+
namespace,
|
|
2594
|
+
emptyText,
|
|
2595
|
+
workloadPods,
|
|
2596
|
+
workloadPodsLoading,
|
|
2597
|
+
workloadPodsError,
|
|
2598
|
+
relationshipPods,
|
|
2599
|
+
onNavigate,
|
|
2600
|
+
}: {
|
|
2601
|
+
namespace: string
|
|
2602
|
+
emptyText?: string
|
|
2603
|
+
workloadPods?: WorkloadPodInfo[]
|
|
2604
|
+
workloadPodsLoading?: boolean
|
|
2605
|
+
workloadPodsError?: Error | null
|
|
2606
|
+
relationshipPods?: ResourceRef[]
|
|
2607
|
+
onNavigate?: NavigateToResource
|
|
2608
|
+
}) {
|
|
2609
|
+
const sortedPods = [...(workloadPods ?? [])].sort(compareWorkloadPods)
|
|
2610
|
+
const [expandedPods, setExpandedPods] = useState(false)
|
|
2611
|
+
const hasPodOverflow = sortedPods.length > POD_VISIBLE_LIMIT
|
|
2612
|
+
const visiblePods = sortedPods.slice(0, POD_VISIBLE_LIMIT)
|
|
2613
|
+
const overflowPods = sortedPods.slice(POD_VISIBLE_LIMIT)
|
|
2614
|
+
const hiddenPodCount = Math.max(0, sortedPods.length - POD_VISIBLE_LIMIT)
|
|
2615
|
+
const fallbackPodRefs = relationshipPods ?? []
|
|
2616
|
+
const hasFallbackOverflow = fallbackPodRefs.length > POD_VISIBLE_LIMIT
|
|
2617
|
+
const fallbackPods = fallbackPodRefs.slice(0, POD_VISIBLE_LIMIT)
|
|
2618
|
+
const overflowFallbackPods = fallbackPodRefs.slice(POD_VISIBLE_LIMIT)
|
|
2619
|
+
const hiddenFallbackCount = Math.max(0, fallbackPodRefs.length - POD_VISIBLE_LIMIT)
|
|
2620
|
+
|
|
2621
|
+
return (
|
|
2622
|
+
<>
|
|
2623
|
+
{workloadPodsLoading ? (
|
|
2624
|
+
<div className="text-sm text-theme-text-tertiary">Loading pod readiness…</div>
|
|
2625
|
+
) : workloadPodsError ? (
|
|
2626
|
+
<div className="rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-600 dark:text-amber-300">
|
|
2627
|
+
Pod readiness unavailable. Use Logs or Timeline for deeper inspection.
|
|
2628
|
+
</div>
|
|
2629
|
+
) : workloadPods ? (
|
|
2630
|
+
visiblePods.length > 0 ? (
|
|
2631
|
+
<PodListFrame
|
|
2632
|
+
expanded={expandedPods}
|
|
2633
|
+
hasOverflow={hasPodOverflow}
|
|
2634
|
+
overflow={overflowPods.map((pod) => (
|
|
2635
|
+
<PodRow
|
|
2636
|
+
key={pod.name}
|
|
2637
|
+
name={pod.name}
|
|
2638
|
+
namespace={namespace}
|
|
2639
|
+
ready={pod.ready}
|
|
2640
|
+
healthLevel={pod.healthLevel}
|
|
2641
|
+
detail={workloadPodDetail(pod)}
|
|
2642
|
+
onNavigate={onNavigate}
|
|
2643
|
+
/>
|
|
2644
|
+
))}
|
|
2645
|
+
toggle={(
|
|
2646
|
+
<PodListToggle
|
|
2647
|
+
expanded={expandedPods}
|
|
2648
|
+
hiddenCount={hiddenPodCount}
|
|
2649
|
+
label="pods"
|
|
2650
|
+
onToggle={() => setExpandedPods((value) => !value)}
|
|
2651
|
+
/>
|
|
2652
|
+
)}
|
|
2653
|
+
>
|
|
2654
|
+
{visiblePods.map((pod) => (
|
|
2655
|
+
<PodRow
|
|
2656
|
+
key={pod.name}
|
|
2657
|
+
name={pod.name}
|
|
2658
|
+
namespace={namespace}
|
|
2659
|
+
ready={pod.ready}
|
|
2660
|
+
healthLevel={pod.healthLevel}
|
|
2661
|
+
detail={workloadPodDetail(pod)}
|
|
2662
|
+
onNavigate={onNavigate}
|
|
2663
|
+
/>
|
|
2664
|
+
))}
|
|
2665
|
+
</PodListFrame>
|
|
2666
|
+
) : (
|
|
2667
|
+
<div className="text-sm text-theme-text-tertiary">{emptyText || 'No pods currently match this workload.'}</div>
|
|
2668
|
+
)
|
|
2669
|
+
) : fallbackPods.length > 0 ? (
|
|
2670
|
+
<PodListFrame
|
|
2671
|
+
expanded={expandedPods}
|
|
2672
|
+
hasOverflow={hasFallbackOverflow}
|
|
2673
|
+
overflow={overflowFallbackPods.map((pod) => (
|
|
2674
|
+
<PodRow
|
|
2675
|
+
key={`${pod.namespace}/${pod.name}`}
|
|
2676
|
+
name={pod.name}
|
|
2677
|
+
namespace={pod.namespace || namespace}
|
|
2678
|
+
ready={null}
|
|
2679
|
+
detail="status unavailable"
|
|
2680
|
+
onNavigate={onNavigate}
|
|
2681
|
+
/>
|
|
2682
|
+
))}
|
|
2683
|
+
toggle={(
|
|
2684
|
+
<PodListToggle
|
|
2685
|
+
expanded={expandedPods}
|
|
2686
|
+
hiddenCount={hiddenFallbackCount}
|
|
2687
|
+
label="pods"
|
|
2688
|
+
onToggle={() => setExpandedPods((value) => !value)}
|
|
2689
|
+
/>
|
|
2690
|
+
)}
|
|
2691
|
+
>
|
|
2692
|
+
{fallbackPods.map((pod) => (
|
|
2693
|
+
<PodRow
|
|
2694
|
+
key={`${pod.namespace}/${pod.name}`}
|
|
2695
|
+
name={pod.name}
|
|
2696
|
+
namespace={pod.namespace || namespace}
|
|
2697
|
+
ready={null}
|
|
2698
|
+
detail="status unavailable"
|
|
2699
|
+
onNavigate={onNavigate}
|
|
2700
|
+
/>
|
|
2701
|
+
))}
|
|
2702
|
+
</PodListFrame>
|
|
2703
|
+
) : (
|
|
2704
|
+
<div className="text-sm text-theme-text-tertiary">{emptyText || 'No pod relationships found.'}</div>
|
|
2705
|
+
)}
|
|
2706
|
+
</>
|
|
2707
|
+
)
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
function PodRow({
|
|
2711
|
+
name,
|
|
2712
|
+
namespace,
|
|
2713
|
+
ready,
|
|
2714
|
+
healthLevel,
|
|
2715
|
+
detail,
|
|
2716
|
+
onNavigate,
|
|
2717
|
+
}: {
|
|
2718
|
+
name: string
|
|
2719
|
+
namespace: string
|
|
2720
|
+
ready: boolean | null
|
|
2721
|
+
healthLevel?: WorkloadPodInfo['healthLevel']
|
|
2722
|
+
detail: string
|
|
2723
|
+
onNavigate?: NavigateToResource
|
|
2724
|
+
}) {
|
|
2725
|
+
const statusLabel = podStatusLabel(healthLevel, ready)
|
|
2726
|
+
const statusClass = podStatusClass(healthLevel, ready)
|
|
2727
|
+
const content = (
|
|
2728
|
+
<>
|
|
2729
|
+
<span className={clsx('h-2 w-2 shrink-0 rounded-full', podDotClass(healthLevel, ready))} />
|
|
2730
|
+
<span className="min-w-0 flex-1">
|
|
2731
|
+
<span className="block truncate text-sm font-medium text-theme-text-primary">{name}</span>
|
|
2732
|
+
<span className="block truncate text-xs text-theme-text-tertiary">{detail}</span>
|
|
2733
|
+
</span>
|
|
2734
|
+
<span className={clsx('badge-sm shrink-0', statusClass)}>
|
|
2735
|
+
{statusLabel}
|
|
2736
|
+
</span>
|
|
2737
|
+
</>
|
|
2738
|
+
)
|
|
2739
|
+
|
|
2740
|
+
if (!onNavigate) {
|
|
2741
|
+
return (
|
|
2742
|
+
<div className="flex w-full min-w-0 items-center gap-3 rounded-md border border-theme-border bg-theme-base px-3 py-2 text-left">
|
|
2743
|
+
{content}
|
|
2744
|
+
</div>
|
|
2745
|
+
)
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
return (
|
|
2749
|
+
<button
|
|
2750
|
+
type="button"
|
|
2751
|
+
onClick={() => onNavigate({ kind: 'pods', namespace, name })}
|
|
2752
|
+
className="flex w-full min-w-0 items-center gap-3 rounded-md border border-theme-border bg-theme-base px-3 py-2 text-left transition-colors hover:bg-theme-hover"
|
|
2753
|
+
>
|
|
2754
|
+
{content}
|
|
2755
|
+
</button>
|
|
2756
|
+
)
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
function PodListFrame({
|
|
2760
|
+
expanded,
|
|
2761
|
+
hasOverflow,
|
|
2762
|
+
overflow,
|
|
2763
|
+
toggle,
|
|
2764
|
+
children,
|
|
2765
|
+
}: {
|
|
2766
|
+
expanded: boolean
|
|
2767
|
+
hasOverflow: boolean
|
|
2768
|
+
overflow?: ReactNode
|
|
2769
|
+
toggle?: ReactNode
|
|
2770
|
+
children: ReactNode
|
|
2771
|
+
}) {
|
|
2772
|
+
return (
|
|
2773
|
+
<div className="space-y-2">
|
|
2774
|
+
<div className="space-y-2">
|
|
2775
|
+
{children}
|
|
2776
|
+
</div>
|
|
2777
|
+
{hasOverflow && (
|
|
2778
|
+
<div
|
|
2779
|
+
className={clsx(
|
|
2780
|
+
'grid transition-[grid-template-rows,opacity] duration-200',
|
|
2781
|
+
expanded ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0',
|
|
2782
|
+
)}
|
|
2783
|
+
style={{ transitionTimingFunction: 'cubic-bezier(0.16, 1, 0.3, 1)' }}
|
|
2784
|
+
aria-hidden={!expanded || undefined}
|
|
2785
|
+
>
|
|
2786
|
+
<div className={clsx('min-h-0 overflow-hidden', expanded && 'max-h-[26rem] overflow-y-auto pr-1')} inert={!expanded || undefined}>
|
|
2787
|
+
<div className="space-y-2">
|
|
2788
|
+
{overflow}
|
|
2789
|
+
</div>
|
|
2790
|
+
</div>
|
|
2791
|
+
</div>
|
|
2792
|
+
)}
|
|
2793
|
+
{toggle}
|
|
2794
|
+
</div>
|
|
2795
|
+
)
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
function PodListToggle({
|
|
2799
|
+
expanded,
|
|
2800
|
+
hiddenCount,
|
|
2801
|
+
label,
|
|
2802
|
+
onToggle,
|
|
2803
|
+
}: {
|
|
2804
|
+
expanded: boolean
|
|
2805
|
+
hiddenCount: number
|
|
2806
|
+
label: string
|
|
2807
|
+
onToggle: () => void
|
|
2808
|
+
}) {
|
|
2809
|
+
if (!expanded && hiddenCount <= 0) return null
|
|
2810
|
+
|
|
2811
|
+
return (
|
|
2812
|
+
<div className="pt-1">
|
|
2813
|
+
<button
|
|
2814
|
+
type="button"
|
|
2815
|
+
aria-expanded={expanded}
|
|
2816
|
+
onClick={onToggle}
|
|
2817
|
+
className="text-xs font-medium text-accent-text hover:underline"
|
|
2818
|
+
>
|
|
2819
|
+
{expanded ? `Collapse ${label}` : `Show ${hiddenCount} more ${label}`}
|
|
2820
|
+
</button>
|
|
2821
|
+
</div>
|
|
2822
|
+
)
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
function compareWorkloadPods(a: WorkloadPodInfo, b: WorkloadPodInfo): number {
|
|
2826
|
+
const severity = podSeverityRank(b) - podSeverityRank(a)
|
|
2827
|
+
if (severity !== 0) return severity
|
|
2828
|
+
const restartDiff = (b.restartCount ?? 0) - (a.restartCount ?? 0)
|
|
2829
|
+
if (restartDiff !== 0) return restartDiff
|
|
2830
|
+
return a.name.localeCompare(b.name)
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
function podSeverityRank(pod: WorkloadPodInfo): number {
|
|
2834
|
+
switch (pod.healthLevel) {
|
|
2835
|
+
case 'unhealthy': return 4
|
|
2836
|
+
case 'degraded': return 3
|
|
2837
|
+
case 'unknown': return 2
|
|
2838
|
+
case 'neutral': return pod.ready ? 0 : 1
|
|
2839
|
+
case 'healthy': return pod.ready ? 0 : 1
|
|
2840
|
+
default: return pod.ready ? 0 : 2
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
function workloadPodDetail(pod: WorkloadPodInfo): string {
|
|
2845
|
+
const parts: string[] = []
|
|
2846
|
+
if (pod.phase) parts.push(pod.reason ? `${pod.phase} / ${pod.reason}` : pod.phase)
|
|
2847
|
+
else if (pod.reason) parts.push(pod.reason)
|
|
2848
|
+
parts.push(`${pod.containers.length} container${pod.containers.length === 1 ? '' : 's'}`)
|
|
2849
|
+
if ((pod.restartCount ?? 0) > 0) parts.push(`${pod.restartCount} restart${pod.restartCount === 1 ? '' : 's'}`)
|
|
2850
|
+
if (pod.lastTerminationReason && !['Unknown', 'Completed'].includes(pod.lastTerminationReason)) {
|
|
2851
|
+
parts.push(`last ${pod.lastTerminationReason}`)
|
|
2852
|
+
}
|
|
2853
|
+
if (pod.createdAt) parts.push(`${formatAge(pod.createdAt)} old`)
|
|
2854
|
+
return parts.join(' · ')
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
function podStatusLabel(healthLevel: WorkloadPodInfo['healthLevel'] | undefined, ready: boolean | null): string {
|
|
2858
|
+
if (healthLevel === 'unhealthy') return 'Unhealthy'
|
|
2859
|
+
if (healthLevel === 'degraded') return 'Degraded'
|
|
2860
|
+
if (healthLevel === 'neutral') return ready ? 'Ready' : 'Neutral'
|
|
2861
|
+
if (healthLevel === 'unknown') return 'Unknown'
|
|
2862
|
+
return ready === null ? 'Unknown' : ready ? 'Ready' : 'Not ready'
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
function podStatusClass(healthLevel: WorkloadPodInfo['healthLevel'] | undefined, ready: boolean | null): string {
|
|
2866
|
+
if (healthLevel === 'unhealthy') return 'status-unhealthy'
|
|
2867
|
+
if (healthLevel === 'degraded') return 'status-degraded'
|
|
2868
|
+
if (healthLevel === 'neutral') return 'status-neutral'
|
|
2869
|
+
if (healthLevel === 'unknown' || ready === null) return 'status-unknown'
|
|
2870
|
+
return ready ? 'status-healthy' : 'status-degraded'
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
function podDotClass(healthLevel: WorkloadPodInfo['healthLevel'] | undefined, ready: boolean | null): string {
|
|
2874
|
+
if (healthLevel === 'unhealthy') return 'bg-red-500'
|
|
2875
|
+
if (healthLevel === 'degraded') return 'bg-amber-500'
|
|
2876
|
+
if (healthLevel === 'neutral') return 'bg-skyhook-500'
|
|
2877
|
+
if (healthLevel === 'unknown' || ready === null) return 'bg-theme-text-tertiary'
|
|
2878
|
+
return ready ? 'bg-emerald-500' : 'bg-amber-500'
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
function MoreRows({ count, label }: { count: number; label: string }) {
|
|
2882
|
+
return <div className="text-xs text-theme-text-tertiary">+{count} more {label} hidden from this overview.</div>
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2885
|
+
type RelationshipGroup = { label: string; refs: ResourceRef[] }
|
|
2886
|
+
|
|
2887
|
+
function ServingConfigurationCard({
|
|
2888
|
+
groups,
|
|
2889
|
+
details = [],
|
|
2890
|
+
renderPortAction,
|
|
2891
|
+
renderPortPanel,
|
|
2892
|
+
onNavigate,
|
|
2893
|
+
onSwitchToTopology,
|
|
2894
|
+
}: {
|
|
2895
|
+
groups: RelationshipGroup[]
|
|
2896
|
+
details?: ServingResourceDetail[]
|
|
2897
|
+
renderPortAction?: (props: ServicePortRenderProps) => ReactNode
|
|
2898
|
+
renderPortPanel?: (props: ServicePortRenderProps) => ReactNode
|
|
2899
|
+
onNavigate?: NavigateToResource
|
|
2900
|
+
onSwitchToTopology?: () => void
|
|
2901
|
+
}) {
|
|
2902
|
+
const services = groups.find((group) => group.label === 'Services')?.refs ?? []
|
|
2903
|
+
const entrypoints = groups.find((group) => group.label === 'Entry points')?.refs ?? []
|
|
2904
|
+
const detailByRef = new Map(details.map((detail) => [resourceRefId(detail.ref), detail]))
|
|
2905
|
+
const serviceDetails = services.map((ref) => detailByRef.get(resourceRefId(ref))).filter(Boolean) as ServingResourceDetail[]
|
|
2906
|
+
const entrypointDetails = entrypoints.map((ref) => detailByRef.get(resourceRefId(ref))).filter(Boolean) as ServingResourceDetail[]
|
|
2907
|
+
const serviceResources = serviceDetails.map((detail) => detail.resource).filter(Boolean)
|
|
2908
|
+
const entrypointResources = entrypointDetails.map((detail) => detail.resource).filter(Boolean)
|
|
2909
|
+
const serviceDetailsLoading = serviceDetails.some((detail) => detail.loading)
|
|
2910
|
+
const serviceCount = services.length
|
|
2911
|
+
const entrypointCount = entrypoints.length
|
|
2912
|
+
const serviceTypes = summarizeServiceTypes(serviceResources, serviceCount, serviceDetailsLoading)
|
|
2913
|
+
const externalLabels = summarizeExternalLabels(serviceResources, entrypointResources)
|
|
2914
|
+
const exposure = summarizeServingExposure(serviceResources, serviceCount, entrypointCount, externalLabels, serviceDetailsLoading)
|
|
2915
|
+
const pathDetail =
|
|
2916
|
+
entrypointCount > 0 && serviceCount > 0
|
|
2917
|
+
? `${entrypointCount} entry point${entrypointCount === 1 ? '' : 's'} route to ${serviceCount} service${serviceCount === 1 ? '' : 's'}.`
|
|
2918
|
+
: entrypointCount > 0
|
|
2919
|
+
? `${entrypointCount} entry point${entrypointCount === 1 ? '' : 's'} detected. Use Topology to inspect the serving graph.`
|
|
2920
|
+
: `${serviceCount} service${serviceCount === 1 ? ' targets' : 's target'} this workload without an ingress or route.`
|
|
2921
|
+
const navigateRef = onNavigate ? (ref: ResourceRef) => onNavigate(refToSelectedResource(ref)) : undefined
|
|
2922
|
+
|
|
2923
|
+
return (
|
|
2924
|
+
<OverviewCard
|
|
2925
|
+
title="Serving configuration"
|
|
2926
|
+
icon={Network}
|
|
2927
|
+
action={onSwitchToTopology && (
|
|
2928
|
+
<button type="button" onClick={onSwitchToTopology} className="inline-flex items-center gap-1 text-xs text-accent-text hover:underline">
|
|
2929
|
+
<GitBranch className="h-3.5 w-3.5" />
|
|
2930
|
+
Topology
|
|
2931
|
+
</button>
|
|
2932
|
+
)}
|
|
2933
|
+
>
|
|
2934
|
+
<div className="space-y-3">
|
|
2935
|
+
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
|
2936
|
+
<span className="text-base font-semibold text-theme-text-primary">{exposure.label}</span>
|
|
2937
|
+
<Badge severity={exposure.severity} size="sm">{exposure.badge}</Badge>
|
|
2938
|
+
<span className="min-w-[12rem] flex-1 text-sm text-theme-text-secondary">{pathDetail}</span>
|
|
2939
|
+
</div>
|
|
2940
|
+
<div className="grid gap-4 lg:grid-cols-[minmax(0,1.35fr)_minmax(18rem,0.8fr)]">
|
|
2941
|
+
<div className="min-w-0 space-y-3">
|
|
2942
|
+
<div className="grid gap-3 sm:grid-cols-2">
|
|
2943
|
+
<OverviewStat label="Service type" value={serviceTypes} />
|
|
2944
|
+
<OverviewStat label="Services" value={serviceCount} />
|
|
2945
|
+
</div>
|
|
2946
|
+
<ServingPortRows
|
|
2947
|
+
services={serviceResources}
|
|
2948
|
+
loading={serviceDetailsLoading}
|
|
2949
|
+
renderPortAction={renderPortAction}
|
|
2950
|
+
renderPortPanel={renderPortPanel}
|
|
2951
|
+
/>
|
|
2952
|
+
<ServingRefChips label="Services" refs={services} onNavigate={navigateRef} />
|
|
2953
|
+
</div>
|
|
2954
|
+
<div className="min-w-0 space-y-3 border-t border-theme-border pt-3 lg:border-l lg:border-t-0 lg:pl-4 lg:pt-0">
|
|
2955
|
+
<OverviewStat label="Entry points" value={entrypointCount || '-'} />
|
|
2956
|
+
<ServingFactChips label="Addresses & hosts" values={externalLabels} empty={entrypointCount > 0 ? 'Route details unavailable.' : 'Internal cluster traffic only.'} />
|
|
2957
|
+
{entrypoints.length > 0 && <ServingRefChips label="Entry point resources" refs={entrypoints} onNavigate={navigateRef} />}
|
|
2958
|
+
</div>
|
|
2959
|
+
</div>
|
|
2960
|
+
</div>
|
|
2961
|
+
</OverviewCard>
|
|
2962
|
+
)
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
function ServingPortRows({
|
|
2966
|
+
services,
|
|
2967
|
+
loading,
|
|
2968
|
+
renderPortAction,
|
|
2969
|
+
renderPortPanel,
|
|
2970
|
+
}: {
|
|
2971
|
+
services: any[]
|
|
2972
|
+
loading?: boolean
|
|
2973
|
+
renderPortAction?: (props: ServicePortRenderProps) => ReactNode
|
|
2974
|
+
renderPortPanel?: (props: ServicePortRenderProps) => ReactNode
|
|
2975
|
+
}) {
|
|
2976
|
+
const servicesWithPorts = services.filter((service) => (service?.spec?.ports ?? []).length > 0)
|
|
2977
|
+
const visible = servicesWithPorts.slice(0, 2)
|
|
2978
|
+
const hidden = Math.max(0, servicesWithPorts.length - visible.length)
|
|
2979
|
+
return (
|
|
2980
|
+
<div className="min-w-0">
|
|
2981
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">Ports</div>
|
|
2982
|
+
{visible.length > 0 ? (
|
|
2983
|
+
<div className="space-y-2">
|
|
2984
|
+
{visible.map((service) => {
|
|
2985
|
+
const serviceName = service?.metadata?.name || 'service'
|
|
2986
|
+
return (
|
|
2987
|
+
<div key={service?.metadata?.uid || `${service?.metadata?.namespace}/${serviceName}`} className="min-w-0">
|
|
2988
|
+
{servicesWithPorts.length > 1 && (
|
|
2989
|
+
<div className="mb-1 font-mono text-[11px] text-theme-text-tertiary">{serviceName}</div>
|
|
2990
|
+
)}
|
|
2991
|
+
<div className="max-w-2xl">
|
|
2992
|
+
<ServicePortCards service={service} renderPortAction={renderPortAction} renderPortPanel={renderPortPanel} />
|
|
2993
|
+
</div>
|
|
2994
|
+
</div>
|
|
2995
|
+
)
|
|
2996
|
+
})}
|
|
2997
|
+
{hidden > 0 && <Badge tone="structural" size="sm">+{hidden} services</Badge>}
|
|
2998
|
+
</div>
|
|
2999
|
+
) : (
|
|
3000
|
+
<div className="text-xs text-theme-text-tertiary">{loading ? 'Loading service ports...' : 'No service ports loaded.'}</div>
|
|
3001
|
+
)}
|
|
3002
|
+
</div>
|
|
3003
|
+
)
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
function ServingRefChips({ label, refs, onNavigate }: { label: string; refs: ResourceRef[]; onNavigate?: (ref: ResourceRef) => void }) {
|
|
3007
|
+
const visible = refs.slice(0, RELATIONSHIP_REF_LIMIT)
|
|
3008
|
+
const hidden = Math.max(0, refs.length - visible.length)
|
|
3009
|
+
return (
|
|
3010
|
+
<div className="min-w-0">
|
|
3011
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">{label}</div>
|
|
3012
|
+
<div className="flex flex-wrap gap-1.5">
|
|
3013
|
+
{visible.map((ref) => (
|
|
3014
|
+
<ResourceRefBadge key={`${ref.kind}/${ref.namespace}/${ref.name}`} resourceRef={ref} onClick={onNavigate} wrapAtSeparator />
|
|
3015
|
+
))}
|
|
3016
|
+
{hidden > 0 && <Badge tone="structural" size="sm">+{hidden}</Badge>}
|
|
3017
|
+
</div>
|
|
3018
|
+
</div>
|
|
3019
|
+
)
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
function ServingFactChips({ label, values, empty }: { label: string; values: string[]; empty: string }) {
|
|
3023
|
+
const visible = values.slice(0, RELATIONSHIP_REF_LIMIT)
|
|
3024
|
+
const hidden = Math.max(0, values.length - visible.length)
|
|
3025
|
+
return (
|
|
3026
|
+
<div>
|
|
3027
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">{label}</div>
|
|
3028
|
+
{visible.length > 0 ? (
|
|
3029
|
+
<div className="flex flex-wrap gap-1.5">
|
|
3030
|
+
{visible.map((value) => (
|
|
3031
|
+
<Badge key={value} tone="structural" size="sm" className="max-w-full whitespace-normal break-all text-left">
|
|
3032
|
+
{value}
|
|
3033
|
+
</Badge>
|
|
3034
|
+
))}
|
|
3035
|
+
{hidden > 0 && <Badge tone="structural" size="sm">+{hidden}</Badge>}
|
|
3036
|
+
</div>
|
|
3037
|
+
) : (
|
|
3038
|
+
<div className="text-xs text-theme-text-tertiary">{empty}</div>
|
|
1457
3039
|
)}
|
|
1458
3040
|
</div>
|
|
1459
3041
|
)
|
|
1460
3042
|
}
|
|
3043
|
+
|
|
3044
|
+
function CronJobRunsCard({
|
|
3045
|
+
resource,
|
|
3046
|
+
namespace,
|
|
3047
|
+
onNavigate,
|
|
3048
|
+
onSwitchToTopology,
|
|
3049
|
+
}: {
|
|
3050
|
+
resource: any
|
|
3051
|
+
namespace: string
|
|
3052
|
+
onNavigate?: NavigateToResource
|
|
3053
|
+
onSwitchToTopology?: () => void
|
|
3054
|
+
}) {
|
|
3055
|
+
const status = resource?.status || {}
|
|
3056
|
+
const spec = resource?.spec || {}
|
|
3057
|
+
const activeJobs = Array.isArray(status.active) ? status.active : []
|
|
3058
|
+
const visibleJobs = activeJobs.slice(0, POD_VISIBLE_LIMIT)
|
|
3059
|
+
const hiddenJobCount = Math.max(0, activeJobs.length - visibleJobs.length)
|
|
3060
|
+
const emptyMessage = spec.suspend
|
|
3061
|
+
? 'No active Jobs. This CronJob is suspended, so new runs will not be scheduled until it is resumed.'
|
|
3062
|
+
: 'No active Jobs. The CronJob is waiting for the next scheduled run.'
|
|
3063
|
+
|
|
3064
|
+
return (
|
|
3065
|
+
<OverviewCard
|
|
3066
|
+
title="Runs"
|
|
3067
|
+
icon={Activity}
|
|
3068
|
+
action={onSwitchToTopology && (
|
|
3069
|
+
<button type="button" onClick={onSwitchToTopology} className="inline-flex items-center gap-1 text-xs text-skyhook-500 hover:underline">
|
|
3070
|
+
<GitBranch className="h-3.5 w-3.5" />
|
|
3071
|
+
Topology
|
|
3072
|
+
</button>
|
|
3073
|
+
)}
|
|
3074
|
+
>
|
|
3075
|
+
<div className="mb-3 grid gap-x-8 gap-y-3 sm:grid-cols-2">
|
|
3076
|
+
<OverviewStat label="Active jobs" value={activeJobs.length} tone={activeJobs.length > 0 ? 'warn' : 'default'} />
|
|
3077
|
+
<OverviewStat label="Last schedule" value={status.lastScheduleTime ? formatAge(status.lastScheduleTime) : 'Never'} />
|
|
3078
|
+
<OverviewStat label="Last success" value={status.lastSuccessfulTime ? formatAge(status.lastSuccessfulTime) : 'Never'} />
|
|
3079
|
+
<OverviewStat label="Retained history" value={`${spec.successfulJobsHistoryLimit ?? 3} ok / ${spec.failedJobsHistoryLimit ?? 1} failed`} />
|
|
3080
|
+
</div>
|
|
3081
|
+
|
|
3082
|
+
{visibleJobs.length > 0 ? (
|
|
3083
|
+
<div className="space-y-2">
|
|
3084
|
+
{visibleJobs.map((job: any) => {
|
|
3085
|
+
const ref: ResourceRef = {
|
|
3086
|
+
kind: job.kind || 'Job',
|
|
3087
|
+
namespace: job.namespace || namespace,
|
|
3088
|
+
name: job.name,
|
|
3089
|
+
}
|
|
3090
|
+
return (
|
|
3091
|
+
<button
|
|
3092
|
+
key={`${ref.namespace}/${ref.name}`}
|
|
3093
|
+
type="button"
|
|
3094
|
+
onClick={() => onNavigate?.(refToSelectedResource(ref))}
|
|
3095
|
+
className={clsx(
|
|
3096
|
+
'flex w-full min-w-0 items-center gap-3 rounded-md border border-theme-border bg-theme-base px-3 py-2 text-left',
|
|
3097
|
+
onNavigate && 'transition-colors hover:bg-theme-hover',
|
|
3098
|
+
)}
|
|
3099
|
+
>
|
|
3100
|
+
<span className="h-2 w-2 shrink-0 rounded-full bg-skyhook-500" />
|
|
3101
|
+
<span className="min-w-0 flex-1">
|
|
3102
|
+
<span className="block truncate text-sm font-medium text-theme-text-primary">{ref.name}</span>
|
|
3103
|
+
<span className="block truncate text-xs text-theme-text-tertiary">{ref.namespace || 'default namespace'}</span>
|
|
3104
|
+
</span>
|
|
3105
|
+
<span className="badge-sm status-neutral">Active</span>
|
|
3106
|
+
</button>
|
|
3107
|
+
)
|
|
3108
|
+
})}
|
|
3109
|
+
{hiddenJobCount > 0 && <MoreRows count={hiddenJobCount} label="jobs" />}
|
|
3110
|
+
</div>
|
|
3111
|
+
) : (
|
|
3112
|
+
<div className="rounded-md border border-theme-border bg-theme-base px-3 py-2 text-sm text-theme-text-tertiary">
|
|
3113
|
+
{emptyMessage}
|
|
3114
|
+
</div>
|
|
3115
|
+
)}
|
|
3116
|
+
</OverviewCard>
|
|
3117
|
+
)
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
function ScalingCard({
|
|
3121
|
+
title,
|
|
3122
|
+
icon,
|
|
3123
|
+
scaling,
|
|
3124
|
+
scalerDiagnostics,
|
|
3125
|
+
hpaDiagnosis,
|
|
3126
|
+
relationships,
|
|
3127
|
+
onNavigate,
|
|
3128
|
+
}: {
|
|
3129
|
+
title: string
|
|
3130
|
+
icon: ComponentType<{ className?: string }>
|
|
3131
|
+
scaling: ScalingSummary
|
|
3132
|
+
scalerDiagnostics?: ScalerDiagnosis[]
|
|
3133
|
+
hpaDiagnosis?: HPADiagnosis
|
|
3134
|
+
relationships?: Relationships
|
|
3135
|
+
onNavigate?: NavigateToResource
|
|
3136
|
+
}) {
|
|
3137
|
+
const scalerRefs = relationships?.scalers ?? []
|
|
3138
|
+
const navigateRef = onNavigate ? (ref: ResourceRef) => onNavigate(refToSelectedResource(ref)) : undefined
|
|
3139
|
+
|
|
3140
|
+
return (
|
|
3141
|
+
<OverviewCard title={title} icon={icon}>
|
|
3142
|
+
<div className="mb-3 grid gap-x-8 gap-y-3 sm:grid-cols-2">
|
|
3143
|
+
{scaling.stats.map((stat) => (
|
|
3144
|
+
<OverviewStat key={String(stat.label)} label={stat.label} value={stat.value} tone={stat.tone} />
|
|
3145
|
+
))}
|
|
3146
|
+
</div>
|
|
3147
|
+
{scalerRefs.length > 0 ? (
|
|
3148
|
+
<div className="space-y-2">
|
|
3149
|
+
<div className="text-xs font-medium text-theme-text-tertiary">Controlled by</div>
|
|
3150
|
+
<div className="flex flex-wrap gap-1.5">
|
|
3151
|
+
{scalerRefs.slice(0, RELATIONSHIP_REF_LIMIT).map((ref) => (
|
|
3152
|
+
<ResourceRefBadge key={`${ref.kind}/${ref.namespace}/${ref.name}`} resourceRef={ref} onClick={navigateRef} wrapAtSeparator />
|
|
3153
|
+
))}
|
|
3154
|
+
</div>
|
|
3155
|
+
{scalerDiagnostics?.map((entry) => (
|
|
3156
|
+
<div key={`${entry.ref.kind}/${entry.ref.namespace}/${entry.ref.name}`} className="rounded-md border border-theme-border bg-theme-base px-3 py-2 text-xs text-theme-text-secondary">
|
|
3157
|
+
{entry.loading ? 'Loading autoscaler diagnosis…' : entry.error ? 'Autoscaler diagnosis unavailable' : entry.diagnosis ? hpaStateLabel(entry.diagnosis.state) : 'Autoscaler status unavailable'}
|
|
3158
|
+
{entry.diagnosis?.summary && <span className="ml-1 text-theme-text-tertiary">{entry.diagnosis.summary}</span>}
|
|
3159
|
+
</div>
|
|
3160
|
+
))}
|
|
3161
|
+
</div>
|
|
3162
|
+
) : hpaDiagnosis ? (
|
|
3163
|
+
<div className="rounded-md border border-theme-border bg-theme-base px-3 py-2 text-xs text-theme-text-secondary">
|
|
3164
|
+
{hpaStateLabel(hpaDiagnosis.state)} <span className="text-theme-text-tertiary">{hpaDiagnosis.summary}</span>
|
|
3165
|
+
</div>
|
|
3166
|
+
) : scaling.detail ? (
|
|
3167
|
+
<div className="text-sm text-theme-text-secondary">{scaling.detail}</div>
|
|
3168
|
+
) : null}
|
|
3169
|
+
</OverviewCard>
|
|
3170
|
+
)
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
interface RolloutProgressSummary {
|
|
3174
|
+
updated: number
|
|
3175
|
+
desired: number
|
|
3176
|
+
ready: number
|
|
3177
|
+
unavailable: number
|
|
3178
|
+
updatedLabel: string
|
|
3179
|
+
readyLabel: string
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
function RolloutProgressBar({ progress, state }: { progress: RolloutProgressSummary; state: ReplicatedWorkloadState }) {
|
|
3183
|
+
const converged = Math.min(progress.updated, progress.ready)
|
|
3184
|
+
const percent = progress.desired > 0 ? Math.max(0, Math.min(100, (converged / progress.desired) * 100)) : 0
|
|
3185
|
+
return (
|
|
3186
|
+
<div className="rounded-md border border-theme-border bg-theme-base px-3 py-2">
|
|
3187
|
+
<div className="mb-1.5 flex min-w-0 items-center justify-between gap-3 text-xs">
|
|
3188
|
+
<span className="font-medium text-theme-text-secondary">Rollout progress</span>
|
|
3189
|
+
<span className="min-w-0 truncate text-theme-text-tertiary">
|
|
3190
|
+
{progress.updatedLabel} · {progress.readyLabel}
|
|
3191
|
+
</span>
|
|
3192
|
+
</div>
|
|
3193
|
+
<div className="h-1.5 overflow-hidden rounded-full bg-theme-elevated">
|
|
3194
|
+
<div
|
|
3195
|
+
className={clsx('h-full rounded-full transition-[width]', rolloutProgressFillClass(state.level))}
|
|
3196
|
+
style={{ width: `${percent}%` }}
|
|
3197
|
+
aria-label={`${progress.updatedLabel}; ${progress.readyLabel}`}
|
|
3198
|
+
/>
|
|
3199
|
+
</div>
|
|
3200
|
+
{progress.unavailable > 0 && (
|
|
3201
|
+
<div className="mt-1.5 text-xs text-amber-600 dark:text-amber-300">
|
|
3202
|
+
{progress.unavailable} unavailable while rollout converges.
|
|
3203
|
+
</div>
|
|
3204
|
+
)}
|
|
3205
|
+
</div>
|
|
3206
|
+
)
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
function rolloutProgressFillClass(level: ReplicatedWorkloadState['level']): string {
|
|
3210
|
+
if (level === 'unhealthy') return 'bg-red-500'
|
|
3211
|
+
if (level === 'degraded') return 'bg-amber-500'
|
|
3212
|
+
return 'bg-accent'
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
function RolloutFactChip({ label, value, tone = 'default' }: { label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }) {
|
|
3216
|
+
return (
|
|
3217
|
+
<span className={clsx(
|
|
3218
|
+
'inline-flex min-w-0 max-w-full items-center gap-1 rounded-md border px-2 py-1 text-xs',
|
|
3219
|
+
tone === 'warn'
|
|
3220
|
+
? 'border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-300'
|
|
3221
|
+
: tone === 'good'
|
|
3222
|
+
? 'border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-300'
|
|
3223
|
+
: 'border-theme-border bg-theme-base text-theme-text-secondary',
|
|
3224
|
+
)}>
|
|
3225
|
+
<span className="shrink-0 text-theme-text-tertiary">{label}</span>
|
|
3226
|
+
<span className="min-w-0 truncate font-medium text-theme-text-primary">{value}</span>
|
|
3227
|
+
</span>
|
|
3228
|
+
)
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
function rolloutStateDotClass(level: ReplicatedWorkloadState['level']): string {
|
|
3232
|
+
if (level === 'unhealthy') return 'bg-red-500'
|
|
3233
|
+
if (level === 'degraded') return 'bg-amber-500'
|
|
3234
|
+
if (level === 'neutral') return 'bg-skyhook-500'
|
|
3235
|
+
if (level === 'unknown') return 'bg-theme-text-tertiary'
|
|
3236
|
+
return 'bg-emerald-500'
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
function rolloutFacts(
|
|
3240
|
+
resource: any,
|
|
3241
|
+
apiKind: string,
|
|
3242
|
+
scaling: ScalingSummary,
|
|
3243
|
+
progressVisible = false,
|
|
3244
|
+
): Array<{ label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }> {
|
|
3245
|
+
const spec = resource?.spec || {}
|
|
3246
|
+
const status = resource?.status || {}
|
|
3247
|
+
const metadata = resource?.metadata || {}
|
|
3248
|
+
const k = apiKind.toLowerCase()
|
|
3249
|
+
const generation = metadata.generation
|
|
3250
|
+
const observedGeneration = status.observedGeneration
|
|
3251
|
+
const controllerBehind =
|
|
3252
|
+
typeof generation === 'number' &&
|
|
3253
|
+
typeof observedGeneration === 'number' &&
|
|
3254
|
+
observedGeneration < generation
|
|
3255
|
+
const facts: Array<{ label: string; value: ReactNode; tone?: 'default' | 'good' | 'warn' }> = []
|
|
3256
|
+
|
|
3257
|
+
if (k === 'daemonsets') {
|
|
3258
|
+
const desired = status.desiredNumberScheduled ?? 0
|
|
3259
|
+
const current = status.currentNumberScheduled ?? 0
|
|
3260
|
+
const updated = status.updatedNumberScheduled ?? 0
|
|
3261
|
+
const unavailable = status.numberUnavailable ?? 0
|
|
3262
|
+
const misscheduled = status.numberMisscheduled ?? 0
|
|
3263
|
+
facts.push({ label: 'Target nodes', value: desired })
|
|
3264
|
+
if (current !== desired) facts.push({ label: 'Scheduled', value: current, tone: 'warn' })
|
|
3265
|
+
if (!progressVisible && updated !== desired) facts.push({ label: 'Updated', value: `${updated}/${desired}`, tone: 'warn' })
|
|
3266
|
+
if (unavailable > 0) facts.push({ label: 'Unavailable', value: unavailable, tone: 'warn' })
|
|
3267
|
+
if (misscheduled > 0) facts.push({ label: 'Misscheduled', value: misscheduled, tone: 'warn' })
|
|
3268
|
+
facts.push({ label: 'Strategy', value: spec.updateStrategy?.type || 'RollingUpdate' })
|
|
3269
|
+
if (controllerBehind) facts.push({ label: 'Controller seen', value: observedGeneration, tone: 'warn' })
|
|
3270
|
+
return facts
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
const desired = spec.replicas ?? status.replicas ?? 0
|
|
3274
|
+
const current = status.replicas ?? desired
|
|
3275
|
+
const updated = status.updatedReplicas ?? 0
|
|
3276
|
+
const unavailable = status.unavailableReplicas ?? Math.max(0, desired - (status.availableReplicas ?? status.readyReplicas ?? 0))
|
|
3277
|
+
facts.push({ label: 'Target replicas', value: desired })
|
|
3278
|
+
if (current !== desired) facts.push({ label: 'Current', value: current, tone: 'warn' })
|
|
3279
|
+
if (!progressVisible && updated !== desired) facts.push({ label: 'Updated', value: `${updated}/${desired}`, tone: 'warn' })
|
|
3280
|
+
if (unavailable > 0) facts.push({ label: 'Unavailable', value: unavailable, tone: 'warn' })
|
|
3281
|
+
facts.push({ label: 'Strategy', value: spec.strategy?.type || spec.updateStrategy?.type || '-' })
|
|
3282
|
+
|
|
3283
|
+
if (k === 'statefulsets') {
|
|
3284
|
+
if (status.updateRevision && status.currentRevision && status.updateRevision !== status.currentRevision) {
|
|
3285
|
+
facts.push({ label: 'Revision', value: `${midTruncate(status.currentRevision, 18)} -> ${midTruncate(status.updateRevision, 18)}`, tone: 'warn' })
|
|
3286
|
+
} else if (spec.updateStrategy?.rollingUpdate?.partition != null) {
|
|
3287
|
+
facts.push({ label: 'Partition', value: spec.updateStrategy.rollingUpdate.partition })
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
if (controllerBehind) facts.push({ label: 'Controller seen', value: observedGeneration, tone: 'warn' })
|
|
3292
|
+
|
|
3293
|
+
const externallyScaled = scaling.stats.some((stat) => !['Desired', 'Current', 'Strategy'].includes(String(stat.label)))
|
|
3294
|
+
if (externallyScaled) {
|
|
3295
|
+
for (const stat of scaling.stats) {
|
|
3296
|
+
const label = String(stat.label)
|
|
3297
|
+
if (!facts.some((existing) => existing.label === label)) facts.push(stat)
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
return facts
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3303
|
+
function rolloutProgress(resource: any, apiKind: string, state: ReplicatedWorkloadState): RolloutProgressSummary | null {
|
|
3304
|
+
const spec = resource?.spec || {}
|
|
3305
|
+
const status = resource?.status || {}
|
|
3306
|
+
const k = apiKind.toLowerCase()
|
|
3307
|
+
|
|
3308
|
+
if (k === 'daemonsets') {
|
|
3309
|
+
const desired = status.desiredNumberScheduled ?? 0
|
|
3310
|
+
const updated = status.updatedNumberScheduled ?? 0
|
|
3311
|
+
const ready = status.numberReady ?? 0
|
|
3312
|
+
const unavailable = status.numberUnavailable ?? Math.max(0, desired - ready)
|
|
3313
|
+
if (!shouldShowRolloutProgress(desired, updated, ready, unavailable, state)) return null
|
|
3314
|
+
return {
|
|
3315
|
+
updated,
|
|
3316
|
+
desired,
|
|
3317
|
+
ready,
|
|
3318
|
+
unavailable,
|
|
3319
|
+
updatedLabel: `${updated}/${desired} nodes updated`,
|
|
3320
|
+
readyLabel: `${ready}/${desired} nodes ready`,
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
|
|
3324
|
+
const desired = spec.replicas ?? status.replicas ?? 0
|
|
3325
|
+
const updated = status.updatedReplicas ?? 0
|
|
3326
|
+
const ready = status.readyReplicas ?? 0
|
|
3327
|
+
const unavailable = status.unavailableReplicas ?? Math.max(0, desired - (status.availableReplicas ?? ready))
|
|
3328
|
+
if (!shouldShowRolloutProgress(desired, updated, ready, unavailable, state)) return null
|
|
3329
|
+
return {
|
|
3330
|
+
updated,
|
|
3331
|
+
desired,
|
|
3332
|
+
ready,
|
|
3333
|
+
unavailable,
|
|
3334
|
+
updatedLabel: `${updated}/${desired} updated`,
|
|
3335
|
+
readyLabel: `${ready}/${desired} ready`,
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
function shouldShowRolloutProgress(
|
|
3340
|
+
desired: number,
|
|
3341
|
+
updated: number,
|
|
3342
|
+
ready: number,
|
|
3343
|
+
unavailable: number,
|
|
3344
|
+
state: ReplicatedWorkloadState,
|
|
3345
|
+
): boolean {
|
|
3346
|
+
if (desired <= 0) return false
|
|
3347
|
+
if (updated < desired || ready < desired || unavailable > 0) return true
|
|
3348
|
+
return state.label === 'Rolling out' || state.label === 'Applying' || state.label === 'Stalled'
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
function rolloutHeadline(resource: any, apiKind: string, readiness: ReadinessSummary, scaling: ScalingSummary): string {
|
|
3352
|
+
const status = resource?.status || {}
|
|
3353
|
+
const k = apiKind.toLowerCase()
|
|
3354
|
+
if (k === 'daemonsets') {
|
|
3355
|
+
return `${readiness.readyLabel} ready on nodes`
|
|
3356
|
+
}
|
|
3357
|
+
if (k === 'statefulsets') {
|
|
3358
|
+
const revision = status.updateRevision && status.currentRevision && status.updateRevision !== status.currentRevision
|
|
3359
|
+
? `${status.currentRevision} -> ${status.updateRevision}`
|
|
3360
|
+
: status.currentRevision || status.updateRevision
|
|
3361
|
+
return `${readiness.readyLabel} ready · ${scaling.label}${revision && status.updateRevision !== status.currentRevision ? ' · updating revision' : ''}`
|
|
3362
|
+
}
|
|
3363
|
+
return `${readiness.readyLabel} ready · ${scaling.label}`
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
function ServingDependenciesCard({
|
|
3367
|
+
title = 'Serving and dependencies',
|
|
3368
|
+
relationships,
|
|
3369
|
+
groups,
|
|
3370
|
+
onNavigate,
|
|
3371
|
+
onSwitchToTopology,
|
|
3372
|
+
}: {
|
|
3373
|
+
title?: string
|
|
3374
|
+
relationships?: Relationships
|
|
3375
|
+
groups?: RelationshipGroup[]
|
|
3376
|
+
onNavigate?: NavigateToResource
|
|
3377
|
+
onSwitchToTopology?: () => void
|
|
3378
|
+
}) {
|
|
3379
|
+
const relationshipGroups = groups ?? buildRelationshipGroups(relationships)
|
|
3380
|
+
const visibleGroups = relationshipGroups.slice(0, RELATIONSHIP_GROUP_LIMIT)
|
|
3381
|
+
const hiddenRefs =
|
|
3382
|
+
visibleGroups.reduce((sum, group) => sum + Math.max(0, group.refs.length - RELATIONSHIP_REF_LIMIT), 0) +
|
|
3383
|
+
relationshipGroups.slice(RELATIONSHIP_GROUP_LIMIT).reduce((sum, group) => sum + group.refs.length, 0)
|
|
3384
|
+
const navigateRef = onNavigate ? (ref: ResourceRef) => onNavigate(refToSelectedResource(ref)) : undefined
|
|
3385
|
+
|
|
3386
|
+
return (
|
|
3387
|
+
<OverviewCard
|
|
3388
|
+
title={title}
|
|
3389
|
+
icon={Network}
|
|
3390
|
+
action={onSwitchToTopology && (
|
|
3391
|
+
<button type="button" onClick={onSwitchToTopology} className="inline-flex items-center gap-1 text-xs text-skyhook-500 hover:underline">
|
|
3392
|
+
<GitBranch className="h-3.5 w-3.5" />
|
|
3393
|
+
Topology
|
|
3394
|
+
</button>
|
|
3395
|
+
)}
|
|
3396
|
+
>
|
|
3397
|
+
{visibleGroups.length > 0 ? (
|
|
3398
|
+
<div className="space-y-3">
|
|
3399
|
+
{visibleGroups.map((group) => (
|
|
3400
|
+
<div key={group.label}>
|
|
3401
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">{group.label}</div>
|
|
3402
|
+
<div className="flex flex-wrap gap-1.5">
|
|
3403
|
+
{group.refs.slice(0, RELATIONSHIP_REF_LIMIT).map((ref) => (
|
|
3404
|
+
<ResourceRefBadge key={`${ref.kind}/${ref.namespace}/${ref.name}`} resourceRef={ref} onClick={navigateRef} wrapAtSeparator />
|
|
3405
|
+
))}
|
|
3406
|
+
{group.refs.length > RELATIONSHIP_REF_LIMIT && (
|
|
3407
|
+
<span className="badge bg-theme-elevated text-theme-text-secondary">+{group.refs.length - RELATIONSHIP_REF_LIMIT}</span>
|
|
3408
|
+
)}
|
|
3409
|
+
</div>
|
|
3410
|
+
</div>
|
|
3411
|
+
))}
|
|
3412
|
+
{hiddenRefs > 0 && <div className="text-xs text-theme-text-tertiary">+{hiddenRefs} more relationships; use Topology for the full graph.</div>}
|
|
3413
|
+
</div>
|
|
3414
|
+
) : (
|
|
3415
|
+
<div className="text-sm text-theme-text-tertiary">No serving or dependency relationships found.</div>
|
|
3416
|
+
)}
|
|
3417
|
+
</OverviewCard>
|
|
3418
|
+
)
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
function ConfigurationInputsCard({
|
|
3422
|
+
serviceAccountName,
|
|
3423
|
+
namespace,
|
|
3424
|
+
relationships,
|
|
3425
|
+
onNavigate,
|
|
3426
|
+
onSwitchToTopology,
|
|
3427
|
+
}: {
|
|
3428
|
+
serviceAccountName: string
|
|
3429
|
+
namespace: string
|
|
3430
|
+
relationships?: Relationships
|
|
3431
|
+
onNavigate?: NavigateToResource
|
|
3432
|
+
onSwitchToTopology?: () => void
|
|
3433
|
+
}) {
|
|
3434
|
+
const configRefs = dedupeResourceRefs(relationships?.configRefs ?? []).filter((ref) =>
|
|
3435
|
+
['ConfigMap', 'Secret', 'SealedSecret'].includes(ref.kind),
|
|
3436
|
+
)
|
|
3437
|
+
const policyRefs = dedupeResourceRefs([
|
|
3438
|
+
...(relationships?.pdbs ?? []),
|
|
3439
|
+
...(relationships?.networkPolicies ?? []),
|
|
3440
|
+
...(relationships?.resourceClaims ?? []),
|
|
3441
|
+
])
|
|
3442
|
+
if (!serviceAccountName && configRefs.length === 0 && policyRefs.length === 0) return null
|
|
3443
|
+
const navigateRef = onNavigate ? (ref: ResourceRef) => onNavigate(refToSelectedResource(ref)) : undefined
|
|
3444
|
+
const serviceAccountRef: ResourceRef = {
|
|
3445
|
+
kind: 'ServiceAccount',
|
|
3446
|
+
namespace,
|
|
3447
|
+
name: serviceAccountName || 'default',
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
return (
|
|
3451
|
+
<OverviewCard
|
|
3452
|
+
title="Configuration inputs"
|
|
3453
|
+
icon={Layers}
|
|
3454
|
+
action={onSwitchToTopology && (
|
|
3455
|
+
<button type="button" onClick={onSwitchToTopology} className="inline-flex items-center gap-1 text-xs text-skyhook-500 hover:underline">
|
|
3456
|
+
<GitBranch className="h-3.5 w-3.5" />
|
|
3457
|
+
Topology
|
|
3458
|
+
</button>
|
|
3459
|
+
)}
|
|
3460
|
+
>
|
|
3461
|
+
<div className="space-y-4">
|
|
3462
|
+
<div className="min-w-0">
|
|
3463
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">Identity</div>
|
|
3464
|
+
<ResourceRefBadge resourceRef={serviceAccountRef} onClick={navigateRef} wrapAtSeparator />
|
|
3465
|
+
</div>
|
|
3466
|
+
<div className="min-w-0">
|
|
3467
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">Config</div>
|
|
3468
|
+
{configRefs.length > 0 ? (
|
|
3469
|
+
<div className="flex flex-wrap gap-1.5">
|
|
3470
|
+
{configRefs.slice(0, RELATIONSHIP_REF_LIMIT).map((ref) => (
|
|
3471
|
+
<ResourceRefBadge key={`${ref.kind}/${ref.namespace}/${ref.name}`} resourceRef={ref} onClick={navigateRef} wrapAtSeparator />
|
|
3472
|
+
))}
|
|
3473
|
+
{configRefs.length > RELATIONSHIP_REF_LIMIT && <Badge tone="structural" size="sm">+{configRefs.length - RELATIONSHIP_REF_LIMIT}</Badge>}
|
|
3474
|
+
</div>
|
|
3475
|
+
) : (
|
|
3476
|
+
<div className="text-xs text-theme-text-tertiary">No ConfigMap or Secret refs found.</div>
|
|
3477
|
+
)}
|
|
3478
|
+
</div>
|
|
3479
|
+
<div className="min-w-0">
|
|
3480
|
+
<div className="mb-1 text-xs font-medium text-theme-text-tertiary">Policy & storage</div>
|
|
3481
|
+
{policyRefs.length > 0 && onSwitchToTopology ? (
|
|
3482
|
+
<button type="button" onClick={onSwitchToTopology} className="text-left text-xs text-theme-text-secondary hover:text-accent-text">
|
|
3483
|
+
{policyRefs.length} related resource{policyRefs.length === 1 ? '' : 's'} in Topology
|
|
3484
|
+
</button>
|
|
3485
|
+
) : policyRefs.length > 0 ? (
|
|
3486
|
+
<div className="text-xs text-theme-text-secondary">{policyRefs.length} related resource{policyRefs.length === 1 ? '' : 's'} found.</div>
|
|
3487
|
+
) : (
|
|
3488
|
+
<div className="text-xs text-theme-text-tertiary">No PDB, NetworkPolicy, or storage refs found.</div>
|
|
3489
|
+
)}
|
|
3490
|
+
</div>
|
|
3491
|
+
</div>
|
|
3492
|
+
</OverviewCard>
|
|
3493
|
+
)
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
function ActivityCard({
|
|
3497
|
+
events,
|
|
3498
|
+
updates,
|
|
3499
|
+
loading,
|
|
3500
|
+
eventsError,
|
|
3501
|
+
updatesError,
|
|
3502
|
+
onSwitchToTimeline,
|
|
3503
|
+
}: {
|
|
3504
|
+
events: TimelineEvent[]
|
|
3505
|
+
updates: TimelineEvent[]
|
|
3506
|
+
loading?: boolean
|
|
3507
|
+
eventsError?: Error | null
|
|
3508
|
+
updatesError?: Error | null
|
|
3509
|
+
onSwitchToTimeline?: () => void
|
|
3510
|
+
}) {
|
|
3511
|
+
const visibleEvents = mergeAndRankEvents(events, updates).slice(0, EVENT_VISIBLE_LIMIT)
|
|
3512
|
+
|
|
3513
|
+
return (
|
|
3514
|
+
<OverviewCard
|
|
3515
|
+
title="Recent activity"
|
|
3516
|
+
icon={Clock3}
|
|
3517
|
+
action={onSwitchToTimeline && (
|
|
3518
|
+
<button type="button" onClick={onSwitchToTimeline} className="inline-flex items-center gap-1 text-xs text-skyhook-500 hover:underline">
|
|
3519
|
+
<ExternalLink className="h-3.5 w-3.5" />
|
|
3520
|
+
Timeline
|
|
3521
|
+
</button>
|
|
3522
|
+
)}
|
|
3523
|
+
>
|
|
3524
|
+
{loading ? (
|
|
3525
|
+
<div className="text-sm text-theme-text-tertiary">Loading activity…</div>
|
|
3526
|
+
) : visibleEvents.length > 0 ? (
|
|
3527
|
+
<div className="space-y-2">
|
|
3528
|
+
{visibleEvents.map((event, i) => (
|
|
3529
|
+
<div key={`${event.id}-${i}`} className="rounded-md border border-theme-border bg-theme-base px-3 py-2">
|
|
3530
|
+
<div className="flex min-w-0 items-start gap-2">
|
|
3531
|
+
<span className={clsx('mt-1 h-2 w-2 shrink-0 rounded-full', isProblematicEvent(event) ? 'bg-amber-500' : 'bg-skyhook-500')} />
|
|
3532
|
+
<div className="min-w-0 flex-1">
|
|
3533
|
+
<div className="flex items-center justify-between gap-2">
|
|
3534
|
+
<span className="truncate text-sm font-medium text-theme-text-primary">{event.reason || event.eventType || 'update'}</span>
|
|
3535
|
+
<span className="shrink-0 text-xs text-theme-text-tertiary">{formatAge(event.timestamp)}</span>
|
|
3536
|
+
</div>
|
|
3537
|
+
<div className="mt-0.5 line-clamp-2 text-xs text-theme-text-secondary">
|
|
3538
|
+
{event.message || event.diff?.summary || `${event.kind} ${event.name}`}
|
|
3539
|
+
</div>
|
|
3540
|
+
</div>
|
|
3541
|
+
</div>
|
|
3542
|
+
</div>
|
|
3543
|
+
))}
|
|
3544
|
+
{(events.length + updates.length) > EVENT_VISIBLE_LIMIT && (
|
|
3545
|
+
<div className="text-xs text-theme-text-tertiary">Showing highest-signal recent events. Timeline has the full history.</div>
|
|
3546
|
+
)}
|
|
3547
|
+
</div>
|
|
3548
|
+
) : (
|
|
3549
|
+
<div className="text-sm text-theme-text-tertiary">No recent activity captured.</div>
|
|
3550
|
+
)}
|
|
3551
|
+
{eventsError && <div className="mt-2 text-xs text-red-500">Failed to load events: {eventsError.message}</div>}
|
|
3552
|
+
{updatesError && <div className="mt-2 text-xs text-red-500">Failed to load changes: {updatesError.message}</div>}
|
|
3553
|
+
</OverviewCard>
|
|
3554
|
+
)
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
function buildRelationshipGroups(relationships: Relationships | undefined): RelationshipGroup[] {
|
|
3558
|
+
return [
|
|
3559
|
+
...buildServingRelationshipGroups(relationships),
|
|
3560
|
+
...buildDependencyRelationshipGroups(relationships),
|
|
3561
|
+
]
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
function buildServingRelationshipGroups(relationships: Relationships | undefined): RelationshipGroup[] {
|
|
3565
|
+
if (!relationships) return []
|
|
3566
|
+
const routeRefs = dedupeResourceRefs([
|
|
3567
|
+
...(relationships.ingresses ?? []),
|
|
3568
|
+
...(relationships.gateways ?? []),
|
|
3569
|
+
...(relationships.routes ?? []),
|
|
3570
|
+
])
|
|
3571
|
+
return [
|
|
3572
|
+
{ label: 'Services', refs: dedupeResourceRefs(relationships.services ?? []) },
|
|
3573
|
+
{ label: 'Entry points', refs: routeRefs },
|
|
3574
|
+
].filter((group) => group.refs.length > 0)
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
function buildDependencyRelationshipGroups(relationships: Relationships | undefined): RelationshipGroup[] {
|
|
3578
|
+
if (!relationships) return []
|
|
3579
|
+
return [
|
|
3580
|
+
{ label: 'Configuration', refs: dedupeResourceRefs(relationships.configRefs ?? []) },
|
|
3581
|
+
{ label: 'Autoscalers', refs: dedupeResourceRefs(relationships.scalers ?? []) },
|
|
3582
|
+
{ label: 'Disruption budgets', refs: dedupeResourceRefs(relationships.pdbs ?? []) },
|
|
3583
|
+
{ label: 'Network policies', refs: dedupeResourceRefs(relationships.networkPolicies ?? []) },
|
|
3584
|
+
{ label: 'Storage claims', refs: dedupeResourceRefs(relationships.resourceClaims ?? []) },
|
|
3585
|
+
].filter((group) => group.refs.length > 0)
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
function summarizeServiceTypes(serviceResources: any[], serviceCount: number, loading: boolean): string {
|
|
3589
|
+
if (loading && serviceResources.length === 0) return 'Loading'
|
|
3590
|
+
const types = Array.from(new Set(
|
|
3591
|
+
serviceResources
|
|
3592
|
+
.map((service) => service?.spec?.type || 'ClusterIP')
|
|
3593
|
+
.filter(Boolean),
|
|
3594
|
+
))
|
|
3595
|
+
if (types.length === 0) return serviceCount > 0 ? 'Unknown' : '-'
|
|
3596
|
+
if (types.length <= 2) return types.join(' / ')
|
|
3597
|
+
return `${types[0]} +${types.length - 1}`
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
function summarizeExternalLabels(serviceResources: any[], entrypointResources: any[]): string[] {
|
|
3601
|
+
const labels: string[] = []
|
|
3602
|
+
for (const service of serviceResources) {
|
|
3603
|
+
const external = getServiceExternalIP(service)
|
|
3604
|
+
if (external) labels.push(`${service?.metadata?.name || 'service'}: ${external}`)
|
|
3605
|
+
}
|
|
3606
|
+
for (const entrypoint of entrypointResources) {
|
|
3607
|
+
const label = summarizeEntrypointResource(entrypoint)
|
|
3608
|
+
if (label) labels.push(label)
|
|
3609
|
+
}
|
|
3610
|
+
return dedupeStrings(labels)
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
function summarizeEntrypointResource(resource: any): string {
|
|
3614
|
+
const kind = resource?.kind
|
|
3615
|
+
const name = resource?.metadata?.name || kind || 'entrypoint'
|
|
3616
|
+
if (kind === 'Ingress') {
|
|
3617
|
+
const hosts = getIngressHosts(resource)
|
|
3618
|
+
const address = getIngressAddress(resource)
|
|
3619
|
+
return `${name}: ${hosts}${address ? ` @ ${address}` : ' (address pending)'}`
|
|
3620
|
+
}
|
|
3621
|
+
if (kind === 'Gateway') {
|
|
3622
|
+
const listeners = getGatewayListeners(resource)
|
|
3623
|
+
const addresses = getGatewayAddresses(resource)
|
|
3624
|
+
return `${name}: ${listeners}${addresses && addresses !== '-' ? ` @ ${addresses}` : ''}`
|
|
3625
|
+
}
|
|
3626
|
+
const hostnames = resource?.spec?.hostnames
|
|
3627
|
+
if (Array.isArray(hostnames) && hostnames.length > 0) {
|
|
3628
|
+
return `${name}: ${hostnames.slice(0, 2).join(', ')}${hostnames.length > 2 ? ` +${hostnames.length - 2}` : ''}`
|
|
3629
|
+
}
|
|
3630
|
+
const parentRefs = resource?.spec?.parentRefs
|
|
3631
|
+
if (Array.isArray(parentRefs) && parentRefs.length > 0) {
|
|
3632
|
+
return `${name}: ${parentRefs.length} parent${parentRefs.length === 1 ? '' : 's'}`
|
|
3633
|
+
}
|
|
3634
|
+
return name
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
function summarizeServingExposure(
|
|
3638
|
+
serviceResources: any[],
|
|
3639
|
+
serviceCount: number,
|
|
3640
|
+
entrypointCount: number,
|
|
3641
|
+
externalLabels: string[],
|
|
3642
|
+
loading: boolean,
|
|
3643
|
+
): { label: string; badge: string; severity: BadgeSeverity } {
|
|
3644
|
+
if (loading && serviceResources.length === 0) return { label: 'Checking serving exposure', badge: 'Loading', severity: 'neutral' }
|
|
3645
|
+
const pendingLoadBalancer = serviceResources.some((service) =>
|
|
3646
|
+
service?.spec?.type === 'LoadBalancer' && getServiceExternalIP(service) === 'Pending',
|
|
3647
|
+
)
|
|
3648
|
+
const hasExternalService = serviceResources.some((service) =>
|
|
3649
|
+
['LoadBalancer', 'NodePort', 'ExternalName'].includes(service?.spec?.type) || Boolean(getServiceExternalIP(service)),
|
|
3650
|
+
)
|
|
3651
|
+
if (entrypointCount > 0) return { label: 'External entrypoint configured', badge: 'External', severity: 'info' }
|
|
3652
|
+
if (pendingLoadBalancer) return { label: 'External service pending', badge: 'Pending', severity: 'warning' }
|
|
3653
|
+
if (hasExternalService || externalLabels.length > 0) return { label: 'External service configured', badge: 'External', severity: 'info' }
|
|
3654
|
+
if (serviceCount > 0) return { label: 'Internal service only', badge: 'Internal', severity: 'neutral' }
|
|
3655
|
+
return { label: 'No serving path detected', badge: 'None', severity: 'neutral' }
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
function dedupeResourceRefs(refs: ResourceRef[]): ResourceRef[] {
|
|
3659
|
+
const seen = new Set<string>()
|
|
3660
|
+
return refs.filter((ref) => {
|
|
3661
|
+
const key = resourceRefId(ref)
|
|
3662
|
+
if (seen.has(key)) return false
|
|
3663
|
+
seen.add(key)
|
|
3664
|
+
return true
|
|
3665
|
+
})
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3668
|
+
function resourceRefId(ref: ResourceRef): string {
|
|
3669
|
+
return `${ref.kind}/${ref.namespace}/${ref.name}/${ref.group ?? ''}`
|
|
3670
|
+
}
|
|
3671
|
+
|
|
3672
|
+
function dedupeStrings(values: string[]): string[] {
|
|
3673
|
+
return Array.from(new Set(values.filter(Boolean)))
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
function mergeAndRankEvents(events: TimelineEvent[], updates: TimelineEvent[]): TimelineEvent[] {
|
|
3677
|
+
const seen = new Set<string>()
|
|
3678
|
+
return [...events, ...updates]
|
|
3679
|
+
.filter((event) => {
|
|
3680
|
+
const key = event.id || `${event.timestamp}/${event.kind}/${event.name}/${event.reason}/${event.message}/${event.diff?.summary}`
|
|
3681
|
+
if (seen.has(key)) return false
|
|
3682
|
+
seen.add(key)
|
|
3683
|
+
return true
|
|
3684
|
+
})
|
|
3685
|
+
.sort((a, b) => {
|
|
3686
|
+
const aProblem = isProblematicEvent(a) ? 1 : 0
|
|
3687
|
+
const bProblem = isProblematicEvent(b) ? 1 : 0
|
|
3688
|
+
if (aProblem !== bProblem) return bProblem - aProblem
|
|
3689
|
+
return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
3690
|
+
})
|
|
3691
|
+
}
|