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 <sseago@redhat.com>
This commit is contained in:
Scott Seago
2023-03-18 13:55:12 -04:00
parent 81bee240fe
commit e500e2d8e5
2 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1 @@
minor fixes for backup_operations_controller

View File

@@ -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 {