fix(pd): resolve hostname entries in IpAuthHandler allowlist#2962
fix(pd): resolve hostname entries in IpAuthHandler allowlist#2962bitflicker64 wants to merge 2 commits intoapache:masterfrom
Conversation
…at startup to avoid Netty DNS blocking
|
How I tested:
Results with pd2 as leader and hostnames only: Before this fix: After this fix: Hostnames are resolved to IPs at startup via |
There was a problem hiding this comment.
Pull request overview
Fixes PD Raft inbound connection allowlisting when the configured allowlist contains hostnames (e.g., Docker bridge service names) by resolving those hostnames to IPs up front and validating connections via a simple set lookup.
Changes:
- Resolve allowlist entries via
InetAddress.getAllByName()at handler construction time - Cache resolved IPs in an immutable
Setused byisIpAllowed() - Log a warning when an allowlist hostname can’t be resolved
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/auth/IpAuthHandler.java
Show resolved
Hide resolved
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/auth/IpAuthHandler.java
Show resolved
Hide resolved
…r changes - Resolve allowlist hostnames to IPs using InetAddress.getAllByName - Add refresh() to update resolved IPs when Raft peer list changes - Wire refresh into RaftEngine.changePeerList() - Add IpAuthHandlerTest covering hostname resolution, refresh behavior, and failure cases
|
While working on this change, I noticed a couple of related behaviors that appear to predate this PR. The /v1/members/change endpoint relies on RestAuthentication, where Authentication.authenticate() currently validates only the username portion of Basic Auth. I also noticed that GrpcAuthentication does not appear to be wired into the gRPC server. These are outside the scope of this fix, but I thought it might be helpful to mention in case they are worth tracking separately. |
Purpose of the PR
IpAuthHandleronly compared the client IP with the allowlist entries directly.When the allowlist contains hostnames, connections from their resolved IPs could be rejected.
Main Changes
InetAddress.getAllByNameSet.contains()lookupVerifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need