Skip to content

Commit 154998b

Browse files
authored
check rate-limit before patch new partition (#884)
Signed-off-by: Kento Takeuchi <kento-takeuchi@cybozu.co.jp>
1 parent 2cbcfc7 commit 154998b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

controllers/partition_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ type StatefulSetPartitionReconciler struct {
5454
func (r *StatefulSetPartitionReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
5555
log := crlog.FromContext(ctx)
5656

57-
if !r.RateLimiter.Allow() {
58-
metrics.PartitionUpdateRetriesTotalVec.WithLabelValues(req.Namespace).Inc()
59-
return reconcile.Result{RequeueAfter: r.UpdateInterval}, nil
60-
}
61-
6257
sts := &appsv1.StatefulSet{}
6358
err := r.Get(ctx, req.NamespacedName, sts)
6459
if err != nil {
@@ -96,6 +91,11 @@ func (r *StatefulSetPartitionReconciler) Reconcile(ctx context.Context, req reco
9691
return reconcile.Result{RequeueAfter: 30 * time.Second}, nil
9792
}
9893

94+
if !r.RateLimiter.Allow() {
95+
metrics.PartitionUpdateRetriesTotalVec.WithLabelValues(req.Namespace).Inc()
96+
return reconcile.Result{RequeueAfter: r.UpdateInterval}, nil
97+
}
98+
9999
if err := r.patchNewPartition(ctx, sts); err != nil {
100100
log.Error(err, "failed to apply new partition")
101101
return reconcile.Result{}, err

0 commit comments

Comments
 (0)