feat(http_server source): add unix domain socket support - #25960
feat(http_server source): add unix domain socket support#25960GobinathAL wants to merge 1 commit into
Conversation
Adds support for listening on Unix Domain Sockets (UDS) in the http_server source by introducing a `socket_path` config parameter, along with permissions/ownership settings.
|
All contributors have signed the CLA ✍️ ✅ |
|
🔗 Commit SHA: 8d9fa8f | Docs | Datadog PR Page | Give us feedback! |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d9fa8f3d1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }; | ||
|
|
||
| #[cfg(unix)] | ||
| use crate::sources::util::{change_socket_ownership, change_socket_permissions}; |
There was a problem hiding this comment.
Gate Unix helpers behind the net-unix feature
When building on Unix with an HTTP-prelude user such as sources-prometheus-remote-write or sources-prometheus-pushgateway, sources-utils-http compiles this file but those features do not enable sources-utils-net-unix in Cargo.toml. The helpers imported here are only re-exported from sources::util when sources-socket or sources-utils-net-unix is enabled, so those feature builds fail with unresolved imports even though they do not use UDS. Gate the new UDS code/imports on the same feature or move the dependency to the shared HTTP feature.
Useful? React with 👍 / 👎.
| let source = SimpleHttpConfig { | ||
| socket_path: Some(socket_path.clone()), | ||
| socket_file_mode: Some(0o660), | ||
| ..Default::default() |
There was a problem hiding this comment.
Clear the default address in the UDS test
This Unix test constructs a UDS config with ..Default::default(), but Default still sets address: Some(0.0.0.0:8080). Since build() calls validate_address() and rejects configs with both address and socket_path, the test panics before the Unix socket is bound; set address: None for this UDS configuration.
Useful? React with 👍 / 👎.
| #[test] | ||
| fn unix_socket_config_validation() { |
There was a problem hiding this comment.
Gate the validation test to Unix
On non-Unix targets this unconditional test fails in the first “valid config” case, because validate_address() deliberately returns an error whenever socket_path is configured on a non-Unix platform. Either add #[cfg(unix)] to this test or split out a non-Unix expectation so Windows CI does not fail on the new UDS-only assertion.
Useful? React with 👍 / 👎.
| let make_svc = make_service_fn(move |_conn: &tokio::net::UnixStream| { | ||
| let svc = ServiceBuilder::new() | ||
| .layer(build_http_trace_layer(span.clone())) | ||
| .service(warp::service(routes.clone())); |
There was a problem hiding this comment.
Honor keepalive limits for Unix sockets
For UDS listeners this service builder omits the MaxConnectionAgeLayer that the TCP branch applies just above, so keepalive.max_connection_age_secs (defaulting to 300 seconds) is ignored for HTTP/1.x clients connected over socket_path. A long-lived UDS client can therefore keep a connection open indefinitely despite the configured keepalive limit; apply the same layer here or explicitly reject/document the setting for UDS.
Useful? React with 👍 / 👎.
| let address = match (&self.address, &self.socket_path) { | ||
| (None, None) => Some(default_address()), |
There was a problem hiding this comment.
Reject configs without a listener
If a user omits both address and socket_path, this now silently falls back to 0.0.0.0:8080; before this change address was a required field, so the same typo/missing listener was rejected instead of opening a public TCP listener on the default port. Treat the (None, None) case as a validation error, or keep the default only for generated/example configs.
Useful? React with 👍 / 👎.
Adds support for listening on Unix Domain Sockets (UDS) in the http_server source by introducing a
socket_pathconfig parameter, along with permissions/ownership settings.Summary
Adds support for listening on Unix Domain Sockets (UDS) as an alternative to TCP in the http_server source. This enables receiving HTTP requests over local Unix sockets with fine-grained file permissions (socket_file_mode) and ownership (socket_file_uid, socket_file_gid) controls.
Resolves #22158.
Vector configuration
How did you test this PR?
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References