listener: add listener info to the contexts#31067
listener: add listener info to the contexts#31067alyssawilk merged 21 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: Kuat Yessenov <kuat@google.com>
|
Great job. But I believe the |
Signed-off-by: Kuat Yessenov <kuat@google.com>
|
Oh, didn't realize the access log factory context is gone. Yes, I can delete it here, since this PR already forces some minor refactors on the code. |
Signed-off-by: Kuat Yessenov <kuat@google.com>
wbpcode
left a comment
There was a problem hiding this comment.
Thanks. LGTM overall. Only two comments are added.
IIUC, envoy can expose |
|
@zirain Yes, the goal is to make istio_stats act like an access logger, which implies the regular access loggers will have access to everything istio_stats uses. |
that's great, I recall I need this. |
wbpcode
left a comment
There was a problem hiding this comment.
Just take a full pass. It's pretty great and I have no much comments to it. Sorry again for the noise of ListenerInfo and ListenerConfig. I think your previous design maybe better.
Thanks so much for your great contribution. And please check the CI.
| * A configuration for an individual listener. | ||
| */ | ||
| class ListenerConfig { | ||
| class ListenerConfig : public ListenerInfo { |
There was a problem hiding this comment.
if it's because the lifetime problem, then I think you previous design is reasonable. (sorry
There was a problem hiding this comment.
No worries, reverted. I kept the change to remove listenerConfig from ListenerFactoryContext and isQuicListener from FactoryContext.
| ON_CALL(context_, listenerMetadata()).WillByDefault(ReturnRef(listener_metadata_)); | ||
| ON_CALL(context_, listenerInfo()).WillByDefault(ReturnRef(listener_info_)); | ||
| ON_CALL(listener_info_, metadata()).WillByDefault(ReturnRef(listener_metadata_)); |
There was a problem hiding this comment.
ON_CALL(context_.listener_info_, ...); is enough. We needn't create a local listener info again.
This reverts commit a63a39d. Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
wbpcode
left a comment
There was a problem hiding this comment.
LGTM. Thanks. cc Hi, @alyssawilk, could you also take a look when you have free time in case I missed something, thanks.
|
|
||
| class ListenerInfoImpl : public Network::ListenerInfo { | ||
| public: | ||
| explicit ListenerInfoImpl(const envoy::config::listener::v3::Listener config) |
There was a problem hiding this comment.
nit, this can be a reference 'const envoy::config::listener::v3::Listener& config'
There was a problem hiding this comment.
Good catch, thanks.
| /** | ||
| * @return ListenerInfo description of the listener. | ||
| */ | ||
| virtual const Network::ListenerInfo& listenerInfo() const PURE; |
There was a problem hiding this comment.
I like the consolidation but it feels like a regression to add more listener info into the non-listener-named factory context. I suspect it'd be a complete PITA to move this accessor down to the ListenerFactoryContext but have we tried to see how bad it would be?
There was a problem hiding this comment.
We'd have to change the signature of network filters at the very least - HCM needs isQuic check which needs the listener info. I suspect most of the uses for FactoryContext are actually ListenerFactoryContext. What is called ListenerFactoryContext is only used by listener filters.
There was a problem hiding this comment.
I suspect most of the uses for FactoryContext are actually ListenerFactoryContext. What is called ListenerFactoryContext is only used by listener filters.
Yeah, actually almost all FactoryContext is a listener factory context that provide isQuicListener, listenerMetadata, listenerTypedMetadata, etc. methods.
Maybe we can just rename it to ListenerFactoryContext in the future with a simple name replacement, if we want.
| */ | ||
| virtual const Network::ListenerConfig& listenerConfig() const PURE; | ||
| }; | ||
| class ListenerFactoryContext : public virtual FactoryContext {}; |
There was a problem hiding this comment.
ooc if we keep this and it has no functions can it just be typeddefd to FactoryContext or does that cause inheritance problems?
There was a problem hiding this comment.
It's still painful with mocks/fakes. I thought it's better to delete it then - do you want to try that?
There was a problem hiding this comment.
I think we can just clean up it with a new PR.
| createListenerFilterFactories(); | ||
| validateFilterChains(); | ||
| buildFilterChains(); | ||
| buildUdpListenerFactory(config, parent_.server_.options().concurrency()); |
There was a problem hiding this comment.
mild preference for leaving these function definitions as-is and adding a protected accessor config() which returns info->config()
There was a problem hiding this comment.
I thought it would be good to delete config() accessor long term because storing the proto as-is can be expensive with large listeners or Wasm. It's only needed for config dump which can be optimized to recreate the proto like it's done in some other places.
| namespace Envoy { | ||
| namespace Server { | ||
|
|
||
| class EmptyListenerInfo : public Network::ListenerInfo { |
There was a problem hiding this comment.
why not just create a listener info impl with minimal contents?
There was a problem hiding this comment.
Didn't want to bring a dependency on extensions...
There was a problem hiding this comment.
admin already depends on listener no? and listenre is moving back to core code soon. we could alternately factor it out into a minimal library? I'm just not a fan of one-off admin classes but I can look the other way if it's a pain =P
There was a problem hiding this comment.
Sure, if we're OK sharing the code in listener_manager, I deleted this dummy class.
| envoy::config::core::v3::TrafficDirection FactoryContextImpl::direction() const { | ||
| return config_.traffic_direction(); | ||
| } | ||
| const Network::ListenerInfo& FactoryContextImpl::listenerInfo() const { return listener_info_; } |
Signed-off-by: Kuat Yessenov <kuat@google.com>
|
CI still requires a check. |
|
/wait |
|
/retest |
|
(Recently, we also are refactoring factory context related things which result in some conflictions. Sorry for that. There are still last one PR.) |
| * without reaching to Envoy maintainers first. | ||
| */ | ||
| class ListenerAccessLogFactoryContext : public virtual CommonFactoryContext { | ||
| class FactoryContext : public virtual CommonFactoryContext { |
There was a problem hiding this comment.
@kyessenov need to update the comment of this class? it looks like a little mismatch?
Commit Message: Refactor to consolidate listener info and expose it in wider contexts. The concrete issue was that I wanted to use listener properties (direction) in the access logger, but only the filter context has it. By keeping the information in one place, I think we can also trim the large listener proto in the future.
Risk Level: low, internal refactor
Testing: regression
Docs Changes: none
Release Notes: none