From 60a6c7384fc61056d9620588d22010759d8fd65d Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Wed, 23 Jul 2025 06:59:51 -0700 Subject: [PATCH] Fix missing defaultVolumesToFsBackup flag output in Velero describe backup cmd (#9056) add changelog file Show defaultVolumesToFsBackup in describe only when set by the user minor ut fix minor fix Signed-off-by: Shubham Pampattiwar --- .../unreleased/9056-shubham-pampattiwar | 1 + pkg/cmd/util/output/backup_describer.go | 3 + pkg/cmd/util/output/backup_describer_test.go | 75 +++++++++++++ pkg/cmd/util/output/schedule_describe_test.go | 104 ++++++++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 changelogs/unreleased/9056-shubham-pampattiwar diff --git a/changelogs/unreleased/9056-shubham-pampattiwar b/changelogs/unreleased/9056-shubham-pampattiwar new file mode 100644 index 000000000..4f4908da6 --- /dev/null +++ b/changelogs/unreleased/9056-shubham-pampattiwar @@ -0,0 +1 @@ +Fix missing defaultVolumesToFsBackup flag output in Velero describe backup cmd \ No newline at end of file diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index c8173afc6..7f7d28932 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -217,6 +217,9 @@ func DescribeBackupSpec(d *Describer, spec velerov1api.BackupSpec) { d.Println() d.Printf("Velero-Native Snapshot PVs:\t%s\n", BoolPointerString(spec.SnapshotVolumes, "false", "true", "auto")) + if spec.DefaultVolumesToFsBackup != nil { + d.Printf("Default Volumes to Fs Backup:\t%s\n", BoolPointerString(spec.DefaultVolumesToFsBackup, "false", "true", "")) + } d.Printf("Snapshot Move Data:\t%s\n", BoolPointerString(spec.SnapshotMoveData, "false", "true", "auto")) if len(spec.DataMover) == 0 { s = defaultDataMover diff --git a/pkg/cmd/util/output/backup_describer_test.go b/pkg/cmd/util/output/backup_describer_test.go index bc5c17796..9b5557ff1 100644 --- a/pkg/cmd/util/output/backup_describer_test.go +++ b/pkg/cmd/util/output/backup_describer_test.go @@ -281,6 +281,71 @@ Hooks: OrderedResources: kind1: rs1-1, rs1-2 +` + input4 := builder.ForBackup("test-ns", "test-backup-4"). + DefaultVolumesToFsBackup(true). + StorageLocation("backup-location"). + Result().Spec + + expect4 := `Namespaces: + Included: * + Excluded: + +Resources: + Included: * + Excluded: + Cluster-scoped: auto + +Label selector: + +Or label selector: + +Storage Location: backup-location + +Velero-Native Snapshot PVs: auto +Default Volumes to Fs Backup: true +Snapshot Move Data: auto +Data Mover: velero + +TTL: 0s + +CSISnapshotTimeout: 0s +ItemOperationTimeout: 0s + +Hooks: +` + + input5 := builder.ForBackup("test-ns", "test-backup-5"). + DefaultVolumesToFsBackup(false). + StorageLocation("backup-location"). + Result().Spec + + expect5 := `Namespaces: + Included: * + Excluded: + +Resources: + Included: * + Excluded: + Cluster-scoped: auto + +Label selector: + +Or label selector: + +Storage Location: backup-location + +Velero-Native Snapshot PVs: auto +Default Volumes to Fs Backup: false +Snapshot Move Data: auto +Data Mover: velero + +TTL: 0s + +CSISnapshotTimeout: 0s +ItemOperationTimeout: 0s + +Hooks: ` testcases := []struct { @@ -303,6 +368,16 @@ OrderedResources: input: input3, expect: expect3, }, + { + name: "DefaultVolumesToFsBackup is true", + input: input4, + expect: expect4, + }, + { + name: "DefaultVolumesToFsBackup is false", + input: input5, + expect: expect5, + }, } for _, tc := range testcases { diff --git a/pkg/cmd/util/output/schedule_describe_test.go b/pkg/cmd/util/output/schedule_describe_test.go index ad4cde9ed..2e26550e6 100644 --- a/pkg/cmd/util/output/schedule_describe_test.go +++ b/pkg/cmd/util/output/schedule_describe_test.go @@ -102,6 +102,100 @@ Backup Template: Hooks: +Last Backup: 2023-06-25 15:04:05 +0000 UTC +` + + input3 := builder.ForSchedule("velero", "schedule-3"). + Phase(velerov1api.SchedulePhaseEnabled). + CronSchedule("0 0 * * *"). + Template(builder.ForBackup("velero", "backup-1").DefaultVolumesToFsBackup(true).Result().Spec). + LastBackupTime("2023-06-25 15:04:05").Result() + expect3 := `Name: schedule-3 +Namespace: velero +Labels: +Annotations: + +Phase: Enabled + +Paused: false + +Schedule: 0 0 * * * + +Backup Template: + Namespaces: + Included: * + Excluded: + + Resources: + Included: * + Excluded: + Cluster-scoped: auto + + Label selector: + + Or label selector: + + Storage Location: + + Velero-Native Snapshot PVs: auto + Default Volumes to Fs Backup: true + Snapshot Move Data: auto + Data Mover: velero + + TTL: 0s + + CSISnapshotTimeout: 0s + ItemOperationTimeout: 0s + + Hooks: + +Last Backup: 2023-06-25 15:04:05 +0000 UTC +` + + input4 := builder.ForSchedule("velero", "schedule-4"). + Phase(velerov1api.SchedulePhaseEnabled). + CronSchedule("0 0 * * *"). + Template(builder.ForBackup("velero", "backup-1").DefaultVolumesToFsBackup(false).Result().Spec). + LastBackupTime("2023-06-25 15:04:05").Result() + expect4 := `Name: schedule-4 +Namespace: velero +Labels: +Annotations: + +Phase: Enabled + +Paused: false + +Schedule: 0 0 * * * + +Backup Template: + Namespaces: + Included: * + Excluded: + + Resources: + Included: * + Excluded: + Cluster-scoped: auto + + Label selector: + + Or label selector: + + Storage Location: + + Velero-Native Snapshot PVs: auto + Default Volumes to Fs Backup: false + Snapshot Move Data: auto + Data Mover: velero + + TTL: 0s + + CSISnapshotTimeout: 0s + ItemOperationTimeout: 0s + + Hooks: + Last Backup: 2023-06-25 15:04:05 +0000 UTC ` @@ -120,6 +214,16 @@ Last Backup: 2023-06-25 15:04:05 +0000 UTC input: input2, expect: expect2, }, + { + name: "schedule with DefaultVolumesToFsBackup is true", + input: input3, + expect: expect3, + }, + { + name: "schedule with DefaultVolumesToFsBackup is false", + input: input4, + expect: expect4, + }, } for _, tc := range testcases {