diff --git a/changelogs/unreleased/7070-blackpiglet b/changelogs/unreleased/7070-blackpiglet new file mode 100644 index 0000000000..75843b7304 --- /dev/null +++ b/changelogs/unreleased/7070-blackpiglet @@ -0,0 +1 @@ +Add VolumeInfo metadata structures. \ No newline at end of file diff --git a/design/pv_backup_info.md b/design/pv_backup_info.md index 287000de77..669150e822 100644 --- a/design/pv_backup_info.md +++ b/design/pv_backup_info.md @@ -42,9 +42,10 @@ The 1 version of `VolumeInfo` definition is: type VolumeInfoV1 struct { PVCName string // The PVC's name. The format should be / PVName string // The PV name. - BackupMethod string // The way the volume data is backed up. The valid value includes `VeleroNativeSnapshot`, `PodVolumeBackup`, `CSISnapshot` and `Skipped`. + BackupMethod string // The way the volume data is backed up. The valid value includes `VeleroNativeSnapshot`, `PodVolumeBackup` and `CSISnapshot`. SnapshotDataMovement bool // Whether the volume's snapshot data is moved to specified storage. + Skipped boolean // Whether the Volume is skipped in this backup. SkippedReason string // The reason for the volume is skipped in the backup. StartTimestamp *metav1.Time // Snapshot starts timestamp. @@ -52,11 +53,12 @@ type VolumeInfoV1 struct { SnapshotDataMoveInfo SnapshotDataMoveInfo NativeSnapshotInfo VeleroNativeSnapshotInfo PVBInfo PodVolumeBackupInfo + PVInfo PVInfo } // CSISnapshotInfo is used for displaying the CSI snapshot status type CSISnapshotInfo struct { - SnapshotHandle string // The actual snapshot ID. It can be the cloud provider's snapshot ID or the file-system uploader's snapshot. + SnapshotHandle string // The actual snapshot ID. It's the storage provider's snapshot ID for CSI. Size int64 // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. Driver string // The name of the CSI driver. @@ -72,7 +74,7 @@ type SnapshotDataMoveInfo struct { // VeleroNativeSnapshotInfo is used for displaying the Velero native snapshot status. type VeleroNativeSnapshotInfo struct { - SnapshotHandle string // The actual snapshot ID. It can be the cloud provider's snapshot ID or the file-system uploader's snapshot. + SnapshotHandle string // The actual snapshot ID. It's the storage provider's snapshot ID for the Velero-native snapshot. Size int64 // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. VolumeType string // The cloud provider snapshot volume type. @@ -82,12 +84,20 @@ type VeleroNativeSnapshotInfo struct { // PodVolumeBackupInfo is used for displaying the PodVolumeBackup snapshot status. type PodVolumeBackupInfo struct { - SnapshotHandle string // The actual snapshot ID. It can be the cloud provider's snapshot ID or the file-system uploader's snapshot. + SnapshotHandle string // The actual snapshot ID. It's the file-system uploader's snapshot ID for PodVolumeBackup. Size int64 // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. UploaderType string // The type of the uploader that uploads the data. The valid values are `kopia` and `restic`. It's useful for file-system backup and snapshot data mover. - VolumeName string // The PVC's corresponding volume name used by Pod - PodName string // The Pod name mounting this PVC. The format should be /. + VolumeName string // The PVC's corresponding volume name used by Pod + PodName string // The Pod name mounting this PVC. The format should be /. + NodeName string // The PVB-taken k8s node's name. +} + +// PVInfo is used to store some PV information modified after creation. +// Those information are lost after PV recreation. +type PVInfo struct { + ReclaimPolicy string // ReclaimPolicy of PV. It could be different from the referenced StorageClass. + labels map[string]string // The PV's labels should be kept after recreation. } ``` @@ -164,11 +174,12 @@ After introducing the VolumeInfo array, the following logic will be added. ... case CSISnapshot: ... - case Skipped: - // Check whether the Velero server should restore the PV depending on the DeletionPolicy setting. default: // Need to check whether the volume is backed up by the SnapshotDataMover. if volumeInfo.SnapshotDataMovement: + + // Check whether the Velero server should restore the PV depending on the DeletionPolicy setting. + if volumeInfo.Skipped: ``` ### How the VolumeInfo metadata file is deleted diff --git a/pkg/volume/volume_info_common.go b/pkg/volume/volume_info_common.go new file mode 100644 index 0000000000..3656c54ee8 --- /dev/null +++ b/pkg/volume/volume_info_common.go @@ -0,0 +1,80 @@ +package volume + +type VolumeInfoVersion struct { + Version string `json:"version"` +} + +const ( + VolumeInfoVersionV1 string = "1" +) + +type VolumeInfos struct { + VolumeInfosV1 []VolumeInfoV1 + Version string +} + +// CSISnapshotInfo is used for displaying the CSI snapshot status +type CSISnapshotInfo struct { + // The actual snapshot ID. It's the storage provider's snapshot ID for CSI. + SnapshotHandle string `json:"snapshotHandle"` + + // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. + Size int64 `json:"size"` + + // The name of the CSI driver. + Driver string `json:"driver"` + + // The name of the VolumeSnapshotContent. + VSCName string `json:"vscName"` +} + +// SnapshotDataMoveInfo is used for displaying the snapshot data mover status. +type SnapshotDataMoveInfo struct { + // The data mover used by the backup. The valid values are `velero` and ``(equals to `velero`). + DataMover string `json:"dataMover"` + + // The type of the uploader that uploads the snapshot data. The valid values are `kopia` and `restic`. It's useful for file-system backup and snapshot data mover. + UploaderType string `json:"uploaderType"` + + // The name or ID of the snapshot associated object(SAO). + RetainedSnapshot string `json:"retainedSnapshot"` +} + +// VeleroNativeSnapshotInfo is used for displaying the Velero native snapshot status. +type VeleroNativeSnapshotInfo struct { + // The actual snapshot ID. It's the storage provider's snapshot ID for the Velero-native snapshot. + SnapshotHandle string `json:"snapshotHandle"` + + // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. + Size int64 `json:"size"` + + // The cloud provider snapshot volume type. + VolumeType string `json:"volumeType"` + + // The cloud provider snapshot volume's availability zones. + VolumeAZ string `json:"volumeAZ"` + + // The cloud provider snapshot volume's IOPS. + IOPS string `json:"iops"` +} + +// PodVolumeBackupInfo is used for displaying the PodVolumeBackup snapshot status. +type PodVolumeBackupInfo struct { + // The actual snapshot ID. It's the file-system uploader's snapshot ID for PodVolumeBackup. + SnapshotHandle string `json:"snapshotHandle"` + + // The snapshot corresponding volume size. Some of the volume backup methods cannot retrieve the data by current design, for example, the Velero native snapshot. + Size int64 `json:"size"` + + // The type of the uploader that uploads the data. The valid values are `kopia` and `restic`. It's useful for file-system backup and snapshot data mover. + UploaderType string `json:"uploaderType"` + + // The PVC's corresponding volume name used by Pod + VolumeName string `json:"volumeName"` + + // The Pod name mounting this PVC. The format should be /. + PodName string `json:"podName"` + + // The PVB-taken k8s node's name. + NodeName string `json:"nodeName"` +} diff --git a/pkg/volume/volume_info_v1.go b/pkg/volume/volume_info_v1.go new file mode 100644 index 0000000000..f6f1c4c178 --- /dev/null +++ b/pkg/volume/volume_info_v1.go @@ -0,0 +1,38 @@ +package volume + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +type VolumeInfosV1 struct { + Infos []VolumeInfoV1 `json:"infos"` + + // VolumeInfo structure's version information. + Version string `json:"version"` +} + +type VolumeInfoV1 struct { + // The PVC's name. The format should be / + PVCName string `json:"pvcName"` + + // The PV name. + PVName string `json:"pvName"` + + // The way the volume data is backed up. The valid value includes `VeleroNativeSnapshot`, `PodVolumeBackup` and `CSISnapshot`. + BackupMethod string `json:"backupMethod,omitempty"` + + // Whether the volume's snapshot data is moved to specified storage. + SnapshotDataMovement bool `json:"snapshotDataMovement"` + + // Whether the Volume is skipped in this backup. + Skipped bool `json:"skipped"` + + // The reason for the volume is skipped in the backup. + SkippedReason string `json:"skippedReason,omitempty"` + + // Snapshot starts timestamp. + StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"` + + CSISnapshotInfo CSISnapshotInfo `json:"csiSnapshotInfo,omitempty"` + SnapshotDataMoveInfo SnapshotDataMoveInfo `json:"snapshotDataMoveInfo,omitempty"` + NativeSnapshotInfo VeleroNativeSnapshotInfo `json:"nativeSnapshotInfo,omitempty"` + PVBInfo PodVolumeBackupInfo `json:"pvbInfo,omitempty"` +}