Skip to content

Commit bf18a51

Browse files
authored
Merge pull request #1089 from yue9944882/client-go-generic-interface-pt0
Use typed client-go constructors for rate-limit related objects
2 parents 28b2e0b + e82a4f0 commit bf18a51

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pkg/controllers/tagging/tagging_controller.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -116,30 +116,32 @@ func NewTaggingController(
116116
return nil, err
117117
}
118118

119-
var rateLimiter workqueue.RateLimiter
119+
var rateLimiter workqueue.TypedRateLimiter[any]
120120
var rateLimitEnabled bool
121121
if rateLimit > 0.0 && burstLimit > 0 {
122122
klog.Infof("Rate limit enabled on controller with rate %f and burst %d.", rateLimit, burstLimit)
123123
// This is the workqueue.DefaultControllerRateLimiter() but in case where throttling is enabled on the controller,
124124
// the rate and burst values are set to the provided values.
125-
rateLimiter = workqueue.NewMaxOfRateLimiter(
126-
workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, 1000*time.Second),
127-
&workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(rateLimit), burstLimit)},
125+
rateLimiter = workqueue.NewTypedMaxOfRateLimiter(
126+
workqueue.NewTypedItemExponentialFailureRateLimiter[any](5*time.Millisecond, 1000*time.Second),
127+
&workqueue.TypedBucketRateLimiter[any]{Limiter: rate.NewLimiter(rate.Limit(rateLimit), burstLimit)},
128128
)
129129
rateLimitEnabled = true
130130
} else {
131131
klog.Infof("Rate limit disabled on controller.")
132-
rateLimiter = workqueue.DefaultControllerRateLimiter()
132+
rateLimiter = workqueue.DefaultTypedControllerRateLimiter[any]()
133133
rateLimitEnabled = false
134134
}
135135

136136
tc := &Controller{
137-
nodeInformer: nodeInformer,
138-
kubeClient: kubeClient,
139-
cloud: awsCloud,
140-
tags: tags,
141-
resources: resources,
142-
workqueue: workqueue.NewNamedRateLimitingQueue(rateLimiter, TaggingControllerClientName),
137+
nodeInformer: nodeInformer,
138+
kubeClient: kubeClient,
139+
cloud: awsCloud,
140+
tags: tags,
141+
resources: resources,
142+
workqueue: workqueue.NewTypedRateLimitingQueueWithConfig[any](rateLimiter, workqueue.TypedRateLimitingQueueConfig[any]{
143+
Name: TaggingControllerClientName,
144+
}),
143145
nodesSynced: nodeInformer.Informer().HasSynced,
144146
nodeMonitorPeriod: nodeMonitorPeriod,
145147
rateLimitEnabled: rateLimitEnabled,

0 commit comments

Comments
 (0)