udp: add router for UDP proxy#18791
Conversation
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
|
Though this PR is working in progress, docs changed and testings have not been completed, I would like to ask @mattklein123 for a pre-review. This patch is a update to #17864 which uses the generic matching API #17633 you metioned, but since the prefix/custom generic matching API is not completed, This patch does not support prefix-range-like matching compared with #17864. |
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks very nice. Flushing out some small comments.
/wait
| useful in support systems such as CI, CD, etc. The | ||
| :ref:`schema validator check tool <install_tools_schema_validator_check_tool>` has been added | ||
| to the tools image. | ||
| * udp_proxy: added :ref:`matcher <envoy_v3_api_field_extensions.filters.udp.udp_proxy.v3.UdpProxyConfig.matcher>` to support matching and routing to different clusters. |
There was a problem hiding this comment.
Please add a note in deprecated below for the deprecated field.
| Network::Address::InstanceConstSharedPtr source_address) const PURE; | ||
|
|
||
| /** | ||
| * Returns all cluster names in the router. The UDP proxy filter requires every cluster names for |
There was a problem hiding this comment.
| * Returns all cluster names in the router. The UDP proxy filter requires every cluster names for | |
| * Returns all cluster names in the router. The UDP proxy filter requires every cluster name for |
| RouterImpl::RouterImpl(const envoy::extensions::filters::udp::udp_proxy::v3::UdpProxyConfig& config, | ||
| Server::Configuration::ServerFactoryContext& factory_context) { | ||
| if (config.has_cluster()) { | ||
| cluster_ = config.cluster(); |
There was a problem hiding this comment.
I think it would be a bit cleaner to just synthesize matcher config for this case. Then you can use unified code for the rest of it? (Basically it makes the deprecated path cheaper to maintain and understand as the only special case is here.)
There was a problem hiding this comment.
I am sorry but I cannot catch your idea here. Do you mention we can move cluster_ out of Router?
There was a problem hiding this comment.
Ok, I catch your thought finally, I will submit the commit soon.
| return cluster_.value(); | ||
| } | ||
|
|
||
| if (source_address->ip()) { |
There was a problem hiding this comment.
Technically isn't it possible to send UDP/datagrams over a pipe? Or do we block this in config? Either way it seems like this should be handled elsewhere as a config load issue vs. on every route request?
There was a problem hiding this comment.
Yes, it is redundant. I will remove it, thanks.
| return; | ||
| } | ||
|
|
||
| ENVOY_LOG(debug, "udp proxy: detaching from cluster {}", cluster); |
There was a problem hiding this comment.
nit: this log is now misleading. I would see if the cluster is used before logging and erasing? If you store an iterator the perf delta will be negligible.
| route(Network::Address::InstanceConstSharedPtr destination_address, | ||
| Network::Address::InstanceConstSharedPtr source_address) const PURE; |
There was a problem hiding this comment.
nit: I would pass by const ref to avoid shared_ptr inc/dec
There was a problem hiding this comment.
Ok, I will make them const.
By the way, InstanceConstSharedPtr is a shared_ptr<const Instance>. I think it is not necessary to change to a const ref since the const Instance cannot be changed.
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks LGTM other than small comment and fixing CI.
/wait
| virtual const std::string | ||
| route(Network::Address::InstanceConstSharedPtr destination_address, | ||
| Network::Address::InstanceConstSharedPtr source_address) const PURE; | ||
| route(const Network::Address::InstanceConstSharedPtr destination_address, |
There was a problem hiding this comment.
Sorry I meant const Network::Address::Instance&
There was a problem hiding this comment.
In the caller method, we will get a InstanceConstSharedPtr. If we change the Router::route's signature to const Network::Address::Instance&, we have to change the code in the caller to
const std::string& route = config_->route(*data.addresses_.local_, *data.addresses_.peer_); Do you think it is acceptable?
There was a problem hiding this comment.
Fixed, I have updated all methods in the caller chain.
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
|
It is strange that the patch does not touch any codes in /retest |
|
Retrying Azure Pipelines: |
|
Flaky macOS test. /retest |
|
Retrying Azure Pipelines: |
This reverts commit 90a1d4b. Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Signed-off-by: Xie Zhihao zhihao.xie@intel.com
Commit Message: udp: add router for UDP proxy
Additional Description: match and route UDP datagrams to different clusters
Risk Level: Medium
Testing: Unit and integration
Docs Changes: UDP proxy example configuration
Release Notes: Added
Platform Specific Features: N/A
Fixes #17652