From e500e2d8e5ccae2c011739a3e39afc3e82dd0bfd Mon Sep 17 00:00:00 2001 From: Scott Seago Date: Sat, 18 Mar 2023 13:55:12 -0400 Subject: [PATCH] minor fixes for backup_operations_controller: 1) default frequency 10s 2) per-reconcile log is now Debug not info 3) added predicate to reduce reconcile events Signed-off-by: Scott Seago --- changelogs/unreleased/5996-sseago | 1 + pkg/controller/backup_operations_controller.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/5996-sseago diff --git a/changelogs/unreleased/5996-sseago b/changelogs/unreleased/5996-sseago new file mode 100644 index 0000000000..7d5bb150bf --- /dev/null +++ b/changelogs/unreleased/5996-sseago @@ -0,0 +1 @@ +minor fixes for backup_operations_controller diff --git a/pkg/controller/backup_operations_controller.go b/pkg/controller/backup_operations_controller.go index cae7c80d53..50beb095c7 100644 --- a/pkg/controller/backup_operations_controller.go +++ b/pkg/controller/backup_operations_controller.go @@ -41,7 +41,7 @@ import ( ) const ( - defaultBackupOperationsFrequency = 2 * time.Minute + defaultBackupOperationsFrequency = 10 * time.Second ) type backupOperationsReconciler struct { @@ -82,9 +82,14 @@ func NewBackupOperationsReconciler( func (c *backupOperationsReconciler) SetupWithManager(mgr ctrl.Manager) error { s := kube.NewPeriodicalEnqueueSource(c.logger, mgr.GetClient(), &velerov1api.BackupList{}, c.frequency, kube.PeriodicalEnqueueSourceOption{}) + gp := kube.NewGenericEventPredicate(func(object client.Object) bool { + backup := object.(*velerov1api.Backup) + return (backup.Status.Phase == velerov1api.BackupPhaseWaitingForPluginOperations || + backup.Status.Phase == velerov1api.BackupPhaseWaitingForPluginOperationsPartiallyFailed) + }) return ctrl.NewControllerManagedBy(mgr). For(&velerov1api.Backup{}, builder.WithPredicates(kube.FalsePredicate{})). - Watches(s, nil). + Watches(s, nil, builder.WithPredicates(gp)). Complete(c) } @@ -94,8 +99,7 @@ func (c *backupOperationsReconciler) SetupWithManager(mgr ctrl.Manager) error { func (c *backupOperationsReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := c.logger.WithField("backup operations for backup", req.String()) - // FIXME: make this log.Debug - log.Info("backupOperationsReconciler getting backup") + log.Debug("backupOperationsReconciler getting backup") original := &velerov1api.Backup{} if err := c.Get(ctx, req.NamespacedName, original); err != nil {