Skip to content
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

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

Stringy
Copy link
Collaborator

@Stringy Stringy commented Nov 20, 2024

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.

@Stringy Stringy requested a review from a team as a code owner November 20, 2024 12:53
Copy link
Collaborator

@Molter73 Molter73 left a 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.

collector/lib/ConfigLoader.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
collector/lib/NetworkStatusNotifier.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@Molter73 Molter73 left a 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();
Copy link
Collaborator

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.

Suggested change
const std::string& container = delta_entry.first.container();
const std::string_view container = delta_entry.first.container();

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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)

@Stringy Stringy merged commit 4b411fd into master Nov 20, 2024
50 of 51 checks passed
@Stringy Stringy deleted the giles/fix-rate-limiting branch November 20, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants