diff --git a/internal/controller/stages/regular_stages.go b/internal/controller/stages/regular_stages.go index df3e35bab..e97ce9da8 100644 --- a/internal/controller/stages/regular_stages.go +++ b/internal/controller/stages/regular_stages.go @@ -74,6 +74,8 @@ type RegularStageReconciler struct { client client.Client eventRecorder record.EventRecorder directivesEngine directives.Engine + + backoffCfg wait.Backoff } // NewRegularStageReconciler creates a new Stages reconciler. @@ -81,6 +83,13 @@ func NewRegularStageReconciler(cfg ReconcilerConfig, engine directives.Engine) * return &RegularStageReconciler{ cfg: cfg, directivesEngine: engine, + backoffCfg: wait.Backoff{ + Duration: 1 * time.Second, + Factor: 2, + Steps: 10, + Cap: 2 * time.Minute, + Jitter: 0.1, + }, } } @@ -1312,13 +1321,7 @@ func (r *RegularStageReconciler) getVerificationResult( // the symptoms for now. We should investigate the root cause of this // issue and remove this retry logic when the root cause has been resolved. ar := rolloutsapi.AnalysisRun{} - if err := retry.OnError(wait.Backoff{ - Duration: 1 * time.Second, - Factor: 2, - Steps: 10, - Cap: 2 * time.Minute, - Jitter: 0.1, - }, func(err error) bool { + if err := retry.OnError(r.backoffCfg, func(err error) bool { return apierrors.IsNotFound(err) }, func() error { return r.client.Get(ctx, types.NamespacedName{ diff --git a/internal/controller/stages/regular_stages_test.go b/internal/controller/stages/regular_stages_test.go index a6b0c7593..aa97bdc3c 100644 --- a/internal/controller/stages/regular_stages_test.go +++ b/internal/controller/stages/regular_stages_test.go @@ -14,6 +14,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -2273,6 +2274,13 @@ func TestRegularStageReconciler_verifyStageFreight(t *testing.T) { RolloutsIntegrationEnabled: !tt.rolloutsDisabled, }, eventRecorder: recorder, + backoffCfg: wait.Backoff{ + Duration: 1 * time.Second, + Factor: 2, + Steps: 2, + Cap: 2 * time.Second, + Jitter: 0.1, + }, } status, err := r.verifyStageFreight(context.Background(), tt.stage, startTime, fixedEndTime) @@ -3519,6 +3527,13 @@ func TestRegularStageReconciler_getVerificationResult(t *testing.T) { cfg: ReconcilerConfig{ RolloutsIntegrationEnabled: !tt.rolloutsDisabled, }, + backoffCfg: wait.Backoff{ + Duration: 1 * time.Second, + Factor: 2, + Steps: 2, + Cap: 1 * time.Second, + Jitter: 0.1, + }, } vi, err := r.getVerificationResult(context.Background(), tt.freight)