Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions source/server/configuration_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ InitialImpl::InitialImpl(const envoy::config::bootstrap::v3::Bootstrap& bootstra
if (layered_runtime_.layers().empty()) {
layered_runtime_.add_layers()->mutable_admin_layer();
}
} else {
Config::translateRuntime(bootstrap.hidden_envoy_deprecated_runtime(), layered_runtime_);
}
if (enable_deprecated_v2_api_) {
auto* enabled_deprecated_v2_api_layer = layered_runtime_.add_layers();
Expand Down
36 changes: 11 additions & 25 deletions test/common/protobuf/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,36 +304,22 @@ TEST_F(ProtobufUtilityTest, LoadBinaryProtoFromFile) {
EXPECT_TRUE(TestUtility::protoEqual(bootstrap, proto_from_file));
}

TEST_F(ProtobufV2ApiUtilityTest, DEPRECATED_FEATURE_TEST(LoadBinaryV2ProtoFromFile)) {
// Allow the use of v2.Bootstrap.runtime.
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{"envoy.deprecated_features:envoy.config.bootstrap.v2.Bootstrap.runtime", "True "}});
envoy::config::bootstrap::v2::Bootstrap bootstrap;
bootstrap.mutable_runtime()->set_symlink_root("/");

const std::string filename =
TestEnvironment::writeStringToFileForTest("proto.pb", bootstrap.SerializeAsString());

envoy::config::bootstrap::v3::Bootstrap proto_from_file;
TestUtility::loadFromFile(filename, proto_from_file, *api_);
EXPECT_EQ("/", proto_from_file.hidden_envoy_deprecated_runtime().symlink_root());
EXPECT_GT(runtime_deprecated_feature_use_.value(), 0);
}

// Verify that a config with a deprecated field can be loaded with runtime global override.
TEST_F(ProtobufUtilityTest, DEPRECATED_FEATURE_TEST(LoadBinaryV2GlobalOverrideProtoFromFile)) {
// Allow the use of v2.Bootstrap.runtime.
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{"envoy.features.enable_all_deprecated_features", "true"}});
envoy::config::bootstrap::v2::Bootstrap bootstrap;
bootstrap.mutable_runtime()->set_symlink_root("/");

TEST_F(ProtobufUtilityTest, DEPRECATED_FEATURE_TEST(LoadBinaryGlobalOverrideProtoFromFile)) {
const std::string bootstrap_yaml = R"EOF(
layered_runtime:
layers:
- name: static_layer
static_layer:
envoy.features.enable_all_deprecated_features: true
watchdog: { miss_timeout: 1s })EOF";
const std::string filename =
TestEnvironment::writeStringToFileForTest("proto.pb", bootstrap.SerializeAsString());
TestEnvironment::writeStringToFileForTest("proto.yaml", bootstrap_yaml);

envoy::config::bootstrap::v3::Bootstrap proto_from_file;
TestUtility::loadFromFile(filename, proto_from_file, *api_);
EXPECT_EQ("/", proto_from_file.hidden_envoy_deprecated_runtime().symlink_root());
TestUtility::validate(proto_from_file);
EXPECT_TRUE(proto_from_file.has_watchdog());
EXPECT_GT(runtime_deprecated_feature_use_.value(), 0);
}

Expand Down
18 changes: 10 additions & 8 deletions test/config/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,16 @@ ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api&
}
}
}

// Ensure we have a basic admin-capable runtime layer.
if (bootstrap_.mutable_layered_runtime()->layers_size() == 0) {
auto* static_layer = bootstrap_.mutable_layered_runtime()->add_layers();
static_layer->set_name("static_layer");
static_layer->mutable_static_layer();
auto* admin_layer = bootstrap_.mutable_layered_runtime()->add_layers();
admin_layer->set_name("admin");
admin_layer->mutable_admin_layer();
}
}

void ConfigHelper::addClusterFilterMetadata(absl::string_view metadata_yaml,
Expand Down Expand Up @@ -741,14 +751,6 @@ void ConfigHelper::configureUpstreamTls(bool use_alpn, bool http3) {
}

void ConfigHelper::addRuntimeOverride(const std::string& key, const std::string& value) {
if (bootstrap_.mutable_layered_runtime()->layers_size() == 0) {
auto* static_layer = bootstrap_.mutable_layered_runtime()->add_layers();
static_layer->set_name("static_layer");
static_layer->mutable_static_layer();
auto* admin_layer = bootstrap_.mutable_layered_runtime()->add_layers();
admin_layer->set_name("admin");
admin_layer->mutable_admin_layer();
}
auto* static_layer =
bootstrap_.mutable_layered_runtime()->mutable_layers(0)->mutable_static_layer();
(*static_layer->mutable_fields())[std::string(key)] = ValueUtil::stringValue(std::string(value));
Expand Down
79 changes: 0 additions & 79 deletions test/server/configuration_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -640,85 +640,6 @@ TEST(InitialImplTest, EmptyLayeredRuntime) {
EXPECT_THAT(config.runtime(), ProtoEq(expected_runtime));
}

// An empty deprecated Runtime has an empty static and admin layer injected.
TEST(InitialImplTest, EmptyDeprecatedRuntime) {
const auto bootstrap = TestUtility::parseYaml<envoy::config::bootstrap::v3::Bootstrap>("{}");
NiceMock<MockOptions> options;
NiceMock<Server::MockInstance> server;
InitialImpl config(bootstrap, options, server);

const std::string expected_yaml = R"EOF(
layers:
- name: base
static_layer: {}
- name: admin
admin_layer: {}
)EOF";
const auto expected_runtime =
TestUtility::parseYaml<envoy::config::bootstrap::v3::LayeredRuntime>(expected_yaml);
EXPECT_THAT(config.runtime(), ProtoEq(expected_runtime));
}

// A deprecated Runtime is transformed to the equivalent LayeredRuntime.
TEST(InitialImplTest, DeprecatedRuntimeTranslation) {
TestDeprecatedV2Api _deprecated_v2_api;
const std::string bootstrap_yaml = R"EOF(
runtime:
symlink_root: /srv/runtime/current
subdirectory: envoy
override_subdirectory: envoy_override
base:
health_check:
min_interval: 5
)EOF";
const auto bootstrap =
TestUtility::parseYaml<envoy::config::bootstrap::v3::Bootstrap>(bootstrap_yaml);
NiceMock<MockOptions> options;
NiceMock<Server::MockInstance> server;
InitialImpl config(bootstrap, options, server);

const std::string expected_yaml = R"EOF(
layers:
- name: base
static_layer:
health_check:
min_interval: 5
- name: root
disk_layer: { symlink_root: /srv/runtime/current, subdirectory: envoy }
- name: override
disk_layer: { symlink_root: /srv/runtime/current, subdirectory: envoy_override, append_service_cluster: true }
- name: admin
admin_layer: {}
)EOF";
const auto expected_runtime =
TestUtility::parseYaml<envoy::config::bootstrap::v3::LayeredRuntime>(expected_yaml);
EXPECT_THAT(config.runtime(), ProtoEq(expected_runtime));
}

// A v2 bootstrap implies runtime override for API features.
TEST(InitialImplTest, V2BootstrapRuntimeInjection) {
const auto bootstrap = TestUtility::parseYaml<envoy::config::bootstrap::v3::Bootstrap>("{}");
NiceMock<MockOptions> options;
absl::optional<uint32_t> version{2};
EXPECT_CALL(options, bootstrapVersion()).WillOnce(ReturnRef(version));
NiceMock<Server::MockInstance> server;
InitialImpl config(bootstrap, options, server);

const std::string expected_yaml = R"EOF(
layers:
- name: base
static_layer: {}
- name: admin
admin_layer: {}
- name: "enabled_deprecated_v2_api (auto-injected)"
static_layer:
envoy.test_only.broken_in_production.enable_deprecated_v2_api: true
)EOF";
const auto expected_runtime =
TestUtility::parseYaml<envoy::config::bootstrap::v3::LayeredRuntime>(expected_yaml);
EXPECT_THAT(config.runtime(), ProtoEq(expected_runtime));
}

TEST_F(ConfigurationImplTest, AdminSocketOptions) {
std::string json = R"EOF(
{
Expand Down