@skyhook-io/radar-app 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { useId, useLayoutEffect, useRef, type ReactNode } from 'react'
|
|
2
|
+
import { clsx } from 'clsx'
|
|
3
|
+
import { DimensionValue, FactGrid, Tooltip, FactRow, FoldSection, WorkspaceCard, WorkspaceProblemCallout, formatAge, toneFillClass, toneTextClass, type WorkspaceProblem } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import {
|
|
5
|
+
substrateErrorCode,
|
|
6
|
+
useSubstrateActorLogs,
|
|
7
|
+
type SubstrateActorDetail,
|
|
8
|
+
type SubstrateAttention,
|
|
9
|
+
type SubstrateEgress,
|
|
10
|
+
type SubstrateActorLogs,
|
|
11
|
+
type SubstrateLogLine,
|
|
12
|
+
type SubstrateRef,
|
|
13
|
+
} from '../../api/substrateWorkspace'
|
|
14
|
+
import { type OpenSubject, SubjectLink } from './SubstrateAttentionList'
|
|
15
|
+
import { ACTOR_STATE_LABEL, KAGENT_OUTCOME, kagentRecoverStep, kagentUnattributedText, shortSessionId, DISCARD_WHY, definitiveFailure, killLineLabel, killTie, killTiming, memoryKillText, attentionTone, bytesText, coverageReason, cpuText, fidelityLabel, refText, resumeConditionSentence, resumeSentence, revertCommand, localTime, relativeTime, servingEvidence, splitReading, withoutRepeats, workerImpactTone } from './readings'
|
|
16
|
+
import { CommandChip, Unread, When } from './shared'
|
|
17
|
+
import { RefreshFailedNotice } from '../workspace/layout'
|
|
18
|
+
|
|
19
|
+
const WORKER_RULES = new Set<SubstrateAttention['rule']>(['workerUnavailable', 'workerDraining', 'workerRestarting'])
|
|
20
|
+
|
|
21
|
+
function crashPlan(detail: SubstrateActorDetail, kill?: SubstrateActorLogs['memoryKill']) {
|
|
22
|
+
const { actor, recovery } = detail
|
|
23
|
+
const golden = detail.attention.find((a) => a.rule === 'goldenSnapshotFailed')
|
|
24
|
+
if (golden) return { text: `This actor built ${refText(actor.template)}’s golden snapshot. ${golden.nextStep}` }
|
|
25
|
+
const crash = detail.attention.find((a) => a.rule === 'crashedActors')
|
|
26
|
+
const remedy = kill?.current && kill.nextStep ? kill : crash
|
|
27
|
+
if (remedy) return { text: remedy.nextStep, command: remedy.command, thenCommand: 'thenCommand' in remedy ? remedy.thenCommand : undefined }
|
|
28
|
+
if (recovery && actor.kagent) return { text: kagentRecoverStep({ ...actor.kagent, ...detail.row.kagent }) }
|
|
29
|
+
return recovery ? { text: 'Fix the crash cause, then revert the actor.', command: revertCommand(actor) } : undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function actorProblem(detail: SubstrateActorDetail, logs?: SubstrateActorLogs): { problem: WorkspaceProblem; additional: SubstrateAttention[] } | undefined {
|
|
33
|
+
const { actor, row: { workerImpact } } = detail
|
|
34
|
+
const subject = { kind: 'Actor', group: '', namespace: actor.atespace, name: actor.name }
|
|
35
|
+
const origin = { label: 'Substrate API' }
|
|
36
|
+
const base = { source: 'reading' as const, subject, origin }
|
|
37
|
+
const additional = detail.attention.filter((a) => !WORKER_RULES.has(a.rule) && a.rule !== 'crashedActors' && !(actor.state === 'crashed' && a.rule === 'goldenSnapshotFailed'))
|
|
38
|
+
if (actor.state === 'crashed') {
|
|
39
|
+
const kill = logs?.memoryKill
|
|
40
|
+
const tie = kill && killTiming(kill, actor.crash?.time)
|
|
41
|
+
const at = actor.crash?.time ?? actor.updateTime
|
|
42
|
+
const message = actor.crash?.message
|
|
43
|
+
return { additional, problem: {
|
|
44
|
+
...base, id: 'crash', category: 'crash', tone: 'unhealthy',
|
|
45
|
+
title: at ? `Actor crashed ${relativeTime(at)}` : 'Actor crashed',
|
|
46
|
+
detail: kill?.current ? `Cause, from its worker’s log: ${memoryKillText(kill)}${tie ? `, ${tie}` : ''}.` : message ? `Substrate’s message: ${splitReading(message)[0]}` : 'Substrate recorded no crash message.',
|
|
47
|
+
rawDetail: kill?.current ? [`Read from the worker’s log in ${kill.namespace}/${kill.pod}. Radar ties it to this crash by timing: the record names this actor${tie ? `, came ${tie},` : ''} and the lines read show no restart between them.`, message].filter(Boolean).join(' ')
|
|
48
|
+
: [message && splitReading(message)[1], kill && `A memory-limit kill attempt was recorded in ${kill.namespace}/${kill.pod}${tie ? ` ${tie}` : ''}. Substrate reported ${message ? splitReading(message)[0] : 'no crash cause'}.`].filter(Boolean).join(' ') || undefined,
|
|
49
|
+
rawDetailLabel: 'Details',
|
|
50
|
+
origin: kill?.current ? { label: 'Worker Pod logs' } : origin,
|
|
51
|
+
nextStep: crashPlan(detail, kill)?.text ?? 'Investigate the crash cause before trying to recover the actor.',
|
|
52
|
+
} }
|
|
53
|
+
}
|
|
54
|
+
if (workerImpact) {
|
|
55
|
+
const title = { unavailable: 'Worker unavailable', draining: 'Worker draining', restarted: 'Worker restarted and sandbox was lost' }[workerImpact.kind]
|
|
56
|
+
const [lead, rest] = splitReading(workerImpact.reading)
|
|
57
|
+
const evidence = workerImpact.kind === 'restarted' ? undefined : servingEvidence(logs?.lines)
|
|
58
|
+
return { additional, problem: {
|
|
59
|
+
...base, id: 'worker', category: 'worker', tone: workerImpactTone(workerImpact.kind) as WorkspaceProblem['tone'], title,
|
|
60
|
+
detail: [lead, `Recorded as ${ACTOR_STATE_LABEL[actor.state].toLowerCase()}` + (evidence?.at
|
|
61
|
+
? `; its last log line was ${relativeTime(evidence.at)}${evidence.recent ? '.' : ', so it may not be serving.'}`
|
|
62
|
+
: evidence ? '; Radar found no output from it in the worker’s log, so it may not be serving.' : '.'),
|
|
63
|
+
workerImpact.deadline && `The Pod is due to be gone ${relativeTime(workerImpact.deadline)}.`].filter(Boolean).join(' '),
|
|
64
|
+
rawDetail: rest, rawDetailLabel: 'Details',
|
|
65
|
+
nextStep: workerImpact.nextStep,
|
|
66
|
+
} }
|
|
67
|
+
}
|
|
68
|
+
const [first, ...rest] = additional
|
|
69
|
+
if (!first) return undefined
|
|
70
|
+
const { title, message } = actorAttentionText(first, detail)
|
|
71
|
+
const nextStep = first.nextStep
|
|
72
|
+
const distinct = withoutRepeats(message, nextStep)
|
|
73
|
+
const [lead, rawDetail] = distinct ? splitReading(distinct) : []
|
|
74
|
+
return { additional: rest, problem: {
|
|
75
|
+
...base, id: first.id, category: first.rule, tone: attentionTone(first), title, detail: lead, rawDetail, rawDetailLabel: 'Details', nextStep,
|
|
76
|
+
} }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** What a revert leaves: the newest stored generation, or nothing. */
|
|
80
|
+
function RecoveryText({ recovery, newest }: { recovery: NonNullable<SubstrateActorDetail['recovery']>; newest?: number }) {
|
|
81
|
+
if (recovery.generation === undefined) {
|
|
82
|
+
return <>A revert returns it to suspended with nothing stored, so it boots fresh.</>
|
|
83
|
+
}
|
|
84
|
+
// At a glance already says how its newest snapshot resumes; only an older target needs saying here.
|
|
85
|
+
return (
|
|
86
|
+
<>
|
|
87
|
+
A revert returns it to suspended at generation {recovery.generation}, its newest stored snapshot.
|
|
88
|
+
{recovery.generation !== newest && <> {resumeConditionSentence(recovery.resumesWith, recovery.resumeCondition)}</>}
|
|
89
|
+
</>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A Needs attention row on one actor's page, said about this actor: the row
|
|
95
|
+
* itself is about every actor it covers, and its reading names the longest.
|
|
96
|
+
*/
|
|
97
|
+
export function actorAttentionText(row: SubstrateAttention, detail: SubstrateActorDetail): { title: string; message?: string } {
|
|
98
|
+
const { actor } = detail
|
|
99
|
+
const held = actor.updateTime ? formatAge(actor.updateTime) : undefined
|
|
100
|
+
const others = row.count - 1
|
|
101
|
+
const alsoText = others > 0 ? `${others === 1 ? '1 other actor is' : `${others} other actors are`} in the same state.` : undefined
|
|
102
|
+
switch (row.rule) {
|
|
103
|
+
case 'stuckTransition':
|
|
104
|
+
return {
|
|
105
|
+
title: `${ACTOR_STATE_LABEL[actor.state]}${held ? ` for at least ${held}` : ''}, longer than a transition should take`,
|
|
106
|
+
message: [detail.row.waitingOn?.reading, alsoText].filter(Boolean).join(' ') || undefined,
|
|
107
|
+
}
|
|
108
|
+
case 'uploadOverdue': {
|
|
109
|
+
const snap = detail.row.newestSnapshot
|
|
110
|
+
return {
|
|
111
|
+
title: `Snapshot${snap ? ` generation ${snap.generation}` : ''} not stored yet${held ? `, for at least ${held}` : ''}`,
|
|
112
|
+
message: [`Until the upload finishes, its state exists only on ${snap?.locality ? `node ${snap.locality}` : 'its node'}; losing that node could lose it.`, alsoText].filter(Boolean).join(' '),
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { title: row.title, message: row.reading }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const EGRESS_DENIED = 'so Substrate denies all outbound traffic'
|
|
120
|
+
|
|
121
|
+
export function egressText(e: SubstrateEgress): { text: ReactNode; tone: 'neutral' | 'unknown' } {
|
|
122
|
+
switch (e.state) {
|
|
123
|
+
case 'set': {
|
|
124
|
+
if (e.rules === 0) return { text: `A policy with no rules, ${EGRESS_DENIED}`, tone: 'neutral' }
|
|
125
|
+
const dest = e.destinations?.length ? ` · ${e.destinations.join(', ')}${e.more ? ` and ${e.more} more` : ''}` : ''
|
|
126
|
+
return { text: `${e.rules} ${e.rules === 1 ? 'rule' : 'rules'}${dest}`, tone: 'neutral' }
|
|
127
|
+
}
|
|
128
|
+
case 'none':
|
|
129
|
+
return { text: `No egress policy, ${EGRESS_DENIED}`, tone: 'neutral' }
|
|
130
|
+
case 'denied':
|
|
131
|
+
return { text: `Substrate denied permission to read this actor’s egress policy${e.message ? `: ${e.message}` : ''}`, tone: 'unknown' }
|
|
132
|
+
default:
|
|
133
|
+
return { text: `Couldn’t be read${e.message ? `: ${e.message}` : ''}`, tone: 'unknown' }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function KagentFact({ detail, session, onOpenSubject }: { detail: SubstrateActorDetail; session: NonNullable<SubstrateActorDetail['actor']['kagent']>; onOpenSubject?: OpenSubject }) {
|
|
138
|
+
const k = detail.row.kagent
|
|
139
|
+
return (
|
|
140
|
+
<FactRow label="kagent">
|
|
141
|
+
<Tooltip content={`kagent session ${session.sessionId}`}>
|
|
142
|
+
<span>session <span className="font-mono">{shortSessionId(session.sessionId)}</span></span>
|
|
143
|
+
</Tooltip>
|
|
144
|
+
{k?.kind === 'agentSession' ? (
|
|
145
|
+
<div>
|
|
146
|
+
Agent <SubjectLink subject={{ kind: 'Agent', namespace: k.agent.namespace, name: k.agent.name }} label={`${k.agent.namespace}/${k.agent.name}`} onOpen={onOpenSubject} withKind={false} />
|
|
147
|
+
{k.earlierRevision && <span className="text-xs text-theme-text-secondary"> · on an earlier revision ({k.revision}) than the one new sessions start on</span>}
|
|
148
|
+
{!k.earlierRevision && !k.newSessions && k.desired && <span className="text-xs text-theme-text-secondary"> · on its desired revision</span>}
|
|
149
|
+
</div>
|
|
150
|
+
) : k?.kind === 'sandbox' ? (
|
|
151
|
+
<div className="text-xs text-theme-text-secondary">A kagent sandbox, from a SandboxTemplate: a standalone environment, not an Agent’s chat.</div>
|
|
152
|
+
) : k ? (
|
|
153
|
+
<div className="text-xs text-theme-text-secondary">{kagentUnattributedText(k, detail.actor.atespace, detail.coverage.kagentAgents)}</div>
|
|
154
|
+
) : null}
|
|
155
|
+
{!session.sandbox && k?.kind !== 'sandbox' && <div className="text-xs text-theme-text-tertiary">{KAGENT_OUTCOME}</div>}
|
|
156
|
+
</FactRow>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function ActorAbout({ detail, onOpenSubject }: { detail: SubstrateActorDetail; onOpenSubject?: OpenSubject }) {
|
|
161
|
+
const { actor, template } = detail
|
|
162
|
+
return (
|
|
163
|
+
<FactGrid>
|
|
164
|
+
{actor.kagent && <KagentFact detail={detail} session={actor.kagent} onOpenSubject={onOpenSubject} />}
|
|
165
|
+
<FactRow label="Template">
|
|
166
|
+
<SubjectLink subject={{ kind: 'ActorTemplate', ...actor.template }} onOpen={onOpenSubject} withKind={false} />
|
|
167
|
+
{template && <div className="text-xs text-theme-text-tertiary">
|
|
168
|
+
{template.cpuMillicores !== undefined ? `${cpuText(template.cpuMillicores)} CPU` : 'CPU unreported'} · {template.memoryBytes !== undefined ? bytesText(template.memoryBytes) : 'memory unreported'} per actor
|
|
169
|
+
</div>}
|
|
170
|
+
</FactRow>
|
|
171
|
+
<FactRow label="Sandbox class">{actor.assignment?.sandboxClass ?? detail.row.newestSnapshot?.sandboxClass ?? <Unread>Unknown</Unread>}</FactRow>
|
|
172
|
+
<FactRow label="Seeded from">{actor.sourceTag ? <span className="font-mono">{refText(actor.sourceTag)}</span> : 'Template'}</FactRow>
|
|
173
|
+
<FactRow label="Created">{actor.createTime ? <When iso={actor.createTime} /> : <Unread>Unknown</Unread>}</FactRow>
|
|
174
|
+
</FactGrid>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function ActorPlacement({ detail, onOpenSubject }: { detail: SubstrateActorDetail; onOpenSubject?: OpenSubject }) {
|
|
179
|
+
const { actor, row, worker } = detail
|
|
180
|
+
const as = actor.assignment
|
|
181
|
+
const workerCoverage = detail.coverage.workers
|
|
182
|
+
const workerReadReason = workerCoverage.state === 'denied'
|
|
183
|
+
? workerCoverage.message ?? 'Substrate denied permission to read this worker'
|
|
184
|
+
: coverageReason(workerCoverage, 'workers')
|
|
185
|
+
const node = row.node ? <SubjectLink subject={{ kind: 'Node', name: row.node }} onOpen={onOpenSubject} withKind={false} /> : undefined
|
|
186
|
+
const pool = as?.pool ? <SubjectLink subject={{ kind: 'WorkerPool', namespace: as.namespace, name: as.pool }} label={as.pool} onOpen={onOpenSubject} withKind={false} /> : undefined
|
|
187
|
+
return (
|
|
188
|
+
<DimensionValue tone={detail.row.workerImpact ? workerImpactTone(detail.row.workerImpact.kind) : worker?.state === 'active' ? 'healthy' : as ? 'unknown' : 'neutral'}
|
|
189
|
+
source={as ? <>Substrate assignment · namespace {as.namespace} · {worker ? `worker ${worker.state}` : 'worker state unknown'}
|
|
190
|
+
{!worker && workerReadReason && ` · ${workerReadReason}`}
|
|
191
|
+
{pool && <> · Pool {pool}</>}{node && <> · Node {node}</>}</>
|
|
192
|
+
: <>No worker assignment in Substrate{node && <> · Last known node {node}</>}</>}>
|
|
193
|
+
{as ? <SubjectLink subject={{ kind: 'Pod', namespace: as.namespace, name: as.pod }} label={as.pod} onOpen={onOpenSubject} withKind={false} />
|
|
194
|
+
: actor.state === 'crashed' ? 'Unassigned while crashed' : 'Unassigned'}
|
|
195
|
+
</DimensionValue>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A line LogLines marks in place: the worker's memory-limit kill, of this crash or an earlier run. */
|
|
200
|
+
export interface MarkedLine {
|
|
201
|
+
index: number
|
|
202
|
+
/** The kill is tied to the present crash: an error rail; otherwise a label alone. */
|
|
203
|
+
current: boolean
|
|
204
|
+
label: string
|
|
205
|
+
/** The line's element id, for "Jump to line". */
|
|
206
|
+
id: string
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function LogLines({ lines, showPod, mark }: { lines: (SubstrateLogLine & { pod?: string; namespace?: string })[]; showPod?: boolean; mark?: MarkedLine }) {
|
|
210
|
+
// Opens at the newest line and follows new ones, unless the reader has scrolled up to read.
|
|
211
|
+
const ref = useRef<HTMLPreElement>(null)
|
|
212
|
+
const following = useRef(true)
|
|
213
|
+
useLayoutEffect(() => {
|
|
214
|
+
const el = ref.current
|
|
215
|
+
if (el && following.current) el.scrollTop = el.scrollHeight
|
|
216
|
+
}, [lines])
|
|
217
|
+
const onScroll = () => {
|
|
218
|
+
const el = ref.current
|
|
219
|
+
if (el) following.current = el.scrollHeight - el.scrollTop - el.clientHeight < 24
|
|
220
|
+
}
|
|
221
|
+
return (
|
|
222
|
+
<pre ref={ref} onScroll={onScroll} className="max-h-[28rem] overflow-auto rounded-lg border border-theme-border bg-theme-base px-3 py-2 font-mono text-[12px] leading-5 text-theme-text-primary">
|
|
223
|
+
{lines.map((l, i) => {
|
|
224
|
+
const marked = mark?.index === i ? mark : undefined
|
|
225
|
+
return (
|
|
226
|
+
<div key={i} id={marked?.id} className={clsx('whitespace-pre-wrap break-words', marked && 'relative')} data-marked={marked ? (marked.current ? 'current' : 'earlier') : undefined}>
|
|
227
|
+
{marked?.current && <span aria-hidden className={clsx('absolute -left-2 bottom-0.5 top-0.5 w-0.5 rounded-sm', toneFillClass('unhealthy'))} />}
|
|
228
|
+
{l.time && <span className="text-theme-text-tertiary">{new Date(l.time).toLocaleTimeString()} </span>}
|
|
229
|
+
{showPod && l.pod && <span className="text-theme-text-tertiary">{l.namespace}/{l.pod} </span>}
|
|
230
|
+
<span className="text-theme-text-tertiary">{l.kind === 'container' ? l.container ?? 'container' : l.kind} </span>
|
|
231
|
+
{l.message ?? l.text}
|
|
232
|
+
{marked && <span className={clsx('ml-2 font-sans text-[11px] font-medium', marked.current ? toneTextClass('unhealthy') : 'text-theme-text-tertiary')}>{marked.label}</span>}
|
|
233
|
+
</div>
|
|
234
|
+
)
|
|
235
|
+
})}
|
|
236
|
+
</pre>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** The loaded line that is the worker's memory-limit kill record, newest first; -1 when the lines read don't hold it. */
|
|
241
|
+
export function memoryKillLine(lines: (SubstrateLogLine & { pod?: string; namespace?: string })[], kill: NonNullable<SubstrateActorLogs['memoryKill']>): number {
|
|
242
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
243
|
+
const l = lines[i]
|
|
244
|
+
if (l.kind === 'worker' && l.memoryLimitBytes !== undefined && l.pod === kill.pod && l.namespace === kill.namespace && (!kill.time || l.time === kill.time)) return i
|
|
245
|
+
}
|
|
246
|
+
return -1
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** The query an external log backend takes for an actor: Substrate's own log attribute keys (ateattr). */
|
|
250
|
+
export function actorLogQuery(actor: SubstrateRef): string {
|
|
251
|
+
return `ate.actor.name="${actor.name}" ate.atespace="${actor.atespace}"`
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** What a log backend search needs for an actor, and the kubectl ate command: Substrate's own log attribute keys. */
|
|
255
|
+
export function LogHandoff({ actor }: { actor: SubstrateActorDetail['actor'] }) {
|
|
256
|
+
const crashed = actor.state === 'crashed' && actor.crash?.time
|
|
257
|
+
return (
|
|
258
|
+
<div className="space-y-1.5 text-sm text-theme-text-secondary">
|
|
259
|
+
<p className="text-xs">To find its lines in your log backend, search for its attributes{crashed ? <> around <span className="font-mono">{localTime(actor.crash!.time!)}</span> (local time)</> : ''}:</p>
|
|
260
|
+
<CommandChip command={actorLogQuery(actor)} />
|
|
261
|
+
|
|
262
|
+
</div>
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
export function workerLogsAvailable(logs: SubstrateActorLogs): boolean {
|
|
268
|
+
return logs.reasonCode === 'candidates' || logs.reasonCode === 'noMatch' ||
|
|
269
|
+
(logs.origin === 'worker' && logs.reasonCode === undefined)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** What a log read could not give, in product terms, from the server's reason code. */
|
|
273
|
+
function logGap(logs: SubstrateActorLogs, actor: SubstrateActorDetail['actor']): string {
|
|
274
|
+
const node = logs.node ? `node ${logs.node}` : 'its node'
|
|
275
|
+
switch (logs.reasonCode) {
|
|
276
|
+
case 'workerPodGone':
|
|
277
|
+
return `The worker Pod ${logs.worker?.pod ?? ''} is gone; Substrate still lists the worker, so its lines went with the Pod.`
|
|
278
|
+
case 'nodeGone':
|
|
279
|
+
return `The node it last ran on, ${logs.node ?? ''}, is gone from the cluster, and its worker Pods’ logs with it.`
|
|
280
|
+
case 'noWorkerPods':
|
|
281
|
+
return `No worker Pod runs on ${node} now: the one it ran in is gone, and its lines with it.`
|
|
282
|
+
case 'podsDenied':
|
|
283
|
+
return `Finding the worker Pods on ${node} requires list on pods in the worker namespaces.`
|
|
284
|
+
case 'logsDenied':
|
|
285
|
+
return `Reading the worker Pod logs on ${node} requires get on pods/log in the worker namespaces.`
|
|
286
|
+
case 'podsNotCollected':
|
|
287
|
+
return `Radar doesn’t hold Pods in every namespace, so it can’t search the worker Pods on ${node}.`
|
|
288
|
+
case 'noWorker':
|
|
289
|
+
default:
|
|
290
|
+
return `A ${ACTOR_STATE_LABEL[actor.state].toLowerCase()} actor runs on no worker, and Substrate names no node it ran on.`
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function SearchedPods({ data }: { data: SubstrateActorLogs }) {
|
|
295
|
+
if (data.searched.length === 0 && !data.morePods) return null
|
|
296
|
+
return (
|
|
297
|
+
<ul aria-label="Worker Pods searched" className="text-xs text-theme-text-tertiary">
|
|
298
|
+
{data.searched.map((p) => (
|
|
299
|
+
<li key={`${p.namespace}/${p.pod}`}>
|
|
300
|
+
<span className="font-mono">{p.namespace}/{p.pod}</span>: {p.outcome === 'read' ? `read, ${p.matched} matching lines${p.truncated ? ' (newest lines cut off)' : ''}` : p.outcome === 'gone' ? 'gone'
|
|
301
|
+
: p.outcome === 'denied' ? p.message ?? `requires get pods/log in ${p.namespace}` : `couldn’t be read${p.message ? `: ${p.message}` : ''}`}
|
|
302
|
+
</li>
|
|
303
|
+
))}
|
|
304
|
+
{data.morePods ? <li>{data.morePods} more worker {data.morePods === 1 ? 'Pod' : 'Pods'} left unsearched</li> : null}
|
|
305
|
+
</ul>
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
type LogsRead = { data?: SubstrateActorLogs; isLoading: boolean; error: unknown; isRefetchError?: boolean; dataUpdatedAt?: number }
|
|
310
|
+
|
|
311
|
+
export function ActorLogsBody({ actor, logs, compact, killNoticeAbove }: { actor: SubstrateActorDetail['actor']; logs: LogsRead; compact?: boolean; killNoticeAbove?: boolean }) {
|
|
312
|
+
const lineId = useId()
|
|
313
|
+
// A refresh that says the log can't be read any more replaces the lines kept from before.
|
|
314
|
+
const data = definitiveFailure(substrateErrorCode(logs.error)) ? undefined : logs.data
|
|
315
|
+
const stale = data && logs.isRefetchError ? <RefreshFailedNotice queries={[{ isRefetchError: true, error: logs.error instanceof Error ? logs.error : null, dataUpdatedAt: logs.dataUpdatedAt ?? 0 }]} /> : null
|
|
316
|
+
if (logs.isLoading) return <p className="text-sm text-theme-text-tertiary">Reading the worker Pod’s log…</p>
|
|
317
|
+
if (logs.error && !data) return <p className="text-sm text-theme-text-tertiary">Radar couldn’t read the log: {logs.error instanceof Error ? logs.error.message : 'unknown error'}.</p>
|
|
318
|
+
if (!data) return <p className="text-sm text-theme-text-tertiary">Worker logs have not been read.</p>
|
|
319
|
+
const truncated = data.searched.some((pod) => pod.truncated)
|
|
320
|
+
const truncatedNotice = truncated && <p className="text-xs text-theme-text-tertiary">The byte limit cut off the newest lines in {data.origin === 'worker' ? 'the worker Pod log' : 'one or more worker Pod logs'}.</p>
|
|
321
|
+
const crashedAt = actor.state === 'crashed' ? actor.crash?.time : undefined
|
|
322
|
+
if (data.lines.length > 0) {
|
|
323
|
+
const pods = [...new Set(data.lines.map((l) => `${l.namespace}/${l.pod}`))]
|
|
324
|
+
const kill = data.memoryKill
|
|
325
|
+
const at = kill ? memoryKillLine(data.lines, kill) : -1
|
|
326
|
+
// Only a kill tied to this crash is its cause; an earlier run's is labelled as one.
|
|
327
|
+
const mark = kill && at >= 0 ? { index: at, current: kill.current, label: killLineLabel(kill, crashedAt), id: lineId } : undefined
|
|
328
|
+
// The cause in full is the Overview banner's; here one short line points at the line, with the timing that ties it.
|
|
329
|
+
const tie = kill ? killTie(kill, crashedAt) : undefined
|
|
330
|
+
const jump = mark && !compact ? (
|
|
331
|
+
<button type="button" onClick={() => document.getElementById(mark.id)?.scrollIntoView({ block: 'center', behavior: 'smooth' })} className="ml-2 whitespace-nowrap text-xs font-medium text-accent-text hover:underline">
|
|
332
|
+
Jump to line
|
|
333
|
+
</button>
|
|
334
|
+
) : null
|
|
335
|
+
return (
|
|
336
|
+
<div className="space-y-1.5">
|
|
337
|
+
{stale}
|
|
338
|
+
{/* One provenance line: where these lines come from. The Overview's heading already says it for a current worker. */}
|
|
339
|
+
{data.origin === 'worker' && data.worker && !compact && (
|
|
340
|
+
<p className="text-xs text-theme-text-secondary">From its current worker Pod <span className="font-mono">{data.worker.namespace}/{data.worker.pod}</span>.</p>
|
|
341
|
+
)}
|
|
342
|
+
{data.origin === 'lastNode' && (
|
|
343
|
+
<p className="text-xs text-theme-text-secondary">
|
|
344
|
+
Candidates from {pods.length === 1 ? <span className="font-mono">{pods[0]}</span> : `${pods.length} worker Pods`} on <span className="font-mono">{data.node}</span>, the node it last ran on{crashedAt ? <>, before it crashed <When iso={crashedAt} /></> : ''}: Substrate doesn’t record which Pod it ran in{pods.length > 1 ? ', so each line names its Pod' : ''}.
|
|
345
|
+
</p>
|
|
346
|
+
)}
|
|
347
|
+
{kill && !compact && !killNoticeAbove && (
|
|
348
|
+
<p className="text-sm text-theme-text-secondary">
|
|
349
|
+
{kill.current
|
|
350
|
+
? <>{at >= 0 ? 'Marked below: the worker’s memory-limit kill' : 'The worker’s log records a memory-limit kill'}{tie ? `, ${tie}` : ''}.</>
|
|
351
|
+
: <>A memory-limit kill attempt was recorded{kill.time && <> <When iso={kill.time} /></>} in {kill.namespace}/{kill.pod}.{actor.state === 'crashed' ? ' Substrate’s crash cause is reported separately.' : ''}</>}
|
|
352
|
+
{jump}
|
|
353
|
+
</p>
|
|
354
|
+
)}
|
|
355
|
+
{data.partial && <p className="text-xs text-theme-text-secondary">Some worker Pod logs on this node could not be searched.</p>}
|
|
356
|
+
{!compact && (data.partial || (truncated && data.origin === 'lastNode')) && <SearchedPods data={data} />}
|
|
357
|
+
<LogLines lines={data.lines} showPod={data.origin === 'lastNode' && pods.length > 1} mark={mark} />
|
|
358
|
+
{truncatedNotice || (data.windowFull && <p className="text-xs text-theme-text-tertiary">Radar reached its log read limit. More lines may exist outside this window.</p>)}
|
|
359
|
+
</div>
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
const noMatch = data.reasonCode === 'noMatch' || (data.origin === 'worker' && !data.reasonCode)
|
|
363
|
+
const showSearch = !compact && (!noMatch || data.origin === 'lastNode' || data.morePods || data.searched.some((p) => p.outcome !== 'read'))
|
|
364
|
+
return (
|
|
365
|
+
<div className="space-y-1.5">
|
|
366
|
+
{stale}
|
|
367
|
+
<p className="text-sm text-theme-text-secondary">{noMatch ? 'No matching log lines.' : logGap(data, actor)}
|
|
368
|
+
{!noMatch && crashedAt && <> It crashed <When iso={crashedAt} />.</>}
|
|
369
|
+
</p>
|
|
370
|
+
{noMatch && data.origin === 'lastNode' && <p className="text-xs text-theme-text-secondary">Radar searched worker Pods on {data.node}, the node where the actor last ran. {data.partial && 'Some worker Pod logs there could not be searched.'}</p>}
|
|
371
|
+
{truncatedNotice || (noMatch && data.windowFull && <p className="text-xs text-theme-text-tertiary">Radar scanned the newest lines. Older lines may exist outside that window.</p>)}
|
|
372
|
+
{showSearch && <SearchedPods data={data} />}
|
|
373
|
+
{!compact && (!noMatch || data.windowFull || data.origin === 'lastNode') && <LogHandoff actor={actor} />}
|
|
374
|
+
</div>
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export function SubstrateActorOverview({
|
|
379
|
+
detail,
|
|
380
|
+
onOpenSubject,
|
|
381
|
+
onShowLogs,
|
|
382
|
+
onShowSnapshots,
|
|
383
|
+
onShowEgress,
|
|
384
|
+
framed = true,
|
|
385
|
+
actions,
|
|
386
|
+
}: {
|
|
387
|
+
detail: SubstrateActorDetail
|
|
388
|
+
onOpenSubject?: OpenSubject
|
|
389
|
+
onShowLogs?: () => void
|
|
390
|
+
onShowSnapshots?: () => void
|
|
391
|
+
onShowEgress?: () => void
|
|
392
|
+
framed?: boolean
|
|
393
|
+
actions?: ReactNode
|
|
394
|
+
}) {
|
|
395
|
+
const { actor, row, recovery } = detail
|
|
396
|
+
const logs = useSubstrateActorLogs(actor, { tailLines: 8, pollMs: actor.assignment?.pod && actor.assignment.namespace ? undefined : false })
|
|
397
|
+
const logData = definitiveFailure(substrateErrorCode(logs.error)) ? undefined : logs.data
|
|
398
|
+
const assessment = actorProblem(detail, logData)
|
|
399
|
+
const plan = actor.state === 'crashed' ? crashPlan(detail, logData?.memoryKill) : undefined
|
|
400
|
+
const otherRemedy = detail.row.workerImpact ?? detail.attention.find((a) => a.id === assessment?.problem.id)
|
|
401
|
+
const command = actor.kagent ? undefined : plan ? plan.command : otherRemedy?.command
|
|
402
|
+
const then = actor.kagent ? undefined : plan ? plan.thenCommand : otherRemedy && 'thenCommand' in otherRemedy ? otherRemedy.thenCommand : undefined
|
|
403
|
+
const egress = egressText(detail.egress)
|
|
404
|
+
const matchingLines = logData?.lines.length ?? 0
|
|
405
|
+
const logsTruncated = logData?.searched.some((pod) => pod.truncated)
|
|
406
|
+
const logsUnavailable = logData && !workerLogsAvailable(logData)
|
|
407
|
+
const logValue = logs.isLoading ? 'Reading worker logs…'
|
|
408
|
+
: logsUnavailable ? 'Worker logs unavailable'
|
|
409
|
+
: logs.error ? 'Worker logs couldn’t be read'
|
|
410
|
+
: !logData ? 'Worker logs not read'
|
|
411
|
+
: matchingLines > 0 ? `${matchingLines}${logsTruncated ? '' : ' recent'} ${matchingLines === 1 ? 'line' : 'lines'} read${logData.partial ? ' from available worker Pods' : ''}`
|
|
412
|
+
: logData.partial || logsTruncated ? 'No matches in the worker logs Radar could search'
|
|
413
|
+
: 'No matches in the recent log window'
|
|
414
|
+
const restore = { memory: 'with memory', filesystem: 'with saved files', volumes: 'with saved volumes only', cold: 'as a fresh boot', unknown: 'with unreported fidelity' }[row.resumesWith]
|
|
415
|
+
const recoveryText = row.resumeGeneration === undefined ? 'Boots fresh'
|
|
416
|
+
: `Resumes from snapshot generation ${row.resumeGeneration} (${row.resumeCondition === 'compatibleRuntime' ? 'with memory, if the runtime is compatible' : restore})`
|
|
417
|
+
const discarded = recovery?.discarded ?? []
|
|
418
|
+
const golden = detail.attention.some((a) => a.rule === 'goldenSnapshotFailed')
|
|
419
|
+
const pending = discarded.find((d) => d.why === 'uploadPending')
|
|
420
|
+
const crashCount = detail.template?.actors?.byState.crashed
|
|
421
|
+
const crashesPartial = detail.coverage.actors.state !== 'full'
|
|
422
|
+
return (
|
|
423
|
+
<div className="space-y-4">
|
|
424
|
+
{assessment && (
|
|
425
|
+
<WorkspaceProblemCallout problem={assessment.problem} rootKind="Actor" subjectIsSelf
|
|
426
|
+
action={actor.state === 'crashed' && !!crashCount && crashCount > 1 && onOpenSubject && (
|
|
427
|
+
<button type="button" className="text-accent-text hover:underline" onClick={() => onOpenSubject({ kind: 'Actors', filter: { state: 'crashed', template: `${actor.template.atespace}/${actor.template.name}` } })}>
|
|
428
|
+
{crashesPartial ? '≥' : ''}{crashCount} reported crashed on this template →
|
|
429
|
+
</button>
|
|
430
|
+
)}
|
|
431
|
+
more={assessment.additional.length > 0 && (
|
|
432
|
+
<FoldSection title={`+${assessment.additional.length} more`} summary="" attention={false}>
|
|
433
|
+
<ul className="space-y-1 text-xs text-theme-text-secondary">
|
|
434
|
+
{assessment.additional.map((a) => <li key={a.id}>{actorAttentionText(a, detail).title}</li>)}
|
|
435
|
+
</ul>
|
|
436
|
+
</FoldSection>
|
|
437
|
+
)} />
|
|
438
|
+
)}
|
|
439
|
+
{actions}
|
|
440
|
+
<WorkspaceCard framed={framed} title="At a glance">
|
|
441
|
+
<FactGrid>
|
|
442
|
+
<FactRow label="Recovery">
|
|
443
|
+
<DimensionValue tone={row.resumesWith === 'unknown' ? 'unknown' : 'neutral'}
|
|
444
|
+
source={actor.kagent ? 'Inferred from the actor name' : <>Current template · {resumeSentence(row)}</>} linkLabel="Snapshots" onOpen={onShowSnapshots}>
|
|
445
|
+
{actor.kagent ? (actor.kagent.sandbox ? 'Looks like a kagent sandbox' : 'Looks like a kagent session') : recoveryText}
|
|
446
|
+
</DimensionValue>
|
|
447
|
+
{(command || (recovery && !actor.kagent && !golden)) && (
|
|
448
|
+
<div className="mt-2">
|
|
449
|
+
<FoldSection title="Recovery steps" summary="" attention={false}>
|
|
450
|
+
<div className="space-y-1.5 text-xs text-theme-text-secondary">
|
|
451
|
+
<p>Target actor <span className="font-mono">{refText(actor)}</span>.</p>
|
|
452
|
+
{recovery && !actor.kagent && !golden && (
|
|
453
|
+
<>
|
|
454
|
+
<p><RecoveryText recovery={recovery} newest={row.newestSnapshot?.generation} /></p>
|
|
455
|
+
{pending && <p>To keep generation {pending.generation}, wait for its upload to finish before reverting.</p>}
|
|
456
|
+
{discarded.length > 0 && <ul className="list-disc pl-4">
|
|
457
|
+
{discarded.map((d) => <li key={d.generation}>A revert drops generation {d.generation}{d.fidelity ? ` (${fidelityLabel(d.fidelity)})` : ''}: {DISCARD_WHY[d.why] ?? d.why}.</li>)}
|
|
458
|
+
</ul>}
|
|
459
|
+
</>
|
|
460
|
+
)}
|
|
461
|
+
{command && <CommandChip command={command} />}
|
|
462
|
+
{command && then && <CommandChip command={then} />}
|
|
463
|
+
</div>
|
|
464
|
+
</FoldSection>
|
|
465
|
+
</div>
|
|
466
|
+
)}
|
|
467
|
+
</FactRow>
|
|
468
|
+
<FactRow label="Placement"><ActorPlacement detail={detail} onOpenSubject={onOpenSubject} /></FactRow>
|
|
469
|
+
<FactRow label="Recent logs">
|
|
470
|
+
<DimensionValue tone={!logData || logsUnavailable || logs.error ? 'unknown' : 'neutral'} source={logsUnavailable ? logGap(logData, actor) : "Actor-filtered records from Kubernetes worker Pods"} linkLabel="Logs" onOpen={onShowLogs}>
|
|
471
|
+
{logValue}
|
|
472
|
+
</DimensionValue>
|
|
473
|
+
{matchingLines > 0 && (
|
|
474
|
+
<div className="mt-2">
|
|
475
|
+
<FoldSection title="Recent lines" summary="" attention={false}><ActorLogsBody actor={actor} logs={logs} compact /></FoldSection>
|
|
476
|
+
</div>
|
|
477
|
+
)}
|
|
478
|
+
</FactRow>
|
|
479
|
+
<FactRow label="Outbound policy">
|
|
480
|
+
<DimensionValue tone={egress.tone} source={detail.egress.state === 'none' || (detail.egress.state === 'set' && detail.egress.rules === 0) ? egress.text : 'Actor egress policy from Substrate'} linkLabel="Egress" onOpen={onShowEgress}>
|
|
481
|
+
{detail.egress.state === 'none' || (detail.egress.state === 'set' && detail.egress.rules === 0) ? 'Default deny' : egress.text}
|
|
482
|
+
</DimensionValue>
|
|
483
|
+
</FactRow>
|
|
484
|
+
</FactGrid>
|
|
485
|
+
</WorkspaceCard>
|
|
486
|
+
<WorkspaceCard framed={framed} title="About"><ActorAbout detail={detail} onOpenSubject={onOpenSubject} /></WorkspaceCard>
|
|
487
|
+
</div>
|
|
488
|
+
)
|
|
489
|
+
}
|