Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix agent update triage and durable action recovery

rcourtmand2c268c0e528
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index eff2b943a1..a1cf6bb366 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -414,6 +414,19 @@ spellings as the same recovered state while preserving the same fail-closed
URL-plus-token threshold. Windows stale-agent update commands remain on the
existing token-gated install transport until the Windows installer owns an
equivalent saved-state update mode.
+The report contract separates runtime family from OS identity. Newly built
+agents derive `Host.Platform` from their compiled GOOS and keep the
+distribution or appliance caption in `Host.OSName`; a Mageia agent therefore
+reports `linux` plus `Mageia`, not `mageia` as an unclassified runtime. Server
+ingest and connection-ledger projection must remain compatible with older
+agents whose gopsutil platform field contains a Linux distribution identifier.
+That compatibility is expressed once through
+`platformsupport.ResolveAgentRuntimePlatform`: Pulse's published Windows,
+macOS, and FreeBSD families resolve explicitly, known unsupported OS families
+fail closed, and the remaining non-empty legacy distribution identifiers
+resolve to Linux without a distro allowlist. Agent Doctor's browser fallback
+mirrors that bounded release-family rule so a stale server payload cannot
+regress long-tail Linux distributions back to an unavailable manual command.
Agent Fleet Doctor diagnostics extend that same read-only lifecycle triage
surface: `GET /api/agents/diagnostics` may explain stale versions, missing
reports, profile deployment drift, expected Docker/Kubernetes telemetry gaps,
@@ -429,9 +442,11 @@ Repair entries remain handoffs to existing lifecycle operations:
`copy_upgrade_command` renders a local operator command and
`allow_reenroll` invokes the existing removed-agent flow. They never enqueue a
remote command or create an action plan. A stale agent with an unknown or
-unsupported platform, or with FreeBSD/pfSense installer state that the server
-cannot verify, must receive an unsupported handoff rather than a guessed
-command. When automatic update is enabled and checking or applying, Agent
+explicitly unsupported runtime family, or with FreeBSD/pfSense installer state
+that the server cannot verify, must receive an unsupported handoff rather than
+a guessed command. A non-empty legacy Linux distribution identifier is not
+unknown: it resolves through the published agent runtime-family contract.
+When automatic update is enabled and checking or applying, Agent
Doctor waits and reports that state instead of prematurely offering a manual
installer path. The `agentDoctor` route key is canonical; the older
`agentUpdates` deep link remains a read-side compatibility alias only. Agent
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 8c0daf32f8..176e5dbc91 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -7712,7 +7712,13 @@ query-only reconciliation, payload-to-tombstone retention, and explicit agent
receipt-protocol capability gate consumed by the APT adapters. A query
`not_found`, interrupted record, or replay-denial tombstone leaves the action
`executing` with its dispatch `receipt_pending`; it never authorizes executor
-or transport resend. Task 10 remains sole schema owner for execution,
+or transport resend. Query-only executor routing is derived from the immutable
+operation kind and action identity committed on the dispatch attempt. Each
+durable executor registers the operation kinds it owns; recovery must not
+rediscover that route through current resource inventory. A successful mutation
+may replace the resource, and a terminal preflight drift refusal may remove the
+capability that admitted the action. In both cases the exact receipt still has
+authority to terminalize its own audit row. Task 10 remains sole schema owner for execution,
verification, evidence, and compensation truth. Compensation and
verification-attempt recovery plus mobile/relay inbox and push-dedup
consumption remain separate work; no mobile or relay-local workaround may
@@ -7721,12 +7727,13 @@ resumption, real browser/lab evidence, and Task 12 certification.
That callable reconciliation path is production-driven, not merely callable:
the API server runs `RecoverExecutingActions` for every organization from a
-startup background worker and again whenever an agent (re)registers on the
-agentexec command server, because a receipt-pending attempt can only be
-answered while the owning agent is connected. Both triggers reuse the same
-bounded, serialized pass; neither introduces a new resend authority, and a
-disconnected agent simply leaves the action `executing`/`receipt_pending`
-until its next registration re-drives reconciliation.
+startup background worker, on a bounded periodic interval, and whenever an
+agent (re)registers on the agentexec command server, because a receipt-pending
+attempt can only be answered while the owning agent is connected. All triggers
+reuse the same bounded, serialized pass; none introduces a new resend
+authority, and a disconnected agent simply leaves the action
+`executing`/`receipt_pending` until a later periodic or registration pass can
+query it.
Typed Docker / Podman container start, stop, and restart operations extend that
same durable boundary rather than creating a provider-local action protocol.
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 427f872ea8..fc2ee5c224 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -1825,23 +1825,30 @@ platform and network evidence, profile drift, and safe repair-handoff support.
It hashes raw machine IDs, filters malformed interface addresses, and redacts
unbounded error strings before returning evidence. Derivation must not mutate
monitor state, probe providers, enqueue commands, or turn a repair hint into
-execution authority. Unknown updater states remain explicit warnings; unknown
-platforms and unverified FreeBSD/pfSense installer state fail closed for
-upgrade-command support. `internal/fleethealth/agent_test.go` and
+execution authority. Runtime-family normalization is shared with agent
+lifecycle through `platformsupport.ResolveAgentRuntimePlatform`. Explicit
+Windows, macOS, and FreeBSD families remain distinct; known unsupported OS
+families and missing evidence fail closed; and unmatched non-empty values from
+legacy agents resolve to Linux because those releases reported gopsutil
+distribution identifiers instead of their compiled GOOS. This intentionally
+avoids a duplicated distro allowlist, so long-tail distributions such as
+Mageia receive the same Linux repair handoff as Ubuntu or Debian. Unknown
+updater states remain explicit warnings, and unverified FreeBSD/pfSense
+installer state still fails closed for upgrade-command support.
+`internal/fleethealth/agent_test.go` and
`internal/monitoring/agent_fleet_doctor_test.go` are the focused runtime proofs.
Removed-agent rows keep command-scoping identity instead of losing it with the
live record: host and Docker removal capture the agent's last-known reported
platform onto the removed record (`RemovedHostAgent.Platform`,
`RemovedDockerHost.Platform`), and the fleet diagnostic resolves that retained
-value through the same strict platform normalization as live subjects, so
-`/api/agents/diagnostics` reports a platform for a removed agent only when its
-last live report identified one. A retained value that does not normalize to a
-known agent platform yields an empty diagnostic platform rather than a guess,
-and removed Kubernetes clusters retain no platform because the cluster report
-never carries one; downstream host-side cleanup handoffs must treat an empty
-platform as "offer explicitly labeled commands for every family, never one
-guessed executable". The retained field is additive and optional on the
+value through the same runtime-family normalization as live subjects, so
+`/api/agents/diagnostics` reports Linux for retained legacy distro identifiers
+but no platform for missing or explicitly unsupported evidence. Removed
+Kubernetes clusters retain no platform because the cluster report never
+carries one; downstream host-side cleanup handoffs must treat an empty platform
+as "offer explicitly labeled commands for every family, never one guessed
+executable". The retained field is additive and optional on the
serialized removed lists, so snapshots recorded before the field existed load
unchanged with an empty platform.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 52d2a516be..71e1300836 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -519,6 +519,14 @@ without blind redispatch, and an interrupted, missing, conflicting, or
tombstoned receipt cannot authorize another mutation. Storage/recovery code must
not add a Docker-specific receipt journal, infer restore readiness from a
terminal container action, or represent cleanup as recovery compensation.
+Query-only reconciliation routes that receipt through the immutable action id
+and operation kind recorded on the admitted dispatch attempt, not through the
+resource's current capability inventory. A completed mutation may replace the
+resource, while a safe update preflight refusal may remove the capability that
+admitted the action; neither condition may strand terminal agent truth or
+authorize redispatch. This routing remains API/action-lifecycle authority, and
+storage/recovery consumers gain no executor selection or recovery authority
+from the operation binding.
Disconnected command-agent readiness for those lifecycle actions remains an
API/runtime fail-closed condition; storage/recovery consumers may observe that
an action is unavailable, but must not reinterpret it as recovery degradation
diff --git a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
index 2eb570fae4..6bd9d0c1a1 100644
--- a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentDoctorModel.test.ts
@@ -147,6 +147,25 @@ describe('Agent Doctor model', () => {
expect(targets[0].commandBlockedReason).toContain('will not guess');
});
+ it('offers the Linux update handoff for a legacy long-tail distro identifier', () => {
+ const connection = connectionFixture({
+ agentIdentity: { hostname: 'mageia-host', platform: 'mageia', osName: 'Mageia' },
+ });
+ const targets = collectInfrastructureAgentDoctorTargets({
+ rows: [rowFixture(connection)],
+ connections: [connection],
+ diagnosticsAvailable: false,
+ targetVersion: '6.2.0',
+ });
+
+ expect(targets[0]).toMatchObject({
+ source: 'ledger-fallback',
+ needsUpdate: true,
+ commandPlatform: 'linux',
+ });
+ expect(targets[0].commandBlockedReason).toBeUndefined();
+ });
+
it('classifies eligible v6 convergence as waiting but keeps the manual command available', () => {
const connection = connectionFixture({
agentUpdate: {
diff --git a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
index c0b2bcc436..8b3078ee7e 100644
--- a/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/infrastructureAgentUpdateCommandsModel.branchcov0720pm.test.ts
@@ -39,7 +39,7 @@ const agentConnection = (overrides: Partial<Connection> = {}): Connection => ({
agentVersion: '6.1.0',
expectedAgentVersion: '6.2.0',
agentUpdateAvailable: true,
- agentIdentity: { hostname: 'host-1', platform: 'ubuntu', architecture: 'amd64' },
+ agentIdentity: { hostname: 'host-1', platform: 'linux', architecture: 'amd64' },
capabilities: { supportsPause: false, supportsScope: false, supportsTest: false },
...overrides,
});
@@ -197,41 +197,15 @@ describe('resolveKnownAgentCommandPlatform', () => {
expect(resolveKnownAgentCommandPlatform(caption)).toBe(expected);
});
- it.each([
- 'linux',
- 'ubuntu',
- 'debian',
- 'debian 12',
- 'almalinux',
- 'amazon',
- 'arch',
- 'centos',
- 'fedora',
- 'gentoo',
- 'manjaro',
- 'nixos',
- 'openwrt',
- 'opensuse',
- 'oracle',
- 'proxmox',
- 'qnap',
- 'raspbian',
- 'redhat',
- 'rhel',
- 'rocky',
- 'sles',
- 'suse',
- 'synology',
- 'unraid',
- 'Ubuntu 22.04.4 LTS',
- ])('classifies known linux caption %s as linux', (caption) => {
- expect(resolveKnownAgentCommandPlatform(caption)).toBe('linux');
- });
-
- it('treats a known distro substring (without trailing space) as unknown', () => {
- // "ubuntufork" neither equals a known distro nor starts with `${candidate} `,
- // so the strict resolver refuses to guess.
- expect(resolveKnownAgentCommandPlatform('ubuntufork')).toBeNull();
+ it('classifies the canonical linux runtime family', () => {
+ expect(resolveKnownAgentCommandPlatform('linux')).toBe('linux');
+ expect(resolveKnownAgentCommandPlatform('LINUX')).toBe('linux');
+ });
+
+ it('classifies legacy Linux distro identifiers without a distro allowlist', () => {
+ expect(resolveKnownAgentCommandPlatform('mageia')).toBe('linux');
+ expect(resolveKnownAgentCommandPlatform('ubuntu')).toBe('linux');
+ expect(resolveKnownAgentCommandPlatform('ubuntufork')).toBe('linux');
});
});
diff --git a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
index 850a660e77..34fdf88792 100644
--- a/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
+++ b/frontend-modern/src/components/Settings/infrastructureAgentUpdateCommandsModel.ts
@@ -113,38 +113,11 @@ const connectionNeedsUpdate = (connection: Connection, targetVersion?: string |
const expectedVersionFor = (connection: Connection, targetVersion?: string | null) =>
connection.expectedAgentVersion?.trim() || formatAgentVersionDisplay(targetVersion) || undefined;
-const KNOWN_LINUX_PLATFORMS = new Set([
- 'alpine',
- 'almalinux',
- 'amazon',
- 'arch',
- 'centos',
- 'debian',
- 'fedora',
- 'gentoo',
- 'linux',
- 'manjaro',
- 'nixos',
- 'openwrt',
- 'opensuse',
- 'oracle',
- 'proxmox',
- 'qnap',
- 'raspbian',
- 'redhat',
- 'rhel',
- 'rocky',
- 'sles',
- 'suse',
- 'synology',
- 'ubuntu',
- 'unraid',
-]);
-
/**
* Agent Doctor must never turn an unknown platform into an executable command.
- * The general installer defaults unknown values to Linux for legacy callers;
- * this stricter resolver is intentionally limited to host-local repair output.
+ * Pulse only publishes agent binaries for Linux, macOS, FreeBSD, and Windows.
+ * Legacy Linux agents report distro identifiers instead of GOOS, so unmatched
+ * non-empty values are Linux unless they name a known unsupported OS family.
*/
export const resolveKnownAgentCommandPlatform = (
platform?: string | null,
@@ -168,14 +141,31 @@ export const resolveKnownAgentCommandPlatform = (
) {
return 'freebsd';
}
- if (
- normalized.includes('linux') ||
- KNOWN_LINUX_PLATFORMS.has(normalized) ||
- Array.from(KNOWN_LINUX_PLATFORMS).some((candidate) => normalized.startsWith(`${candidate} `))
- ) {
- return 'linux';
+ for (const unsupported of [
+ 'aix',
+ 'android',
+ 'beos',
+ 'dragonfly',
+ 'haiku',
+ 'hurd',
+ 'illumos',
+ 'ios',
+ 'js',
+ 'netbsd',
+ 'openbsd',
+ 'plan9',
+ 'solaris',
+ 'wasip1',
+ ]) {
+ if (
+ normalized === unsupported ||
+ normalized.startsWith(`${unsupported} `) ||
+ normalized.startsWith(`${unsupported}-`)
+ ) {
+ return null;
+ }
}
- return null;
+ return 'linux';
};
const pushTarget = (
diff --git a/internal/api/action_executor.go b/internal/api/action_executor.go
index 6a47c50ab8..ebcefcd98a 100644
--- a/internal/api/action_executor.go
+++ b/internal/api/action_executor.go
@@ -20,9 +20,14 @@ type actionHandlerProvider interface {
ActionHandlerNames() []string
}
+type actionDispatchOperationProvider interface {
+ ActionDispatchOperationKinds() []string
+}
+
type routedActionExecutor struct {
- resources *ResourceHandlers
- byHandler map[string]ActionExecutor
+ resources *ResourceHandlers
+ byHandler map[string]ActionExecutor
+ byOperation map[string]ActionExecutor
}
func newRoutedActionExecutor(resources *ResourceHandlers, executors ...ActionExecutor) ActionExecutor {
@@ -30,8 +35,9 @@ func newRoutedActionExecutor(resources *ResourceHandlers, executors ...ActionExe
return nil
}
routed := routedActionExecutor{
- resources: resources,
- byHandler: map[string]ActionExecutor{},
+ resources: resources,
+ byHandler: map[string]ActionExecutor{},
+ byOperation: map[string]ActionExecutor{},
}
for _, executor := range executors {
if executor == nil {
@@ -47,6 +53,14 @@ func newRoutedActionExecutor(resources *ResourceHandlers, executors ...ActionExe
routed.byHandler[handler] = executor
}
}
+ if operations, ok := executor.(actionDispatchOperationProvider); ok {
+ for _, operation := range operations.ActionDispatchOperationKinds() {
+ operation = strings.TrimSpace(operation)
+ if operation != "" {
+ routed.byOperation[operation] = executor
+ }
+ }
+ }
}
if len(routed.byHandler) == 0 {
return nil
@@ -79,7 +93,7 @@ func (e routedActionExecutor) BindActionDispatch(ctx context.Context, record uni
}
func (e routedActionExecutor) ReconcileActionDispatch(ctx context.Context, record unified.ActionAuditRecord, attempt unified.ActionDispatchAttempt) (*unified.ExecutionResult, unified.ActionDispatchReceipt, bool, error) {
- executor, err := e.executorForAction(ctx, record.Request)
+ executor, err := e.executorForDispatchAttempt(record, attempt)
if err != nil {
return nil, unified.ActionDispatchReceipt{}, false, err
}
@@ -90,6 +104,27 @@ func (e routedActionExecutor) ReconcileActionDispatch(ctx context.Context, recor
return reconciler.ReconcileActionDispatch(ctx, record, attempt)
}
+// executorForDispatchAttempt routes query-only recovery from the immutable
+// operation binding committed before dispatch. Current inventory is
+// deliberately not consulted: a successful mutation can replace the resource,
+// while a safe preflight refusal can remove the capability that originally
+// admitted the action. Either outcome must still be able to consume its exact
+// durable receipt and terminalize the audit row.
+func (e routedActionExecutor) executorForDispatchAttempt(record unified.ActionAuditRecord, attempt unified.ActionDispatchAttempt) (ActionExecutor, error) {
+ if strings.TrimSpace(attempt.ActionID) == "" || attempt.ActionID != record.ID {
+ return nil, fmt.Errorf("durable dispatch attempt does not belong to action %q", record.ID)
+ }
+ operation := strings.TrimSpace(attempt.OperationKind)
+ if operation == "" {
+ return nil, fmt.Errorf("durable dispatch operation binding is missing")
+ }
+ executor := e.byOperation[operation]
+ if executor == nil {
+ return nil, fmt.Errorf("unsupported durable dispatch operation %q", operation)
+ }
+ return executor, nil
+}
+
func (e routedActionExecutor) CheckActionAvailable(ctx context.Context, req unified.ActionRequest, resource unified.Resource) unified.ResourceActionReadiness {
capability, ok := resourceCapabilityByName(resource.Capabilities, req.CapabilityName)
if !ok || strings.TrimSpace(capability.InternalHandler) == "" {
diff --git a/internal/api/connections_aggregator.go b/internal/api/connections_aggregator.go
index ec95210476..a468a066ff 100644
--- a/internal/api/connections_aggregator.go
+++ b/internal/api/connections_aggregator.go
@@ -1232,7 +1232,11 @@ func connectionAgentIdentityForHost(host models.Host) *ConnectionAgentIdentity {
}
func connectionAgentPlatformForHost(host models.Host, hostProfile string) string {
- return platformsupport.NormalizeRuntimePlatformForAgentHostProfile(hostProfile, host.Platform)
+ platform := platformsupport.NormalizeRuntimePlatformForAgentHostProfile(hostProfile, host.Platform)
+ if runtimePlatform, ok := platformsupport.ResolveAgentRuntimePlatform(platform); ok {
+ return runtimePlatform
+ }
+ return platformsupport.NormalizeAgentReportedPlatform(platform)
}
func connectionAgentHostProfileForHost(host models.Host) string {
diff --git a/internal/api/connections_aggregator_test.go b/internal/api/connections_aggregator_test.go
index 22f7a6e340..e64eb66552 100644
--- a/internal/api/connections_aggregator_test.go
+++ b/internal/api/connections_aggregator_test.go
@@ -8,6 +8,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
"github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
+ "github.com/rcourtman/pulse-go-rewrite/internal/platformsupport"
"github.com/rcourtman/pulse-go-rewrite/internal/remoteconfig"
)
@@ -290,6 +291,34 @@ func TestBuildConnections_AgentHostAliasesIncludeReportedIdentityHints(t *testin
}
}
+func TestBuildConnections_ProjectsLegacyLinuxDistroToRuntimePlatform(t *testing.T) {
+ now := time.Now()
+ got := buildConnections(aggregatorInputs{
+ hosts: []models.Host{{
+ ID: "mageia-host",
+ Hostname: "mageia-host",
+ Platform: "mageia",
+ OSName: "Mageia",
+ Architecture: "x86_64",
+ LastSeen: now,
+ AgentVersion: "6.1.0-rc.4",
+ CommandsEnabled: true,
+ }},
+ expectedAgentVersion: "6.1.1",
+ now: now,
+ })
+
+ if len(got) != 1 || got[0].AgentIdentity == nil {
+ t.Fatalf("expected one connection with agent identity, got %+v", got)
+ }
+ if got[0].AgentIdentity.Platform != platformsupport.RuntimePlatformLinux {
+ t.Fatalf("agent platform = %q, want linux", got[0].AgentIdentity.Platform)
+ }
+ if got[0].AgentIdentity.OSName != "Mageia" {
+ t.Fatalf("agent OS name = %q, want Mageia", got[0].AgentIdentity.OSName)
+ }
+}
+
func TestBuildConnections_AgentHostProfileFromUnraidStorageFacts(t *testing.T) {
now := time.Now()
in := aggregatorInputs{
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 25212b6a9a..9f7b2c35ac 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -20413,6 +20413,7 @@ func TestContract_DockerLifecycleActionsResolveCommandAgentAndDispatchOneTypedOp
"resource.Docker.AgentID",
"e.agents.GetAgentForHost(strings.TrimSpace(resource.Docker.Hostname))",
"ExecuteDockerContainerLifecycle(context.Context, string, agentexec.DockerContainerLifecyclePayload)",
+ "ActionDispatchOperationKinds",
"BindActionDispatch",
"ReconcileActionDispatch",
"dockerContainerExecutionResult",
@@ -20427,6 +20428,24 @@ func TestContract_DockerLifecycleActionsResolveCommandAgentAndDispatchOneTypedOp
if !strings.Contains(sharedSrc, "GetAgentForHost(hostname string) (string, bool)") {
t.Fatal("shared action command interface must keep hostname-based command-agent resolution available")
}
+ for _, snippet := range []string{
+ "byOperation map[string]ActionExecutor",
+ "executorForDispatchAttempt(record, attempt)",
+ "executor := e.byOperation[operation]",
+ } {
+ if !strings.Contains(sharedSrc, snippet) {
+ t.Fatalf("durable recovery routing must use immutable operation binding snippet %q", snippet)
+ }
+ }
+ reconcileStart := strings.Index(sharedSrc, "func (e routedActionExecutor) ReconcileActionDispatch")
+ reconcileEnd := strings.Index(sharedSrc, "func (e routedActionExecutor) CheckActionAvailable")
+ if reconcileStart < 0 || reconcileEnd <= reconcileStart {
+ t.Fatal("shared action executor is missing its bounded reconciliation section")
+ }
+ reconcileSource := sharedSrc[reconcileStart:reconcileEnd]
+ if strings.Contains(reconcileSource, "executorForAction(ctx, record.Request)") {
+ t.Fatal("durable reconciliation must not rediscover its executor from current resource inventory")
+ }
if strings.Index(src, "if agentID := strings.TrimSpace(resource.Docker.AgentID)") >
strings.Index(src, "e.agents.GetAgentForHost(strings.TrimSpace(resource.Docker.Hostname))") {
t.Fatal("docker lifecycle executor must try the Docker reporting agent id before falling back to hostname resolution")
diff --git a/internal/api/docker_container_action_executor.go b/internal/api/docker_container_action_executor.go
index 9c3a76b8d0..3af89a91ae 100644
--- a/internal/api/docker_container_action_executor.go
+++ b/internal/api/docker_container_action_executor.go
@@ -112,6 +112,15 @@ func (e dockerContainerActionExecutor) ActionHandlerNames() []string {
return []string{dockerContainerLifecycleHandler, dockerContainerUpdateHandler}
}
+func (e dockerContainerActionExecutor) ActionDispatchOperationKinds() []string {
+ return []string{
+ agentexec.DockerContainerOperationStart,
+ agentexec.DockerContainerOperationStop,
+ agentexec.DockerContainerOperationRestart,
+ agentexec.DockerContainerOperationUpdate,
+ }
+}
+
func (e dockerContainerActionExecutor) ExecuteAction(ctx context.Context, record unified.ActionAuditRecord) (*unified.ExecutionResult, error) {
attempt, ok := actionlifecycle.DispatchAttemptFromContext(ctx)
if !ok || attempt.ActionID != record.ID {
diff --git a/internal/api/host_storage_cleanup_action_executor.go b/internal/api/host_storage_cleanup_action_executor.go
index 7973164673..10302dab5e 100644
--- a/internal/api/host_storage_cleanup_action_executor.go
+++ b/internal/api/host_storage_cleanup_action_executor.go
@@ -54,6 +54,10 @@ func (e hostStorageCleanupActionExecutor) ActionHandlerNames() []string {
return []string{hostStorageCleanupActionHandler}
}
+func (e hostStorageCleanupActionExecutor) ActionDispatchOperationKinds() []string {
+ return []string{agentexec.HostStorageCleanupOperationPackageCache}
+}
+
func (e hostStorageCleanupActionExecutor) CheckActionAvailable(_ context.Context, req unified.ActionRequest, resource unified.Resource) unified.ResourceActionReadiness {
if strings.TrimSpace(req.CapabilityName) != hostStorageCleanupCapability {
return unified.ResourceActionReadiness{}
diff --git a/internal/api/host_update_action_executor.go b/internal/api/host_update_action_executor.go
index 32f12e9b94..6825dd4d5d 100644
--- a/internal/api/host_update_action_executor.go
+++ b/internal/api/host_update_action_executor.go
@@ -59,6 +59,10 @@ func (e hostUpdateActionExecutor) ActionHandlerNames() []string {
return []string{hostPackageUpdateActionHandler}
}
+func (e hostUpdateActionExecutor) ActionDispatchOperationKinds() []string {
+ return []string{agentexec.HostUpdateOperationInstall}
+}
+
func (e hostUpdateActionExecutor) CheckActionAvailable(ctx context.Context, req unified.ActionRequest, resource unified.Resource) unified.ResourceActionReadiness {
if strings.TrimSpace(req.CapabilityName) != hostPackageUpdateCapability {
return unified.ResourceActionReadiness{}
diff --git a/internal/api/router_action_recovery_test.go b/internal/api/router_action_recovery_test.go
index f8a6ab9cb4..0610edca42 100644
--- a/internal/api/router_action_recovery_test.go
+++ b/internal/api/router_action_recovery_test.go
@@ -40,6 +40,18 @@ func (e *callbackLossDockerExecutor) ReconcileActionDispatch(ctx context.Context
return e.inner.ReconcileActionDispatch(ctx, record, attempt)
}
+func (e *callbackLossDockerExecutor) ActionHandlerNames() []string {
+ return e.inner.ActionHandlerNames()
+}
+
+func (e *callbackLossDockerExecutor) ActionDispatchOperationKinds() []string {
+ return e.inner.ActionDispatchOperationKinds()
+}
+
+func (e *callbackLossDockerExecutor) CheckActionAvailable(ctx context.Context, req unified.ActionRequest, resource unified.Resource) unified.ResourceActionReadiness {
+ return e.inner.CheckActionAvailable(ctx, req, resource)
+}
+
// TestRouterRecoverExecutingActionsReconcilesDurableReceipt pins the
// production recovery pass shared by the startup lifecycle worker and the
// agentexec agent-registered notifier: an action stuck in the executing state
@@ -126,3 +138,121 @@ func TestRouterRecoverExecutingActionsReconcilesDurableReceipt(t *testing.T) {
t.Fatalf("receipt queries = %d, want exactly 1", len(agents.queries))
}
}
+
+// A preflight refusal can make the update capability disappear before the
+// server consumes the terminal receipt (for example when the live image digest
+// no longer matches the planned digest). Recovery must route from the committed
+// operation binding instead of mutable current inventory, or the action remains
+// receipt-pending forever even though the agent has terminal truth.
+func TestRouterRecoverExecutingDockerUpdateAfterCapabilityDisappears(t *testing.T) {
+ now := time.Now().UTC()
+ resource := dockerContainerUpdateActionResource("app-container:api", "docker", now)
+ h := newActionTestResourceHandlers(t, &config.Config{DataPath: t.TempDir()})
+ h.SetStateProvider(resourceUnifiedSeedProvider{
+ snapshot: models.StateSnapshot{LastUpdate: now},
+ resources: []unified.Resource{resource},
+ })
+ agents := &fakeDockerActionAgentCommander{}
+ callbackLoss := &callbackLossDockerExecutor{inner: newDockerContainerActionExecutor(h, agents).(dockerContainerActionExecutor)}
+ h.SetActionExecutor(newRoutedActionExecutor(h, callbackLoss))
+
+ planRec := httptest.NewRecorder()
+ planReq := httptest.NewRequest(http.MethodPost, "/api/actions/plan", bytes.NewBufferString(`{
+ "requestId":"req-update-preflight-recovery",
+ "resourceId":"app-container:api",
+ "capabilityName":"update",
+ "reason":"apply the reviewed container update"
+ }`))
+ h.HandlePlanAction(planRec, actionHandlerTestRequest(planReq, "[email protected]"))
+ if planRec.Code != http.StatusOK {
+ t.Fatalf("plan status=%d body=%s", planRec.Code, planRec.Body.String())
+ }
+ var plan unified.ActionPlan
+ if err := json.Unmarshal(planRec.Body.Bytes(), &plan); err != nil || plan.ActionID == "" {
+ t.Fatalf("plan decode err=%v plan=%#v", err, plan)
+ }
+
+ decisionRec := httptest.NewRecorder()
+ decisionReq := httptest.NewRequest(http.MethodPost, "/api/actions/"+plan.ActionID+"/decision", bytes.NewBufferString(`{"outcome":"approved","reason":"controlled recovery proof"}`))
+ decisionReq.SetPathValue("id", plan.ActionID)
+ h.HandleDecideAction(decisionRec, actionHandlerTestRequest(decisionReq, "[email protected]"))
+ if decisionRec.Code != http.StatusOK {
+ t.Fatalf("decision status=%d body=%s", decisionRec.Code, decisionRec.Body.String())
+ }
+
+ executionReq := httptest.NewRequest(http.MethodPost, "/api/actions/"+plan.ActionID+"/execute", bytes.NewBufferString(`{"reason":"exercise terminal preflight recovery"}`))
+ executionReq.SetPathValue("id", plan.ActionID)
+ h.HandleExecuteAction(httptest.NewRecorder(), actionHandlerTestRequest(executionReq, "[email protected]"))
+
+ store, err := h.getStore("default")
+ if err != nil {
+ t.Fatal(err)
+ }
+ attempt, found, err := store.GetActionDispatchAttempt(plan.ActionID)
+ if err != nil || !found || attempt.State != unified.ActionDispatchReceiptPending {
+ t.Fatalf("pending attempt found=%v err=%v attempt=%#v", found, err, attempt)
+ }
+ if attempt.OperationKind != agentexec.DockerContainerOperationUpdate || callbackLoss.executions != 1 {
+ t.Fatalf("dispatch binding=%#v executions=%d", attempt, callbackLoss.executions)
+ }
+
+ facts := agentexec.DockerContainerUpdateResultPayload{
+ RequestID: attempt.ID, ActionID: attempt.ActionID,
+ Operation: attempt.OperationKind, OperationVersion: attempt.OperationVersion,
+ RequestDigest: attempt.RequestDigest, ContainerID: resource.Docker.ContainerID,
+ ExecutionPhase: agentexec.DockerContainerPhasePreflight,
+ Error: "container image digest no longer matches the planned update",
+ }
+ raw, err := json.Marshal(facts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ identity := operationreceipt.Identity{
+ AttemptID: attempt.ID, ActionID: attempt.ActionID,
+ OperationKind: attempt.OperationKind, OperationVersion: attempt.OperationVersion,
+ RequestDigest: attempt.RequestDigest, AgentID: attempt.AgentID,
+ }
+ agents.queryResult = operationreceipt.QueryResult{
+ Version: operationreceipt.ProtocolVersion,
+ Status: operationreceipt.QueryFoundTerminal,
+ Record: &operationreceipt.Record{
+ Identity: identity, State: operationreceipt.StateTerminal,
+ AcceptedAt: now.Add(-4 * time.Second), StartedAt: now.Add(-3 * time.Second),
+ TerminalAt: now, ResultKind: agentexec.DockerContainerUpdateReceiptKind,
+ ResultVersion: agentexec.DockerContainerUpdateReceiptVersion, Result: raw,
+ },
+ }
+
+ // The drift that caused preflight refusal also removes update from current
+ // inventory. This is the state that previously made routed recovery fail.
+ drifted := resource
+ drifted.Docker.UpdateStatus = nil
+ drifted.Capabilities = drifted.Capabilities[:1]
+ h.SetStateProvider(resourceUnifiedSeedProvider{
+ snapshot: models.StateSnapshot{LastUpdate: now.Add(time.Second)},
+ resources: []unified.Resource{drifted},
+ })
+
+ router := &Router{resourceHandlers: h}
+ router.recoverExecutingActions("system:periodic-recovery")
+
+ audit, found, err := store.GetActionAudit(plan.ActionID)
+ if err != nil || !found || audit.State != unified.ActionStateFailed {
+ t.Fatalf("recovered audit found=%v err=%v audit=%#v", found, err, audit)
+ }
+ if audit.Result == nil || audit.Result.ActionResultV2 == nil {
+ t.Fatalf("recovered action result=%#v", audit.Result)
+ }
+ truth := audit.Result.ActionResultV2
+ if truth.Execution.Status != unified.ActionExecutionNotRun ||
+ truth.Execution.ReasonCode != "preflight_refused" ||
+ truth.Verification.Status != unified.ActionVerificationInconclusive {
+ t.Fatalf("recovered preflight truth=%#v", truth)
+ }
+ if callbackLoss.executions != 1 {
+ t.Fatalf("executions after recovery=%d, want one (query-only recovery)", callbackLoss.executions)
+ }
+ if len(agents.queries) != 1 {
+ t.Fatalf("receipt queries=%d, want one", len(agents.queries))
+ }
+}
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index f8aa56991d..7633f00300 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -280,7 +280,7 @@ func New(cfg Config) (*Agent, error) {
agentID = hostname
}
- platform := normalisePlatform(info.Platform)
+ platform := normaliseRuntimePlatform(collector.GOOS(), info.Platform)
// Use Platform (specific distro like "ubuntu") over PlatformFamily (distro family like "debian")
// This ensures Ubuntu shows as "ubuntu 24.04" not "debian 24.04" (refs #927)
osName := strings.TrimSpace(info.Platform)
@@ -1384,6 +1384,21 @@ func normalisePlatform(platform string) string {
return normalized
}
+func normaliseRuntimePlatform(goos, reportedPlatform string) string {
+ switch strings.ToLower(strings.TrimSpace(goos)) {
+ case "linux":
+ return platformsupport.RuntimePlatformLinux
+ case "darwin":
+ return platformsupport.RuntimePlatformMacOS
+ case "freebsd":
+ return platformsupport.RuntimePlatformFreeBSD
+ case "windows":
+ return platformsupport.RuntimePlatformWindows
+ default:
+ return normalisePlatform(reportedPlatform)
+ }
+}
+
func normalizePulseURL(rawURL string) (string, error) {
parsed, err := securityutil.NormalizePulseHTTPBaseURLWithOptions(rawURL, securityutil.PulseURLValidationOptions{
AllowLocalNetworkHTTP: true,
diff --git a/internal/hostagent/agent_new_test.go b/internal/hostagent/agent_new_test.go
index 3c5b9471b3..dc1a81c61e 100644
--- a/internal/hostagent/agent_new_test.go
+++ b/internal/hostagent/agent_new_test.go
@@ -120,8 +120,8 @@ func TestNew_ResolvesProxmoxVEHostIdentity(t *testing.T) {
if err != nil {
t.Fatalf("New() error = %v", err)
}
- if agent.platform != "debian" {
- t.Fatalf("platform = %q, want Debian runtime platform", agent.platform)
+ if agent.platform != "linux" {
+ t.Fatalf("platform = %q, want Linux runtime platform", agent.platform)
}
if agent.osName != proxmoxPVEOSName {
t.Fatalf("osName = %q, want %q", agent.osName, proxmoxPVEOSName)
@@ -1229,3 +1229,25 @@ func TestNormalisePlatformCanonicalisesReportedCaptions(t *testing.T) {
})
}
}
+
+func TestNormaliseRuntimePlatformUsesBuildTarget(t *testing.T) {
+ cases := []struct {
+ name string
+ goos string
+ reported string
+ want string
+ }{
+ {"linux distro", "linux", "mageia", "linux"},
+ {"macOS caption", "darwin", "darwin", "macos"},
+ {"FreeBSD caption", "freebsd", "FreeBSD 14.1-RELEASE", "freebsd"},
+ {"Windows caption", "windows", "Microsoft Windows 11 Pro", "windows"},
+ {"unknown build target preserves report", "plan9", "plan9", "plan9"},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := normaliseRuntimePlatform(tc.goos, tc.reported); got != tc.want {
+ t.Fatalf("normaliseRuntimePlatform(%q, %q) = %q, want %q", tc.goos, tc.reported, got, tc.want)
+ }
+ })
+ }
+}
diff --git a/internal/monitoring/agent_fleet_doctor.go b/internal/monitoring/agent_fleet_doctor.go
index ec57cd4f63..7456374c96 100644
--- a/internal/monitoring/agent_fleet_doctor.go
+++ b/internal/monitoring/agent_fleet_doctor.go
@@ -749,28 +749,13 @@ func safeAgentUpdatePlatform(subject agentFleetSubject) (string, bool) {
platformsupport.RuntimePlatformLinux:
return normalized, true
}
- if knownLinuxAgentPlatform(normalized) {
- return platformsupport.RuntimePlatformLinux, true
+ if runtimePlatform, ok := platformsupport.ResolveAgentRuntimePlatform(normalized); ok {
+ return runtimePlatform, true
}
}
return "", false
}
-func knownLinuxAgentPlatform(value string) bool {
- value = strings.ToLower(strings.TrimSpace(value))
- for _, token := range []string{
- "almalinux", "alpine", "amazon linux", "arch", "centos", "debian",
- "fedora", "gentoo", "linux", "nixos", "opensuse", "oracle linux",
- "proxmox", "qnap", "raspbian", "red hat", "rhel", "rocky", "suse",
- "synology", "ubuntu", "unraid",
- } {
- if value == token || strings.Contains(value, token+" ") || strings.Contains(value, token+"-") {
- return true
- }
- }
- return false
-}
-
func machineIDFingerprint(machineID string) string {
machineID = strings.TrimSpace(machineID)
if machineID == "" {
diff --git a/internal/monitoring/agent_fleet_doctor_test.go b/internal/monitoring/agent_fleet_doctor_test.go
index c9beb4b9a5..9aa444ad1a 100644
--- a/internal/monitoring/agent_fleet_doctor_test.go
+++ b/internal/monitoring/agent_fleet_doctor_test.go
@@ -156,6 +156,30 @@ func TestAgentFleetDiagnosticsDoesNotOfferUpgradeCommandForUnknownPlatform(t *te
}
}
+func TestAgentFleetDiagnosticsOffersUpgradeCommandForLegacyLinuxDistro(t *testing.T) {
+ now := time.Date(2026, 7, 23, 12, 0, 0, 0, time.UTC)
+ monitor := newAgentFleetDoctorTestMonitor(t)
+ monitor.state.UpsertHost(models.Host{
+ ID: "agent-mageia",
+ Hostname: "mageia-node",
+ Platform: "mageia",
+ OSName: "Mageia",
+ Architecture: "x86_64",
+ Status: "online",
+ LastSeen: now,
+ AgentVersion: "6.1.0-rc.4",
+ })
+
+ agent := requireAgentDiagnostic(t, monitor.GetAgentFleetDiagnostics("6.1.1", now), "agent-agent-mageia")
+ repair := requireRepairCode(t, agent, AgentFleetActionCopyUpgradeCommand)
+ if !repair.Supported || repair.Platform != platformsupport.RuntimePlatformLinux {
+ t.Fatalf("Mageia upgrade repair = %+v, want supported Linux repair", repair)
+ }
+ if agent.Platform != platformsupport.RuntimePlatformLinux {
+ t.Fatalf("Mageia diagnostic platform = %q, want linux", agent.Platform)
+ }
+}
+
func TestAgentFleetDiagnosticsDoesNotOfferUpgradeCommandForUnverifiedFreeBSDState(t *testing.T) {
now := time.Date(2026, 7, 13, 12, 0, 0, 0, time.UTC)
monitor := newAgentFleetDoctorTestMonitor(t)
diff --git a/internal/platformsupport/runtime_platform.go b/internal/platformsupport/runtime_platform.go
index 3e464eaeef..02764bf11d 100644
--- a/internal/platformsupport/runtime_platform.go
+++ b/internal/platformsupport/runtime_platform.go
@@ -34,19 +34,50 @@ func NormalizeAgentReportedPlatform(platform string) string {
return normalized
}
+// ResolveAgentRuntimePlatform maps an agent-reported platform onto the
+// runtime families for which Pulse publishes agent binaries. Linux agents
+// historically reported gopsutil's distro identifier (for example "ubuntu"
+// or "mageia") instead of GOOS, so any non-empty value that is not a known
+// non-Linux runtime is a Linux distro unless it names an explicitly
+// unsupported OS family.
+func ResolveAgentRuntimePlatform(platform string) (string, bool) {
+ normalized := NormalizeAgentReportedPlatform(platform)
+ switch normalized {
+ case "":
+ return "", false
+ case RuntimePlatformWindows,
+ RuntimePlatformMacOS,
+ RuntimePlatformFreeBSD,
+ RuntimePlatformLinux:
+ return normalized, true
+ }
+ if unsupportedAgentRuntimePlatform(normalized) {
+ return "", false
+ }
+ return RuntimePlatformLinux, true
+}
+
+func unsupportedAgentRuntimePlatform(platform string) bool {
+ for _, token := range []string{
+ "aix", "android", "beos", "dragonfly", "haiku", "hurd", "illumos",
+ "ios", "js", "netbsd", "openbsd", "plan9", "solaris", "wasip1",
+ } {
+ if platform == token ||
+ strings.HasPrefix(platform, token+" ") ||
+ strings.HasPrefix(platform, token+"-") {
+ return true
+ }
+ }
+ return false
+}
+
// AgentCommandPlatform resolves the install/upgrade command platform for an
// agent-reported platform string. Anything without a canonical non-Linux
// mapping resolves to linux: the long tail of unmatched values is Linux
// distro names, for which the shell installer is correct.
func AgentCommandPlatform(platform string) string {
- switch NormalizeAgentReportedPlatform(platform) {
- case RuntimePlatformWindows:
- return RuntimePlatformWindows
- case RuntimePlatformMacOS:
- return RuntimePlatformMacOS
- case RuntimePlatformFreeBSD:
- return RuntimePlatformFreeBSD
- default:
- return RuntimePlatformLinux
+ if resolved, ok := ResolveAgentRuntimePlatform(platform); ok {
+ return resolved
}
+ return RuntimePlatformLinux
}
diff --git a/internal/platformsupport/runtime_platform_test.go b/internal/platformsupport/runtime_platform_test.go
index f7035fdab2..c9c13ab201 100644
--- a/internal/platformsupport/runtime_platform_test.go
+++ b/internal/platformsupport/runtime_platform_test.go
@@ -54,3 +54,31 @@ func TestAgentCommandPlatform(t *testing.T) {
})
}
}
+
+func TestResolveAgentRuntimePlatform(t *testing.T) {
+ cases := []struct {
+ name string
+ platform string
+ want string
+ ok bool
+ }{
+ {"missing", "", "", false},
+ {"canonical linux", "linux", RuntimePlatformLinux, true},
+ {"legacy mageia distro", "Mageia", RuntimePlatformLinux, true},
+ {"legacy slackware distro", "slackware 15.0", RuntimePlatformLinux, true},
+ {"windows caption", "Microsoft Windows 11 Pro", RuntimePlatformWindows, true},
+ {"darwin", "darwin", RuntimePlatformMacOS, true},
+ {"freebsd caption", "FreeBSD 14.1-RELEASE", RuntimePlatformFreeBSD, true},
+ {"unsupported haiku", "Haiku", "", false},
+ {"unsupported plan9 caption", "plan9-9front", "", false},
+ {"unsupported openbsd caption", "OpenBSD 7.7", "", false},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ got, ok := ResolveAgentRuntimePlatform(tc.platform)
+ if got != tc.want || ok != tc.ok {
+ t.Fatalf("ResolveAgentRuntimePlatform(%q) = (%q, %t), want (%q, %t)", tc.platform, got, ok, tc.want, tc.ok)
+ }
+ })
+ }
+}