Skip to content

Commit

Permalink
minor fixes for backup_operations_controller:
Browse files Browse the repository at this point in the history
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 <sseago@redhat.com>
  • Loading branch information
sseago committed Mar 20, 2023
1 parent 81bee24 commit e500e2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5996-sseago
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
minor fixes for backup_operations_controller
12 changes: 8 additions & 4 deletions pkg/controller/backup_operations_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
)

const (
defaultBackupOperationsFrequency = 2 * time.Minute
defaultBackupOperationsFrequency = 10 * time.Second
)

type backupOperationsReconciler struct {
Expand Down Expand Up @@ -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)
}

Expand All @@ -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 {
Expand Down

0 comments on commit e500e2d

Please sign in to comment.