Browse Source

feat: rely on controller backoff/retry instead of static requeue (#2100)

* feat: rely on controller backoff/retry instead of static requeue
interval

Fixes #2088

more context in: https://github.com/external-secrets/external-secrets/pull/934

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>

* fix: respect refreshInterval on delete/retain

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>

---------

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Moritz Johner 3 years ago
parent
commit
9edc957aef
1 changed files with 4 additions and 5 deletions
  1. 4 5
      pkg/controllers/externalsecret/externalsecret_controller.go

+ 4 - 5
pkg/controllers/externalsecret/externalsecret_controller.go

@@ -46,7 +46,6 @@ import (
 )
 
 const (
-	requeueAfter            = time.Second * 30
 	fieldOwnerTemplate      = "externalsecrets.external-secrets.io/%v"
 	errGetES                = "could not get ExternalSecret"
 	errConvert              = "could not apply conversion strategy to keys: %v"
@@ -192,7 +191,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 		conditionSynced := NewExternalSecretCondition(esv1beta1.ExternalSecretReady, v1.ConditionFalse, esv1beta1.ConditionReasonSecretSyncedError, errGetSecretData)
 		SetExternalSecretCondition(&externalSecret, *conditionSynced)
 		syncCallsError.With(resourceLabels).Inc()
-		return ctrl.Result{RequeueAfter: requeueAfter}, nil
+		return ctrl.Result{}, err
 	}
 
 	// if no data was found we can delete the secret if needed.
@@ -209,7 +208,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 				conditionSynced := NewExternalSecretCondition(esv1beta1.ExternalSecretReady, v1.ConditionFalse, esv1beta1.ConditionReasonSecretSyncedError, errDeleteSecret)
 				SetExternalSecretCondition(&externalSecret, *conditionSynced)
 				syncCallsError.With(resourceLabels).Inc()
-				return ctrl.Result{RequeueAfter: requeueAfter}, nil
+				return ctrl.Result{}, err
 			}
 			err = r.Delete(ctx, secret)
 			if err != nil && !apierrors.IsNotFound(err) {
@@ -222,14 +221,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
 
 			conditionSynced := NewExternalSecretCondition(esv1beta1.ExternalSecretReady, v1.ConditionTrue, esv1beta1.ConditionReasonSecretDeleted, "secret deleted due to DeletionPolicy")
 			SetExternalSecretCondition(&externalSecret, *conditionSynced)
-			return ctrl.Result{RequeueAfter: requeueAfter}, nil
+			return ctrl.Result{RequeueAfter: refreshInt}, err
 
 		case esv1beta1.DeletionPolicyMerge:
 			// noop, handled below
 
 		// In case provider secrets don't exist the kubernetes secret will be kept as-is.
 		case esv1beta1.DeletionPolicyRetain:
-			return ctrl.Result{RequeueAfter: requeueAfter}, nil
+			return ctrl.Result{RequeueAfter: refreshInt}, nil
 		}
 	}