filters: allow envoy filters to be created as exception free#30765
filters: allow envoy filters to be created as exception free#30765alyssawilk merged 3 commits intoenvoyproxy:mainfrom
Conversation
e0cf27e to
e410dbf
Compare
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
e410dbf to
ac263ee
Compare
|
/retest |
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Wow, awesome! Would you mind updating the PR description briefly to explain the new class name and factory API that this PR introduces?
| EXPECT_TRUE(admission_control_filter_factory | ||
| .createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_, | ||
| factory_context.getServerFactoryContext()) | ||
| .ok()), |
There was a problem hiding this comment.
I don't understand how this construct is working? EXPECT_TRUE doesn't throw an exception does it? And if the inner part threw an exception then .ok() wouldn't be true so it seems like it ought to fail either way?
Even if it does work, I think the concept would be more readable like
EXPECT_THAT(admission_control_filter_factory
.createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_,
factory_context.getServerFactoryContext()),
HasStatusMessage(HasSubstr("Success rate threshold cannot be less than 1.0%.")));
Or, if the thing is that it's throwing an exception and the EXPECT_TRUE is being ignored, then
EXPECT_THROW_WITH_MESSAGE(
admission_control_filter_factory
.createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_,
factory_context.getServerFactoryContext())
.IgnoreResult(),
EnvoyException, "Success rate threshold cannot be less than 1.0%.");
There was a problem hiding this comment.
the assert is being ignored.
no member named 'IgnoreResult' in 'absl::StatusOr<std::function<void (Envoy::Http::FilterChainFactoryCallbacks &)>>' ditto absl::Status not sure what you're suggesting I use?
There was a problem hiding this comment.
Hm, memory failure on this. Just dropping the ASSERT/EXPECT would be what I would expect to see, I assumed they were there because there was an ABSL_MUST_USE_RESULT tag involved.
Bit of a search suggests that's probably right (.ok() is tagged with ABSL_MUST_USE_RESULT), and I meant replace .ok() with .IgnoreError() (from here)
There was a problem hiding this comment.
oooh yeah that's much cleaner. on it!
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
There was a problem hiding this comment.
LGTM. Thanks.
Seems there are three type of ways to handle the return value when we expect a exception. Call thevalue() directly, call the IgnoreError() directly, call the status().IgnoreError(). Is it oversight or by design? (But it's OK for me if CI is passed. I think we will gradually revise these exception to be error message checking?)
| AwsLambdaFilterFactory factory; | ||
|
|
||
| EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context), | ||
| EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context).value(), |
| admission_control_filter_factory | ||
| .createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_, | ||
| factory_context.getServerFactoryContext()) | ||
| .IgnoreError(), |
| EXPECT_THROW(factory_.createFilterFactoryFromProto(config_, "stats", context_).IgnoreError(), | ||
| EnvoyException); |
Relates: envoyproxy/envoy#30765 Relates: envoyproxy/envoy#31189 Signed-off-by: Tam Mach <tam.mach@cilium.io>
I tried my best here to keep churn minimal, so the default APIs are the same for almost all cc code (though not for tests) and you opt into exceptionless filters.
Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]
envoyproxy/envoy-mobile#176