Repository navigation
feat(kernel): expose HTTP/2 opt-out #580
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
base: main
Are you sure you want to change the base?
Changes from all commits
c3c8a7d
0122360
f2addf7
18d210b
e149e91
0960f51
4724cad
7b65079
fad2470
f8a5123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,6 +267,9 @@ | |
| if err := k.applyEnableGeoSpatialSupport(cfg); err != nil { | ||
| return err | ||
| } | ||
| if err := k.applyEnableHTTP2(cfg); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Retry / backoff policy (WithRetries). See applyRetry. | ||
| if err := k.applyRetry(cfg); err != nil { | ||
|
|
@@ -468,6 +471,18 @@ | |
| return nil | ||
| } | ||
|
|
||
| func (k *KernelBackend) applyEnableHTTP2(cfg *C.KernelSessionConfig) error { | ||
| if k.cfg.EnableHTTP2 == nil { | ||
| return nil | ||
| } | ||
| if err := call(func() C.KernelStatusCode { | ||
| return C.kernel_session_config_set_http2_enabled(cfg, C.bool(*k.cfg.EnableHTTP2)) | ||
|
Check failure on line 479 in internal/backend/kernel/backend.go
|
||
|
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. 🟠 High — The new cgo call references 🔀 Found by both reviewers · confirmed by the judge |
||
| }); err != nil { | ||
| return fmt.Errorf("kernel: set_http2_enabled: %w", toConnError(err)) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // applyRetry forwards the driver's HTTP retry / backoff policy to the session | ||
| // config. A no-op when Config.Retry is nil, so the kernel's own default policy | ||
| // (exponential backoff with jitter, 5 retries, 1s..60s, 900s budget) is preserved | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| //go:build cgo && databricks_kernel | ||
|
|
||
| package dbsql | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/pem" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "os" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| func TestKernelHTTP2Transport(t *testing.T) { | ||
| for _, name := range []string{"HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "ALL_PROXY", "all_proxy"} { | ||
| if os.Getenv(name) != "" { | ||
| t.Skipf("unset %s to test direct HTTP/2 negotiation", name) | ||
| } | ||
| } | ||
| cases := []struct { | ||
| name string | ||
| options []ConnOption | ||
| wantVersion int | ||
| }{ | ||
| {name: "default", wantVersion: 2}, | ||
| {name: "opt_out", options: []ConnOption{WithEnableHTTP2(false)}, wantVersion: 1}, | ||
| } | ||
| for _, tc := range cases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| versions := make(chan int, 4) | ||
| server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| versions <- r.ProtoMajor | ||
| w.Header().Set("Content-Type", "application/json") | ||
| _, _ = w.Write([]byte(`{"session_id":"http2-test"}`)) | ||
| })) | ||
| server.EnableHTTP2 = true | ||
| server.StartTLS() | ||
| defer server.Close() | ||
| ca := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: server.Certificate().Raw}) | ||
| options := []ConnOption{ | ||
| WithServerHostname(server.URL), | ||
| WithHTTPPath("/sql/1.0/warehouses/test"), | ||
| WithAccessToken("test-token"), | ||
| WithUseKernel(true), | ||
| WithKernelTrustedCerts(ca), | ||
| WithRetries(-1, 0, 0), | ||
| } | ||
| connector, err := NewConnector(append(options, tc.options...)...) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
| defer cancel() | ||
| connection, err := connector.Connect(ctx) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := connection.Close(); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| for range 2 { | ||
| select { | ||
| case got := <-versions: | ||
| if got != tc.wantVersion { | ||
| t.Fatalf("HTTP/%d received, want HTTP/%d", got, tc.wantVersion) | ||
| } | ||
| case <-ctx.Done(): | ||
| t.Fatal(ctx.Err()) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High — The new cgo call uses
kernel_session_config_set_http2_enabled, which this PR adds to the header by hand. go.mod still pins the bindings modules at v1.4.0 and the PR doesn't bump them or KERNEL_REV, so default kernel-tagged builds likely fail to link. Bump all seven bindings pins, update go.sum, sync KERNEL_REV, and use the published header.🔀 Found by both reviewers · confirmed by the judge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate of the release prerequisite at #580 (comment). This PR is blocked on the kernel #483 release; the seven bindings pins, go.sum and KERNEL_REV must be updated, and the complete header copied from that revision, before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still open at 1f2066d: the bindings are still pinned at v1.4.0 with no go.sum, KERNEL_REV or header sync. Keeping this open until the kernel #483 release lands.