Skip inactive storages during content scans
This commit is contained in:
parent
5a570c89a5
commit
527b7ceacc
4 changed files with 32 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
22
internal/monitoring/storage_filters.go
Normal file
22
internal/monitoring/storage_filters.go
Normal file
|
|
@ -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/<name>/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
|
||||
}
|
||||
Loading…
Reference in a new issue