-
Notifications
You must be signed in to change notification settings - Fork 24
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
Rate limiting fixes (config parsing, better logging) #1967
Conversation
…message construction
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.
Most of my comments are nitpicks, but some are about avoiding string copies, so I'd like them at least acknowledged before approving.
Co-Authored-By: Mauro Ezequiel Moltrasio <[email protected]>
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!
@@ -326,15 +330,25 @@ void NetworkStatusNotifier::AddConnections(::google::protobuf::RepeatedPtrField< | |||
// the case where we send a close event for a connection that it doesn't | |||
// know about. | |||
// | |||
if (!rate_limiter.Allow(delta_entry.first.container())) { | |||
CLOG_THROTTLED(INFO, std::chrono::seconds(5)) << "Rate limiting connections reported from container " << delta_entry.first.container(); | |||
const std::string& container = delta_entry.first.container(); |
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.
Could we use a std::string_view
directly? I believe it's a trivial cast back to const std::string&
so the call to Allow
on the next line should still work.
const std::string& container = delta_entry.first.container(); | |
const std::string_view container = delta_entry.first.container(); |
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.
I didn't realise this implicit casting was a thing, I'll change it.
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.
Unfortunately it looks like the string_view is not able to cast back into a string (I think since it would require a copy)
Description
So this is embarrassing. The rate limit wasn't parsed from the config and copied over to the local runtime config object, which meant that the rate limit was set to zero and no network connections were sent from Collector.
This fixes that. It also adds some more useful logging around rate limiting.
Testing Performed
Tested locally on OCP 4 cluster.