-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
overload: tcp connection refusal overload action #13311
Merged
mattklein123
merged 12 commits into
envoyproxy:master
from
akonradi:scaled-connection-refusal
Oct 13, 2020
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b984e0c
Add TcpListenerImpl::setRejectFraction method
akonradi 8eda768
Add overload action for rejecting TCP connections
akonradi cf2edf7
Merge commit '52161ce8cec0512de4158c95fdc01c8e39f7938c' into HEAD
akonradi 792fd41
Record reject fraction in connection handler
akonradi fa931af
Merge remote-tracking branch 'upstream/master' into scaled-connection…
akonradi dbba9e9
Use separate stats for connection rejection
akonradi 6e4525b
Add release notes and documentation
akonradi fdcb8ce
Add missing period
akonradi 5b2f333
Relax ordering constraints for events
akonradi 9cc57ce
Add ASSERT and stat tests
akonradi b0abb08
Merge remote-tracking branch 'upstream/master' into scaled-connection…
akonradi 7457331
Merge remote-tracking branch 'upstream/master' into scaled-connection…
akonradi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,9 @@ void ConnectionHandlerImpl::addListener(absl::optional<uint64_t> overridden_list | |
if (disable_listeners_) { | ||
details.listener_->pauseListening(); | ||
} | ||
if (auto* listener = details.listener_->listener(); listener != nullptr) { | ||
listener->setRejectFraction(listener_reject_fraction_); | ||
} | ||
listeners_.emplace_back(config.listenSocketFactory().localAddress(), std::move(details)); | ||
} | ||
|
||
|
@@ -148,6 +151,13 @@ void ConnectionHandlerImpl::enableListeners() { | |
} | ||
} | ||
|
||
void ConnectionHandlerImpl::setListenerRejectFraction(float reject_fraction) { | ||
listener_reject_fraction_ = reject_fraction; | ||
for (auto& listener : listeners_) { | ||
listener.second.listener_->listener()->setRejectFraction(reject_fraction); | ||
} | ||
} | ||
|
||
void ConnectionHandlerImpl::ActiveTcpListener::removeConnection(ActiveTcpConnection& connection) { | ||
ENVOY_CONN_LOG(debug, "adding to cleanup list", *connection.connection_); | ||
ActiveConnections& active_connections = connection.active_connections_; | ||
|
@@ -391,6 +401,17 @@ void ConnectionHandlerImpl::ActiveTcpListener::onAccept(Network::ConnectionSocke | |
onAcceptWorker(std::move(socket), config_->handOffRestoredDestinationConnections(), false); | ||
} | ||
|
||
void ConnectionHandlerImpl::ActiveTcpListener::onReject(RejectCause cause) { | ||
switch (cause) { | ||
case RejectCause::GlobalCxLimit: | ||
stats_.downstream_global_cx_overflow_.inc(); | ||
break; | ||
case RejectCause::OverloadAction: | ||
stats_.downstream_cx_overload_reject_.inc(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please verify this stat increment in one of your tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a unit test. |
||
break; | ||
} | ||
} | ||
|
||
void ConnectionHandlerImpl::ActiveTcpListener::onAcceptWorker( | ||
Network::ConnectionSocketPtr&& socket, bool hand_off_restored_destination_connections, | ||
bool rebalanced) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 you ASSERT 0 <= reject_fraction <= 1? I think the Bernoulli function correctly handles out of bounds but might as well try to check for obvious config/code bugs. (Bonus points would be to introduce a struct wrapper for the float which would check this at point of assignment, etc. but up to you.)
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.
Done.