Skip to content

stream info: add listener info - #31365

Merged
kyessenov merged 11 commits into
envoyproxy:mainfrom
kyessenov:listener_info_stream
Dec 19, 2023
Merged

kyessenov merged 11 commits into
envoyproxy:mainfrom
kyessenov:listener_info_stream

Conversation

@kyessenov

@kyessenov kyessenov commented Dec 14, 2023 •

Copy link
Copy Markdown
Contributor

Commit Message: Expose listener info in stream info.
Additional Description: Add relevant accessors in the access log and CEL attributes.
Risk Level: low
Testing: added
Docs Changes: yes
Release Notes: yes
Fixes: #24303

CC @zirain @wbpcode

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @abeyad
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #31365 was opened by kyessenov.

see: more, trace.

@kyessenov kyessenov changed the title Listener info stream stream info: add listener info Dec 14, 2023
Comment thread envoy/network/socket.h Resolved
Comment thread envoy/network/listener.h Resolved
constexpr absl::string_view RouteMetadata = "route_metadata";
constexpr absl::string_view UpstreamHostMetadata = "upstream_host_metadata";
constexpr absl::string_view FilterChainName = "filter_chain_name";
constexpr absl::string_view ListenerMetadata = "listener_metadata";

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.

In what consideration not to use listener.metadata and listener.direction?

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.

You mean Wasm attributes? We should recommend the standard xds attributes once we finish replacing them, and then deprecate those one-off cases.

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.

My bad, I misunderstood.

@wbpcode wbpcode left a comment

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.

This enhancement look good to me. Two comments are added first to start review.

abeyad
abeyad previously approved these changes Dec 14, 2023

@abeyad abeyad left a comment

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.

/lgtm api

Comment thread source/common/network/socket_impl.h Resolved
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
@kyessenov

Copy link
Copy Markdown
Contributor Author

/retest

Comment thread source/common/network/socket_impl.h Outdated
std::string ja3_hash_;
absl::optional<std::chrono::milliseconds> round_trip_time_;
FilterChainInfoConstSharedPtr filter_chain_info_;
OptRef<const ListenerInfo> listener_info_;

@wbpcode wbpcode Dec 15, 2023 •

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.

hmmm, the premise of my previous comments is that connection info provider will own a copy of listener info shared pointer.

So, I think the listenerInfo() of ListenerConfig needn't to change it's signature. But seems if we don't change the signature, there is no way to store a listener info shared pointer to the connection info provider.

Seems I was wrong, my bad.

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.

Maybe revert to your previous implementation would be better (use a shared pointer here).

Sorry again. 😞

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.

No problem, reverted. It was worth exploring the other option.

Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>

@wbpcode wbpcode left a comment

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.

LGTM overall. It is almost done. Only two minor comments about the docs and an optional ASSERT.

route_name, string, Route name
route_metadata, :ref:`Metadata<envoy_v3_api_msg_config.core.v3.metadata>`, Route metadata
upstream_host_metadata, :ref:`Metadata<envoy_v3_api_msg_config.core.v3.metadata>`, Upstream host metadata
node, :ref:`Node<envoy_v3_api_msg_config.core.v3.node>`, Local node description. DEPRECATED: please use `xds` attributes.

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.

Seems node is not supported in the xds attributes from above docs?

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.

Good catch, the PR just went in, and fixed the missing doc.

Comment on lines -12 to -14
if (listener_info_ == nullptr) {
listener_info_ = std::make_shared<ListenerInfoImpl>();
}

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: ASSERT(listener_info_ == nullptr); to avoid unexpected regression.

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.

Done.

Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>

@wbpcode wbpcode left a comment

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.

LGTM. Thanks.

@kyessenov
kyessenov merged commit ff991f3 into envoyproxy:main Dec 19, 2023
@kyessenov
kyessenov deleted the listener_info_stream branch December 19, 2023 16:57
dgoffredo pushed a commit to DataDog/envoy that referenced this pull request Dec 26, 2023
Commit Message: Expose listener info in stream info.
Additional Description: Add relevant accessors in the access log and CEL attributes.
Risk Level: low
Testing: added
Docs Changes: yes
Release Notes: yes
Fixes: envoyproxy#24303
wbpcode added a commit that referenced this pull request Aug 28, 2026
Commit Message: wasm: fix multiple bug of vm key and plugin key
calculation
Additional Description:

This PR fixed tow bugs of wasm vm cache key and wasm plugin cache key:
- now, the whole PluginConfig will be used to calculate the cache key.
Before this change, the plugins with different
`allow_on_headers_stop_iteration` may hit same cached plugin handle and
make unexpected behavior.
- now, the `capability_restriction_config` and `runtime` will be used to
calculate the vm cache key. Before this change, the plugin VMs with
different `capability_restriction_config` and `runtime` may hit same
cache and result in unexpected behavior.

---

Now, we also removed the traffic direction from the plugin cache key.
It's safe because it's unnecessary now.

Long time ago, before the #31365, we cannot extract the listener info
from the connection info, so the WASM will get the traffic direction and
listener metadata from the FactoryContext and store the reference at the
cached plugin. Then when `get_property` ABI is used, the plugin could
serve the related attributes.

And to avoid the wasm plugins that be configured in different listeners
(with different direction/metadata) hit same plugin cache, we added the
listener metadata and traffic direction in to plugin cache key
calculation at #17243.


But at the #36619 , we have did a great refactoring and removed the
dependencies to the traffic direction and listener metadata from the
FactoryContext. The `get_property` ABI will get attributes from the
stream info and stream level context. So, after that, it's unnecessary
to use the listener metadata and traffic direction as cache key. And at
the #36941, we removed the traffic direction and listener metadata from
the cached plugin completely. After that, the traffic direction/metadata
make nonsense in the cache key.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode <[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.

stream info: support listener info

4 participants