Fix [Basic][Snapshot] failure on AddintionalBSL case.

It failed with fetching the wrong VolumeInfo. Correct it.
Add AdditionalBSL label for applied cases.
Remove not needed default BSL kibishii test for additional bsl case.

Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
Xun Jiang
2025-08-06 22:14:02 +08:00
committed by Xun Jiang/Bruce Jiang
parent 6085044de2
commit ce09996854
4 changed files with 50 additions and 60 deletions

View File

@@ -26,6 +26,7 @@ import (
. "github.com/onsi/gomega"
. "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/kibishii"
. "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())
// Create additional BSL using credential
additionalBsl := "add-bsl"
Expect(VeleroCreateBackupLocation(context.TODO(),
veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace,
additionalBsl,
common.AdditionalBSLName,
veleroCfg.AdditionalBSLProvider,
veleroCfg.AdditionalBSLBucket,
veleroCfg.AdditionalBSLPrefix,
@@ -207,32 +207,25 @@ func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
secretKey,
)).To(Succeed())
BSLs := []string{"default", additionalBsl}
for _, bsl := range BSLs {
backupName = fmt.Sprintf("backup-%s", bsl)
restoreName = fmt.Sprintf("restore-%s", bsl)
// 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
// We can remove the logic once the issue is fixed
if bsl == "default" {
backupName = fmt.Sprintf("%s-%s", backupName, UUIDgen)
restoreName = fmt.Sprintf("%s-%s", restoreName, UUIDgen)
}
veleroCfg.ProvideSnapshotsVolumeParam = !provideSnapshotVolumesParmInBackup
workloadNS := kibishiiNamespace + bsl
Expect(
RunKibishiiTests(
veleroCfg,
backupName,
restoreName,
bsl,
workloadNS,
useVolumeSnapshots,
!useVolumeSnapshots,
),
).To(Succeed(),
"Failed to successfully backup and restore Kibishii namespace using BSL %s", bsl)
}
// 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
// We can remove the logic once the issue is fixed
backupName = "backup-" + common.AdditionalBSLName
restoreName = "restore-" + common.AdditionalBSLName
veleroCfg.ProvideSnapshotsVolumeParam = !provideSnapshotVolumesParmInBackup
workloadNS := kibishiiNamespace + common.AdditionalBSLName
Expect(
RunKibishiiTests(
veleroCfg,
backupName,
restoreName,
common.AdditionalBSLName,
workloadNS,
useVolumeSnapshots,
!useVolumeSnapshots,
),
).To(Succeed(),
"Failed to successfully backup and restore Kibishii namespace with additional BSL %s", common.AdditionalBSLName)
})
})
}

View File

@@ -398,25 +398,25 @@ var _ = Describe(
// Test backup and restore of Kibishii using restic
var _ = Describe(
"Velero tests on cluster using the plugin provider for object storage and Restic for volume backups",
Label("Basic", "Restic"),
Label("Basic", "Restic", "AdditionalBSL"),
BackupRestoreWithRestic,
)
var _ = Describe(
"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,
)
var _ = Describe(
"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,
)
var _ = Describe(
"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,
)
@@ -597,12 +597,12 @@ var _ = Describe(
var _ = Describe(
"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,
)
var _ = Describe(
"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,
)

View File

@@ -17,6 +17,11 @@ const (
WorkerOSWindows string = "windows"
)
const (
DefaultBSLName string = "default"
AdditionalBSLName string = "add-bsl"
)
type OsCommandLine struct {
Cmd 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("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(
veleroCfg.ObjectStoreProvider,
veleroCfg.CloudCredentialsFile,
veleroCfg.BSLBucket,
veleroCfg.BSLPrefix,
veleroCfg.BSLConfig,
objectStoreProvider,
cloudCredentialsFile,
bslBucket,
bslPrefix,
bslConfig,
backupName,
BackupObjectsPrefix+"/"+backupName,
)
@@ -187,27 +200,6 @@ func RunKibishiiTests(
if pvbNum != pvCount {
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