-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: Bind metrics, REST registry, ui, and lineage servers dual-stack #6886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
140d837
a7fe15b
63c5b6d
2531291
e769fd0
3c93662
2ce805a
202fde8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
start_server (ui_server.py) and start_lineage_server (lineage_server.py) both call uvicorn.run(app, host=host, port=port) directly. A plain host="::" there binds IPv6-only -- asyncio's loop.create_server sets IPV6_V6ONLY=1 on any socket it creates itself from a host string -- which silently drops IPv4 clients on every host, not just IPv6-less ones. This is the same bug the metrics and REST registry servers had, fixed separately on fix/sdk-dual-stack-binds. Add feast.utils._make_dual_stack_socket(port), a shared version of _make_rest_socket's pre-bound-socket approach, and route both servers through it when host == "::": build the socket with IPV6_V6ONLY cleared and hand it to uvicorn.Server(config).run(sockets=[sock]) instead of uvicorn.run(host=...). Any other host keeps today's plain uvicorn.run behavior unchanged. This closes the gap the Operator's dualStack option (feat/operator-dual-stack) depends on: without this fix, enabling dualStack for the ui/lineage services would have silently regressed their IPv4 reachability instead of adding IPv6. Signed-off-by: dbbvitor <vitor.diniz@gympass.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,6 +80,31 @@ def _ipv6_available() -> bool: | |
| return False | ||
|
|
||
|
|
||
| def _make_dual_stack_socket(port: int) -> socket.socket: | ||
| """Build a listening socket bound dual-stack ("::") when the host supports | ||
| IPv6, or IPv4-only ("0.0.0.0") otherwise (e.g. ``ipv6.disable=1`` kernels). | ||
|
|
||
| A plain ``host="::"`` passed to a framework's own server (uvicorn's | ||
| ``uvicorn.run``, asyncio's ``loop.create_server``) gets ``IPV6_V6ONLY=1`` | ||
| set on the socket it creates for itself, which silently drops IPv4 | ||
| clients on every host, not just IPv6-less ones. Binding the socket here, | ||
| with ``IPV6_V6ONLY`` explicitly cleared, and handing it to the server | ||
| pre-built avoids that. | ||
| """ | ||
| if _ipv6_available(): | ||
| sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) | ||
| sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) | ||
| address: tuple = ("::", port) | ||
| else: | ||
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
| address = ("0.0.0.0", port) | ||
| sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||
| sock.bind(address) | ||
| sock.listen(socket.SOMAXCONN) | ||
| sock.setblocking(False) | ||
| return sock | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Socket leak: if try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(address)
sock.listen(socket.SOMAXCONN)
sock.setblocking(False)
except:
sock.close()
raise
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try-except pattern adopted |
||
|
|
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the |
||
| def _parse_feature_or_view_ref(ref: str) -> Tuple[str, Optional[int], Optional[str]]: | ||
| """Parse 'fv_name[@version][:feature]' into (fv_name, version_number, feature_name). | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.