Skip to content
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

[Logs agent] Disable HTTP/2 when using a proxy #32308

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/logs/client/http/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ func httpClientFactory(timeout time.Duration, cfg pkgconfigmodel.Reader) func()
var transport *http.Transport

transportConfig := cfg.Get("logs_config.http_protocol")

// If any proxy is set, use http1
// This will be removed in a future version
if cfg.GetProxies() != nil {
transportConfig = "http1"
}

// Configure transport based on user setting
switch transportConfig {
case "http1":
Expand Down
31 changes: 31 additions & 0 deletions pkg/logs/client/http/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,34 @@ func TestTransportProtocol_HTTP1FallBack(t *testing.T) {
// Assert that the server automatically falls back to HTTP/1.1
assert.Equal(t, "HTTP/1.1", resp.Proto)
}

func TestTransportProtocol_HTTP1WhenUsingProxy(t *testing.T) {
c := configmock.New(t)

// Force client to use ALNP
c.SetWithoutSource("logs_config.http_protocol", "auto")
c.SetWithoutSource("skip_ssl_validation", true)
remeh marked this conversation as resolved.
Show resolved Hide resolved

// The test server uses TLS, so if we set the http proxy (not https), it still makes
// a request to the test server, but disable HTTP/2 since a proxy is configured.
c.SetWithoutSource("proxy.http", "http://foo.bar")

server := NewTestHTTPSServer(false)
defer server.Close()

timeout := 5 * time.Second
client := httpClientFactory(timeout, c)()

req, err := http.NewRequest("POST", server.URL, nil)
if err != nil {
t.Fatalf("Failed to create request: %v", err)
}
resp, err := client.Do(req)
if err != nil {
t.Fatalf("Failed to send request: %v", err)
}
defer resp.Body.Close()

// Assert that the server chose HTTP/1.1 because a proxy was configured
assert.Equal(t, "HTTP/1.1", resp.Proto)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
features:
- |
Introduced a new configuration variable `logs_config.http_protocol`, allowing users to enforce HTTP/1.1 for outgoing HTTP connections in the Datadog Agent. This provides better control over transport protocols and improves compatibility with systems that do not support HTTP/2.
By default, the log agent will now attempt to use HTTP/2 and fall back to the best available protocol if HTTP/2 is not supported.
By default, the log agent will now attempt to use HTTP/2 (unless a proxy is configured) and fall back to the best available protocol if HTTP/2 is not supported.
enhancements:
- |
Improved logging to add visiblity for latency and transport protocol
Improved logging to add visibility for latency and transport protocol
Loading