Fix/load limits from settings at init - #2431
urielkelman wants to merge 2 commits into
Conversation
…imiter is first instantiated
|
👋 urielkelman, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
📊 API Diff Results
|
It is safe since we still fall back to the other defaults. I don't like the background context, but I'm not sure what else we can do. Maybe defer constructing the actual backing rate limiter until first use? |
I would like to understand the other part of the change first |
Agree it's not ideal. MakeRateLimiter doesn't get a ctx, and the updater right below already uses context.Background(). For a global limit the ctx wouldn't change the value anyway, and the settings are in memory so there's nothing to cancel. I guess (dont have 100% context on everything) the lazy init proposal could work, but I think that could be done as follow up. or I can drop the global part from this PR if you like, i just wanted to make it consistent with the newRateLimiter constructor. |
After a Gateway restart, the first burst to a workflow was limited to the code default instead of the org override. New buckets were created full at the default burst, and the configured value was only applied afterwards by the background poll. Raising the burst does not add tokens, so the bucket stayed short until it refilled. With every30s:30 that takes about 13.5 minutes.
Changes
pkg/settings/limits/rate.go
SetBurst behaviour is unchanged, so lowering and then raising a limit still does not hand out an extra burst.