fix(zrpc): skip not-ready endpoints in kube resolver by SulimanAbdulrazzaq · Pull Request #5786 · zeromicro/go-zero · GitHub
Skip to content

fix(zrpc): skip not-ready endpoints in kube resolver - #5786

Open
SulimanAbdulrazzaq wants to merge 2 commits into
zeromicro:masterfrom
SulimanAbdulrazzaq:fix/kube-resolver-not-ready
Open

SulimanAbdulrazzaq wants to merge 2 commits into
zeromicro:masterfrom
SulimanAbdulrazzaq:fix/kube-resolver-not-ready

Conversation

@SulimanAbdulrazzaq

Copy link
Copy Markdown

Fixes #5647

The kube resolver moved from the Endpoints API to EndpointSlices in #4987. Endpoints only listed ready addresses in subsets[].addresses (not-ready ones went to notReadyAddresses), but an EndpointSlice lists every endpoint and reports readiness in conditions. Since the migration, EventHandler adds every address, so terminating and not-ready pods are handed to gRPC as targets. During a rolling update clients keep dialing pods that are shutting down and get connection refused, as described in the issue.

This change skips endpoints whose Ready condition is false in OnAdd and Update. A nil Ready is treated as ready, as the EndpointSlice API asks consumers to do. Kubernetes reports terminating endpoints as not ready, so they are dropped too, which gives the same address set the Endpoints API used to publish. OnDelete is unchanged: it removes the slice's addresses whether or not they were ready.

Tests: TestAddSkipsNotReadyEndpoints and TestUpdateSkipsNotReadyEndpoints cover a ready endpoint, one with no Ready condition, a not-ready one and a terminating one. Both fail without the fix (the not-ready and terminating addresses are included) and pass with it. go test -race ./zrpc/resolver/... passes.

@kevwan
kevwan force-pushed the fix/kube-resolver-not-ready branch from f3d35e6 to e5d3a90 Compare September 25, 2026 15:37
SulimanAbdulrazzaq and others added 2 commits September 26, 2026 00:04
The kube resolver moved from the Endpoints API to EndpointSlices in
zeromicro#4987. Endpoints only listed ready addresses in subsets[].addresses, but
an EndpointSlice lists every endpoint and reports readiness in its
conditions, so terminating and not-ready pods were handed to gRPC as
targets. During a rolling update clients kept dialing pods that were
shutting down and got connection refused.

Only add endpoints whose Ready condition is true or unset, which is the
set Endpoints used to publish.

Fixes zeromicro#5647
@kevwan
kevwan force-pushed the fix/kube-resolver-not-ready branch from 70f4d32 to daecb0f Compare September 25, 2026 16:04
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

@SulimanAbdulrazzaq

Copy link
Copy Markdown
Author

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.

k8s resolver should filter terminating or unready EndpointSlice endpoints

2 participants