feat(Python-client):add dns resolution support#2306
feat(Python-client):add dns resolution support#2306WJSGDBZ wants to merge 7 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds DNS resolution support to the Python Pegasus client to improve resilience when meta servers become unavailable. When meta server queries fail, the client now attempts to re-resolve DNS hostnames to obtain potentially updated IP addresses, allowing the client to recover from IP address changes without requiring a restart.
Key changes:
- DNS resolution capability for both IPv4 (A records) and IPv6 (AAAA records) hostnames
- Automatic re-resolution and stale session cleanup when all meta servers fail
- Enhanced host_port type system to distinguish between IPv4, IPv6, and mixed address groups
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python-client/pypegasus/pgclient.py | Implements DNS resolution logic, adds re-resolution on query failures, refactors meta server initialization to be asynchronous |
| python-client/pypegasus/base/ttypes.py | Updates host_port_types enum to include IPv6 type and reorder Group type |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
0c1a543 to
541fb52
Compare
|
@WJSGDBZ Could you please add some simple tests, and fix the conflicts |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Sure, I've already added the test process above. |
The conflict is still exist :( |
Thanks for the reminder, the conflict has been resolved. |
| continue | ||
|
|
||
| if has_ipv4 and has_ipv6: | ||
| return host_port_types.kHostTypeGroup |
There was a problem hiding this comment.
On the server side, kHostTypeGroup means that the host_port class stores a list of addresses. However, in the Python client it is defined as a mix of IPv4 and IPv6, which is inconsistent with the server-side definition. What is the rationale behind this design?
There was a problem hiding this comment.
@empiredan already fix this to be compatible with the server
What problem does this PR solve?
add dns resolution support
What is changed and how does it work?
When the Pegasus operation times out, it will attempt to fetch the topology from meta. If all meta servers fail to respond, it will try to re-resolve the DNS to obtain new IP addresses.
Checklist
Tests
Objective: Validate DNS resolution failover mechanism in
resolve_all_ipsfunction.Steps:
Modify
resolve_all_ipsto force initial DNS resolution to Onebox (127.0.0.1).when client fail to query server after 5 times, dns-resolve will be trigger.
second in resolve_all_ips , it will truly resolve hostname to ip address, and start to query real server.
Real test process as follow