fix: Properly show disabled storage status from Proxmox

Storage that is disabled in Proxmox (Datacenter > Storage > enabled=no)
was incorrectly showing as "available" in Pulse. The issue was that
Enabled/Active fields defaulted to true and were never set to false
from the per-node API response.

Now the model correctly initializes Enabled/Active from the Proxmox
per-node storage API response, and the status determination prioritizes
checking the disabled state first.

Related to #796
This commit is contained in:
rcourtman 2025-12-02 15:03:40 +00:00
parent be23624592
commit ac4e48fa4a

View file

@ -1319,6 +1319,7 @@ func (m *Monitor) pollStorageWithNodes(ctx context.Context, instanceName string,
shared := hasClusterConfig && clusterConfig.Shared == 1 shared := hasClusterConfig && clusterConfig.Shared == 1
// Create storage model // Create storage model
// Initialize Enabled/Active from per-node API response
modelStorage := models.Storage{ modelStorage := models.Storage{
ID: storageID, ID: storageID,
Name: storage.Storage, Name: storage.Storage,
@ -1332,8 +1333,8 @@ func (m *Monitor) pollStorageWithNodes(ctx context.Context, instanceName string,
Usage: safePercentage(float64(storage.Used), float64(storage.Total)), Usage: safePercentage(float64(storage.Used), float64(storage.Total)),
Content: sortContent(storage.Content), Content: sortContent(storage.Content),
Shared: shared, Shared: shared,
Enabled: true, Enabled: storage.Enabled == 1,
Active: true, Active: storage.Active == 1,
} }
// If this is ZFS storage, attach pool status information // If this is ZFS storage, attach pool status information
@ -1380,13 +1381,14 @@ func (m *Monitor) pollStorageWithNodes(ctx context.Context, instanceName string,
} }
} }
// Determine status based on active/enabled flags // Determine status based on enabled/active flags
if storage.Active == 1 || modelStorage.Active { // Priority: disabled storage always shows as "disabled", regardless of active state
modelStorage.Status = "available" if !modelStorage.Enabled {
} else if modelStorage.Enabled {
modelStorage.Status = "inactive"
} else {
modelStorage.Status = "disabled" modelStorage.Status = "disabled"
} else if modelStorage.Active {
modelStorage.Status = "available"
} else {
modelStorage.Status = "inactive"
} }
nodeStorageList = append(nodeStorageList, modelStorage) nodeStorageList = append(nodeStorageList, modelStorage)