mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 14:34:17 +00:00
rename pvbr param (#5370)
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -86,7 +86,7 @@ type backupController struct {
|
||||
newPluginManager func(logrus.FieldLogger) clientmgmt.Manager
|
||||
backupTracker BackupTracker
|
||||
defaultBackupLocation string
|
||||
defaultVolumesToRestic bool
|
||||
defaultVolumesToFsBackup bool
|
||||
defaultBackupTTL time.Duration
|
||||
defaultCSISnapshotTimeout time.Duration
|
||||
snapshotLocationLister velerov1listers.VolumeSnapshotLocationLister
|
||||
@@ -112,7 +112,7 @@ func NewBackupController(
|
||||
backupTracker BackupTracker,
|
||||
kbClient kbclient.Client,
|
||||
defaultBackupLocation string,
|
||||
defaultVolumesToRestic bool,
|
||||
defaultVolumesToFsBackup bool,
|
||||
defaultBackupTTL time.Duration,
|
||||
defaultCSISnapshotTimeout time.Duration,
|
||||
volumeSnapshotLocationLister velerov1listers.VolumeSnapshotLocationLister,
|
||||
@@ -138,7 +138,7 @@ func NewBackupController(
|
||||
backupTracker: backupTracker,
|
||||
kbClient: kbClient,
|
||||
defaultBackupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: defaultVolumesToRestic,
|
||||
defaultVolumesToFsBackup: defaultVolumesToFsBackup,
|
||||
defaultBackupTTL: defaultBackupTTL,
|
||||
defaultCSISnapshotTimeout: defaultCSISnapshotTimeout,
|
||||
snapshotLocationLister: volumeSnapshotLocationLister,
|
||||
@@ -263,7 +263,7 @@ func (c *backupController) processBackup(key string) error {
|
||||
}
|
||||
|
||||
log.Debug("Preparing backup request")
|
||||
request := c.prepareBackupRequest(original)
|
||||
request := c.prepareBackupRequest(original, log)
|
||||
if len(request.Status.ValidationErrors) > 0 {
|
||||
request.Status.Phase = velerov1api.BackupPhaseFailedValidation
|
||||
} else {
|
||||
@@ -349,7 +349,7 @@ func patchBackup(original, updated *velerov1api.Backup, client velerov1client.Ba
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkgbackup.Request {
|
||||
func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup, logger logrus.FieldLogger) *pkgbackup.Request {
|
||||
request := &pkgbackup.Request{
|
||||
Backup: backup.DeepCopy(), // don't modify items in the cache
|
||||
}
|
||||
@@ -373,8 +373,15 @@ func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkg
|
||||
// calculate expiration
|
||||
request.Status.Expiration = &metav1.Time{Time: c.clock.Now().Add(request.Spec.TTL.Duration)}
|
||||
|
||||
if request.Spec.DefaultVolumesToRestic == nil {
|
||||
request.Spec.DefaultVolumesToRestic = &c.defaultVolumesToRestic
|
||||
// TODO: post v1.10. Remove this code block after DefaultVolumesToRestic is removed from CRD
|
||||
// For now, for CRs created by old versions, we need to respect the DefaultVolumesToRestic value if it is set true
|
||||
if boolptr.IsSetToTrue(request.Spec.DefaultVolumesToRestic) {
|
||||
logger.Warn("DefaultVolumesToRestic field will be deprecated, use DefaultVolumesToFsBackup instead. Automatically remap it to DefaultVolumesToFsBackup")
|
||||
request.Spec.DefaultVolumesToFsBackup = request.Spec.DefaultVolumesToRestic
|
||||
}
|
||||
|
||||
if request.Spec.DefaultVolumesToFsBackup == nil {
|
||||
request.Spec.DefaultVolumesToFsBackup = &c.defaultVolumesToFsBackup
|
||||
}
|
||||
|
||||
// find which storage location to use
|
||||
|
||||
@@ -280,7 +280,7 @@ func TestBackupLocationLabel(t *testing.T) {
|
||||
formatFlag: formatFlag,
|
||||
}
|
||||
|
||||
res := c.prepareBackupRequest(test.backup)
|
||||
res := c.prepareBackupRequest(test.backup, logger)
|
||||
assert.NotNil(t, res)
|
||||
assert.Equal(t, test.expectedBackupLocation, res.Labels[velerov1api.StorageLocationLabel])
|
||||
})
|
||||
@@ -342,7 +342,7 @@ func TestDefaultBackupTTL(t *testing.T) {
|
||||
formatFlag: formatFlag,
|
||||
}
|
||||
|
||||
res := c.prepareBackupRequest(test.backup)
|
||||
res := c.prepareBackupRequest(test.backup, logger)
|
||||
assert.NotNil(t, res)
|
||||
assert.Equal(t, test.expectedTTL, res.Spec.TTL)
|
||||
assert.Equal(t, test.expectedExpiration, *res.Status.Expiration)
|
||||
@@ -350,6 +350,121 @@ func TestDefaultBackupTTL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultVolumesToResticDeprecation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
backup *velerov1api.Backup
|
||||
globalVal bool
|
||||
expectGlobal bool
|
||||
expectRemap bool
|
||||
expectVal bool
|
||||
}{
|
||||
{
|
||||
name: "DefaultVolumesToRestic is not set, DefaultVolumesToFsBackup is not set",
|
||||
backup: defaultBackup().Result(),
|
||||
globalVal: true,
|
||||
expectGlobal: true,
|
||||
expectVal: true,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is not set, DefaultVolumesToFsBackup is set to false",
|
||||
backup: defaultBackup().DefaultVolumesToFsBackup(false).Result(),
|
||||
globalVal: true,
|
||||
expectVal: false,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is not set, DefaultVolumesToFsBackup is set to true",
|
||||
backup: defaultBackup().DefaultVolumesToFsBackup(true).Result(),
|
||||
globalVal: false,
|
||||
expectVal: true,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to false, DefaultVolumesToFsBackup is not set",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(false).Result(),
|
||||
globalVal: false,
|
||||
expectGlobal: true,
|
||||
expectVal: false,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to false, DefaultVolumesToFsBackup is set to true",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(false).DefaultVolumesToFsBackup(true).Result(),
|
||||
globalVal: false,
|
||||
expectVal: true,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to false, DefaultVolumesToFsBackup is set to false",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(false).DefaultVolumesToFsBackup(false).Result(),
|
||||
globalVal: true,
|
||||
expectVal: false,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to true, DefaultVolumesToFsBackup is not set",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(true).Result(),
|
||||
globalVal: false,
|
||||
expectRemap: true,
|
||||
expectVal: true,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to true, DefaultVolumesToFsBackup is set to false",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(true).DefaultVolumesToFsBackup(false).Result(),
|
||||
globalVal: false,
|
||||
expectRemap: true,
|
||||
expectVal: true,
|
||||
},
|
||||
{
|
||||
name: "DefaultVolumesToRestic is set to true, DefaultVolumesToFsBackup is set to true",
|
||||
backup: defaultBackup().DefaultVolumesToRestic(true).DefaultVolumesToFsBackup(true).Result(),
|
||||
globalVal: false,
|
||||
expectRemap: true,
|
||||
expectVal: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
formatFlag := logging.FormatText
|
||||
|
||||
var (
|
||||
clientset = fake.NewSimpleClientset(test.backup)
|
||||
sharedInformers = informers.NewSharedInformerFactory(clientset, 0)
|
||||
logger = logging.DefaultLogger(logrus.DebugLevel, formatFlag)
|
||||
fakeClient = velerotest.NewFakeControllerRuntimeClient(t)
|
||||
)
|
||||
|
||||
apiServer := velerotest.NewAPIServer(t)
|
||||
discoveryHelper, err := discovery.NewHelper(apiServer.DiscoveryClient, logger)
|
||||
require.NoError(t, err)
|
||||
|
||||
c := &backupController{
|
||||
genericController: newGenericController("backup-test", logger),
|
||||
discoveryHelper: discoveryHelper,
|
||||
client: clientset.VeleroV1(),
|
||||
lister: sharedInformers.Velero().V1().Backups().Lister(),
|
||||
kbClient: fakeClient,
|
||||
snapshotLocationLister: sharedInformers.Velero().V1().VolumeSnapshotLocations().Lister(),
|
||||
clock: &clock.RealClock{},
|
||||
formatFlag: formatFlag,
|
||||
defaultVolumesToFsBackup: test.globalVal,
|
||||
}
|
||||
|
||||
res := c.prepareBackupRequest(test.backup, logger)
|
||||
assert.NotNil(t, res)
|
||||
assert.NotNil(t, res.Spec.DefaultVolumesToFsBackup)
|
||||
if test.expectRemap {
|
||||
assert.Equal(t, res.Spec.DefaultVolumesToRestic, res.Spec.DefaultVolumesToFsBackup)
|
||||
} else if test.expectGlobal {
|
||||
assert.False(t, res.Spec.DefaultVolumesToRestic == res.Spec.DefaultVolumesToFsBackup)
|
||||
assert.Equal(t, &c.defaultVolumesToFsBackup, res.Spec.DefaultVolumesToFsBackup)
|
||||
} else {
|
||||
assert.False(t, res.Spec.DefaultVolumesToRestic == res.Spec.DefaultVolumesToFsBackup)
|
||||
assert.False(t, &c.defaultVolumesToFsBackup == res.Spec.DefaultVolumesToFsBackup)
|
||||
}
|
||||
|
||||
assert.Equal(t, test.expectVal, *res.Spec.DefaultVolumesToFsBackup)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessBackupCompletions(t *testing.T) {
|
||||
defaultBackupLocation := builder.ForBackupStorageLocation("velero", "loc-1").Default(true).Bucket("store-1").Result()
|
||||
|
||||
@@ -359,20 +474,20 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
timestamp := metav1.NewTime(now)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
backup *velerov1api.Backup
|
||||
backupLocation *velerov1api.BackupStorageLocation
|
||||
defaultVolumesToRestic bool
|
||||
expectedResult *velerov1api.Backup
|
||||
backupExists bool
|
||||
existenceCheckError error
|
||||
name string
|
||||
backup *velerov1api.Backup
|
||||
backupLocation *velerov1api.BackupStorageLocation
|
||||
defaultVolumesToFsBackup bool
|
||||
expectedResult *velerov1api.Backup
|
||||
backupExists bool
|
||||
existenceCheckError error
|
||||
}{
|
||||
// Completed
|
||||
{
|
||||
name: "backup with no backup location gets the default",
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: true,
|
||||
name: "backup with no backup location gets the default",
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -391,8 +506,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -405,10 +520,10 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup with a specific backup location keeps it",
|
||||
backup: defaultBackup().StorageLocation("alt-loc").Result(),
|
||||
backupLocation: builder.ForBackupStorageLocation("velero", "alt-loc").Bucket("store-1").Result(),
|
||||
defaultVolumesToRestic: false,
|
||||
name: "backup with a specific backup location keeps it",
|
||||
backup: defaultBackup().StorageLocation("alt-loc").Result(),
|
||||
backupLocation: builder.ForBackupStorageLocation("velero", "alt-loc").Bucket("store-1").Result(),
|
||||
defaultVolumesToFsBackup: false,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -427,8 +542,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: "alt-loc",
|
||||
DefaultVolumesToRestic: boolptr.False(),
|
||||
StorageLocation: "alt-loc",
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -447,7 +562,7 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
Bucket("store-1").
|
||||
AccessMode(velerov1api.BackupStorageLocationAccessModeReadWrite).
|
||||
Result(),
|
||||
defaultVolumesToRestic: true,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -466,8 +581,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: "read-write",
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: "read-write",
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -480,10 +595,10 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup with a TTL has expiration set",
|
||||
backup: defaultBackup().TTL(10 * time.Minute).Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: false,
|
||||
name: "backup with a TTL has expiration set",
|
||||
backup: defaultBackup().TTL(10 * time.Minute).Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToFsBackup: false,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -502,9 +617,9 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
TTL: metav1.Duration{Duration: 10 * time.Minute},
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.False(),
|
||||
TTL: metav1.Duration{Duration: 10 * time.Minute},
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -517,11 +632,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup without an existing backup will succeed",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: true,
|
||||
name: "backup without an existing backup will succeed",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -540,8 +655,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -554,12 +669,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup specifying a false value for 'DefaultVolumesToRestic' keeps it",
|
||||
name: "backup specifying a false value for 'DefaultVolumesToFsBackup' keeps it",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().DefaultVolumesToRestic(false).Result(),
|
||||
backup: defaultBackup().DefaultVolumesToFsBackup(false).Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
// value set in the controller is different from that specified in the backup
|
||||
defaultVolumesToRestic: true,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -578,8 +693,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.False(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -592,12 +707,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup specifying a true value for 'DefaultVolumesToRestic' keeps it",
|
||||
name: "backup specifying a true value for 'DefaultVolumesToFsBackup' keeps it",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().DefaultVolumesToRestic(true).Result(),
|
||||
backup: defaultBackup().DefaultVolumesToFsBackup(true).Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
// value set in the controller is different from that specified in the backup
|
||||
defaultVolumesToRestic: false,
|
||||
defaultVolumesToFsBackup: false,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -616,8 +731,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -630,12 +745,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup specifying no value for 'DefaultVolumesToRestic' gets the default true value",
|
||||
name: "backup specifying no value for 'DefaultVolumesToFsBackup' gets the default true value",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
// value set in the controller is different from that specified in the backup
|
||||
defaultVolumesToRestic: true,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -654,8 +769,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -668,12 +783,12 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "backup specifying no value for 'DefaultVolumesToRestic' gets the default false value",
|
||||
name: "backup specifying no value for 'DefaultVolumesToFsBackup' gets the default false value",
|
||||
backupExists: false,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
// value set in the controller is different from that specified in the backup
|
||||
defaultVolumesToRestic: false,
|
||||
defaultVolumesToFsBackup: false,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -692,8 +807,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.False(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
@@ -708,11 +823,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
|
||||
// Failed
|
||||
{
|
||||
name: "backup with existing backup will fail",
|
||||
backupExists: true,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: true,
|
||||
name: "backup with existing backup will fail",
|
||||
backupExists: true,
|
||||
backup: defaultBackup().Result(),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -731,8 +846,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseFailed,
|
||||
@@ -746,11 +861,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "error when checking if backup exists will cause backup to fail",
|
||||
backup: defaultBackup().Result(),
|
||||
existenceCheckError: errors.New("Backup already exists in object storage"),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToRestic: true,
|
||||
name: "error when checking if backup exists will cause backup to fail",
|
||||
backup: defaultBackup().Result(),
|
||||
existenceCheckError: errors.New("Backup already exists in object storage"),
|
||||
backupLocation: defaultBackupLocation,
|
||||
defaultVolumesToFsBackup: true,
|
||||
expectedResult: &velerov1api.Backup{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Backup",
|
||||
@@ -769,8 +884,8 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: velerov1api.BackupSpec{
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToRestic: boolptr.True(),
|
||||
StorageLocation: defaultBackupLocation.Name,
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseFailed,
|
||||
@@ -823,21 +938,21 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
c := &backupController{
|
||||
genericController: newGenericController("backup-test", logger),
|
||||
discoveryHelper: discoveryHelper,
|
||||
client: clientset.VeleroV1(),
|
||||
lister: sharedInformers.Velero().V1().Backups().Lister(),
|
||||
kbClient: fakeClient,
|
||||
snapshotLocationLister: sharedInformers.Velero().V1().VolumeSnapshotLocations().Lister(),
|
||||
defaultBackupLocation: defaultBackupLocation.Name,
|
||||
defaultVolumesToRestic: test.defaultVolumesToRestic,
|
||||
backupTracker: NewBackupTracker(),
|
||||
metrics: metrics.NewServerMetrics(),
|
||||
clock: clock.NewFakeClock(now),
|
||||
newPluginManager: func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
|
||||
backupStoreGetter: NewFakeSingleObjectBackupStoreGetter(backupStore),
|
||||
backupper: backupper,
|
||||
formatFlag: formatFlag,
|
||||
genericController: newGenericController("backup-test", logger),
|
||||
discoveryHelper: discoveryHelper,
|
||||
client: clientset.VeleroV1(),
|
||||
lister: sharedInformers.Velero().V1().Backups().Lister(),
|
||||
kbClient: fakeClient,
|
||||
snapshotLocationLister: sharedInformers.Velero().V1().VolumeSnapshotLocations().Lister(),
|
||||
defaultBackupLocation: defaultBackupLocation.Name,
|
||||
defaultVolumesToFsBackup: test.defaultVolumesToFsBackup,
|
||||
backupTracker: NewBackupTracker(),
|
||||
metrics: metrics.NewServerMetrics(),
|
||||
clock: clock.NewFakeClock(now),
|
||||
newPluginManager: func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
|
||||
backupStoreGetter: NewFakeSingleObjectBackupStoreGetter(backupStore),
|
||||
backupper: backupper,
|
||||
formatFlag: formatFlag,
|
||||
}
|
||||
|
||||
pluginManager.On("GetBackupItemActions").Return(nil, nil)
|
||||
|
||||
Reference in New Issue
Block a user