Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1234 from adrianludwin/retry
Browse files Browse the repository at this point in the history
Cap the backoff for the object reconciler to 10s
  • Loading branch information
k8s-ci-robot authored Oct 27, 2020
2 parents 1e47bb4 + f326ff7 commit 548df0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions incubator/hnc/internal/reconcilers/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"reflect"
"sync"
"time"

"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -28,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand Down Expand Up @@ -749,6 +751,18 @@ func (r *ObjectReconciler) SetupWithManager(mgr ctrl.Manager, maxReconciles int)
target.SetGroupVersionKind(r.GVK)
opts := controller.Options{
MaxConcurrentReconciles: maxReconciles,

// Unlike the other HNC reconcilers, the object reconciler can easily be affected by objects
// that do not directly cause reconciliations when they're modified - see, e.g.,
// https://github.com/kubernetes-sigs/multi-tenancy/issues/1154. To address this, replace the
// default exponential backoff with one with a 10s cap.
//
// I wanted to pick five seconds since I feel like that's about how much time it would take you to check
// to see if something's wrong, realize it hasn't been propagated, and then try again. However,
// the default etcd timeout is 10s, which apparently is a more realistic measure of how K8s can
// behave under heavy load, so I raised it to 10s during the PR review. The _average_ delay seen
// by users should still be about 5s though.
RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(250*time.Millisecond, 10*time.Second),
}
return ctrl.NewControllerManagedBy(mgr).
For(target).
Expand Down

0 comments on commit 548df0a

Please sign in to comment.