Skip to content

Commit a4f9f6c

Browse files
committed
Fix NODE column in backups to show actual guest node
Related to discussion #577 When backups are stored on shared storage accessible from multiple nodes, the backup polling code was incorrectly assigning the backup to whichever node it was discovered on during the scan, rather than the node where the VM/container actually resides. This fix: - Builds a lookup map of VMID -> actual node at the start of backup polling - Uses this map to assign the correct node for guest backups (VMID > 0) - Preserves existing behavior for host backups (VMID == 0) - Falls back to the queried node if the guest is not found in the map This ensures the NODE column accurately reflects which node hosts each guest, matching the information displayed on the main page.
1 parent 6fd1c85 commit a4f9f6c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

internal/monitoring/monitor.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7735,6 +7735,20 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceName
77357735
contentFailures := 0 // Number of failed storage content fetches
77367736
storageQueryErrors := 0 // Number of nodes where storage list could not be queried
77377737

7738+
// Build guest lookup map to find actual node for each VMID
7739+
snapshot := m.state.GetSnapshot()
7740+
guestNodeMap := make(map[int]string) // VMID -> actual node name
7741+
for _, vm := range snapshot.VMs {
7742+
if vm.Instance == instanceName {
7743+
guestNodeMap[vm.VMID] = vm.Node
7744+
}
7745+
}
7746+
for _, ct := range snapshot.Containers {
7747+
if ct.Instance == instanceName {
7748+
guestNodeMap[int(ct.VMID)] = ct.Node
7749+
}
7750+
}
7751+
77387752
// For each node, get storage and check content
77397753
for _, node := range nodes {
77407754
if nodeEffectiveStatus[node.Node] != "online" {
@@ -7828,8 +7842,15 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceName
78287842
backupType = "qemu"
78297843
}
78307844

7831-
// Always use the actual node name
7845+
// Determine the correct node: for guest backups (VMID > 0), use the actual guest's node
7846+
// For host backups (VMID == 0), use the node where the backup was found
78327847
backupNode := node.Node
7848+
if content.VMID > 0 {
7849+
if actualNode, found := guestNodeMap[content.VMID]; found {
7850+
backupNode = actualNode
7851+
}
7852+
// If not found in map, fall back to queried node (shouldn't happen normally)
7853+
}
78337854
isPBSStorage := strings.HasPrefix(storage.Storage, "pbs-") || storage.Type == "pbs"
78347855

78357856
// Check verification status for PBS backups

0 commit comments

Comments
 (0)