Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate deprecated fields via validation visitor #10853

Merged
merged 29 commits into from
Jun 5, 2020

Conversation

nezdolik
Copy link
Member

@nezdolik nezdolik commented Apr 20, 2020

Description: Duplicate of #10307
This change intends to unify field deprecation and unknown field handling behind the validation visitor. So far validation of unknown fields was done through validation visitor and validation of deprecated fields was performed inline.
Risk Level:Low
Testing: TBD
Docs Changes:NA
Release Notes:TBD
Fixes #8092

Kateryna Nezdolii added 4 commits March 9, 2020 17:29
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
wip
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@htuch htuch self-requested a review April 20, 2020 16:04
@htuch htuch self-assigned this Apr 20, 2020
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@@ -7,7 +7,7 @@ def envoy_copts(repository, test = False):
posix_options = [
"-Wall",
"-Wextra",
"-Werror",
# "-Werror",
Copy link
Member Author

Choose a reason for hiding this comment

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

oops

@nezdolik
Copy link
Member Author

still need to update/add more tests

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks great, with one caveat (see comment).

source/common/protobuf/utility.cc Show resolved Hide resolved
@nezdolik
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10853 (comment) was created by @nezdolik.

see: more, trace.

// which occurs prior to the initialization of the stats subsystem.
Stats::Counter* deprecated_counter_{};
uint64_t prestats_unknown_count_{};
uint64_t prestats_deprecated_count_{};
Copy link
Member Author

Choose a reason for hiding this comment

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

adding extra counter for deprecated fields may not be needed, as there is stats counter in Runtime already: deprecated_feature_use

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that's fair enough.

Copy link
Member

Choose a reason for hiding this comment

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

True, it's a bit strange that we bump the stat in runtime rather than in the calling code, but I don't think we can undo that at this point as folks are likely relying on it. So, yeah, we can simplify the code here quite a bit as a result.

Kateryna Nezdolii added 2 commits April 24, 2020 14:39
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@nezdolik
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

🐴 hold your horses - no failures detected, yet.

🐱

Caused by: a #10853 (comment) was created by @nezdolik.

see: more, trace.

"#using-runtime-overrides-for-deprecated-features for how to apply a temporary and "
"highly discouraged override.";
throw ProtoValidationException(with_overridden + fatal_error, message);
validation_visitor.onDeprecatedField("type " + message.GetTypeName() + " " + with_overridden);
Copy link
Member

Choose a reason for hiding this comment

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

I think this should always be called, even if warning, but we can add a parameter to control whether it's expected to log or throw an exception (warn_only), maybe call it soft_deprecation?

// which occurs prior to the initialization of the stats subsystem.
Stats::Counter* deprecated_counter_{};
uint64_t prestats_unknown_count_{};
uint64_t prestats_deprecated_count_{};
Copy link
Member

Choose a reason for hiding this comment

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

True, it's a bit strange that we bump the stat in runtime rather than in the calling code, but I don't think we can undo that at this point as folks are likely relying on it. So, yeah, we can simplify the code here quite a bit as a result.

@stale
Copy link

stale bot commented May 4, 2020

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label May 4, 2020
@nezdolik
Copy link
Member Author

nezdolik commented May 6, 2020

keepalive ping, i was busy with another pr

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label May 6, 2020
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@nezdolik nezdolik changed the title Validate deprecated fields via validation visitor [wip] Validate deprecated fields via validation visitor May 11, 2020
Kateryna Nezdolii added 5 commits May 11, 2020 18:06
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@repokitteh-read-only
Copy link

🐴 hold your horses - no failures detected, yet.

🐱

Caused by: a #10853 (comment) was created by @nezdolik.

see: more, trace.

@nezdolik
Copy link
Member Author

Caused by: io.grpc.StatusRuntimeException: FAILED_PRECONDITION: there are no bots capable of executing the action, requested action properties: OSFamily = Linux, concurrency = exclusive (Added by RBE; concurrent actions are incompatible with the following requested properties: dockerSiblingContainers = true)

Not sure how to fix this

Kateryna Nezdolii added 2 commits May 15, 2020 11:09
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
test/mocks/protobuf/mocks.h Outdated Show resolved Hide resolved
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Other than the nits around file organization, LGTM. Thanks!

namespace Envoy {
namespace ProtobufMessage {

void ValidationVisitor::onDeprecatedFieldDefault(absl::string_view description,
Copy link
Member

Choose a reason for hiding this comment

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

We tend to prefer that even default behavior lives in source/ vs. include/, the latter of which is generally just pure virtual functions and classes.

include/envoy/protobuf/message_validator.h Outdated Show resolved Hide resolved
Kateryna Nezdolii added 2 commits May 18, 2020 11:24
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, build needs fixing.

include/envoy/protobuf/BUILD Outdated Show resolved Hide resolved
source/common/protobuf/message_validator_impl.cc Outdated Show resolved Hide resolved
Kateryna Nezdolii added 2 commits May 19, 2020 14:25
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@nezdolik
Copy link
Member Author

Thanks for review @htuch. I will need to fix few tests that use MockValdationVisitors

Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@nezdolik
Copy link
Member Author

nezdolik commented Jun 2, 2020

@htuch this PR is ready for review

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good, but not sure why of a few changes in the last updates.
/wait

source/common/protobuf/message_validator_impl.cc Outdated Show resolved Hide resolved
source/common/protobuf/message_validator_impl.cc Outdated Show resolved Hide resolved
} else {
counter_->inc();
throw DeprecatedProtoFieldException(absl::StrCat(description, deprecation_error));
}
Copy link
Member

Choose a reason for hiding this comment

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

How come the common method is inline now?

Copy link
Member Author

Choose a reason for hiding this comment

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

@htuch if i understand your question correctly, you mean previous version of PR where both visitors shared common method for incrementing stats and logging message? i've changed impl, there is no longer common method. There is little benefit to have common method as deprecated field validation does not increment counters and log messages are different.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but looking at the two implementations, I'm not seeing a stats increment in either, and still unclear why the warnings are different.

Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Kateryna Nezdolii added 3 commits June 4, 2020 19:56
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
@nezdolik
Copy link
Member Author

nezdolik commented Jun 5, 2020

/retest

@repokitteh-read-only
Copy link

🤷‍♀️ nothing to rebuild.

🐱

Caused by: a #10853 (comment) was created by @nezdolik.

see: more, trace.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Appreciate the patience while iterating on this.

@htuch htuch merged commit 67376d9 into envoyproxy:master Jun 5, 2020
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
This change intends to unify field deprecation and unknown field handling behind the validation visitor. So far validation of unknown fields was done through validation visitor and validation of deprecated fields was performed inline.

Risk Level:Low

Fixes envoyproxy#8092

Signed-off-by: Kateryna Nezdolii <nezdolik@spotify.com>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify field deprecation and unknown field handling behind the validation visitor
2 participants