Skip to content

Commit

Permalink
Include UUID of disk backing in disk backup
Browse files Browse the repository at this point in the history
This change modifies the disk backups to also include disk backing
UUIDs.  This allows us to look up and identify disks using UUIDs to
differentiate classic disks from disks that should be FCDs.

For now, the disk UUIDs are only used in failover workflows since
vSphere Replication guarantees that the disks will be restored with
the same UUID as the primary/source.
  • Loading branch information
aruneshpa committed Jan 23, 2025
1 parent 9d40af0 commit 538355d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/backup/api/backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@ type PVCDiskData struct {
PVCName string
// AccessMode is the access modes of the PVC backed by the virtual disk.
AccessModes []string

// UUID is the UUID of the virtual disk device backing. This
// is only used in fail-over workflows.
UUID string
}

// ClassicDiskData contains the backup data of a classic (static) disk attached
// to VM.
type ClassicDiskData struct {
// Filename is the datastore path to the virtual disk.
FileName string

// UUID is the UUID of the virtual disk device backing. This
// is only used in fail-over workflows.
UUID string
}

const (
Expand Down
2 changes: 2 additions & 0 deletions pkg/providers/vsphere/virtualmachine/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,12 @@ func getDesiredDiskDataForBackup(opts BackupVirtualMachineOptions) (string, stri
FileName: b.FileName,
PVCName: pvc.Name,
AccessModes: backupapi.ToPersistentVolumeAccessModes(pvc.Spec.AccessModes),
UUID: b.Uuid,
})
} else if _, ok := opts.ClassicDiskUUIDs[b.Uuid]; ok {
classicDiskData = append(classicDiskData, backupapi.ClassicDiskData{
FileName: b.FileName,
UUID: b.Uuid,
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/providers/vsphere/virtualmachine/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,10 @@ func backupTests() {

diskData := []backupapi.PVCDiskData{
{
FileName: vcSimDiskFileName,
FileName: vcSimDiskFileName, //
PVCName: dummyPVC.Name,
AccessModes: backupapi.ToPersistentVolumeAccessModes(dummyPVC.Spec.AccessModes),
UUID: vcSimDiskUUID,
},
}
diskDataJSON, err := json.Marshal(diskData)
Expand Down Expand Up @@ -1010,6 +1011,7 @@ func backupTests() {
diskData := []backupapi.ClassicDiskData{
{
FileName: vcSimDiskFileName,
UUID: vcSimDiskUUID,
},
}
diskDataJSON, err := json.Marshal(diskData)
Expand Down

0 comments on commit 538355d

Please sign in to comment.