From cdf80dbab5130dd1f842789270779737f766dc78 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 22 Oct 2025 13:47:51 +0000 Subject: [PATCH] Align backup node column with current host (#577) --- internal/models/models.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/models/models.go b/internal/models/models.go index 8eb8362..11c5d6c 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -1392,6 +1392,30 @@ func (s *State) UpdateStorageBackupsForInstance(instanceName string, backups []S s.mu.Lock() defer s.mu.Unlock() + // When storage is shared across nodes, backups can appear under whichever node reported the content. + // Align each backup with the guest's current node so the frontend column matches the VM/CT placement. + guestNodeByVMID := make(map[int]string) + for _, vm := range s.VMs { + if vm.Instance == instanceName && vm.Node != "" { + guestNodeByVMID[vm.VMID] = vm.Node + } + } + for _, ct := range s.Containers { + if ct.Instance == instanceName && ct.Node != "" { + guestNodeByVMID[ct.VMID] = ct.Node + } + } + + normalizedBackups := make([]StorageBackup, 0, len(backups)) + for _, backup := range backups { + if backup.VMID > 0 { + if node, ok := guestNodeByVMID[backup.VMID]; ok { + backup.Node = node + } + } + normalizedBackups = append(normalizedBackups, backup) + } + // Create a map of existing backups, excluding those from this instance backupMap := make(map[string]StorageBackup) for _, backup := range s.PVEBackups.StorageBackups { @@ -1402,7 +1426,7 @@ func (s *State) UpdateStorageBackupsForInstance(instanceName string, backups []S } // Add or update backups from this instance - for _, backup := range backups { + for _, backup := range normalizedBackups { backupMap[backup.ID] = backup }