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.

Publish the canonical subject in persisted protection posture

pulse-triage[bot]b0d76d7cea27
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 83be71b81e..f217582b91 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -23,8 +23,8 @@
### 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
+Protection posture selects stored points and publishes its subject ID 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
@@ -32,7 +32,8 @@ 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
+qualification/scope controls. `store_posture_test.go` checks canonical requested
+subjects and state-filtered reads without an obsolete attention record. 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.
diff --git a/internal/recovery/store/store_posture.go b/internal/recovery/store/store_posture.go
index 4666cd3e4a..5c64af212b 100644
--- a/internal/recovery/store/store_posture.go
+++ b/internal/recovery/store/store_posture.go
@@ -576,7 +576,10 @@ func (s *Store) writeProtectionPostures(
points := pointsByKey[key]
subjectResourceID := ""
for _, point := range points {
- if value := strings.TrimSpace(point.SubjectResourceID); value != "" {
+ // The bucket's subject key already recognises Proxmox legacy
+ // aliases. Publish that same canonical subject, not whichever
+ // historical representation the newest point happened to carry.
+ if value := recovery.CanonicalSubjectResourceID(point.Provider, point.SubjectResourceID, point.SubjectRef); value != "" {
subjectResourceID = value
break
}
diff --git a/internal/recovery/store/store_posture_test.go b/internal/recovery/store/store_posture_test.go
index c6b054ec7b..d1b950f165 100644
--- a/internal/recovery/store/store_posture_test.go
+++ b/internal/recovery/store/store_posture_test.go
@@ -10,6 +10,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust"
"github.com/rcourtman/pulse-go-rewrite/internal/recovery"
+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
)
func TestStoreProtectionPosturePersistsProviderAwareTruth(t *testing.T) {
@@ -750,3 +751,44 @@ func TestBackupRollupConnectionWaitingHonoursDeadline(t *testing.T) {
t.Fatalf("rollups after releasing held connection: %v", err)
}
}
+
+func TestStoreProtectionPosturePublishesCanonicalLegacySubject(t *testing.T) {
+ t.Parallel()
+ store, err := Open(filepath.Join(t.TempDir(), "recovery.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer store.Close()
+ now := time.Now().UTC().Truncate(time.Second)
+ stale, fresh := now.Add(-17*24*time.Hour), now.Add(-time.Hour)
+ canonical := unifiedresources.ProxmoxGuestCanonicalID(unifiedresources.ResourceTypeSystemContainer, "estate-a", 101)
+ legacy := unifiedresources.SourceSpecificID(unifiedresources.ResourceTypeSystemContainer, unifiedresources.SourceProxmox, "estate-a:old-node:101")
+ observation, err := recovery.NewProtectionProviderObservation(recovery.ProviderProxmoxPVE, "pve-backup-enumeration", "estate-a", recovery.OutcomeSuccess, recovery.ProtectionHistoryComplete, operationaltrust.EvidencePermissionsSufficient, false, now, now, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := store.UpsertProtectionProviderObservations(context.Background(), []recovery.ProtectionProviderObservation{observation}); err != nil {
+ t.Fatal(err)
+ }
+ points := []recovery.RecoveryPoint{
+ {ID: "pve-backup:old", Provider: recovery.ProviderProxmoxPVE, ProviderScope: "estate-a", Kind: recovery.KindBackup, Mode: recovery.ModeLocal, Outcome: recovery.OutcomeSuccess, CompletedAt: &stale, SubjectResourceID: canonical},
+ {ID: "pve-backup:fresh", Provider: recovery.ProviderProxmoxPVE, ProviderScope: "estate-a", Kind: recovery.KindBackup, Mode: recovery.ModeLocal, Outcome: recovery.OutcomeSuccess, CompletedAt: &fresh, SubjectResourceID: legacy, SubjectRef: &recovery.ExternalRef{Type: "proxmox-lxc", ID: "estate-a:old-node:101", Namespace: "estate-a"}},
+ }
+ if err := store.UpsertPoints(context.Background(), points); err != nil {
+ t.Fatal(err)
+ }
+ for _, q := range []recovery.ProtectionPostureQuery{{SubjectResourceIDs: []string{canonical}}, {State: recovery.ProtectionStateProtected}} {
+ got, total, err := store.ListProtectionPostures(context.Background(), q)
+ if err != nil || total != 1 || len(got) != 1 {
+ t.Fatalf("postures total=%d len=%d err=%v", total, len(got), err)
+ }
+ p := got[0]
+ if p.SubjectResourceID != canonical || p.State != recovery.ProtectionStateProtected || p.LastSuccessfulPointAt == nil || !p.LastSuccessfulPointAt.Equal(fresh) {
+ t.Fatalf("legacy point forked canonical posture: %+v", p)
+ }
+ }
+ attention, total, err := store.ListProtectionPostures(context.Background(), recovery.ProtectionPostureQuery{State: recovery.ProtectionStateAttention})
+ if err != nil || total != 0 || len(attention) != 0 {
+ t.Fatalf("obsolete attention posture remains: %+v total=%d err=%v", attention, total, err)
+ }
+}