Merge branch 'main' into issue-#9029

This commit is contained in:
Priyansh Choudhary
2025-08-11 13:43:58 +05:30
committed by GitHub
4 changed files with 50 additions and 60 deletions

View File

@@ -26,6 +26,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
. "github.com/vmware-tanzu/velero/test" . "github.com/vmware-tanzu/velero/test"
"github.com/vmware-tanzu/velero/test/util/common"
. "github.com/vmware-tanzu/velero/test/util/k8s" . "github.com/vmware-tanzu/velero/test/util/k8s"
. "github.com/vmware-tanzu/velero/test/util/kibishii" . "github.com/vmware-tanzu/velero/test/util/kibishii"
. "github.com/vmware-tanzu/velero/test/util/velero" . "github.com/vmware-tanzu/velero/test/util/velero"
@@ -194,11 +195,10 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
Expect(CreateSecretFromFiles(context.TODO(), *veleroCfg.ClientToInstallVelero, veleroCfg.VeleroNamespace, secretName, files)).To(Succeed()) Expect(CreateSecretFromFiles(context.TODO(), *veleroCfg.ClientToInstallVelero, veleroCfg.VeleroNamespace, secretName, files)).To(Succeed())
// Create additional BSL using credential // Create additional BSL using credential
additionalBsl := "add-bsl"
Expect(VeleroCreateBackupLocation(context.TODO(), Expect(VeleroCreateBackupLocation(context.TODO(),
veleroCfg.VeleroCLI, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace, veleroCfg.VeleroNamespace,
additionalBsl, common.AdditionalBSLName,
veleroCfg.AdditionalBSLProvider, veleroCfg.AdditionalBSLProvider,
veleroCfg.AdditionalBSLBucket, veleroCfg.AdditionalBSLBucket,
veleroCfg.AdditionalBSLPrefix, veleroCfg.AdditionalBSLPrefix,
@@ -207,32 +207,25 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
secretKey, secretKey,
)).To(Succeed()) )).To(Succeed())
BSLs := []string{"default", additionalBsl} // We limit the length of backup name here to avoid the issue of vsphere plugin
// https://github.com/vmware-tanzu/velero-plugin-for-vsphere/issues/370
for _, bsl := range BSLs { // We can remove the logic once the issue is fixed
backupName = fmt.Sprintf("backup-%s", bsl) backupName = "backup-" + common.AdditionalBSLName
restoreName = fmt.Sprintf("restore-%s", bsl) restoreName = "restore-" + common.AdditionalBSLName
// We limit the length of backup name here to avoid the issue of vsphere plugin https://github.com/vmware-tanzu/velero-plugin-for-vsphere/issues/370 veleroCfg.ProvideSnapshotsVolumeParam = !provideSnapshotVolumesParmInBackup
// We can remove the logic once the issue is fixed workloadNS := kibishiiNamespace + common.AdditionalBSLName
if bsl == "default" { Expect(
backupName = fmt.Sprintf("%s-%s", backupName, UUIDgen) RunKibishiiTests(
restoreName = fmt.Sprintf("%s-%s", restoreName, UUIDgen) veleroCfg,
} backupName,
veleroCfg.ProvideSnapshotsVolumeParam = !provideSnapshotVolumesParmInBackup restoreName,
workloadNS := kibishiiNamespace + bsl common.AdditionalBSLName,
Expect( workloadNS,
RunKibishiiTests( useVolumeSnapshots,
veleroCfg, !useVolumeSnapshots,
backupName, ),
restoreName, ).To(Succeed(),
bsl, "Failed to successfully backup and restore Kibishii namespace with additional BSL %s", common.AdditionalBSLName)
workloadNS,
useVolumeSnapshots,
!useVolumeSnapshots,
),
).To(Succeed(),
"Failed to successfully backup and restore Kibishii namespace using BSL %s", bsl)
}
}) })
}) })
} }

View File

@@ -398,25 +398,25 @@ var _ = Describe(
// Test backup and restore of Kibishii using restic // Test backup and restore of Kibishii using restic
var _ = Describe( var _ = Describe(
"Velero tests on cluster using the plugin provider for object storage and Restic for volume backups", "Velero tests on cluster using the plugin provider for object storage and Restic for volume backups",
Label("Basic", "Restic"), Label("Basic", "Restic", "AdditionalBSL"),
BackupRestoreWithRestic, BackupRestoreWithRestic,
) )
var _ = Describe( var _ = Describe(
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups", "Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Snapshot", "SkipVanillaZfs"), Label("Basic", "Snapshot", "SkipVanillaZfs", "AdditionalBSL"),
BackupRestoreWithSnapshots, BackupRestoreWithSnapshots,
) )
var _ = Describe( var _ = Describe(
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups", "Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Snapshot", "RetainPV"), Label("Basic", "Snapshot", "RetainPV", "AdditionalBSL"),
BackupRestoreRetainedPVWithSnapshots, BackupRestoreRetainedPVWithSnapshots,
) )
var _ = Describe( var _ = Describe(
"Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups", "Velero tests on cluster using the plugin provider for object storage and snapshots for volume backups",
Label("Basic", "Restic", "RetainPV"), Label("Basic", "Restic", "RetainPV", "AdditionalBSL"),
BackupRestoreRetainedPVWithRestic, BackupRestoreRetainedPVWithRestic,
) )
@@ -597,12 +597,12 @@ var _ = Describe(
var _ = Describe( var _ = Describe(
"Local backups will be deleted once the corresponding backup storage location is deleted", "Local backups will be deleted once the corresponding backup storage location is deleted",
Label("BSL", "Deletion", "Snapshot", "SkipVanillaZfs"), Label("BSL", "Deletion", "Snapshot", "SkipVanillaZfs", "AdditionalBSL"),
BslDeletionWithSnapshots, BslDeletionWithSnapshots,
) )
var _ = Describe( var _ = Describe(
"Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted", "Local backups and Restic repos will be deleted once the corresponding backup storage location is deleted",
Label("BSL", "Deletion", "Restic"), Label("BSL", "Deletion", "Restic", "AdditionalBSL"),
BslDeletionWithRestic, BslDeletionWithRestic,
) )

View File

@@ -17,6 +17,11 @@ const (
WorkerOSWindows string = "windows" WorkerOSWindows string = "windows"
) )
const (
DefaultBSLName string = "default"
AdditionalBSLName string = "add-bsl"
)
type OsCommandLine struct { type OsCommandLine struct {
Cmd string Cmd string
Args []string Args []string

View File

@@ -142,12 +142,25 @@ func RunKibishiiTests(
fmt.Printf("VeleroBackupNamespace done %s\n", time.Now().Format("2006-01-02 15:04:05")) fmt.Printf("VeleroBackupNamespace done %s\n", time.Now().Format("2006-01-02 15:04:05"))
fmt.Printf("KibishiiVerifyAfterBackup %s\n", time.Now().Format("2006-01-02 15:04:05")) fmt.Printf("KibishiiVerifyAfterBackup %s\n", time.Now().Format("2006-01-02 15:04:05"))
objectStoreProvider := veleroCfg.ObjectStoreProvider
cloudCredentialsFile := veleroCfg.CloudCredentialsFile
bslBucket := veleroCfg.BSLBucket
bslPrefix := veleroCfg.BSLPrefix
bslConfig := veleroCfg.BSLConfig
if backupLocation == common.AdditionalBSLName {
objectStoreProvider = veleroCfg.AdditionalBSLProvider
cloudCredentialsFile = veleroCfg.AdditionalBSLCredentials
bslBucket = veleroCfg.AdditionalBSLBucket
bslPrefix = veleroCfg.AdditionalBSLPrefix
bslConfig = veleroCfg.AdditionalBSLConfig
}
backupVolumeInfo, err := GetVolumeInfo( backupVolumeInfo, err := GetVolumeInfo(
veleroCfg.ObjectStoreProvider, objectStoreProvider,
veleroCfg.CloudCredentialsFile, cloudCredentialsFile,
veleroCfg.BSLBucket, bslBucket,
veleroCfg.BSLPrefix, bslPrefix,
veleroCfg.BSLConfig, bslConfig,
backupName, backupName,
BackupObjectsPrefix+"/"+backupName, BackupObjectsPrefix+"/"+backupName,
) )
@@ -187,27 +200,6 @@ func RunKibishiiTests(
if pvbNum != pvCount { if pvbNum != pvCount {
return errors.New(fmt.Sprintf("PVB count %d should be %d in namespace %s", pvbNum, pvCount, kibishiiNamespace)) return errors.New(fmt.Sprintf("PVB count %d should be %d in namespace %s", pvbNum, pvCount, kibishiiNamespace))
} }
if providerName != Vsphere {
// wait for a period to confirm no snapshots content exist for the backup
time.Sleep(1 * time.Minute)
if strings.EqualFold(veleroFeatures, FeatureCSI) {
_, err = BuildSnapshotCheckPointFromVolumeInfo(veleroCfg, backupVolumeInfo, 0,
kibishiiNamespace, backupName, KibishiiPVCNameList)
if err != nil {
return errors.Wrap(err, "failed to get snapshot checkPoint")
}
} else {
err = CheckSnapshotsInProvider(
veleroCfg,
backupName,
SnapshotCheckPoint{},
false,
)
if err != nil {
return errors.Wrap(err, "exceed waiting for snapshot created in cloud")
}
}
}
} }
// Modify PV data right after backup. If PV's reclaim policy is retain, PV will be restored with the origin resource config // Modify PV data right after backup. If PV's reclaim policy is retain, PV will be restored with the origin resource config