Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backup): modify backup APIs for backup target and volume name (backport #3471) #3472

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,19 @@ func toBackupResource(b *longhorn.Backup) *Backup {
return nil
}

// For frontend, it will use the backup target name and volume name to tell this backup is belong to which backup volume.
// The backup not in `completed` state will not have the backup target name and volume name in `Status`.
backupTargetName := b.Status.BackupTargetName
volumeName := b.Status.VolumeName
if b.Labels != nil {
if backupTargetName == "" {
backupTargetName = b.Labels[types.LonghornLabelBackupTarget]
}
if volumeName == "" {
volumeName = b.Labels[types.LonghornLabelBackupVolume]
}
}

getSnapshotNameFromBackup := func(b *longhorn.Backup) string {
if b.Spec.SnapshotName != "" {
return b.Spec.SnapshotName
Expand All @@ -1976,14 +1989,14 @@ func toBackupResource(b *longhorn.Backup) *Backup {
Labels: b.Status.Labels,
BackupMode: b.Spec.BackupMode,
Messages: b.Status.Messages,
VolumeName: b.Status.VolumeName,
VolumeName: volumeName,
VolumeSize: b.Status.VolumeSize,
VolumeCreated: b.Status.VolumeCreated,
VolumeBackingImageName: b.Status.VolumeBackingImageName,
CompressionMethod: string(b.Status.CompressionMethod),
NewlyUploadedDataSize: b.Status.NewlyUploadedDataSize,
ReUploadedDataSize: b.Status.ReUploadedDataSize,
BackupTargetName: b.Status.BackupTargetName,
BackupTargetName: backupTargetName,
}
// Set the volume name from backup CR's label if it's empty.
// This field is empty probably because the backup state is not Ready
Expand Down
Loading