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

golang: add OnStreamComplete callback to mutate final metadata #35742

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

spacewander
Copy link
Contributor

As discussed from #35595 (comment), the AccessLogHandler::log is not designed for mutating the StreamInfo. It's recommended to use OnStreamComplete to do the final metadata management.

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:]

As discussed from https:
//github.com/envoyproxy/pull/35595#issuecomment-2278413889,
the `AccessLogHandler::log` is not designed for mutating the
StreamInfo. It's recommended to use `OnStreamComplete` to do the
final metadata management.

Signed-off-by: spacewander <[email protected]>
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: #35742 was opened by spacewander.

see: more, trace.

@spacewander
Copy link
Contributor Author

CC @doujiang24

@sunaydagli
Copy link
Contributor

I wanted to confirm whether or not this fixes #30859 as AccessLogger will access dynamicMetadata after WASM writes to it?

@spacewander
Copy link
Contributor Author

I wanted to confirm whether or not this fixes #30859 as AccessLogger will access dynamicMetadata after WASM writes to it?

No, this change is only about the Golang filter. If we want to support this in Wasm, we need to add OnStreamComplete callback in Wasm too.

@adisuissa
Copy link
Contributor

Assigning @doujiang24 as codeowner
/assign @doujiang24

@adisuissa
Copy link
Contributor

/assign-from @envoyproxy/envoy-maintainers

Copy link

@envoyproxy/envoy-maintainers assignee is @RyanTheOptimist

🐱

Caused by: a #35742 (comment) was created by @adisuissa.

see: more, trace.

Copy link
Member

@doujiang24 doujiang24 left a comment

Choose a reason for hiding this comment

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

Nice work, lgtm~

@RyanTheOptimist RyanTheOptimist merged commit e6b1c8b into envoyproxy:main Aug 20, 2024
47 checks passed
@sunaydagli
Copy link
Contributor

sunaydagli commented Aug 22, 2024

I wanted to confirm whether or not this fixes #30859 as AccessLogger will access dynamicMetadata after WASM writes to it?

No, this change is only about the Golang filter. If we want to support this in Wasm, we need to add OnStreamComplete callback in Wasm too.

@spacewander I am unsure if the onStreamComplete callback is already added in Wasm, as per envoy/http/filter.h and envoy/source/common/http/filter_manager.h. In this case, would moving the onStreamComplete call to after the destroyFilters() (which uses onDestroy) call in envoy/source/common/http/conn_manager_impl.cc provide the desired change? Thanks for the help!

@spacewander
Copy link
Contributor Author

I wanted to confirm whether or not this fixes #30859 as AccessLogger will access dynamicMetadata after WASM writes to it?

No, this change is only about the Golang filter. If we want to support this in Wasm, we need to add OnStreamComplete callback in Wasm too.

@spacewander I am unsure if the onStreamComplete callback is already added in Wasm, as per envoy/http/filter.h and envoy/source/common/http/filter_manager.h. In this case, would moving the onStreamComplete call to after the destroyFilters() (which uses onDestroy) call in envoy/source/common/http/conn_manager_impl.cc provide the desired change? Thanks for the help!

No, the wasm filter doesn't override the onStreamComplete so it's empty for Wasm.
Another idea is that you might create a wasm access logger before the real logger: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/access_loggers/wasm/v3/wasm.proto. I haven't tested it yet.

spacewander added a commit to mosn/envoy that referenced this pull request Sep 6, 2024
…proxy#35742)

As discussed from
envoyproxy#35595 (comment),
the `AccessLogHandler::log` is not designed for mutating the StreamInfo.
It's recommended to use `OnStreamComplete` to do the final metadata
management.

Signed-off-by: spacewander <[email protected]>
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