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

filters: allow envoy filters to be created as exception free #30765

Merged
merged 3 commits into from
Nov 15, 2023

Conversation

alyssawilk
Copy link
Contributor

@alyssawilk alyssawilk commented Nov 7, 2023

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

Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #30765 was opened by alyssawilk.

see: more, trace.

@alyssawilk alyssawilk force-pushed the filter_factory branch 8 times, most recently from e0cf27e to e410dbf Compare November 13, 2023 21:07
@alyssawilk
Copy link
Contributor Author

/retest

Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

Wow, awesome! Would you mind updating the PR description briefly to explain the new class name and factory API that this PR introduces?

Comment on lines 78 to 81
EXPECT_TRUE(admission_control_filter_factory
.createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_,
factory_context.getServerFactoryContext())
.ok()),
Copy link
Contributor

Choose a reason for hiding this comment

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

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%.");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Contributor

@ravenblackx ravenblackx Nov 14, 2023

Choose a reason for hiding this comment

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

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oooh yeah that's much cleaner. on it!

Signed-off-by: Alyssa Wilk <[email protected]>
wbpcode
wbpcode previously approved these changes Nov 15, 2023
Copy link
Member

@wbpcode wbpcode 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.

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?)

@@ -110,7 +112,7 @@ arn: "arn:aws:lambda:region:424242:fun"
testing::NiceMock<Server::Configuration::MockFactoryContext> context;
AwsLambdaFilterFactory factory;

EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context),
EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context).value(),
Copy link
Member

Choose a reason for hiding this comment

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

nit: status().IgnoreError()?

admission_control_filter_factory
.createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_,
factory_context.getServerFactoryContext())
.IgnoreError(),
Copy link
Member

Choose a reason for hiding this comment

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

nit: status().IgnoreError()?

Comment on lines 57 to 58
EXPECT_THROW(factory_.createFilterFactoryFromProto(config_, "stats", context_).IgnoreError(),
EnvoyException);
Copy link
Member

Choose a reason for hiding this comment

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

ditto.

Signed-off-by: Alyssa Wilk <[email protected]>
@alyssawilk alyssawilk enabled auto-merge (squash) November 15, 2023 16:16
@alyssawilk alyssawilk merged commit 17b0b04 into envoyproxy:main Nov 15, 2023
105 checks passed
@alyssawilk alyssawilk deleted the filter_factory branch March 19, 2024 19:46
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 23, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 23, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 23, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 23, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 23, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Mar 25, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 2, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 5, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 6, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 16, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 16, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 16, 2024
sayboras added a commit to sayboras/proxy that referenced this pull request Apr 17, 2024
github-merge-queue bot pushed a commit to cilium/proxy that referenced this pull request Apr 17, 2024
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.

4 participants