Skip to content

fix(zrpc): clarify Kubernetes EndpointSlice RBAC errors - #5710

Open
014-code wants to merge 5 commits into
zeromicro:masterfrom
014-code:fix/k8s-endpointslice-rbac-error
Open

014-code wants to merge 5 commits into
zeromicro:masterfrom
014-code:fix/k8s-endpointslice-rbac-error

Conversation

@014-code

@014-code 014-code commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #5617.

The Kubernetes RPC resolver already supports k8s://<namespace>/<service>:<port>, but when the client service account lacks permission to read EndpointSlices, the old error was misleading and looked like the service was not started.

This PR improves that failure path by wrapping EndpointSlice list errors with a clearer message that points to the required RBAC permissions on endpointslices.discovery.k8s.io (get, list, watch).

It also adds a short Kubernetes RPC discovery note to readme.md with the target format and the minimal RBAC example.

Tests

  • go test ./zrpc/...
  • go test ./zrpc/resolver/internal -run 'TestKubeBuilder|TestWrapEndpointSliceListError' -count=1

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan
kevwan requested a lite review from Copilot August 9, 2026 07:06
@kevwan
kevwan force-pushed the fix/k8s-endpointslice-rbac-error branch from 41411bf to 45a0695 Compare August 9, 2026 07:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Kubernetes (k8s://) zrpc resolver failure mode when EndpointSlice access is denied, making RBAC-related discovery failures easier to diagnose, and adds a brief README note documenting Kubernetes RPC discovery and required permissions.

Changes:

  • Wrap EndpointSlice list “forbidden” errors with a clearer, RBAC-focused message (including required permissions).
  • Refactor a few kube-builder dependencies behind package-level vars to enable targeted unit testing.
  • Document Kubernetes RPC discovery target format and minimal EndpointSlice RBAC rules in readme.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
zrpc/resolver/internal/kubebuilder.go Wraps EndpointSlice list RBAC errors with a clearer message and adds small seams to improve testability.
zrpc/resolver/internal/kubebuilder_test.go Adds unit tests covering the new error-wrapping behavior and injected failure paths.
readme.md Adds a short section describing Kubernetes RPC discovery target format and minimal EndpointSlice RBAC permissions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread zrpc/resolver/internal/kubebuilder_test.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.

Bug: In some released go-zero version, RPC service discovery failed in a k8s environment

3 participants