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
Keep canonical protection aligned with recognised Proxmox subjects
pulse-triage[bot]38655aae5045
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 30b6a1d718..83be71b81e 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -21,6 +21,22 @@## Purpose+### Canonical posture recognises recovery's Proxmox subject aliases++Protection posture selects stored points using the same recognised Proxmox+subject normalisation as recovery rollups. Retired node-scoped hashes, raw+source triples and the legacy LXC prefix can advance the canonical guest's+successful-point timestamp; a fresh point cannot be silently omitted while an+older canonical point keeps the posture stale. Instance, guest and type+boundaries remain in the existing identity resolver. Running archives, task-only+success and partial/unreadable collection do not establish protection.++`posture_test.go` covers mixed historical/current identities and adverse+qualification/scope controls. The ordinary poll/async-ingest regression in+`pve_backup_posture_identity_test.go` exercises four LXC guests across independent+estates, with canonical and legacy resource views. These are synthetic source+proofs, not confirmation of a reported installation's identity or recovery.+### Configuration-import replays cannot repeat recent replacementImport admission spans the existing file transaction and runtime apply. Adiff --git a/internal/monitoring/pve_backup_posture_identity_test.go b/internal/monitoring/pve_backup_posture_identity_test.gonew file mode 100644index 0000000000..034681a5e1--- /dev/null+++ b/internal/monitoring/pve_backup_posture_identity_test.go@@ -0,0 +1,83 @@+package monitoring++import (+ "context"+ "fmt"+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/models"+ "github.com/rcourtman/pulse-go-rewrite/internal/recovery"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+ "github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"+)++type postureIdentityClient struct {+ PVEClientInterface+ at time.Time+}++func (c *postureIdentityClient) GetStorage(context.Context, string) ([]proxmox.Storage, error) {+ return []proxmox.Storage{{Storage: "local", Type: "dir", Content: "backup", Active: 1, Enabled: 1}}, nil+}+func (c *postureIdentityClient) GetStorageContent(_ context.Context, _, _ string) ([]proxmox.StorageContent, error) {+ var out []proxmox.StorageContent+ for _, id := range []int{101, 102} {+ at := c.at.Add(-time.Duration(id-101) * time.Hour)+ out = append(out, proxmox.StorageContent{Volid: fmt.Sprintf("local:backup/vzdump-lxc-%d-%d.tar.zst", id, at.Unix()), VMID: id, CTime: at.Unix(), Size: 2048, Content: "backup", Format: "tar.zst"})+ }+ return out, nil+}++// Imported resource views can retain the retired node-scoped ID. Rollup keys+// already recognise that identity; canonical posture must read the same points.+func TestPVEBackupPostureRecognisesLegacySubjectIdentity(t *testing.T) {+ for _, legacy := range []bool{false, true} {+ t.Run(fmt.Sprintf("legacy=%t", legacy), func(t *testing.T) {+ m, manager := recoveryIngestTestMonitor(t)+ m.state = models.NewState()+ store, err := manager.StoreForOrg("default")+ if err != nil {+ t.Fatal(err)+ }+ f := &pveReconciliationFixture{m: m, store: store}+ t.Cleanup(func() { f.wait(t); _ = store.Close() })+ now := time.Now().UTC().Truncate(time.Second)+ client := &postureIdentityClient{at: now.Add(-time.Hour)}+ var resources []unifiedresources.Resource+ var containers []models.Container+ for _, instance := range []string{"estate-a", "estate-b"} {+ for _, id := range []int{101, 102} {+ source := makeGuestID(instance, "node", id)+ canonical := unifiedresources.ProxmoxGuestCanonicalID(unifiedresources.ResourceTypeSystemContainer, instance, id)+ rid := canonical+ if legacy {+ rid = unifiedresources.SourceSpecificID(unifiedresources.ResourceTypeSystemContainer, unifiedresources.SourceProxmox, source)+ }+ f.ids = append(f.ids, canonical)+ containers = append(containers, models.Container{ID: source, Instance: instance, Node: "node", VMID: id, Name: fmt.Sprintf("guest-%d", id), Status: "running"})+ resources = append(resources, unifiedresources.Resource{ID: rid, Type: unifiedresources.ResourceTypeSystemContainer, Name: fmt.Sprintf("guest-%d", id), Status: unifiedresources.StatusOnline, Proxmox: &unifiedresources.ProxmoxData{Instance: instance, NodeName: "node", VMID: id, SourceID: source}})+ }+ }+ m.state.UpdateContainers(containers)+ m.resourceStore = backupReadStateResourceStore(resources)+ for _, instance := range []string{"estate-a", "estate-b"} {+ m.pollStorageBackupsWithNodes(context.Background(), instance, client, []proxmox.Node{{Node: "node"}}, map[string]string{"node": "online"})+ }+ f.wait(t)+ if len(m.state.GetSnapshot().PVEBackups.StorageBackups) != 4 {+ t.Fatal("fresh inventory lost a guest")+ }+ points := f.points(t)+ if len(points) != 4 {+ t.Fatalf("points=%d want 4", len(points))+ }+ for _, p := range f.postures(t) {+ if p.State != recovery.ProtectionStateProtected || p.LastSuccessfulPointAt == nil || p.LastSuccessfulPointAt.Before(now.Add(-2*time.Hour)) {+ t.Errorf("fresh inventory did not advance canonical subject %s: state=%s success=%v", p.SubjectResourceID, p.State, p.LastSuccessfulPointAt)+ }+ }++ })+ }+}diff --git a/internal/recovery/posture.go b/internal/recovery/posture.goindex 5065c6528b..6b2174b324 100644--- a/internal/recovery/posture.go+++ b/internal/recovery/posture.go@@ -268,7 +268,10 @@ func BuildProtectionPostureFromPointsAt(}for _, point := range points {- if strings.TrimSpace(point.SubjectResourceID) != subjectResourceID {+ // Use the same identity normalization as SubjectKeyForPoint. A stored+ // Proxmox point can still carry a recognised legacy node-scoped ID+ // even though its recovery rollup is keyed to the canonical guest.+ if CanonicalSubjectResourceID(point.Provider, point.SubjectResourceID, point.SubjectRef) != subjectResourceID {continue}scope := ProviderScopeForPoint(point)diff --git a/internal/recovery/posture_test.go b/internal/recovery/posture_test.goindex 9bf2041b78..d8ff825511 100644--- a/internal/recovery/posture_test.go+++ b/internal/recovery/posture_test.go@@ -1,11 +1,13 @@package recoveryimport (+ "fmt""strings""testing""time""github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")func protectionTestSummary(@@ -470,3 +472,83 @@ func TestFormatPostureWindowReadsAsDaysOrHours(t *testing.T) {}}}++// Canonical posture and rollups must select the same subject. Historical+// node-scoped aliases are not another guest, nor permission to use another+// installation's backup merely because the VMID/name is the same.+func TestBuildProtectionPostureUsesCanonicalPointIdentity(t *testing.T) {+ t.Parallel()+ now := time.Date(2026, 10, 25, 12, 0, 0, 0, time.UTC)+ stale, fresh := now.Add(-17*24*time.Hour), now.Add(-time.Hour)+ for _, kind := range []struct {+ typ unifiedresources.ResourceType+ ref string+ }{+ {unifiedresources.ResourceTypeVM, "proxmox-vm"},+ {unifiedresources.ResourceTypeSystemContainer, "proxmox-lxc"},+ } {+ for _, provider := range []Provider{ProviderProxmoxPVE, ProviderProxmoxPBS} {+ t.Run(fmt.Sprintf("%s/%s", provider, kind.typ), func(t *testing.T) {+ const instance = "estate-a"+ source := instance + ":old-node:101"+ canonical := unifiedresources.ProxmoxGuestCanonicalID(kind.typ, instance, 101)+ aliases := []string{source, unifiedresources.SourceSpecificID(kind.typ, unifiedresources.SourceProxmox, source)}+ if kind.typ == unifiedresources.ResourceTypeSystemContainer {+ aliases = append(aliases, strings.Replace(aliases[1], "system-container-", "lxc-", 1))+ }+ observation, err := NewProtectionProviderObservation(provider, "backup-enumeration", instance, OutcomeSuccess, ProtectionHistoryComplete, operationaltrust.EvidencePermissionsSufficient, false, now, now, nil)+ if err != nil {+ t.Fatal(err)+ }+ baseline := RecoveryPoint{ID: "old-backup", Provider: provider, ProviderScope: instance, Kind: KindBackup, Mode: ModeLocal, Outcome: OutcomeSuccess, CompletedAt: &stale, SubjectResourceID: canonical}+ for _, alias := range aliases {+ t.Run(alias, func(t *testing.T) {+ latest := baseline+ latest.ID = "fresh-backup"+ latest.CompletedAt = &fresh+ latest.SubjectResourceID = alias+ latest.SubjectRef = &ExternalRef{Type: kind.ref, ID: source, Namespace: instance, Name: "same-name"}+ if SubjectKeyForPoint(latest) != SubjectKeyForPoint(baseline) {+ t.Fatal("control does not share a canonical rollup")+ }+ got := BuildProtectionPostureFromPointsAt(canonical, []RecoveryPoint{baseline, latest}, []ProtectionProviderObservation{observation}, DefaultProtectionPosturePolicy, now)+ if got.State != ProtectionStateProtected || got.Freshness != ProtectionFreshnessCurrent || got.LastSuccessfulPointAt == nil || !got.LastSuccessfulPointAt.Equal(fresh) {+ t.Fatalf("fresh legacy point ignored: state=%s freshness=%s success=%v", got.State, got.Freshness, got.LastSuccessfulPointAt)+ }+ // Running files and successful task records remain distinct from a+ // completed backup, even when their identity is a recognised alias.+ for _, limiting := range []RecoveryPoint{+ func() RecoveryPoint { p := latest; p.Outcome = OutcomeRunning; return p }(),+ func() RecoveryPoint { p := latest; p.Kind = KindOther; return p }(),+ func() RecoveryPoint {+ p := latest+ p.SubjectResourceID = unifiedresources.ProxmoxGuestCanonicalID(kind.typ, "estate-b", 101)+ p.SubjectRef = &ExternalRef{Type: kind.ref, ID: "estate-b:node:101", Namespace: "estate-b", Name: "same-name"}+ return p+ }(),+ func() RecoveryPoint {+ p := latest+ p.SubjectResourceID = unifiedresources.ProxmoxGuestCanonicalID(kind.typ, instance, 102)+ p.SubjectRef = &ExternalRef{Type: kind.ref, ID: instance + ":node:102", Namespace: instance}+ return p+ }(),+ } {+ got := BuildProtectionPostureFromPointsAt(canonical, []RecoveryPoint{baseline, limiting}, []ProtectionProviderObservation{observation}, DefaultProtectionPosturePolicy, now)+ if got.State != ProtectionStateAttention || got.LastSuccessfulPointAt == nil || !got.LastSuccessfulPointAt.Equal(stale) {+ t.Fatalf("unqualified/foreign point renewed protection: %+v", got)+ }+ }+ partial := observation.Clone()+ partial.HistoryCompleteness = ProtectionHistoryPartial+ partial.Evidence.Completeness = operationaltrust.EvidencePartial+ partial.Evidence.Reason = &operationaltrust.EvidenceReason{Code: "partial_inventory"}+ got = BuildProtectionPostureFromPointsAt(canonical, []RecoveryPoint{baseline, latest}, []ProtectionProviderObservation{partial}, DefaultProtectionPosturePolicy, now)+ if got.State == ProtectionStateProtected || got.Coverage != ProtectionCoveragePartial {+ t.Fatalf("alias bypassed limited collection: %+v", got)+ }+ })+ }+ })+ }+ }+}