fix: correct handling of endpointSlices in Kubernetes service discovery#12634
Merged
Conversation
Spelling error. post_List should be post_list
Baoyuantop
requested review from
AlinsRan,
bzp2010,
nic-6443,
nic-chen and
shreemaan-abhishek
December 29, 2025 07:41
nic-6443
reviewed
Jan 26, 2026
nic-6443
reviewed
Jan 26, 2026
nic-6443
reviewed
Jan 26, 2026
Contributor
Author
|
The code changes have been completed; please help review the code again. |
nic-chen
previously approved these changes
Jan 27, 2026
membphis
reviewed
Jan 27, 2026
| return | ||
| end | ||
|
|
||
| core.log.debug(core.json.delay_encode(endpoint_slice)) |
Member
There was a problem hiding this comment.
we can add more text to explain this error message
make it easier to understand
| return | ||
| end | ||
|
|
||
| core.log.debug(core.json.delay_encode(endpoint_slice)) |
nic-6443
previously approved these changes
Jan 28, 2026
nic-chen
previously approved these changes
Jan 28, 2026
teset case fix
membphis
approved these changes
Jan 28, 2026
nic-6443
approved these changes
Jan 28, 2026
nic-chen
approved these changes
Jan 28, 2026
wistefan
pushed a commit
to wistefan/apisix
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently, the Kubernetes service discovery implementation in APISIX incorrectly handles EndpointSlices, treating each individual slice as the complete set of endpoints for a service. This contradicts the official Kubernetes documentation.
According to the Kubernetes EndpointSlice documentation:
The correct behavior should be to combine all EndpointSlices sharing the same
kubernetes.io/service-namelabel to form the complete endpoint set for a service.Solution Approach
1. Add EndpointSlices Cache
endpoint_slices_cacheto store all EndpointSlices with the structure:endpoint_slices_cache["k8s_id/namespace/k8s_service_name:port_name"] = {slice1, slice2, ...}2. Code Refactoring
3. Some Bug Fixes
addressesfield: Theaddressesfield contains a list of IP strings, not objects with.ipattributesendpoint_bufferprocessing:endpoint_bufferuses ports as keys and node lists as values, requiring only a single iteration level.Checklist