Skip to content

Define findListenerByPort to fix use_original_dst flag#493

Merged
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
kyessenov:listener_by_port
Feb 17, 2017
Merged

Define findListenerByPort to fix use_original_dst flag#493
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
kyessenov:listener_by_port

Conversation

@kyessenov
Copy link
Copy Markdown
Contributor

The listener socket address and getOriginalDst address do not match (0.0.0.0 vs link-local IP), causing an issue in finding a matching listener. The fix is to search by the port value alone for IP addresses. Since Envoy binds on all localhost addresses now, the function is well-defined for IP addresses.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

small nits otherwise looks good, thanks.

Network::Listener* ConnectionHandlerImpl::findListener(const std::string& socket_name) {
auto l = listeners_.find(socket_name);
Network::Listener* ConnectionHandlerImpl::findListenerByPort(uint32_t port) {
auto l = std::find_if(
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: given that the number of listeners is going to be tiny (or potentially even 1), I think using a list here is good. Can you just drop a small comment in that we are doing an O(N) scan here that won't work well for a large number of listeners and we may need to use a map in the future.

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.

added a comment

ActiveListenerPtr l(
new ActiveListener(*this, socket, factory, bind_to_port, use_proxy_proto, use_orig_dst));
listeners_.insert(std::make_pair(socket.localAddress()->asString(), std::move(l)));
listeners_.push_back(std::make_pair(socket.localAddress(), std::move(l)));
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: if you do emplace_back you can avoid std::make_pair, same below.

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

@mattklein123 mattklein123 merged commit abef64f into envoyproxy:master Feb 17, 2017
@kyessenov kyessenov deleted the listener_by_port branch February 17, 2017 08:29
lizan pushed a commit to lizan/envoy that referenced this pull request Jun 4, 2020
Signed-off-by: John Plevyak <jplevyak@gmail.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
**Commit Message**

This commit scaffolds the foundation for the Inference Extension API
[1]. The design documentation was merged in #492. The controller needs
to be started with `--enableInferenceExtension=true` to not break the
existing controller deployment where the Inference Extension CRDs are
not installed.

This commit doesn't implement the actual "metrics-aware" load balancing
and instead it just does the random routing out of given (resolved)
endpoints. The follow up implementations will add more advanced
algorithm while expanding the metrics interface that currently only
provides the setter APIs.

The summary of the implementation is:
* Added `kind` field to AIGatewayRouteRuleBackendRef so that it can
reference InferencePool.
* InferencePool.Spec.Selector is allowed to specify multiple
AIServiceBackend.
* When building up all the extproc config via filterapi.Config, the
controller reads the referenced InferencePool and its binding
InferenceModels, and group them together into a single
filterapi.DynamicLoadBalancing configuration.
* When the extproc loads the configuration containing
DynamicLoadBalancing, it will resolve all the IP addresses for hostnames
belonging to the DyanmicLoadbalancing. The presence of
DynamicLoadBalancing in th config forces the config watcher reload and
refresh the config regardless of the updates. That way, the list of ip
addresses will always be updated (eventual consistency anyways) in a
non-hot path.
* On the request path, the ChatCompletionProcessor will check the
existence of the DynamicLoadBalancing config for the backend selected by
the router. If so, it further tries to resolve the ip:port level
endpoint selection.
* The selected ip:port will be set to the special header that will be
routed to ORIGINAL_DST.
* ORIGINAL_DST cluster will be added by the EG extension sever
implementation. Also, the extension server modifies some routes to
properly route to that cluster.

1: https://github.com/kubernetes-sigs/gateway-api-inference-extension

**Related Issues/PRs (if applicable)**

Built on #492
Contributes to #423

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.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.

2 participants