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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix(doctor): stop reporting a live credential as a credential outage
rcourtman8f8c2bda1a95
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex fb3dcc043a..400ad4cc8c 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -2739,6 +2739,17 @@ last successful heartbeat alone. A live host whose reported `TokenID` nolonger resolves emits `agent_credential_missing`; a resolved but expired recordemits `agent_credential_expired`; both are critical and expose a boundedauthentication-repair handoff only when the runtime family is safely known.+A missing-credential verdict is additionally cross-checked against the+subject's own authentication evidence: when a row reporting the judged token+id shows it authenticated within the freshness window (three report+intervals, ten-minute floor), the diagnostic emits the warning+`agent_credential_registry_stale` naming the id and the last authentication+instead of the critical outage, and offers no authentication-repair handoff,+because a credential that authenticated moments before diagnosis is not+revoked — the server's token registry view is stale (#1730). Only same-token+rows vouch; a fresh sibling row on a different credential never rescues a+genuinely revoked one, and rows with stale or absent authentication evidence+keep the critical missing verdict.An active record is not sufficient when the host reports Pulse commandexecution enabled: if that record lacks `agent:exec`, the diagnostic emits thecritical `agent_exec_scope_missing` reason and exposes the same boundeddiff --git a/internal/monitoring/agent_fleet_doctor.go b/internal/monitoring/agent_fleet_doctor.goindex 0f31a3b9b0..bc82bbf3d5 100644--- a/internal/monitoring/agent_fleet_doctor.go+++ b/internal/monitoring/agent_fleet_doctor.go@@ -37,6 +37,7 @@ const (AgentFleetReasonModuleDegraded = "agent_module_degraded"AgentFleetReasonCredentialMissing = "agent_credential_missing"AgentFleetReasonCredentialExpired = "agent_credential_expired"+ AgentFleetReasonCredentialUnlisted = "agent_credential_registry_stale"AgentFleetReasonExecScopeMissing = "agent_exec_scope_missing"AgentFleetReasonDuplicateInstallation = "duplicate_host_agent_installation"@@ -449,7 +450,7 @@ func diagnoseAgentFleetSubject(}result.Reasons = append(result.Reasons, diagnoseAgentConnectivity(subject, now)...)- result.Reasons = append(result.Reasons, diagnoseAgentCredential(subject, tokenInventory)...)+ result.Reasons = append(result.Reasons, diagnoseAgentCredential(subject, tokenInventory, now)...)result.Reasons = append(result.Reasons, diagnoseAgentVersion(subject, serverVersion)...)result.Reasons = append(result.Reasons, diagnoseAgentUpdate(subject, serverVersion)...)result.Reasons = append(result.Reasons, diagnoseAgentModules(subject)...)@@ -550,7 +551,7 @@ func diagnosticHasAnyReason(reasons []AgentFleetDiagnosticReason, codes ...strinreturn false}-func diagnoseAgentCredential(subject agentFleetSubject, inventory agentFleetTokenInventory) []AgentFleetDiagnosticReason {+func diagnoseAgentCredential(subject agentFleetSubject, inventory agentFleetTokenInventory, now time.Time) []AgentFleetDiagnosticReason {tokenID := strings.TrimSpace(subject.tokenID)if subject.removed || !inventory.known || tokenID == "" {return nil@@ -577,6 +578,25 @@ func diagnoseAgentCredential(subject agentFleetSubject, inventory agentFleetTokeEvidence: []string{"Credential status: expired", "Credential id: " + tokenID},}}}+ // The row itself proves whether the credential still authenticates. If it+ // was used moments ago, a missing inventory entry means the server's token+ // registry view is stale, not that the agent lost access (#1730), and the+ // repair-authentication loop cannot fix that. Only a same-token row can+ // vouch, so a fresh sibling row on a different credential never rescues a+ // genuinely revoked one.+ if lastUsed := agentFleetCredentialLastUsed(subject, tokenID); lastUsed != nil &&+ now.Sub(*lastUsed) <= agentFleetCredentialFreshnessWindow(subject) {+ return []AgentFleetDiagnosticReason{{+ Code: AgentFleetReasonCredentialUnlisted,+ Severity: AgentFleetStatusWarning,+ Message: "The credential last used by this agent authenticated recently but is missing from this server's token registry view.",+ Evidence: []string{+ "Credential status: authenticating but unlisted",+ "Credential id: " + tokenID,+ "Credential last authenticated: " + lastUsed.UTC().Format(time.RFC3339),+ },+ }}+ }// The judged id is the token record UUID this host row last reported// with, not secret material. Without it an operator cannot tell which// credential the verdict is about, so a host that re-enrolled onto a@@ -589,6 +609,44 @@ func diagnoseAgentCredential(subject agentFleetSubject, inventory agentFleetToke}}}+// agentFleetCredentialLastUsed returns the newest time the judged credential+// authenticated according to the subject's own rows. Only rows that reported+// with the same token id count.+func agentFleetCredentialLastUsed(subject agentFleetSubject, tokenID string) *time.Time {+ var newest *time.Time+ consider := func(rowTokenID string, lastUsed *time.Time) {+ if strings.TrimSpace(rowTokenID) != tokenID || lastUsed == nil || lastUsed.IsZero() {+ return+ }+ if newest == nil || lastUsed.After(*newest) {+ t := *lastUsed+ newest = &t+ }+ }+ if subject.host != nil {+ consider(subject.host.TokenID, subject.host.TokenLastUsedAt)+ }+ if subject.docker != nil {+ consider(subject.docker.TokenID, subject.docker.TokenLastUsedAt)+ }+ if subject.kubernetes != nil {+ consider(subject.kubernetes.TokenID, subject.kubernetes.TokenLastUsedAt)+ }+ return newest+}++// agentFleetCredentialFreshnessWindow bounds how recent an authentication has+// to be before it outweighs a missing token registry entry. Slow-reporting+// agents get a window scaled to their interval so a normal gap between+// reports never re-opens the false outage.+func agentFleetCredentialFreshnessWindow(subject agentFleetSubject) time.Duration {+ window := 10 * time.Minute+ if interval := time.Duration(subject.intervalSeconds) * time.Second; interval*3 > window {+ window = interval * 3+ }+ return window+}+func diagnoseDuplicateHostAgentInstallation(subject agentFleetSubject, state models.StateSnapshot) []AgentFleetDiagnosticReason {if subject.removed || subject.host == nil {return nildiff --git a/internal/monitoring/agent_fleet_doctor_test.go b/internal/monitoring/agent_fleet_doctor_test.goindex 1b416f8158..2f6e4d5b9e 100644--- a/internal/monitoring/agent_fleet_doctor_test.go+++ b/internal/monitoring/agent_fleet_doctor_test.go@@ -105,6 +105,69 @@ func TestAgentFleetDiagnosticsDetectsMissingAndExpiredCredentials(t *testing.T)}}+func TestAgentFleetDiagnosticsTreatsFreshlyUsedUnlistedCredentialAsRegistryStale(t *testing.T) {+ now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)+ lastUsed := now.Add(-30 * time.Second)+ monitor := newAgentFleetDoctorTestMonitor(t)+ // The judged token is absent from the inventory, but the host row shows it+ // authenticated seconds ago (#1730). That contradiction means the server's+ // token registry view is stale, so the verdict must not read as a+ // credential outage and must not offer the repair-authentication loop.+ monitor.state.UpsertHost(models.Host{+ ID: "agent-auth",+ Hostname: "auth-node",+ Platform: "linux",+ Status: "online",+ LastSeen: now,+ IntervalSeconds: 30,+ AgentVersion: "6.2.0",+ TokenID: "unlisted-token",+ TokenLastUsedAt: &lastUsed,+ })++ agent := requireAgentDiagnostic(t, monitor.GetAgentFleetDiagnostics("6.2.0", now), "agent-agent-auth")+ reason := requireReasonCode(t, agent, AgentFleetReasonCredentialUnlisted)+ if reason.Severity != AgentFleetStatusWarning {+ t.Fatalf("severity = %q, want %q", reason.Severity, AgentFleetStatusWarning)+ }+ if agent.Status != AgentFleetStatusWarning {+ t.Fatalf("status = %q, want %q", agent.Status, AgentFleetStatusWarning)+ }+ for _, r := range agent.Reasons {+ if r.Code == AgentFleetReasonCredentialMissing {+ t.Fatalf("fresh authentication must suppress the missing-credential outage: %#v", agent.Reasons)+ }+ }+ for _, repair := range agent.RepairActions {+ if repair.Code == AgentFleetActionRepairAuthentication {+ t.Fatalf("registry-stale verdict must not offer repair authentication: %#v", agent.RepairActions)+ }+ }+}++func TestAgentFleetDiagnosticsKeepsMissingCredentialCriticalWhenUseIsStale(t *testing.T) {+ now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)+ lastUsed := now.Add(-2 * time.Hour)+ monitor := newAgentFleetDoctorTestMonitor(t)+ monitor.state.UpsertHost(models.Host{+ ID: "agent-auth",+ Hostname: "auth-node",+ Platform: "linux",+ Status: "online",+ LastSeen: now,+ IntervalSeconds: 30,+ AgentVersion: "6.2.0",+ TokenID: "revoked-token",+ TokenLastUsedAt: &lastUsed,+ })++ agent := requireAgentDiagnostic(t, monitor.GetAgentFleetDiagnostics("6.2.0", now), "agent-agent-auth")+ requireReasonCode(t, agent, AgentFleetReasonCredentialMissing)+ if agent.Status != AgentFleetStatusCritical {+ t.Fatalf("status = %q, want %q", agent.Status, AgentFleetStatusCritical)+ }+}+func TestAgentFleetDiagnosticsAcceptsActiveCredential(t *testing.T) {now := time.Date(2026, 8, 9, 12, 0, 0, 0, time.UTC)monitor := newAgentFleetDoctorTestMonitor(t)