pgv: validation support for Bootstrap/xDS/filters.#2146
pgv: validation support for Bootstrap/xDS/filters.#2146htuch merged 9 commits intoenvoyproxy:masterfrom
Conversation
|
@akonradi @mattklein123 (also @rodaine FYI) if we can agree on this approach, I can flesh out the PR. |
|
I really wish there was a way to generically call Validate() on the base class. It would be so much cleaner. Barring that, I think this is the best we can do. LGTM. |
|
I'm okay with the general approach here but I'll defer to @mattklein123 and others' stylistic preferences. |
|
@mattklein123 I will bring this up when we meet with the protobuf team. For 1.5, this is the way it has to be I believe. |
bazel/repository_locations.bzl
Outdated
* Bootstrap and xDS APIs implemented with negative tests. There is a known issue with recursive validation of repeated messages in PGV that needs to be fixed before we can enable ValidateFail in rds_impl_test. Positive tests not required, since this is exercised by all tests that aren't failing. * Added validation support of filters and negative tests (where applicable). Signed-off-by: Harvey Tuch <htuch@google.com>
a399eb7 to
c01919e
Compare
|
This is ready for review. |
mattklein123
left a comment
There was a problem hiding this comment.
Sweet. Few random comments and needs merge.
source/common/protobuf/utility.h
Outdated
| try { | ||
| validate(message); | ||
| } catch (const EnvoyException&) { | ||
| message.Clear(); |
There was a problem hiding this comment.
what's the reasoning behind clearing here? We don't do it in the other functions where we validate. Just because we also loaded here so we own the whole thing? Maybe comment?
There was a problem hiding this comment.
Yeah, it had to do with some later code that depended on this being clear on failure in server init. TBH, that's an anti-pattern, I will fix that code instead.
| Json::ObjectSharedPtr config = Json::Factory::loadFromString(config_json); | ||
| envoy::api::v2::filter::network::Rds rds; | ||
| Envoy::Config::Utility::translateRdsConfig(*config, rds); | ||
| // Negative test for protoc-gen-validate constraints. |
There was a problem hiding this comment.
Worth leaving this code for now? Or just delete and add TODO up above? I'm fine either way. Maybe also link to issue tracking this?
There was a problem hiding this comment.
Coverage is broken until some recent PGV fixups make their way across to data-plane-api. Need to merge https://github.com/lyft/protoc-gen-validate/pull/40 first though. So, will wait until that all happens, then this test should work for real.
| Protobuf::RepeatedPtrField<envoy::api::v2::Cluster> clusters; | ||
| clusters.Add(); | ||
|
|
||
| EXPECT_THROW(dynamic_cast<CdsApiImpl*>(cds_.get())->onConfigUpdate(clusters), |
There was a problem hiding this comment.
EXPECT_THROW_WITH_MESSAGE? Maybe not convenient because exception contains entire debug string? Same elsewhere?
There was a problem hiding this comment.
It will get a bit fragile, since the current errors thrown by PGV are not very pretty, so will probably be evolved. This is why I added ProtoValidationException in this PR, so we can at least sure that these are PGV errors.
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
|
@mattklein123 @akonradi ready for final review, PGV works really well (thanks @akonradi @rodaine!). |
source/common/protobuf/utility.cc
Outdated
| const Protobuf::Message& message) | ||
| : EnvoyException(fmt::format("Proto constraint validation failed ({}): {}", validation_error, | ||
| message.DebugString())) { | ||
| ENVOY_LOG_MISC(debug, "Throwing {}", what()); |
There was a problem hiding this comment.
nit: kind of a strange debug message: "Proto validation error. Throwing ..." ?
Signed-off-by: Harvey Tuch <htuch@google.com>
* API sha for proxy * API sha for proxy
Updates to the latest version of Envoy upstream Fixes a flaky stats test that got worse with the bump Forces the registration of the new client channel factory extension that is part of core Implements a new method for the synthetic address Signed-off-by: Snow Pettersen <snowp@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Updates to the latest version of Envoy upstream Fixes a flaky stats test that got worse with the bump Forces the registration of the new client channel factory extension that is part of core Implements a new method for the synthetic address Signed-off-by: Snow Pettersen <snowp@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
This patch lands checking via https://github.com/lyft/protoc-gen-validate in Envoy for bootstrap, xDS ingestion and during filter instantiation.
Risk Level: Medium (things might start blowing up on config ingestion that were slipping through before).
Testing: Mostly negative tests for bootstrap/xDS/filters, since the happy path is already validated through the existing test suite.
Signed-off-by: Harvey Tuch htuch@google.com