Skip to content

Add max backoff flag for TargetGroupBinding reconciler #2029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions controllers/elbv2/targetgroupbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package controllers
import (
"context"
"fmt"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/aws-load-balancer-controller/controllers/elbv2/eventhandlers"
"sigs.k8s.io/aws-load-balancer-controller/pkg/config"
"sigs.k8s.io/aws-load-balancer-controller/pkg/k8s"
Expand Down Expand Up @@ -55,7 +58,8 @@ func NewTargetGroupBindingReconciler(k8sClient client.Client, eventRecorder reco
tgbResourceManager: tgbResourceManager,
logger: logger,

maxConcurrentReconciles: config.TargetGroupBindingMaxConcurrentReconciles,
maxConcurrentReconciles: config.TargetGroupBindingMaxConcurrentReconciles,
maxExponentialBackoffDelay: config.TargetGroupBindingMaxExponentialBackoffDelay,
}
}

Expand All @@ -67,7 +71,8 @@ type targetGroupBindingReconciler struct {
tgbResourceManager targetgroupbinding.ResourceManager
logger logr.Logger

maxConcurrentReconciles int
maxConcurrentReconciles int
maxExponentialBackoffDelay time.Duration
}

// +kubebuilder:rbac:groups=elbv2.k8s.aws,resources=targetgroupbindings,verbs=get;list;watch;update;patch;create;delete
Expand Down Expand Up @@ -157,7 +162,9 @@ func (r *targetGroupBindingReconciler) SetupWithManager(ctx context.Context, mgr
Watches(&source.Kind{Type: &corev1.Service{}}, svcEventHandler).
Watches(&source.Kind{Type: &corev1.Endpoints{}}, epsEventsHandler).
Watches(&source.Kind{Type: &corev1.Node{}}, nodeEventsHandler).
WithOptions(controller.Options{MaxConcurrentReconciles: r.maxConcurrentReconciles}).
WithOptions(controller.Options{
MaxConcurrentReconciles: r.maxConcurrentReconciles,
RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, r.maxExponentialBackoffDelay)}).
Complete(r)
}

Expand Down
28 changes: 18 additions & 10 deletions pkg/config/controller_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"time"

"github.com/pkg/errors"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -9,16 +11,18 @@ import (
)

const (
flagLogLevel = "log-level"
flagK8sClusterName = "cluster-name"
flagDefaultTags = "default-tags"
flagExternalManagedTags = "external-managed-tags"
flagServiceMaxConcurrentReconciles = "service-max-concurrent-reconciles"
flagTargetGroupBindingMaxConcurrentReconciles = "targetgroupbinding-max-concurrent-reconciles"
flagDefaultSSLPolicy = "default-ssl-policy"
defaultLogLevel = "info"
defaultMaxConcurrentReconciles = 3
defaultSSLPolicy = "ELBSecurityPolicy-2016-08"
flagLogLevel = "log-level"
flagK8sClusterName = "cluster-name"
flagDefaultTags = "default-tags"
flagExternalManagedTags = "external-managed-tags"
flagServiceMaxConcurrentReconciles = "service-max-concurrent-reconciles"
flagTargetGroupBindingMaxConcurrentReconciles = "targetgroupbinding-max-concurrent-reconciles"
flagTargetGroupBindingMaxExponentialBackoffDelay = "targetgroupbinding-max-exponential-backoff-delay"
flagDefaultSSLPolicy = "default-ssl-policy"
defaultLogLevel = "info"
defaultMaxConcurrentReconciles = 3
defaultMaxExponentialBackoffDelay = time.Second * 1000
defaultSSLPolicy = "ELBSecurityPolicy-2016-08"
)

var (
Expand Down Expand Up @@ -62,6 +66,8 @@ type ControllerConfig struct {
ServiceMaxConcurrentReconciles int
// Max concurrent reconcile loops for TargetGroupBinding objects
TargetGroupBindingMaxConcurrentReconciles int
// Max exponential backoff delay for reconcile failures of TargetGroupBinding
TargetGroupBindingMaxExponentialBackoffDelay time.Duration
}

// BindFlags binds the command line flags to the fields in the config object
Expand All @@ -77,6 +83,8 @@ func (cfg *ControllerConfig) BindFlags(fs *pflag.FlagSet) {
"Maximum number of concurrently running reconcile loops for service")
fs.IntVar(&cfg.TargetGroupBindingMaxConcurrentReconciles, flagTargetGroupBindingMaxConcurrentReconciles, defaultMaxConcurrentReconciles,
"Maximum number of concurrently running reconcile loops for targetGroupBinding")
fs.DurationVar(&cfg.TargetGroupBindingMaxExponentialBackoffDelay, flagTargetGroupBindingMaxExponentialBackoffDelay, defaultMaxExponentialBackoffDelay,
"Maximum duration of exponential backoff for targetGroupBinding reconcile failures")
fs.StringVar(&cfg.DefaultSSLPolicy, flagDefaultSSLPolicy, defaultSSLPolicy,
"Default SSL policy for load balancers listeners")

Expand Down