From 527b7ceacc46d07ba3b914eeb73e02dccb92984c Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 18 Nov 2025 09:46:48 +0000 Subject: [PATCH] Skip inactive storages during content scans --- internal/monitoring/container_disk_usage.go | 3 +++ internal/monitoring/monitor.go | 6 +++++ internal/monitoring/monitor_snapshots_test.go | 2 +- internal/monitoring/storage_filters.go | 22 +++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 internal/monitoring/storage_filters.go diff --git a/internal/monitoring/container_disk_usage.go b/internal/monitoring/container_disk_usage.go index 38c1a55..9acde03 100644 --- a/internal/monitoring/container_disk_usage.go +++ b/internal/monitoring/container_disk_usage.go @@ -85,6 +85,9 @@ func (m *Monitor) collectContainerRootUsage(ctx context.Context, client PVEClien if !storageSupportsContainerVolumes(storage.Content) { continue } + if !storageContentQueryable(storage) { + continue + } contents, err := client.GetStorageContent(ctx, node, storage.Storage) if err != nil { diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go index 53787dd..fe7145c 100644 --- a/internal/monitoring/monitor.go +++ b/internal/monitoring/monitor.go @@ -8436,6 +8436,9 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceName if !strings.Contains(storage.Content, "backup") { continue } + if !storageContentQueryable(storage) { + continue + } storagesWithBackup++ @@ -9106,6 +9109,9 @@ func (m *Monitor) collectSnapshotSizes(ctx context.Context, instanceName string, if !strings.Contains(contentTypes, "images") && !strings.Contains(contentTypes, "rootdir") { continue } + if !storageContentQueryable(storage) { + continue + } contents, err := client.GetStorageContent(ctx, nodeName, storage.Storage) if err != nil { diff --git a/internal/monitoring/monitor_snapshots_test.go b/internal/monitoring/monitor_snapshots_test.go index efa71e4..a6f6134 100644 --- a/internal/monitoring/monitor_snapshots_test.go +++ b/internal/monitoring/monitor_snapshots_test.go @@ -113,7 +113,7 @@ func TestCollectSnapshotSizes(t *testing.T) { client := fakeSnapshotClient{ storages: map[string][]proxmox.Storage{ "node1": { - {Storage: "local-zfs", Content: "images"}, + {Storage: "local-zfs", Content: "images", Active: 1, Enabled: 1}, }, }, contents: map[string]map[string][]proxmox.StorageContent{ diff --git a/internal/monitoring/storage_filters.go b/internal/monitoring/storage_filters.go new file mode 100644 index 0000000..ec5a654 --- /dev/null +++ b/internal/monitoring/storage_filters.go @@ -0,0 +1,22 @@ +package monitoring + +import ( + "strings" + + "github.com/rcourtman/pulse-go-rewrite/pkg/proxmox" +) + +// storageContentQueryable reports whether it's safe to inspect the contents of a storage target. +// Proxmox returns storages that exist in the datacenter config even when the current node +// cannot access them. When Active==0 or the entry is disabled, querying /storage//content +// yields 500 errors that make Pulse think the node is unreachable. Guard calls so we only +// touch storages that are enabled, active on this node, and have a usable name. +func storageContentQueryable(storage proxmox.Storage) bool { + if strings.TrimSpace(storage.Storage) == "" { + return false + } + if storage.Enabled == 0 { + return false + } + return storage.Active == 1 +}