diff --git a/pkg/controller/backup_queue_controller.go b/pkg/controller/backup_queue_controller.go index 723e324ee..5a99c6328 100644 --- a/pkg/controller/backup_queue_controller.go +++ b/pkg/controller/backup_queue_controller.go @@ -124,7 +124,7 @@ func (r *backupQueueReconciler) SetupWithManager(mgr ctrl.Manager) error { return oldBackup.Status.Phase == velerov1api.BackupPhaseInProgress && newBackup.Status.Phase != velerov1api.BackupPhaseInProgress || oldBackup.Status.Phase != velerov1api.BackupPhaseQueued && - newBackup.Status.Phase == velerov1api.BackupPhaseQueued + newBackup.Status.Phase == velerov1api.BackupPhaseQueued }, CreateFunc: func(event.CreateEvent) bool { return false diff --git a/pkg/controller/backup_queue_controller_test.go b/pkg/controller/backup_queue_controller_test.go index 73aecf8f2..ed85282d6 100644 --- a/pkg/controller/backup_queue_controller_test.go +++ b/pkg/controller/backup_queue_controller_test.go @@ -23,10 +23,12 @@ import ( "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + //metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + //"sigs.k8s.io/controller-runtime/pkg/client/fake" velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" @@ -60,7 +62,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectPhase: velerov1api.BackupPhaseInProgress, }, { - name: "Second New Backup gets queued with queuePosition 2", + name: "Second New Backup gets queued with queuePosition 2", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).Result(), }, @@ -74,7 +76,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectPhase: velerov1api.BackupPhaseReadyToStart, }, { - name: "Queued Backup remains queued if no spaces available", + name: "Queued Backup remains queued if no spaces available", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(), builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseInProgress).Result(), @@ -85,7 +87,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Queued Backup remains queued if no spaces available including ReadyToStart", + name: "Queued Backup remains queued if no spaces available including ReadyToStart", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(), builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseReadyToStart).Result(), @@ -96,7 +98,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Queued Backup remains queued if earlier runnable backup is also queued", + name: "Queued Backup remains queued if earlier runnable backup is also queued", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(), builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).Result(), @@ -107,7 +109,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 2, }, { - name: "Queued Backup remains queued if in conflict with running backup", + name: "Queued Backup remains queued if in conflict with running backup", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("foo").Result(), }, @@ -118,7 +120,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Queued Backup remains queued if in conflict with ReadyToStart backup", + name: "Queued Backup remains queued if in conflict with ReadyToStart backup", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseReadyToStart).IncludedNamespaces("foo").Result(), }, @@ -129,7 +131,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Queued Backup remains queued if in conflict with earlier queued backup", + name: "Queued Backup remains queued if in conflict with earlier queued backup", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).IncludedNamespaces("foo").Result(), }, @@ -140,7 +142,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 2, }, { - name: "Queued Backup remains queued if earlier non-ns-conflict backup exists", + name: "Queued Backup remains queued if earlier non-ns-conflict backup exists", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("bar").Result(), builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseQueued).QueuePosition(1).IncludedNamespaces("foo").Result(), @@ -152,7 +154,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 2, }, { - name: "Running all-namespace backup conflicts with queued one-namespace backup ", + name: "Running all-namespace backup conflicts with queued one-namespace backup ", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("*").Result(), }, @@ -163,7 +165,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Running one-namespace backup conflicts with queued all-namespace backup ", + name: "Running one-namespace backup conflicts with queued all-namespace backup ", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).IncludedNamespaces("bar").Result(), }, @@ -174,7 +176,7 @@ func TestBackupQueueReconciler(t *testing.T) { expectQueuePosition: 1, }, { - name: "Queued Backup moves to ReadyToStart if running count < concurrentBackups", + name: "Queued Backup moves to ReadyToStart if running count < concurrentBackups", priorBackups: []*velerov1api.Backup{ builder.ForBackup(velerov1api.DefaultNamespace, "backup-11").Phase(velerov1api.BackupPhaseInProgress).Result(), builder.ForBackup(velerov1api.DefaultNamespace, "backup-12").Phase(velerov1api.BackupPhaseInProgress).Result(),