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.

Correct legacy zero-date TrueNAS snapshot outcomes too

pulse-triage[bot]0b3693fc2257
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 06dfd8d8a2..35fdd41cca 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -26,8 +26,9 @@
Undated or zero-date ZFS snapshots retain no start/completion time and have
Unknown outcome. Their IDs remain stable across polls regardless of collection
time; native dated snapshot IDs/times and replication semantics are unchanged.
-On store open, former successful snapshot rows with a completion but no start
-(the old collection-time fallback) become undated Unknown observations. Every
+On store open, former successful snapshot rows with no start become undated
+Unknown observations: completion-only rows used the old collection-time fallback,
+and rows with neither date could come from a zero native date. Every
row, ID and reference remains; valid detail objects retain the old synthetic
value as `legacyCollectedAtMs`, not creation evidence. No schema or retention
change, deletion, native snapshot, replication or restore is performed.
diff --git a/internal/recovery/store/store_test.go b/internal/recovery/store/store_test.go
index da3ad6e941..4b6c02c3f2 100644
--- a/internal/recovery/store/store_test.go
+++ b/internal/recovery/store/store_test.go
@@ -1299,7 +1299,9 @@ func TestStore_OpenCorrectsTrueNASSnapshotCollectionTimes(t *testing.T) {
p.SubjectRef = &recovery.ExternalRef{Type: "fixture-control", ID: tc.id, Name: tc.id}
controls = append(controls, p)
}
- seed := append([]recovery.RecoveryPoint{legacy, second}, controls...)
+ legacyZero := legacy
+ legacyZero.ID, legacyZero.CompletedAt = "legacy-zero-date", nil
+ seed := append([]recovery.RecoveryPoint{legacy, second, legacyZero}, controls...)
if err := db.UpsertPoints(ctx, seed); err != nil {
t.Fatal(err)
}
@@ -1331,7 +1333,7 @@ func TestStore_OpenCorrectsTrueNASSnapshotCollectionTimes(t *testing.T) {
for _, p := range points {
byID[p.ID] = p
}
- for _, original := range []recovery.RecoveryPoint{legacy, second, broken} {
+ for _, original := range []recovery.RecoveryPoint{legacy, second, legacyZero, broken} {
p, ok := byID[original.ID]
if !ok || p.Outcome != recovery.OutcomeUnknown || p.CompletedAt != nil || p.StartedAt != nil {
t.Errorf("legacy collection still claims completion: %+v", p)
@@ -1340,8 +1342,15 @@ func TestStore_OpenCorrectsTrueNASSnapshotCollectionTimes(t *testing.T) {
t.Errorf("correction lost artifact evidence: %+v", p)
}
if original.ID != broken.ID {
- if p.Details["retained"] != "artifact-evidence" || p.Details["legacyCollectedAtMs"] != float64(original.CompletedAt.UnixMilli()) {
- t.Errorf("lost prior collection evidence: %+v", p.Details)
+ if p.Details["retained"] != "artifact-evidence" {
+ t.Errorf("lost artifact evidence: %+v", p.Details)
+ }
+ if original.CompletedAt != nil {
+ if p.Details["legacyCollectedAtMs"] != float64(original.CompletedAt.UnixMilli()) {
+ t.Errorf("lost prior collection evidence: %+v", p.Details)
+ }
+ } else if _, ok := p.Details["legacyCollectedAtMs"]; ok {
+ t.Errorf("invented collection evidence for a legacy zero date: %+v", p.Details)
}
}
}
diff --git a/internal/recovery/store/truenas_snapshot_times.go b/internal/recovery/store/truenas_snapshot_times.go
index 2d72623b2e..31a48cb0ef 100644
--- a/internal/recovery/store/truenas_snapshot_times.go
+++ b/internal/recovery/store/truenas_snapshot_times.go
@@ -2,14 +2,15 @@ package store
// correctTrueNASSnapshotCollectionTimes removes a former mapper's synthetic
// completion date. That mapper always paired native creation dates with a
-// start date; only its collection-time fallback had a completion but no start.
+// start date; its collection-time fallback had a completion but no start.
+// Zero creation dates were stored with neither date and also remain unknown.
// Keep every artifact ID, reference and row. Retain the old value explicitly as
// legacy collection evidence, never as a native creation or successful backup.
// This is idempotent and runs before any reads or posture backfill on open.
func (s *Store) correctTrueNASSnapshotCollectionTimes() error {
_, err := s.db.Exec(`
UPDATE recovery_points
- SET details_json = CASE WHEN json_valid(details_json) THEN
+ SET details_json = CASE WHEN completed_at_ms IS NOT NULL AND json_valid(details_json) THEN
CASE WHEN json_type(details_json) = 'object' THEN
json_set(details_json, '$.legacyCollectedAtMs', completed_at_ms)
ELSE details_json END
@@ -18,7 +19,6 @@ func (s *Store) correctTrueNASSnapshotCollectionTimes() error {
outcome = 'unknown'
WHERE provider = 'truenas' AND kind = 'snapshot' AND mode = 'snapshot'
AND outcome = 'success' AND started_at_ms IS NULL
- AND completed_at_ms IS NOT NULL
`)
return err
}