Skip to content

ext_proc: template gRPC client and move it to common folder#38898

Merged
botengyao merged 10 commits intoenvoyproxy:mainfrom
botengyao:grpc_client_refactor
Mar 31, 2025
Merged

ext_proc: template gRPC client and move it to common folder#38898
botengyao merged 10 commits intoenvoyproxy:mainfrom
botengyao:grpc_client_refactor

Conversation

@botengyao
Copy link
Copy Markdown
Member

@botengyao botengyao commented Mar 25, 2025

This PR will make the gRPC external processor client in l7_ext_proc share with the l4_ext_proc filter.

Commit Message:
Additional Description:
Risk Level: low
Testing:
Docs Changes:
Release Notes:

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
@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: #38898 was opened by botengyao.

see: more, trace.

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao
Copy link
Copy Markdown
Member Author

/retest

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/coverage-shephards: FYI only for changes made to (test/per_file_coverage.sh).
envoyproxy/coverage-shephards assignee is @alyssawilk

🐱

Caused by: #38898 was synchronize by botengyao.

see: more, trace.

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.

coverage LGTM

@yanjunxiang-google
Copy link
Copy Markdown
Contributor

LGTM in general. Thanks for working on this refactoring!
Left a few nit comments. It's okay if you want to address it in the follow up PR.

Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
Signed-off-by: Boteng Yao <boteng@google.com>
Copy link
Copy Markdown
Member Author

@botengyao botengyao left a comment

Choose a reason for hiding this comment

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

thanks for the review, done.

Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
Comment thread source/extensions/filters/common/ext_proc/grpc_client.h Outdated
@tyxia
Copy link
Copy Markdown
Member

tyxia commented Mar 28, 2025

Templates are great to provide flexible interfaces but it also will make interface/code more complicated. As we can see in this PR , template arguments are passed around/specified through the multiple layers in the stack.

Some high level comments:

  1. Do you have the e2e working prototype of using this interface in L4 ext_proc?
  2. Can (or will it be possible that) this gRPC client be generic enough to be shared with clients other than ext_proc?
  3. Have you explored the techniques like CTAD; default template argument etc to reduce template specification?

It seems to be a major change, I don't have strong opinion if 1 above is working

@botengyao
Copy link
Copy Markdown
Member Author

Templates are great to provide flexible interfaces but it also will make interface/code more complicated. As we can see in this PR , template arguments are passed around/specified through the multiple layers in the stack.

Some high level comments:

  1. Do you have the e2e working prototype of using this interface in L4 ext_proc?

  2. Can (or will it be possible that) this gRPC client be generic enough to be shared with clients other than ext_proc?

  3. Have you explored the techniques like CTAD; default template argument etc to reduce template specification?

It seems to be a major change, I don't have strong opinion if 1 above is working

Thanks Tianyu for the review. yes it will work with the new l4 ext_proc, and I think this can be shared for other cases as well for different message types.

Good to know CTAD, I will explore it, can it be a follow up? Thanks!

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Follow-up actions are fine to me.
it will be great to reduce the code complexity (i.e., have easy to maintain code) while leveraging's template's power of writing generic code.

@botengyao botengyao merged commit ac05cf0 into envoyproxy:main Mar 31, 2025
24 checks passed
@botengyao botengyao deleted the grpc_client_refactor branch March 31, 2025 19:54
jewertow pushed a commit to jewertow/envoy that referenced this pull request Apr 2, 2025
…xy#38898)

This PR will make the gRPC external processor client in l7_ext_proc
share with the l4_ext_proc filter.

Commit Message:
Additional Description:
Risk Level: low
Testing:
Docs Changes:
Release Notes:

---------

Signed-off-by: Boteng Yao <boteng@google.com>
krinkinmu added a commit to krinkinmu/envoy that referenced this pull request Apr 8, 2025
In envoyproxy#38898 @botengyao added an exception for the ext_proc tests for
coverage. That's because clang source based coverage reported missing
coverage for the comments (the desirable behavior here is that comments
are not counted in the coverage reports).

Digging through it, what I realized is that for only some tests report
counters for the comments. And all the tests that report thos bogus
counters don't actually exercise the affected code.

I still don't fully understand what triggers the issue here, but that
observation suggests a workaround that this PR implements. I basically
remove dependency on the grpc_client_impl.h from the tests that don't
need it.

I started a thread on LLVM discussions, but given that I couldn't come
up with a small enough reproducer, I don't think that we can resolve it
quickly.

That being said, removing unnecessary includes and moving functions from
headers to cc files is in general a good strategy as it reduces
depndencies between translation units and reduces the amount of work
compiler has to do, so I think we can still push this workaround
upstream, even though I don't have a root cause for the problem.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
botengyao pushed a commit that referenced this pull request Apr 8, 2025
Commit Message:

In #38898 @botengyao added an exception for the ext_proc tests for
coverage. That's because clang source based coverage reported missing
coverage for the comments (the desirable behavior here is that comments
are not counted in the coverage reports).

Digging through it, what I realized is that for only some tests report
counters for the comments. And all the tests that report thos bogus
counters don't actually exercise the affected code.

I still don't fully understand what triggers the issue here, but that
observation suggests a workaround that this PR implements. I basically
remove dependency on the grpc_client_impl.h from the tests that don't
need it.

I started a thread on LLVM discussions
(https://discourse.llvm.org/t/llvm-source-based-coverage-sometimes-generates-counter-for-comments/85730),
but given that I couldn't come up with a small enough reproducer, I
don't think that we can resolve it quickly.

That being said, removing unnecessary includes and moving functions from
headers to cc files is in general a good strategy as it reduces
depndencies between translation units and reduces the amount of work
compiler has to do, so I think we can still push this workaround
upstream, even though I don't have a root cause for the problem.

Additional Description:

It was reported in #37911, but other than that I don't think it's
relevant.

Risk Level: n/a
Testing: regular CI tests, but with coverage targets changed to remove
the exception for the ext_proc.
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

---------

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
agrawroh pushed a commit to agrawroh/envoy that referenced this pull request Apr 9, 2025
…xy#38898)

This PR will make the gRPC external processor client in l7_ext_proc
share with the l4_ext_proc filter.

Commit Message:
Additional Description:
Risk Level: low
Testing:
Docs Changes:
Release Notes:

---------

Signed-off-by: Boteng Yao <boteng@google.com>
yanavlasov pushed a commit that referenced this pull request Apr 23, 2025
Added the basic ext_proc gRPC callout functions without the data loss
that was addressed in #38778.
gRPC client was shared with HTTP ext_proc that was templated by
#38898

Pending:
* COUNTER will be in the followup RPs.
* filter_metadata handling is pending.
* log info is pending.
* timeout setting is pending
* flow control is pending

Commit Message:
Additional Description:
Risk Level: low
Testing:

#38721

---------

Signed-off-by: Boteng Yao <boteng@google.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.

5 participants