-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
add a DIalContext function to SpdyRoundTripper #112848
add a DIalContext function to SpdyRoundTripper #112848
Conversation
Hi @tzneal. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I found #109135 after running into this problem, coding this up and looking for an issue to link the PR to. I had written some additional tests and that PR has merge conflicts, so I submitted this PR. |
89f2a52
to
7131d36
Compare
/assign @aojea |
can you split the changes in 2 different commits?
|
Sure, two PRs or just two commits in the same PR? |
2 commits is fine /cc @enj |
/ok-to-test |
7131d36
to
d83d7f2
Compare
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Show resolved
Hide resolved
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Show resolved
Hide resolved
29a7242
to
a62621e
Compare
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper_test.go
Outdated
Show resolved
Hide resolved
a62621e
to
98f52bb
Compare
// This code is identical to tls.Dial but replicated here so we can | ||
// use our own DialContext function. | ||
tlsConfig := s.tlsConfig | ||
if tlsConfig == nil { | ||
tlsConfig = &tls.Config{} | ||
} | ||
|
||
// If no ServerName is set, infer the ServerName | ||
// from the hostname we're connecting to. | ||
if tlsConfig.ServerName == "" { | ||
tlsConfig = tlsConfig.Clone() | ||
colonPos := strings.LastIndex(dialAddr, ":") | ||
if colonPos == -1 { | ||
colonPos = len(dialAddr) | ||
} | ||
tlsConfig.ServerName = dialAddr[:colonPos] | ||
} |
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.
it's really unfortunate we have to duplicate this and manage handshaking ourselves... there's no way to use stdlib tls setup with a custom dialer?
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.
Agreed, but I don't see a way around it given the current state of things:
package tls
func Dial(network, addr string, config *Config) (*Conn, error) {
return DialWithDialer(new(net.Dialer), network, addr, config)
}
func DialWithDialer(dialer *net.Dialer, network, addr string, config *Config) (*Conn, error) {
return dial(context.Background(), dialer, network, addr, config)
}
func dial(ctx context.Context, netDialer *net.Dialer, network, addr string, config *Config) (*Conn, error) {
...
There's an issue golang/go#9360 that suggests using a standard dialer interface throughout the Go stdlib when only dial methods are used. I can't find any specific language that prohibits replacing a concrete type with an interface with respect to Go1 compatibility, but I suspect it's considered a breaking change as the issue is tagged v2.
98f52bb
to
ec11d37
Compare
New changes are detected. LGTM label has been removed. |
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/roundtripper.go
Outdated
Show resolved
Hide resolved
Add a DialContext function to SpdyRoundTripper and use it for creating underlying connections if supplied. Mark the exiting Dialer as deprecated. pr comments - Implement the ContextDialer interface - Add DialContext to spdy.RoundTripperConfig asd
client-go: pass dial function to the spdy upgrade This causes the spdy connection to be established with the dial function configured in the rest config.
ec11d37
to
36e5e1d
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tzneal The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@tzneal: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
If you still need this PR then please rebase, if not, please close the PR |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add a DIalContext function to SpdyRoundTripper and use it for creating underlying connections. Update remotecommand.RoundTripperFor to pass the rest.Config's Dial function to the SpdyRoundTripper.
Prior to this change, remotecommand.RoundTripperFor would ignore the Dial function set on the rest.Config.
Which issue(s) this PR fixes:
Fixes #112847
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: