Skip to content

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

Merged
alyssawilk merged 3 commits intoenvoyproxy:mainfrom
alyssawilk:filter_factory
Nov 15, 2023
Merged

filters: allow envoy filters to be created as exception free#30765
alyssawilk merged 3 commits intoenvoyproxy:mainfrom
alyssawilk:filter_factory

Conversation

@alyssawilk
Copy link
Copy Markdown
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

@repokitteh-read-only
Copy link
Copy Markdown

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
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <alyssar@chromium.org>
wbpcode
wbpcode previously approved these changes Nov 15, 2023
Copy link
Copy Markdown
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?)

AwsLambdaFilterFactory factory;

EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context),
EXPECT_THROW(factory.createFilterFactoryFromProto(proto_config, "stats", context).value(),
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.

nit: status().IgnoreError()?

admission_control_filter_factory
.createFilterFactoryFromProtoTyped(proto, "whatever", dual_info_,
factory_context.getServerFactoryContext())
.IgnoreError(),
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.

nit: status().IgnoreError()?

Comment on lines +57 to +58
EXPECT_THROW(factory_.createFilterFactoryFromProto(config_, "stats", context_).IgnoreError(),
EnvoyException);
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.

ditto.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk enabled auto-merge (squash) November 15, 2023 16:16
@alyssawilk alyssawilk merged commit 17b0b04 into envoyproxy:main Nov 15, 2023
@alyssawilk alyssawilk deleted the filter_factory branch March 19, 2024 19:46
github-merge-queue Bot pushed a commit to cilium/proxy that referenced this pull request Apr 17, 2024
Relates: envoyproxy/envoy#30765
Relates: envoyproxy/envoy#31189

Signed-off-by: Tam Mach <tam.mach@cilium.io>
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