Prevent throttle the reconciliation loop

This commit is contained in:
Tomasz Sęk
2019-12-19 13:06:11 +01:00
parent 99af93fe60
commit 76cd868cdd
@@ -3,7 +3,9 @@ package jenkins
import (
"context"
"fmt"
"math/rand"
"reflect"
"time"
"github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2"
jenkinsclient "github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/client"
@@ -187,6 +189,9 @@ func (r *ReconcileJenkins) Reconcile(request reconcile.Request) (reconcile.Resul
}
return reconcile.Result{Requeue: true}, nil
}
if result.Requeue && result.RequeueAfter == 0 {
result.RequeueAfter = time.Duration(rand.Intn(10)) * time.Millisecond
}
return result, nil
}