-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Listener: respect the connection balancer of the redirected listener (#…
…15842) If listener1 redirects the connection to listener2, the balancer field in listener2 decides whether to rebalance. Previously we rely on the rebalancing at listener1, however, the rebalance is weak because listener1 is likely to not own any connection and the rebalance is no-op. Risk Level: MID. Rebalance may introduce latency. User needs to clear rebalancer field of listener2 to recover the original behavior. Fix #15146 #16113 Signed-off-by: Yuchen Dai <silentdai@gmail.com>
- Loading branch information
Showing
16 changed files
with
431 additions
and
14 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
generated_api_shadow/envoy/config/listener/v4alpha/listener.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
test/integration/filters/address_restore_listener_filter.cc
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
|
||
#include "envoy/network/filter.h" | ||
#include "envoy/network/listen_socket.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
#include "common/network/address_impl.h" | ||
#include "common/network/utility.h" | ||
|
||
namespace Envoy { | ||
|
||
// The FakeOriginalDstListenerFilter restore desired local address without the dependency of OS. | ||
class FakeOriginalDstListenerFilter : public Network::ListenerFilter { | ||
public: | ||
// Network::ListenerFilter | ||
Network::FilterStatus onAccept(Network::ListenerFilterCallbacks& cb) override { | ||
FANCY_LOG(debug, "in FakeOriginalDstListenerFilter::onAccept"); | ||
Network::ConnectionSocket& socket = cb.socket(); | ||
socket.addressProvider().restoreLocalAddress( | ||
std::make_shared<Network::Address::Ipv4Instance>("127.0.0.2", 80)); | ||
FANCY_LOG(debug, "current local socket address is {} restored = {}", | ||
socket.addressProvider().localAddress()->asString(), | ||
socket.addressProvider().localAddressRestored()); | ||
return Network::FilterStatus::Continue; | ||
} | ||
}; | ||
|
||
class FakeOriginalDstListenerFilterConfigFactory | ||
: public Server::Configuration::NamedListenerFilterConfigFactory { | ||
public: | ||
// NamedListenerFilterConfigFactory | ||
Network::ListenerFilterFactoryCb createListenerFilterFactoryFromProto( | ||
const Protobuf::Message&, | ||
const Network::ListenerFilterMatcherSharedPtr& listener_filter_matcher, | ||
Server::Configuration::ListenerFactoryContext&) override { | ||
return [listener_filter_matcher](Network::ListenerFilterManager& filter_manager) -> void { | ||
filter_manager.addAcceptFilter(listener_filter_matcher, | ||
std::make_unique<FakeOriginalDstListenerFilter>()); | ||
}; | ||
} | ||
|
||
ProtobufTypes::MessagePtr createEmptyConfigProto() override { | ||
return ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Struct()}; | ||
} | ||
|
||
std::string name() const override { | ||
// This fake original_dest should be used only in integration test! | ||
return "envoy.filters.listener.original_dst"; | ||
} | ||
}; | ||
|
||
static Registry::RegisterFactory<FakeOriginalDstListenerFilterConfigFactory, | ||
Server::Configuration::NamedListenerFilterConfigFactory> | ||
register_; | ||
} // namespace Envoy |
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.