Add support for configuring VGS label key (#8938)
Some checks failed
Run the E2E test on kind / build (push) Failing after 6m38s
Run the E2E test on kind / setup-test-matrix (push) Successful in 2s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 31s
Close stale issues and PRs / stale (push) Successful in 10s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m17s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m40s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 49s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 45s

add changelog file

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
Shubham Pampattiwar
2025-05-30 08:03:47 -07:00
committed by GitHub
parent 681a874298
commit d2c6b6bc3e
10 changed files with 98 additions and 2 deletions

View File

@@ -479,6 +479,69 @@ func TestDefaultBackupTTL(t *testing.T) {
}
}
func TestPrepareBackupRequest_SetsVGSLabelKey(t *testing.T) {
now, err := time.Parse(time.RFC1123Z, time.RFC1123Z)
require.NoError(t, err)
now = now.Local()
defaultVGSLabelKey := "velero.io/volume-group-snapshot"
tests := []struct {
name string
backup *velerov1api.Backup
serverFlagKey string
expectedLabelKey string
}{
{
name: "backup with spec label key set",
backup: builder.ForBackup("velero", "backup-1").
VolumeGroupSnapshotLabelKey("spec-key").
Result(),
serverFlagKey: "server-key",
expectedLabelKey: "spec-key",
},
{
name: "backup with no spec key, uses server flag",
backup: builder.ForBackup("velero", "backup-2").Result(),
serverFlagKey: "server-key",
expectedLabelKey: "server-key",
},
{
name: "backup with no spec or server flag, uses default",
backup: builder.ForBackup("velero", "backup-3").Result(),
serverFlagKey: defaultVGSLabelKey,
expectedLabelKey: defaultVGSLabelKey,
},
}
for _, test := range tests {
formatFlag := logging.FormatText
logger := logging.DefaultLogger(logrus.DebugLevel, formatFlag)
t.Run(test.name, func(t *testing.T) {
fakeClient := velerotest.NewFakeControllerRuntimeClient(t, test.backup)
apiServer := velerotest.NewAPIServer(t)
discoveryHelper, err := discovery.NewHelper(apiServer.DiscoveryClient, logger)
require.NoError(t, err)
c := &backupReconciler{
logger: logger,
kbClient: fakeClient,
defaultVGSLabelKey: test.serverFlagKey,
discoveryHelper: discoveryHelper,
clock: testclocks.NewFakeClock(now),
workerPool: pkgbackup.StartItemBlockWorkerPool(context.Background(), 1, logger),
}
defer c.workerPool.Stop()
res := c.prepareBackupRequest(test.backup, logger)
assert.NotNil(t, res)
assert.Equal(t, test.expectedLabelKey, res.Spec.VolumeGroupSnapshotLabelKey)
})
}
}
func TestDefaultVolumesToResticDeprecation(t *testing.T) {
tests := []struct {
name string