From 8f51c1c08c6fb457b196c8fee7658cec2f9bb86c Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Wed, 23 Jul 2025 06:59:51 -0700 Subject: [PATCH 1/2] 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 (cherry picked from commit 60a6c7384fc61056d9620588d22010759d8fd65d) update changelog filename Signed-off-by: Shubham Pampattiwar --- .../unreleased/9103-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/9103-shubham-pampattiwar diff --git a/changelogs/unreleased/9103-shubham-pampattiwar b/changelogs/unreleased/9103-shubham-pampattiwar new file mode 100644 index 000000000..4f4908da6 --- /dev/null +++ b/changelogs/unreleased/9103-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 b81bad002..77d124dd6 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 b6be5e831..f41887f2e 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 { From 78fd58fb43f9f34aea8bc4fcb7d12fde38ccfcef Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Wed, 23 Jul 2025 14:55:28 -0700 Subject: [PATCH 2/2] Update Backup describe string for DefaultVolumesToFSBackup flag (#9105) add changelog file Signed-off-by: Shubham Pampattiwar (cherry picked from commit aa2e09c69e2f971b2440b9c99194d8c3d2deb4f0) --- changelogs/unreleased/9105-shubham-pampattiwar | 1 + pkg/cmd/util/output/backup_describer.go | 2 +- pkg/cmd/util/output/backup_describer_test.go | 4 ++-- pkg/cmd/util/output/schedule_describe_test.go | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/9105-shubham-pampattiwar diff --git a/changelogs/unreleased/9105-shubham-pampattiwar b/changelogs/unreleased/9105-shubham-pampattiwar new file mode 100644 index 000000000..157fe7c6a --- /dev/null +++ b/changelogs/unreleased/9105-shubham-pampattiwar @@ -0,0 +1 @@ +Update "Default Volumes to Fs Backup" to "File System Backup (Default)" diff --git a/pkg/cmd/util/output/backup_describer.go b/pkg/cmd/util/output/backup_describer.go index 77d124dd6..332aac0f1 100644 --- a/pkg/cmd/util/output/backup_describer.go +++ b/pkg/cmd/util/output/backup_describer.go @@ -218,7 +218,7 @@ 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("File System Backup (Default):\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 { diff --git a/pkg/cmd/util/output/backup_describer_test.go b/pkg/cmd/util/output/backup_describer_test.go index f41887f2e..97723a2fd 100644 --- a/pkg/cmd/util/output/backup_describer_test.go +++ b/pkg/cmd/util/output/backup_describer_test.go @@ -303,7 +303,7 @@ Or label selector: Storage Location: backup-location Velero-Native Snapshot PVs: auto -Default Volumes to Fs Backup: true +File System Backup (Default): true Snapshot Move Data: auto Data Mover: velero @@ -336,7 +336,7 @@ Or label selector: Storage Location: backup-location Velero-Native Snapshot PVs: auto -Default Volumes to Fs Backup: false +File System Backup (Default): false Snapshot Move Data: auto Data Mover: velero diff --git a/pkg/cmd/util/output/schedule_describe_test.go b/pkg/cmd/util/output/schedule_describe_test.go index 2e26550e6..4d002619b 100644 --- a/pkg/cmd/util/output/schedule_describe_test.go +++ b/pkg/cmd/util/output/schedule_describe_test.go @@ -138,7 +138,7 @@ Backup Template: Storage Location: Velero-Native Snapshot PVs: auto - Default Volumes to Fs Backup: true + File System Backup (Default): true Snapshot Move Data: auto Data Mover: velero @@ -185,7 +185,7 @@ Backup Template: Storage Location: Velero-Native Snapshot PVs: auto - Default Volumes to Fs Backup: false + File System Backup (Default): false Snapshot Move Data: auto Data Mover: velero