@@ -3,6 +3,8 @@ package dbinstance
33import (
44 "context"
55 "errors"
6+ "os"
7+ "strconv"
68 "time"
79
810 kciv1alpha1 "github.com/kloeckner-i/db-operator/pkg/apis/kci/v1alpha1"
@@ -28,7 +30,13 @@ func Add(mgr manager.Manager) error {
2830
2931// newReconciler returns a new reconcile.Reconciler
3032func newReconciler (mgr manager.Manager ) reconcile.Reconciler {
31- return & ReconcileDbInstance {client : mgr .GetClient (), scheme : mgr .GetScheme ()}
33+ interval := os .Getenv ("RECONCILE_INTERVAL" )
34+ i , err := strconv .ParseInt (interval , 10 , 64 )
35+ if err != nil {
36+ i = 60
37+ logrus .Infof ("Set default reconcile period to %d s for dbinstance-controller" , i )
38+ }
39+ return & ReconcileDbInstance {client : mgr .GetClient (), scheme : mgr .GetScheme (), interval : time .Duration (i )}
3240}
3341
3442// add adds a new Controller to mgr with r as the reconcile.Reconciler
@@ -55,8 +63,9 @@ var _ reconcile.Reconciler = &ReconcileDbInstance{}
5563type ReconcileDbInstance struct {
5664 // This client, initialized using mgr.Client() above, is a split client
5765 // that reads objects from the cache and writes to the apiserver
58- client client.Client
59- scheme * runtime.Scheme
66+ client client.Client
67+ scheme * runtime.Scheme
68+ interval time.Duration
6069}
6170
6271var (
7584func (r * ReconcileDbInstance ) Reconcile (request reconcile.Request ) (reconcile.Result , error ) {
7685 // reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
7786 // reqLogger.Info("Reconciling DbInstance")
78- reconcilePeriod := 60 * time .Second
87+ reconcilePeriod := r . interval * time .Second
7988 reconcileResult := reconcile.Result {RequeueAfter : reconcilePeriod }
8089
8190 ctx := context .TODO ()
0 commit comments