-
Notifications
You must be signed in to change notification settings - Fork 347
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
fix: enqueue a single request for all resources #1813
Conversation
Signed-off-by: David Boslee <david@goteleport.com>
Signed-off-by: David Boslee <david@goteleport.com>
predicate.NewPredicateFuncs(r.httpRoutesForAuthenticationFilter)); err != nil { | ||
return err | ||
} | ||
|
||
// Watch RateLimitFilter CRUDs and enqueue associated HTTPRoute objects. | ||
if err := c.Watch( | ||
source.Kind(mgr.GetCache(), &egv1a1.RateLimitFilter{}), | ||
&handler.EnqueueRequestForObject{}, | ||
handler.EnqueueRequestsFromMapFunc(r.enqueueClass), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also do this for L1318 ?
@@ -147,7 +147,7 @@ func newResourceMapping() *resourceMappings { | |||
} | |||
|
|||
func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { | |||
r.log.WithName(request.Name).Info("reconciling object", "namespace", request.Namespace, "name", request.Name) | |||
r.log.WithName(request.Name).Info("reconciling gateways") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a comment / doc string mentioning that all watched resources trigger this single Reconcile
. Also can we discard _ reconcile.Request
with a comment mentioning that the requests content dont map to a specific resource.
Codecov Report
@@ Coverage Diff @@
## main #1813 +/- ##
==========================================
+ Coverage 65.11% 65.21% +0.10%
==========================================
Files 86 86
Lines 12316 12318 +2
==========================================
+ Hits 8019 8033 +14
+ Misses 3782 3774 -8
+ Partials 515 511 -4
|
this is a neat idea, thanks for implementing this @dboslee, trying to understand this better, by using |
Signed-off-by: David Boslee <david@goteleport.com>
I think you've got it more or less. There isn't a specific duration here other than the rate limiting provided by the controller. Here are a few examples describing the behavior. At startup a single call to reconcile is executed since the controller will wait for all caches to initialized and events are coalesced. In general, during a re-sync of many resources, any events that are processed before The time in between calls to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for introducing this design pattern to improve performance at scale !
ah makes sense, thanks for the explanation ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
What this PR does / why we need it:
The current behavior of the controller is to run
Reconcile
for each resource that is updated. This gets quite expensive when you have 100s-1000s of resources.This change allows for multiple resource updates to result in a single run of
Reconcile
.This greatly reduces the cpu/memory consumption at startup and during periodic re-syncs of all resources.
Which issue(s) this PR fixes:
Fixes #1797