Repository navigation
feat(gateway): Fallback to IPv4 when IPv6 is unavailable - #485
Closed
hossain-rayhan wants to merge 1 commit into
Closed
hossain-rayhan wants to merge 1 commit into
hossain-rayhan wants to merge 1 commit into
Conversation
Extract TCP listener binding into create_tcp_listener() and attempt IPv6 dual-stack ([::])) first, falling back to IPv4 (0.0.0.0) when IPv6 is not supported. This enables the gateway to run in environments without IPv6 support such as AKS Edge. Add unit tests covering all binding scenarios. Signed-off-by: Rayhan Hossain <[email protected]>
xgerman
approved these changes
Mar 5, 2026
guanzhousongmicrosoft
pushed a commit
to guanzhousongmicrosoft/documentdb
that referenced
this pull request
Mar 23, 2026
…s for environments without IPv6 ### Does this PR have any customer impact? Yes, unblock customers to run gateway on environment where with no ipv6 support like AKS Edge. ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Bugfix. ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ## Summary Implements dual IPv4/IPv6 TCP listener support for the OSS Rust gateway, enabling operation in environments where IPv6 is unavailable (e.g., AKS Edge). ## Changes - Added `create_tcp_listeners()` function that binds to both IPv4 (`0.0.0.0`) and IPv6 (`[::]`) addresses - Uses `IPV6_V6ONLY` socket option via `socket2` crate for consistent cross-platform behavior - Linux defaults to dual-stack (IPv6 socket accepts IPv4), Windows/macOS default to IPv6-only - Explicitly setting `IPV6_V6ONLY=true` ensures we need both listeners on all platforms - If one address family fails to bind, logs a warning and continues with the other - Returns an error only if both bindings fail - Refactored connection accept loop with `spawn_tcp_handler`/`spawn_unix_handler` helpers ## Behavior | Scenario | Result | |----------|--------| | Both IPv4 and IPv6 available | Both listeners active | | Only IPv4 available (no IPv6) | IPv4 listener active, warning logged | | Only IPv6 available | IPv6 listener active, warning logged | | Neither available | Error returned | ## Testing - Added 7 unit tests covering localhost, non-localhost, port assignment, partial failure, and total failure scenarios - All 19 existing tests pass ## Related - Follows pattern from documentdb#485 - Matches C# gateway dual-listener approach (`IPAddress.Any` + `IPAddress.IPv6Any`) Signed-off-by: Guanzhou Song <[email protected]>
guanzhousongmicrosoft
pushed a commit
to guanzhousongmicrosoft/documentdb
that referenced
this pull request
Mar 23, 2026
…s for environments without IPv6 ### Does this PR have any customer impact? Yes, unblock customers to run gateway on environment where with no ipv6 support like AKS Edge. ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Bugfix. ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ## Summary Implements dual IPv4/IPv6 TCP listener support for the OSS Rust gateway, enabling operation in environments where IPv6 is unavailable (e.g., AKS Edge). ## Changes - Added `create_tcp_listeners()` function that binds to both IPv4 (`0.0.0.0`) and IPv6 (`[::]`) addresses - Uses `IPV6_V6ONLY` socket option via `socket2` crate for consistent cross-platform behavior - Linux defaults to dual-stack (IPv6 socket accepts IPv4), Windows/macOS default to IPv6-only - Explicitly setting `IPV6_V6ONLY=true` ensures we need both listeners on all platforms - If one address family fails to bind, logs a warning and continues with the other - Returns an error only if both bindings fail - Refactored connection accept loop with `spawn_tcp_handler`/`spawn_unix_handler` helpers ## Behavior | Scenario | Result | |----------|--------| | Both IPv4 and IPv6 available | Both listeners active | | Only IPv4 available (no IPv6) | IPv4 listener active, warning logged | | Only IPv6 available | IPv6 listener active, warning logged | | Neither available | Error returned | ## Testing - Added 7 unit tests covering localhost, non-localhost, port assignment, partial failure, and total failure scenarios - All 19 existing tests pass ## Related - Follows pattern from documentdb#485 - Matches C# gateway dual-listener approach (`IPAddress.Any` + `IPAddress.IPv6Any`) Signed-off-by: Guanzhou Song <[email protected]>
guanzhousongmicrosoft
pushed a commit
to guanzhousongmicrosoft/documentdb
that referenced
this pull request
Mar 24, 2026
…s for environments without IPv6 ### Does this PR have any customer impact? Yes, unblock customers to run gateway on environment where with no ipv6 support like AKS Edge. ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Bugfix. ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ## Summary Implements dual IPv4/IPv6 TCP listener support for the OSS Rust gateway, enabling operation in environments where IPv6 is unavailable (e.g., AKS Edge). ## Changes - Added `create_tcp_listeners()` function that binds to both IPv4 (`0.0.0.0`) and IPv6 (`[::]`) addresses - Uses `IPV6_V6ONLY` socket option via `socket2` crate for consistent cross-platform behavior - Linux defaults to dual-stack (IPv6 socket accepts IPv4), Windows/macOS default to IPv6-only - Explicitly setting `IPV6_V6ONLY=true` ensures we need both listeners on all platforms - If one address family fails to bind, logs a warning and continues with the other - Returns an error only if both bindings fail - Refactored connection accept loop with `spawn_tcp_handler`/`spawn_unix_handler` helpers ## Behavior | Scenario | Result | |----------|--------| | Both IPv4 and IPv6 available | Both listeners active | | Only IPv4 available (no IPv6) | IPv4 listener active, warning logged | | Only IPv6 available | IPv6 listener active, warning logged | | Neither available | Error returned | ## Testing - Added 7 unit tests covering localhost, non-localhost, port assignment, partial failure, and total failure scenarios - All 19 existing tests pass ## Related - Follows pattern from documentdb#485 - Matches C# gateway dual-listener approach (`IPAddress.Any` + `IPAddress.IPv6Any`) Signed-off-by: Guanzhou Song <[email protected]>
guanzhousongmicrosoft
pushed a commit
that referenced
this pull request
Mar 26, 2026
…s for environments without IPv6 ### Does this PR have any customer impact? Yes, unblock customers to run gateway on environment where with no ipv6 support like AKS Edge. ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Bugfix. ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ## Summary Implements dual IPv4/IPv6 TCP listener support for the OSS Rust gateway, enabling operation in environments where IPv6 is unavailable (e.g., AKS Edge). ## Changes - Added `create_tcp_listeners()` function that binds to both IPv4 (`0.0.0.0`) and IPv6 (`[::]`) addresses - Uses `IPV6_V6ONLY` socket option via `socket2` crate for consistent cross-platform behavior - Linux defaults to dual-stack (IPv6 socket accepts IPv4), Windows/macOS default to IPv6-only - Explicitly setting `IPV6_V6ONLY=true` ensures we need both listeners on all platforms - If one address family fails to bind, logs a warning and continues with the other - Returns an error only if both bindings fail - Refactored connection accept loop with `spawn_tcp_handler`/`spawn_unix_handler` helpers ## Behavior | Scenario | Result | |----------|--------| | Both IPv4 and IPv6 available | Both listeners active | | Only IPv4 available (no IPv6) | IPv4 listener active, warning logged | | Only IPv6 available | IPv6 listener active, warning logged | | Neither available | Error returned | ## Testing - Added 7 unit tests covering localhost, non-localhost, port assignment, partial failure, and total failure scenarios - All 19 existing tests pass ## Related - Follows pattern from #485 - Matches C# gateway dual-listener approach (`IPAddress.Any` + `IPAddress.IPv6Any`) Signed-off-by: Guanzhou Song <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On systems without IPv6 support (e.g., AKS Edge), the gateway fails to
start because it unconditionally binds to
[::]. This change addsautomatic fallback to IPv4 (
0.0.0.0) when IPv6 binding fails.Changes
create_tcp_listener()function for testability.
[::]) first; if it fails, log a warning andfall back to IPv4 (
0.0.0.0).127.0.0.1) is unchanged.Testing
All new unit tests pass:
cargo test --lib -p documentdb_gateway_core -- tests::