Skip to content

Amend the endpoint picker protocol to support multiple fallback endpoints #761

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

wbpcode
Copy link

@wbpcode wbpcode commented Apr 30, 2025

Part of #414

  1. This PR extend value format of x-gateway-destination-endpoint to support multiple endpoints.
  2. The new format could support mutliple fallback endpoints.
  3. The new format is compatible with previous format becase the previous format could be treat a speical case of new format.
  4. This will simplify the proxy implementation. The proxy needn't to handle different endpoint sources.
  5. This will simplify the EPP implementation because the EPP needn't to set different endpoint sources.
  6. It's possible to specify the fallback endpoints by HTTP header now.

Copy link

linux-foundation-easycla bot commented Apr 30, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot requested review from ahg-g and danehans April 30, 2025 13:30
@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 30, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @wbpcode!

It looks like this is your first PR to kubernetes-sigs/gateway-api-inference-extension 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gateway-api-inference-extension has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 30, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @wbpcode. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 30, 2025
Copy link

netlify bot commented Apr 30, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 6a3c8f6
🔍 Latest deploy log https://app.netlify.com/sites/gateway-api-inference-extension/deploys/6822c0369eba680009f39f78
😎 Deploy Preview https://deploy-preview-761--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@wbpcode wbpcode force-pushed the dev-multiple-fallback-support branch from 77fbe07 to c62d3b3 Compare April 30, 2025 13:34
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 30, 2025
@wbpcode
Copy link
Author

wbpcode commented Apr 30, 2025

When I am reviewing the related Envoy implementation of this EPP (envoyproxy/envoy#38757), I found the current design only support single fallback endpoint. That inspire me to create this PR.

And if we want to support multiple fallback endpoints, the EPP must send a list of addresses to proxy. If there must be a list of addresses, i think it would be better to make the x-gateway-destination-endpoint a list directly. Then we needn't break the list into different two headers or metadata entries.

And from the proxy's pespective, I will prefer only one source to get the external specfied endpoints. And the proxy could iterate the endpoints list in order and select the first valid one. If the retrying happens, the proxy could continue the iteration from the position where it stop last time.

cc @yanavlasov

@ahg-g
Copy link
Contributor

ahg-g commented Apr 30, 2025

/assign @LiorLieberman for review

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 30, 2025
@ahg-g
Copy link
Contributor

ahg-g commented Apr 30, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 30, 2025
@LiorLieberman
Copy link
Member

/cc

@k8s-ci-robot k8s-ci-robot requested a review from LiorLieberman May 1, 2025 00:42
Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

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

Thanks @wbpcode!

Question - how would it work with an implementation that leverage envoy subsets?

For ref - see the istio implementation of this API

@wbpcode
Copy link
Author

wbpcode commented May 1, 2025

Thanks @wbpcode!

Question - how would it work with an implementation that leverage envoy subsets?

For ref - see the istio implementation of this API

Sorry,I am not allowed to access the doc. But I think it is impossible for subset lb based solution to support multiple fallback endpoints. That's say, if the istio's implementation is used, then the EPP couldn't support multiple fallback endpoints anyway and the legacy format should be used. And I believe the subset lb based solution couldn't support retrying also. (The problem is similar with the original dst based solution.)

I will also suggest the istio to update the implementation to use the new override host lb.


From the reference document, seems it's an experimental implementation and hasn't implemented the fallback mechanism, so I think it's possible to take the retrying and multiple fallback endpoints into account at this timepoint.

@wbpcode
Copy link
Author

wbpcode commented May 1, 2025

I think another alternative is to define a new key like x-gateway-destination-endpoints for both primary host and multiple fallback endpoints. But anyway, the EPP may need additional switch to enable fallback endpoints or not, it is possible to keep compatibility with the implementation detail of istio.


The istio haven't release this feature and I think it's possible to switch subset lb to the override host lb in the future.

}
```

Single fallback endpoint also CAN be set using the key `x-gateway-destination-endpoint-fallback` in the same metadata namespace as one used for `x-gateway-destination-endpoint` as follows:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the EPP still support x-gateway-destination-endpoint-fallback if x-gateway-destination-endpoint now supports endpoint fallback by listing multiple addresses? cc: @ahg-g @kfswain

Copy link
Author

@wbpcode wbpcode May 2, 2025

Choose a reason for hiding this comment

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

Is the API break change acceptable or is there a way to deprecate the x-gateway-destination-endpoint-fallback? Ideally, the EPP should has a flag to enable the new format or use the legacy format. And then we can deprecate the legacy format gradually.

- Setting different value leads to unpredictable behavior because proxies aren't guaranteed to support both paths, and so this protocol does not define what takes precedence.

### Destination endpoint fallback
A single fallback endpoint CAN be set using the key `x-gateway-destination-endpoint-fallback` in the same metadata namespace as one used for `x-gateway-destination-endpoint` as follows:

For each HTTP request, if destination endpoint fallback is necessary or possible, the EPP CAN set the `x-gateway-destination-endpoint` HTTP header or metadata entry with multiple addresses in `<ip:port>,<ip:port>,...` format. Multiple addresses are separated by commas. The first valid endpoint in the addresses list will be used as the primary endpoint. And if retrying is happening, the proxy will try the endpoints after the selected endpoint in order.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we continue to have this subsection or update the ## Destination Endpoint section to state that one address MUST be set or multiple addresses CAN be set for fallback purposes? Thoughts @ahg-g @kfswain?

Copy link
Author

Choose a reason for hiding this comment

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

SGTM.

Copy link
Author

Choose a reason for hiding this comment

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

I have updated content of the ## Destination Endpoint section.

The value of the header or metadata entry MUST contains at least one endpoint in `<ip:port>` format or multiple endpoints in `<ip:port>,<ip:port>,...` format. Multiple endpoints are separated by commas. The first valid endpoint in the value will be used. And if retrying is happening, the proxy will try the endpoints after the previously selected endpoint in order.

The x-gateway-destination-endpoint-fallback is still be kept for backward compatibility.

- Setting different value leads to unpredictable behavior because proxies aren't guaranteed to support both paths, and so this protocol does not define what takes precedence.

### Destination endpoint fallback
A single fallback endpoint CAN be set using the key `x-gateway-destination-endpoint-fallback` in the same metadata namespace as one used for `x-gateway-destination-endpoint` as follows:

For each HTTP request, if destination endpoint fallback is necessary or possible, the EPP CAN set the `x-gateway-destination-endpoint` HTTP header or metadata entry with multiple addresses in `<ip:port>,<ip:port>,...` format. Multiple addresses are separated by commas. The first valid endpoint in the addresses list will be used as the primary endpoint. And if retrying is happening, the proxy will try the endpoints after the selected endpoint in order.

Choose a reason for hiding this comment

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

Note that this is a breaking change that will impact the Istio implementation at least, which is based on Envoy LB subsetting and requires a single value to be specified.

Adding @LiorLieberman for feedback.

Copy link
Author

Choose a reason for hiding this comment

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

From API's perspective, this is not a break change. But if take the implementation detail into account, this actually may break the istio implementation. But ideally, we should have a flag to enable the new format or use legacy format in the EPP.

Copy link
Member

Choose a reason for hiding this comment

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

left a comment below

Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

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

The istio haven't release this feature and I think it's possible to switch subset lb to the override host lb in the future.

Its definitely possible to switch. I assume you are talking about envoyproxy/envoy#38757 ?

Will need to to catch up with this PR its been a month or two since I last look at it.

This PR is not even merged yet though - whats the timeline to get it a non experimental API in envoy?

@wbpcode
Copy link
Author

wbpcode commented May 6, 2025

The istio haven't release this feature and I think it's possible to switch subset lb to the override host lb in the future.

Its definitely possible to switch. I assume you are talking about envoyproxy/envoy#38757 ?

Will need to to catch up with this PR its been a month or two since I last look at it.

This PR is not even merged yet though - whats the timeline to get it a non experimental API in envoy?

We hope the envoyproxy/envoy#38757 could be used to support EPP with multiple fallback endpionts and retrying support.

If we can get agreement with the multiple addresses header/metadata format (<ip>:<port>,<ip>:<port>,..., no matter which key is used), I think it will be pretty quick for Envoy to merge that (may be only one or two weeks, I will discuss that with @yanavlasov)

@wbpcode
Copy link
Author

wbpcode commented May 9, 2025

cc @LiorLieberman The override host lb is merged and will be released at next envoy major version. :)

With the new override host lb, both the legacy format and the new format could be supported. With following configuration, all the endpoints will be joined as an endpoints list. The first valid endpoint will be used. And if retrying is happening, the proxy will try the endpoints after the previously selected endpoint in order.

By this way, multiple fallback endpoints, retrying could be supported. And it's compatible to the legacy format (every header/metadata contains only one endpoint).

override_host_sources:
- header: "x-gateway-destination-endpoint"
- metadata:
    key: "envoy.lb"
    path:
    - key: "x-gateway-destination-endpoint"
- header: "x-gateway-destination-endpoint-fallback"
- metadata:
    key: "envoy.lb"
    path:
    - key: "x-gateway-destination-endpoint-fallback"

or

override_host_sources:
- header: "x-gateway-destination-endpoint"
- header: "x-gateway-destination-endpoint-fallback"

or

override_host_sources:
- header: "x-gateway-destination-endpoint"

Signed-off-by: wangbaiping(wbpcode) <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 9, 2025
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
@LiorLieberman
Copy link
Member

LiorLieberman commented May 9, 2025

Thanks, will take a deeper look tmrw. FTR I opened istio/istio#56230 and cc'd you earlier today.

Also https://docs.google.com/document/d/1F82G_o3ENM94Imx5pYKG0x-m508_FSJyfbu1d8J8CCk/edit which is still in early stages (you will need to be either istio or dev@Kubernetes to view it)

Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

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

I am going to take this proposal with other istio folks, hopefully we can converge on override_host_lb, but would like to get the feedback first.

@wbpcode To clarify - what is the benefit of supporting multiple keys in x-gateway-destination-endpoint as opposed to x-gateway-destination-endpoint-fallback or -fallback*s*?

  1. This will simplify the proxy implementation. The proxy needn't to handle different endpoint sources.
  2. This will simplify the EPP implementation because the EPP needn't to set different endpoint sources.
  3. It's possible to specify the fallback endpoints by HTTP header now.

I dont see any major simplification by moving the fallbacks to x-gateway-destination-endpoint. I would in fact prefer to leave x-gateway-destination-endpoint a single value now, and in the future maybe evolve it to support some key:value map or list formatted values. For example one random idea in mind, x-gateway-destination-endpoint: zone-a:<ip:port>,zone-b:<ip-port> to support some version of topology. Is this too crazy?

@wbpcode
Copy link
Author

wbpcode commented May 10, 2025

To clarify - what is the benefit of supporting multiple keys in x-gateway-destination-endpoint as opposed to x-gateway-destination-endpoint-fallback or -fallbacks

The key benefit is the multiple fallback endpoints support. In the current proposal, only one primary endpoint and an optional fallback endpoint could be selected.

With the new format, the EPP server could select a list of endpoints and the proxy could try them one by one. And from the perspective of the API, this is a compatible change.

I dont see any major simplification by moving the fallbacks to x-gateway-destination-endpoint.

At the initial design of the override host lb, we designed a little complex API to support fallback endpoints. This is why I think moving the fallbacks to x-gateway-destination-endpoint could simplify the proxy implementation. But finally we resolved it in the new design.

But anyway, I still think single/clear/explicit endpoints source would be helpful for both proxy and EPP server.

I would in fact prefer to leave x-gateway-destination-endpoint a single value now, and in the future maybe evolve it to support some key:value map or list formatted values. For example one random idea in mind, x-gateway-destination-endpoint: zone-a:ip:port,zone-b: to support some version of topology. Is this too crazy?

If there is reasonable requirement, I think it's fine to support more complex format in the future. But considering the fact the <ip:port> basically is the most fine-grained unit, I didn't get why the zone make sense here?

Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

why do we need 2 lists of endpoints? I would expect either a single endpoint + fallback OR a list of endpoints, but not 2 lists?

@@ -58,7 +60,16 @@ dynamicMetadata: {
}
```

### Why envoy.lb namespace as a default?
The endpoints specified in `x-gateway-destination-endpoint-fallback` MAY be tried after the endpoints specified in `x-gateway-destination-endpoint` if all the endpoints specified in `x-gateway-destination-endpoint` are unavailable.
Copy link
Contributor

Choose a reason for hiding this comment

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

When x-gateway-destination-endpoint defines more than one IP:Port, the additional entries act as a fallback, correct? If so, why is x-gateway-destination-endpoint-fallback still needed?

Copy link
Author

Choose a reason for hiding this comment

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

it's unnecessary, but not sure if it's ok or not to remove it directly from the proposal. I will removed it first.

@wbpcode
Copy link
Author

wbpcode commented May 13, 2025

why do we need 2 lists of endpoints? I would expect either a single endpoint + fallback OR a list of endpoints, but not 2 lists?

Yeah. I think we all prefer the only one list of endpoints. In the format, Only the x-gateway-destination-endpoint could be a list of endpoints and the x-gateway-destination-endpoint-fallback is only be kept for API backward compatibility.


I have removed the x-gateway-destination-endpoint-fallback according to comments from @danehans @howardjohn

wbpcode added 2 commits May 13, 2025 11:42
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
@danehans
Copy link
Contributor

Only the x-gateway-destination-endpoint could be a list of endpoints and the x-gateway-destination-endpoint-fallback is only be kept for API backward compatibility.

@LiorLieberman, can you confirm whether x-gateway-destination-endpoint-fallback is still required by the Istio implementation? If so, @wbpcode, we can mark it as deprecated and remove it in a future release.

Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

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

If there is reasonable requirement, I think it's fine to support more complex format in the future. But considering the fact the ip:port basically is the most fine-grained unit, I didn't get why the zone make sense here?

Theoretically the API can evolve to support something like "this is the best endpoint in this zone" (or any other topology key). Thats what I was referring to.

@LiorLieberman, can you confirm whether x-gateway-destination-endpoint-fallback is still required by the Istio implementation? If so, @wbpcode, we can mark it as deprecated and remove it in a future release.

Istio does not support this key currently, so it is safe from this perspective. But would be good to check with all implementations of this API, last time we had a breaking change in the EPP istio release could not function.

If you all in agreement that one list is better than two, I am fine with that. I thought a different key is slightly cleaner and leaves more room for expansion but this opinion is not very strong.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiorLieberman, wbpcode
Once this PR has been reviewed and has the lgtm label, please assign jeffwan for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@danehans
Copy link
Contributor

@ahg-g, since you applied the hold, PTAL now that @LiorLieberman provided feedback.

cc: @arkodg and @kfswain to confirm whether Envoy Gateway uses x-gateway-destination-endpoint-fallback.

@wbpcode
Copy link
Author

wbpcode commented May 19, 2025

friendly ping @ahg-g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants