Repository navigation
refactor(storage): use s2a-go v0.1.11 NextProtos and share S2A dialer - #5133
anushka567 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the github.com/google/s2a-go dependency to v0.1.11 and refactors S2A dialer configuration by introducing helper functions newS2AClientOptions and newS2ADialTLSContextWithDialer to ensure HTTP/1.1 connections respect base dialer settings. Unit tests have also been added to verify these changes. The reviewer suggests unifying the dialer creation for both HTTP/1.1 and HTTP/2 to ensure base dialer settings (like local socket address and DNS cache) are consistently applied and to avoid recreating the TLS client config factory on every dial.
ed1ddf1 to
6bddd3b
Compare
s2a-go v0.1.11 (google/s2a-go#161) adds ClientOptions.NextProtos, so a client can choose the ALPN protocols offered during the S2A TLS handshake instead of always offering "h2". Upgrade to v0.1.11 and set ClientOptions.NextProtos = []string{"http/1.1"} when clientProtocol is http1, replacing the workaround that overwrote tlsConfig.NextProtos after factory.Build. With ALPN configured via ClientOptions, http1 and http2 can share a single S2A dialer helper (newS2ADialTLSContext) that opens its TCP connection with the base net.Dialer. Previously http2 called s2a.NewS2ADialTLSContextFunc, which dials with a zero-value net.Dialer, and http.Transport ignores DialContext for HTTPS once DialTLSContext is set; sharing the helper keeps --experimental-local-socket-address and --enable-http-dns-cache working for both http1 and http2 when S2A is enabled.
6bddd3b to
75307d4
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request upgrades the github.com/google/s2a-go dependency to v0.1.11 and refactors the S2A dialer setup in client.go. It unifies the S2A TLS dialer creation for both HTTP/1.1 and HTTP/2 protocols under a single newS2ADialTLSContext function, ensuring that the underlying TCP connection is opened using the configured base dialer. This preserves features like local socket addresses and HTTP DNS caching when S2A is enabled. Additionally, the unit tests have been expanded to verify dial behavior for both protocols. There are no review comments, so we have no feedback to provide.
Description
s2a-go v0.1.11 (google/s2a-go#161) adds
ClientOptions.NextProtos/TLSClientConfigOptions.NextProtos, so a client can choose the ALPN protocols offered during the S2A TLS handshake instead of always offeringh2. This PR:github.com/google/s2a-gofrom v0.1.10 to v0.1.11.s2aClientOptions.NextProtos = []string{"http/1.1"}whenclient-protocolishttp1, replacing the post-BuildtlsConfig.NextProtosoverwrite from feat: add direct S2A authentication support for HTTP and gRPC transports #5112.newS2ADialTLSContextForHTTP1tonewS2ADialTLSContextand uses it for bothhttp1andhttp2.http.Transport.DialTLSContextis set,DialContextis not used for HTTPS requests, ands2a.NewS2ADialTLSContextFuncalways dials with a zero-valuenet.Dialer.http2calleds2a.NewS2ADialTLSContextFunc, which silently dropped--experimental-local-socket-address(dialer.LocalAddr) and--enable-http-dns-cache(dialer.Resolver, enabled by default) when S2A was enabled. SharingnewS2ADialTLSContextkeeps both settings working acrosshttp1andhttp2and removes thehttp1/http2dialer branch.Link to the issue in case of a bug fix.
NA. Follow-up to #5112.
Testing details
--s2a-address,--s2a-spiffe-id,--token-url, and defaultclient-protocol(http1) withenable-http-dns-cacheat its defaulttrue.File system has been successfully mounted.and the gcsfuse logs had no HTTP errors.NextProtos = []string{http1ALPNProto}assignment removed so s2a-go falls back to offeringh2, the write returnedInput/output errorand every JSON API request failed with:go test -count=1 ./internal/storage/...passes, withTestCreateHttpClientWithS2A_DialVerificationnow parameterized over bothhttp1andhttp2.Any backward incompatible change? If so, please explain.
No. The
http1S2A path still offers onlyhttp/1.1, andhttp2with S2A now honors--experimental-local-socket-addressand--enable-http-dns-cachejust likehttp1.