Description
Currently, the Go SDK client has been refactored (following PR #910) to use a deterministic IP selection rule when connecting to a Sandbox via the Router. In dual-stack environments, the Go client scans the Pod IPs list, prioritizes IPv4 addresses, and normalizes mapped IPv6 formats (e.g. ::ffff:10.0.0.1 to 10.0.0.1) for maximum compatibility with the downstream router's routing handler.
In contrast, the Python SDK (specifically k8s_agent_sandbox/sandbox.py:get_pod_ip) simply returns the first element of the status IPs (pod_ips[0]) without any family-specific prioritization or normalization. This can cause routing issues in dual-stack environments or when encountering mapped IPv6 addresses.
Proposed Changes
Align the Python SDK with the Go SDK's implementation of selectPodIP:
- Iterate over the status
podIPs list.
- Validate each IP string and prefer IPv4 addresses over IPv6.
- Normalize mapped IPv6 addresses (e.g.
::ffff:10.0.0.1 -> 10.0.0.1).
- Fall back to the first valid IP if no IPv4 is present.
- Add unit tests covering dual-stack IP prioritization and normalization cases in
test_sandbox.py.
Description
Currently, the Go SDK client has been refactored (following PR #910) to use a deterministic IP selection rule when connecting to a Sandbox via the Router. In dual-stack environments, the Go client scans the Pod IPs list, prioritizes IPv4 addresses, and normalizes mapped IPv6 formats (e.g.
::ffff:10.0.0.1to10.0.0.1) for maximum compatibility with the downstream router's routing handler.In contrast, the Python SDK (specifically
k8s_agent_sandbox/sandbox.py:get_pod_ip) simply returns the first element of the status IPs (pod_ips[0]) without any family-specific prioritization or normalization. This can cause routing issues in dual-stack environments or when encountering mapped IPv6 addresses.Proposed Changes
Align the Python SDK with the Go SDK's implementation of
selectPodIP:podIPslist.::ffff:10.0.0.1->10.0.0.1).test_sandbox.py.