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
Exercise backup ownership through the ordinary provider scheduler
pulse-triage[bot]5bb0e6311de9
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex c4cf593aa1..4cb5202534 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -6440,7 +6440,8 @@"allow_same_subsystem_tests": false,"test_prefixes": [],"exact_files": [- "internal/monitoring/pve_backup_lifecycle_test.go"+ "internal/monitoring/pve_backup_lifecycle_test.go",+ "internal/monitoring/pve_backup_scheduler_test.go"]},{diff --git a/internal/monitoring/pve_backup_lifecycle_test.go b/internal/monitoring/pve_backup_lifecycle_test.goindex 51fd41fd9e..208a95f857 100644--- a/internal/monitoring/pve_backup_lifecycle_test.go+++ b/internal/monitoring/pve_backup_lifecycle_test.go@@ -312,3 +312,29 @@ func TestPVEBackupLifecycleCompletedReplacementRefreshesImmediately(t *testing.T}})}++func TestPVEBackupLifecycleRuntimeReplacementKeepsSameClientSafe(t *testing.T) {+ synctest.Test(t, func(t *testing.T) {+ release := make(chan struct{})+ var taskReads atomic.Int32+ var oldCtx context.Context+ c := &backupLifecycleClient{label: "accepted", read: func(ctx context.Context, p string) {+ if p == "tasks" && taskReads.Add(1) == 1 {+ oldCtx = ctx+ <-release+ }+ }}+ m := newBackupLifecycleMonitor(c, "qemu")+ scheduleBackupLifecycle(m, c)+ synctest.Wait()+ m.setRuntimeContext(context.Background(), nil)+ scheduleBackupLifecycle(m, c)+ synctest.Wait()+ before := m.state.GetSnapshot().PVEBackups+ require.Equal(t, int32(2), taskReads.Load())+ close(release)+ synctest.Wait()+ require.Error(t, oldCtx.Err())+ require.Equal(t, before, m.state.GetSnapshot().PVEBackups)+ })+}diff --git a/internal/monitoring/pve_backup_scheduler_test.go b/internal/monitoring/pve_backup_scheduler_test.gonew file mode 100644index 0000000000..eaac48db83--- /dev/null+++ b/internal/monitoring/pve_backup_scheduler_test.go@@ -0,0 +1,68 @@+package monitoring++import (+ "context"+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"+ "github.com/stretchr/testify/require"+)++type scheduledBackupLifecycleClient struct{ backupLifecycleClient }++func (c *scheduledBackupLifecycleClient) GetNodes(context.Context) ([]proxmox.Node, error) {+ return []proxmox.Node{{Node: "node-a", Status: "online"}}, nil+}++func TestPVEBackupLifecycleSchedulerLeavesBackgroundOwnerAlive(t *testing.T) {+ started := make(chan struct{})+ release := make(chan struct{})+ var readCtx context.Context+ c := &scheduledBackupLifecycleClient{backupLifecycleClient: backupLifecycleClient{label: "scheduled", read: func(ctx context.Context, phase string) {+ if phase == "tasks" {+ readCtx = ctx+ close(started)+ <-release+ }+ }}}+ m := newReplicationLifecycleMonitor(t, c, false)+ m.config.EnableBackupPolling = true+ m.config.BackupPollingCycles = 1+ m.config.PVEInstances[0].MonitorBackups = true+ runCtx, cancel := context.WithCancel(context.Background())+ defer cancel()+ m.setRuntimeContext(runCtx, nil)+ released := false+ defer func() {+ if !released {+ close(release)+ }+ }()+ runReplicationCycle(m)+ waitReplication(t, started, "scheduled backup read")+ require.NoError(t, readCtx.Err(), "finished core-cycle context canceled its background scan")+ m.mu.RLock()+ owner := m.pveBackupPolls["site-a"]+ m.mu.RUnlock()+ require.NotNil(t, owner)+ cancel()+ require.Error(t, readCtx.Err(), "runtime cancellation did not reach the background owner")+ close(release)+ released = true+ waitReplication(t, owner.done, "scheduled backup completion")+ m.mu.RLock()+ remaining := m.pveBackupPolls["site-a"]+ m.mu.RUnlock()+ require.Nil(t, remaining)+ require.Empty(t, m.state.GetSnapshot().PVEBackups.BackupTasks, "canceled scheduler published late tasks")+ // The stopped runtime remains stopped even if another ordinary cycle is due.+ m.mu.Lock()+ m.lastPVEBackupPoll["site-a"] = time.Time{}+ m.mu.Unlock()+ scheduleBackupLifecycle(m, c)+ m.mu.RLock()+ remaining = m.pveBackupPolls["site-a"]+ m.mu.RUnlock()+ require.Nil(t, remaining)+}