Skip to content

Commit

Permalink
Switch to no global runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk committed Mar 15, 2022
1 parent ddb9a94 commit ce1ad14
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 50 deletions.
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Minor Behavior Changes
* listener: the :ref:`ipv4_compat <envoy_api_field_core.SocketAddress.ipv4_compat>` flag can only be set on Ipv6 address and Ipv4-mapped Ipv6 address. A runtime guard is added ``envoy.reloadable_features.strict_check_on_ipv4_compat`` and the default is true.
* perf: ssl contexts are now tracked without scan based garbage collection and greatly improved the performance on secret update.
* router: record upstream request timeouts for all the cases and not just for those requests which are awaiting headers. This behavioral change can be temporarily reverted by setting runtime guard ``envoy.reloadable_features.do_not_await_headers_on_upstream_timeout_to_emit_stats`` to false.
* runtime: removed global runtime as Envoy default. This behavioral change can be reverted by setting runtime guard ``envoy.restart_features.no_runtime_singleton`` to false.
* sip-proxy: add customized affinity support by adding :ref:`tra_service_config <envoy_v3_api_msg_extensions.filters.network.sip_proxy.tra.v3alpha.TraServiceConfig>` and :ref:`customized_affinity <envoy_v3_api_msg_extensions.filters.network.sip_proxy.v3alpha.CustomizedAffinity>`.
* sip-proxy: add support for the ``503`` response code. When there is something wrong occurred, send ``503 Service Unavailable`` back to downstream.
* stateful session http filter: only enable cookie based session state when request path matches the configured cookie path.
Expand Down
3 changes: 1 addition & 2 deletions source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ RUNTIME_GUARD(envoy_reloadable_features_update_grpc_response_error_tag);
RUNTIME_GUARD(envoy_reloadable_features_use_dns_ttl);
RUNTIME_GUARD(envoy_reloadable_features_validate_connect);
RUNTIME_GUARD(envoy_restart_features_explicit_wildcard_resource);
RUNTIME_GUARD(envoy_restart_features_no_runtime_singleton);
RUNTIME_GUARD(envoy_restart_features_use_apple_api_for_dns_lookups);

// Begin false flags. These should come with a TODO to flip true.
Expand All @@ -75,8 +76,6 @@ FALSE_RUNTIME_GUARD(envoy_reloadable_features_test_feature_false);
FALSE_RUNTIME_GUARD(envoy_reloadable_features_allow_multiple_dns_addresses);
// TODO(adisuissa) reset to true to enable unified mux by default
FALSE_RUNTIME_GUARD(envoy_reloadable_features_unified_mux);
// TODO(alyssar) flip false once issue complete.
FALSE_RUNTIME_GUARD(envoy_restart_features_no_runtime_singleton);
// TODO(kbaichoo): Make this enabled by default when fairness and chunking
// are implemented, and we've had more cpu time.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_defer_processing_backedup_streams);
Expand Down
18 changes: 6 additions & 12 deletions test/common/http/http2/codec_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,8 @@ class Http2CodecImplTestFixture {
}

virtual void initialize() {
scoped_runtime_->mergeValues(
{{"envoy.reloadable_features.http2_new_codec_wrapper",
enable_new_codec_wrapper_ ? "true" : "false"}});
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{std::string(Runtime::defer_processing_backedup_streams),
defer_processing_backedup_streams_ ? "true" : "false"}});
scoped_runtime_.mergeValues({{"envoy.reloadable_features.http2_new_codec_wrapper",
enable_new_codec_wrapper_ ? "true" : "false"}});
http2OptionsFromTuple(client_http2_options_, client_settings_);
http2OptionsFromTuple(server_http2_options_, server_settings_);
client_ = std::make_unique<TestClientConnectionImpl>(
Expand Down Expand Up @@ -3599,12 +3595,10 @@ class Http2CodecMetadataTest : public Http2CodecImplTestFixture, public ::testin

protected:
void initialize() override {
scoped_runtime_->mergeValues(
{{"envoy.reloadable_features.http2_new_codec_wrapper",
enable_new_codec_wrapper_ ? "true" : "false"}});
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{std::string(Runtime::defer_processing_backedup_streams),
defer_processing_backedup_streams_ ? "true" : "false"}});
scoped_runtime_.mergeValues({{"envoy.reloadable_features.http2_new_codec_wrapper",
enable_new_codec_wrapper_ ? "true" : "false"}});
scoped_runtime_.mergeValues({{std::string(Runtime::defer_processing_backedup_streams),
defer_processing_backedup_streams_ ? "true" : "false"}});
allow_metadata_ = true;
http2OptionsFromTuple(client_http2_options_, client_settings_);
http2OptionsFromTuple(server_http2_options_, server_settings_);
Expand Down
8 changes: 4 additions & 4 deletions test/common/network/listener_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ TEST_P(TcpListenerImplTest, GlobalConnectionLimitEnforcement) {
auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(
Network::Test::getCanonicalLoopbackAddress(version_));
Network::MockTcpListenerCallbacks listener_callbacks;
Network::ListenerPtr listener = dispatcher_->createListener(
socket, listener_callbacks, scoped_runtime.loader(), true, false);
Network::ListenerPtr listener =
dispatcher_->createListener(socket, listener_callbacks, scoped_runtime.loader(), true, false);

std::vector<Network::ClientConnectionPtr> client_connections;
std::vector<Network::ConnectionPtr> server_connections;
Expand Down Expand Up @@ -193,8 +193,8 @@ TEST_P(TcpListenerImplTest, GlobalConnectionLimitListenerOptOut) {
auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(
Network::Test::getCanonicalLoopbackAddress(version_));
Network::MockTcpListenerCallbacks listener_callbacks;
Network::ListenerPtr listener = dispatcher_->createListener(
socket, listener_callbacks, scoped_runtime.loader(), true, true);
Network::ListenerPtr listener =
dispatcher_->createListener(socket, listener_callbacks, scoped_runtime.loader(), true, true);

std::vector<Network::ClientConnectionPtr> client_connections;
std::vector<Network::ConnectionPtr> server_connections;
Expand Down
2 changes: 1 addition & 1 deletion test/common/protobuf/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ class DeprecatedFieldsTest : public testing::Test, protected RuntimeStatsHelper
};

TEST_F(DeprecatedFieldsTest, NoCrashIfRuntimeMissing) {
loader_.reset();
runtime_.reset();

envoy::test::deprecation_test::Base base;
base.set_not_deprecated("foo");
Expand Down
1 change: 1 addition & 0 deletions test/common/quic/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ envoy_cc_test(
"//test/mocks/server:instance_mocks",
"//test/test_common:network_utility_lib",
"//test/test_common:simulated_time_system_lib",
"//test/test_common:test_runtime_lib",
"@com_github_google_quiche//:quic_test_tools_crypto_server_config_peer_lib",
"@envoy_api//envoy/config/listener/v3:pkg_cc_proto",
],
Expand Down
10 changes: 5 additions & 5 deletions test/common/quic/active_quic_listener_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "test/test_common/environment.h"
#include "test/test_common/network_utility.h"
#include "test/test_common/simulated_time_system.h"
#include "test/test_common/test_runtime.h"
#include "test/test_common/utility.h"

#include "absl/time/time.h"
Expand Down Expand Up @@ -116,8 +117,7 @@ class ActiveQuicListenerTest : public testing::TestWithParam<Network::Address::I
.WillRepeatedly(ReturnRef(filter_chain_manager_));
quic_listener_ =
staticUniquePointerCast<ActiveQuicListener>(listener_factory_->createActiveUdpListener(
Runtime::LoaderSingleton::get(), 0, connection_handler_, *dispatcher_,
listener_config_));
scoped_runtime_.loader(), 0, connection_handler_, *dispatcher_, listener_config_));
quic_dispatcher_ = ActiveQuicListenerPeer::quicDispatcher(*quic_listener_);
quic::QuicCryptoServerConfig& crypto_config =
ActiveQuicListenerPeer::cryptoConfig(*quic_listener_);
Expand Down Expand Up @@ -243,7 +243,6 @@ class ActiveQuicListenerTest : public testing::TestWithParam<Network::Address::I
}
// Trigger alarm to fire before listener destruction.
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
Runtime::LoaderSingleton::clear();
}

protected:
Expand Down Expand Up @@ -271,6 +270,7 @@ class ActiveQuicListenerTest : public testing::TestWithParam<Network::Address::I
handshake_timeout_);
}

TestScopedRuntime scoped_runtime_;
Network::Address::IpVersion version_;
Event::SimulatedTimeSystemHelper simulated_time_system_;
Api::ApiPtr api_;
Expand Down Expand Up @@ -444,14 +444,14 @@ TEST_P(ActiveQuicListenerTest, QuicProcessingDisabledAndEnabled) {
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_EQ(quic_dispatcher_->NumSessions(), 1);

Runtime::LoaderSingleton::getExisting()->mergeValues({{"quic.enabled", " false"}});
scoped_runtime_.mergeValues({{"quic.enabled", " false"}});
sendCHLO(quic::test::TestConnectionId(2));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
// If listener was enabled, there should have been session created for active connection.
EXPECT_EQ(quic_dispatcher_->NumSessions(), 1);
EXPECT_FALSE(ActiveQuicListenerPeer::enabled(*quic_listener_));

Runtime::LoaderSingleton::getExisting()->mergeValues({{"quic.enabled", " true"}});
scoped_runtime_.mergeValues({{"quic.enabled", " true"}});
sendCHLO(quic::test::TestConnectionId(2));
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_EQ(quic_dispatcher_->NumSessions(), 2);
Expand Down
1 change: 0 additions & 1 deletion test/common/upstream/eds_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class EdsSpeedTest {
subscription_stats_(Config::Utility::generateStats(stats_)),
api_(Api::createApiForTest(stats_)), async_client_(new Grpc::MockAsyncClient()),
config_validators_(std::make_unique<NiceMock<Config::MockCustomConfigValidators>>()) {
TestDeprecatedV2Api::allowDeprecatedV2();
if (use_unified_mux_) {
grpc_mux_.reset(new Config::XdsMux::GrpcMuxSotw(
std::unique_ptr<Grpc::MockAsyncClient>(async_client_), dispatcher_,
Expand Down
8 changes: 4 additions & 4 deletions test/integration/buffer_accounting_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ INSTANTIATE_TEST_SUITE_P(

TEST_P(Http2DeferredProcessingIntegrationTest, CanBufferInDownstreamCodec) {
config_helper_.setBufferLimits(1000, 1000);
config_helper_.addRuntimeOverride(std::string(Runtime::defer_processing_backedup_streams),
"true");
initialize();
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{std::string(Runtime::defer_processing_backedup_streams), "true"}});

// Stop writes to the upstream.
write_matcher_->setDestinationPort(fake_upstreams_[0]->localAddress()->ip()->port());
Expand Down Expand Up @@ -784,9 +784,9 @@ TEST_P(Http2DeferredProcessingIntegrationTest, CanBufferInDownstreamCodec) {

TEST_P(Http2DeferredProcessingIntegrationTest, CanBufferInUpstreamCodec) {
config_helper_.setBufferLimits(1000, 1000);
config_helper_.addRuntimeOverride(std::string(Runtime::defer_processing_backedup_streams),
"true");
initialize();
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{std::string(Runtime::defer_processing_backedup_streams), "true"}});

// Stop writes to the downstream.
write_matcher_->setSourcePort(lookupPort("http"));
Expand Down
2 changes: 1 addition & 1 deletion test/server/config_validation/server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TEST_P(RuntimeFeatureValidationServerTest, ValidRuntimeLoaderSingleton) {
Network::Address::InstanceConstSharedPtr(), stats_store,
access_log_lock, component_factory_, Thread::threadFactoryForTest(),
Filesystem::fileSystemForTest());
EXPECT_TRUE(server.runtime().snapshot().getBoolean("test.runtime.loaded"));
EXPECT_TRUE(server.runtime().snapshot().getBoolean("test.runtime.loaded", false));
server.registerCallback(ServerLifecycleNotifier::Stage::ShutdownExit, [] { FAIL(); });
server.registerCallback(ServerLifecycleNotifier::Stage::ShutdownExit,
[](Event::PostCb) { FAIL(); });
Expand Down
13 changes: 0 additions & 13 deletions test/server/config_validation/test_data/runtime_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ layered_runtime:
- name: static-layer
static_layer:
"test.runtime.loaded": true
static_resources:
listeners:
- name: "test.listener"
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 0
filter_chains:
- filters:
- name: envoy.filters.network.test
typed_config:
"@type": type.googleapis.com/google.protobuf.Struct
admin:
address:
socket_address:
Expand Down
4 changes: 2 additions & 2 deletions test/server/listener_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ TEST_F(ListenerManagerImplTest, RejectIpv4CompatOnIpv4Address) {

TEST_F(ListenerManagerImplTest, AcceptIpv4CompatOnIpv4Address) {
auto scoped_runtime_guard = std::make_unique<TestScopedRuntime>();
Runtime::LoaderSingleton::getExisting()->mergeValues(
scoped_runtime_guard->mergeValues(
{{"envoy.reloadable_features.strict_check_on_ipv4_compat", "false"}});
const std::string yaml = R"EOF(
name: "foo"
Expand Down Expand Up @@ -631,7 +631,7 @@ TEST_F(ListenerManagerImplTest, AcceptIpv4CompatOnNonCanonicalIpv6AnyAddress) {

TEST_F(ListenerManagerImplTest, AcceptIpv4CompatOnNonIpv4MappedIpv6address) {
auto scoped_runtime_guard = std::make_unique<TestScopedRuntime>();
Runtime::LoaderSingleton::getExisting()->mergeValues(
scoped_runtime_guard->mergeValues(
{{"envoy.reloadable_features.strict_check_on_ipv4_compat", "false"}});
const std::string yaml = R"EOF(
name: "foo"
Expand Down
9 changes: 4 additions & 5 deletions test/test_common/test_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ class TestScopedRuntime {
// The existence of an admin layer is required for mergeValues() to work.
config.add_layers()->mutable_admin_layer();

Runtime::LoaderPtr runtime_ptr =
std::make_unique<Runtime::LoaderImpl>(dispatcher_, tls_, config, local_info_, store_,
generator_, validation_visitor_, *api_);
Runtime::LoaderPtr runtime_ptr = std::make_unique<Runtime::LoaderImpl>(
dispatcher_, tls_, config, local_info_, store_, generator_, validation_visitor_, *api_);
// This will ignore values set in test, but just use flag defaults!
if (Runtime::runtimeFeatureEnabled("envoy.restart_features.no_runtime_singleton") {
if (Runtime::runtimeFeatureEnabled("envoy.restart_features.no_runtime_singleton")) {
runtime_ = std::move(runtime_ptr);
} else {
runtime_singleton_ = std::make_unique<Runtime::ScopedLoaderSingleton>(std::move(runtime_ptr));
Expand Down Expand Up @@ -71,7 +70,7 @@ class TestDeprecatedV2Api : public TestScopedRuntime {
public:
TestDeprecatedV2Api() { allowDeprecatedV2(); }
void allowDeprecatedV2() {
loader()->mergeValues({
loader().mergeValues({
{"envoy.test_only.broken_in_production.enable_deprecated_v2_api", "true"},
{"envoy.features.enable_all_deprecated_features", "true"},
});
Expand Down

0 comments on commit ce1ad14

Please sign in to comment.