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

Client transports no longer implement WrappedRoundTripper() #19885

Closed
liggitt opened this issue Jan 20, 2016 · 6 comments
Closed

Client transports no longer implement WrappedRoundTripper() #19885

liggitt opened this issue Jan 20, 2016 · 6 comments
Assignees
Labels
sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@liggitt
Copy link
Member

liggitt commented Jan 20, 2016

#16126 removed the implementations of WrappedRoundTripper() http.RoundTripper present in all of the client transports.

This is required to allow the proxy handlers to drill down and use the Dial and TLSConfig data in the innermost http.Transport when doing upgrade requests.

@krousey

@liggitt
Copy link
Member Author

liggitt commented Jan 20, 2016

This implementation depends on transports constructed from kubeconfig files conforming to the RoundTripperWrapper interface:

type RoundTripperWrapper interface {
    http.RoundTripper
    WrappedRoundTripper() http.RoundTripper
}

type DialFunc func(net, addr string) (net.Conn, error)

func Dialer(transport http.RoundTripper) (DialFunc, error) {
    if transport == nil {
        return nil, nil
    }

    switch transport := transport.(type) {
    case *http.Transport:
        return transport.Dial, nil
    case RoundTripperWrapper:
        return Dialer(transport.WrappedRoundTripper())
    default:
        return nil, fmt.Errorf("unknown transport type: %v", transport)
    }
}

@krousey
Copy link
Contributor

krousey commented Jan 20, 2016

Interesting. We can certainly add them back for now, but this seems like something that should be done another way. Why rely on a http.RoundTripper to supply a dialer and TLS config, especially when wrapping them is such a common idiom? Wouldn't it be better for the proxy/upgrade handlers to just know what Dialer and TLSConfig they should use instead of trying (and failing in this case) to discover from a naively wrapped http.RoundTripper?

@liggitt
Copy link
Member Author

liggitt commented Jan 20, 2016

The proxy code handles generically proxying/upgrading connections to node, pod, and service back ends. The transport to use is part of what is handed to the proxy code.

I'm fine with a refactor, but I'd like to unbreak this asap and work on a better solution at leisure. This is seen to have an effect when connecting to things with custom dialers like GKE and a tunneling dialer

@krousey
Copy link
Contributor

krousey commented Jan 20, 2016

Agreed whole-heartedly with quick fix + thinking about a better way. Are you doing this? Or should I?

FWIW this is a similar situation to http.Transport.CancelRequest(). People naively wrapped the round tripper, http.Client's Timeout would no longer worked. They ended up bypassing the need to type assert down to that method by adding a Cancel channel to the http.Request object.

@liggitt
Copy link
Member Author

liggitt commented Jan 20, 2016

Also, there are e2e tests that should have caught this, but they may have been conditionalized away in GKE :-/

@liggitt
Copy link
Member Author

liggitt commented Jan 20, 2016

If you can, I can do a quick review

@krousey krousey self-assigned this Jan 20, 2016
@alex-mohr alex-mohr added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

3 participants