Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Minor Behavior Changes
----------------------
*Changes that may cause incompatibilities for some users, but should not for most*

* config: configuration files ending in .yml now load as YAML.
* config: reduced log level for "Unable to establish new stream" xDS logs to debug. The log level
for "gRPC config stream closed" is now reduced to debug when the status is ``Ok`` or has been
retriable (``DeadlineExceeded``, ``ResourceExhausted``, or ``Unavailable``) for less than 30
Expand Down
3 changes: 2 additions & 1 deletion source/common/protobuf/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ void MessageUtil::loadFromFile(const std::string& path, Protobuf::Message& messa
}
return;
}
if (absl::EndsWith(path, FileExtensions::get().Yaml)) {
if (absl::EndsWith(path, FileExtensions::get().Yaml) ||
absl::EndsWith(path, FileExtensions::get().Yml)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe using absl::EndsWithIgnoreCase is better, feel loose check better than strict check here. But yes, this isn't the scope of this PR also.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a good idea. I will do this and a few more tests per @htuch

loadFromYaml(contents, message, validation_visitor, do_boosting);
} else {
loadFromJson(contents, message, validation_visitor, do_boosting);
Expand Down
1 change: 1 addition & 0 deletions source/common/protobuf/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class MessageUtil {
const std::string ProtoText = ".pb_text";
const std::string Json = ".json";
const std::string Yaml = ".yaml";
const std::string Yml = ".yml";
};

using FileExtensions = ConstSingleton<FileExtensionValues>;
Expand Down
2 changes: 1 addition & 1 deletion test/config/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ filegroup(
name = "server_xds_files",
srcs = [
"server_xds.bootstrap.udpa.yaml",
"server_xds.bootstrap.yaml",
"server_xds.bootstrap.yml",
"server_xds.cds.with_unknown_field.yaml",
"server_xds.cds.yaml",
"server_xds.eds.ads_cluster.yaml",
Expand Down
10 changes: 5 additions & 5 deletions test/integration/dynamic_validation_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ INSTANTIATE_TEST_SUITE_P(
// Protocol options in CDS with unknown fields are rejected if and only if strict.
TEST_P(DynamicValidationIntegrationTest, CdsProtocolOptionsRejected) {
api_filesystem_config_ = {
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional nit: technically an orthogonal test for this would be cleaner, but not that big a deal.

"test/config/integration/server_xds.cds.with_unknown_field.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.yaml",
Expand All @@ -122,7 +122,7 @@ TEST_P(DynamicValidationIntegrationTest, CdsProtocolOptionsRejected) {
TEST_P(DynamicValidationIntegrationTest, LdsFilterRejected) {
allow_lds_rejection_ = true;
api_filesystem_config_ = {
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.with_unknown_field.yaml",
Expand Down Expand Up @@ -153,7 +153,7 @@ TEST_P(DynamicValidationIntegrationTest, LdsFilterRejected) {
TEST_P(DynamicValidationIntegrationTest, LdsFilterRejectedTypedStruct) {
allow_lds_rejection_ = true;
api_filesystem_config_ = {
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.with_unknown_field.typed_struct.yaml",
Expand Down Expand Up @@ -182,7 +182,7 @@ TEST_P(DynamicValidationIntegrationTest, LdsFilterRejectedTypedStruct) {
// Unknown fields in RDS cause config load failure if and only if strict.
TEST_P(DynamicValidationIntegrationTest, RdsFailedBySubscription) {
api_filesystem_config_ = {
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.yaml",
Expand Down Expand Up @@ -210,7 +210,7 @@ TEST_P(DynamicValidationIntegrationTest, RdsFailedBySubscription) {
// Unknown fields in EDS cause config load failure if and only if strict.
TEST_P(DynamicValidationIntegrationTest, EdsFailedBySubscription) {
api_filesystem_config_ = {
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.with_unknown_field.yaml",
"test/config/integration/server_xds.lds.yaml",
Expand Down
4 changes: 2 additions & 2 deletions test/integration/xds_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class XdsIntegrationTest : public testing::TestWithParam<Network::Address::IpVer

void createEnvoy() override {
createEnvoyServer({
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.yaml",
Expand Down Expand Up @@ -59,7 +59,7 @@ class XdsIntegrationTestTypedStruct : public XdsIntegrationTest {

void createEnvoy() override {
createEnvoyServer({
"test/config/integration/server_xds.bootstrap.yaml",
"test/config/integration/server_xds.bootstrap.yml",
"test/config/integration/server_xds.cds.yaml",
"test/config/integration/server_xds.eds.yaml",
"test/config/integration/server_xds.lds.typed_struct.yaml",
Expand Down
4 changes: 1 addition & 3 deletions test/test_common/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,7 @@ std::string TestEnvironment::temporaryFileSubstitute(const std::string& path,
out_json_string = substitute(out_json_string, version);

auto name = Filesystem::fileSystemForTest().splitPathFromFilename(path).file_;
const std::string extension = absl::EndsWith(name, ".yaml") ? ".yaml"
: absl::EndsWith(name, ".pb_text") ? ".pb_text"
: ".json";
const std::string extension = std::string(name.substr(name.rfind('.')));
const std::string out_json_path =
TestEnvironment::temporaryPath(name) + ".with.ports" + extension;
{
Expand Down