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
Allow configuring DialContext for RoundTripper. #2963
Conversation
Hi @briantkennedy. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
Thanks @briantkennedy! /ok-to-test |
This seems reasonable to me, will defer to someone else for LGTM. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: briantkennedy, robscott The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
roundTripper = &roundtripper.DefaultRoundTripper{ | ||
Debug: options.Debug, | ||
TimeoutConfig: options.TimeoutConfig, | ||
CustomDialContext: options.RoundTripperDialContext, |
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.
I'm not sure CustomDialContext
belongs in the default without some kind of default value.
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.
Hi @candita, thanks for the comment. Please correct me if I'm wrong, but according to the http.Transport
docs, a nil
DialContext
will result in the Dial method from the net
package being used.
https://pkg.go.dev/net/http#Transport
// DialContext specifies the dial function for creating unencrypted TCP connections.
// If DialContext is nil (and the deprecated Dial below is also nil),
// then the transport dials using package net.
//
// DialContext runs concurrently with calls to RoundTrip.
// A RoundTrip call that initiates a dial may end up using
// a connection dialed previously when the earlier connection
// becomes idle before the later DialContext completes.
RestConfig *rest.Config | ||
GatewayClassName string | ||
Debug bool | ||
RoundTripperDialContext func(context.Context, string, string) (net.Conn, error) |
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.
I believe you'll also want to add this to the ConformanceTestSuite. See 60d3e58 for an example in reverse.
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.
Leaving this value as nil
should preserve the existing behavior. Please refer to the other comment regarding default value.
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.
Options can be used to intialize a ConformanceTestSuite
, so you need to add RoundTripperDialContext
to ConformanceTestSuite
and make sure it gets populated from the ConformanceOptions
.
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.
Hi @candita, RoundTripperDialContext
is used for initializing a roundtripper.DefaultRoundTripper
on line 190 which is then added to ConformanceTestSuite
if the user has not provided a custom RoundTripper implementation. Given that this is only specific to the RoundTripper, it's not essential to incorporate this as a member of ConformanceTestSuite
since it will be present in ConformanceTestSuite.RoundTripper
. Please let me know if ConformanceOptions.RoundTripperDialContext
should have a docstring describing this behavior.
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.
I'm not sure I understand. You want to add this option but not allow it to be set to anything other than nil?
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.
HI @candita glad to explain the life of a RoundTripperDialContext
option:
- User configures a
ConformanceOptions
with a non-nilRoundTripperDialContext
. - User calls
NewConformanceTestSuite
with the configured (non-nil)RoundTripperDialContext
- sutie.go:190: a
roundtripper.DefaultRoundTripper
,roundTripper
, is constructed using the custom dial context if the user has not specified a round tripper implementation. - sutie.go:236:
roundTripper
is assigned toConformanceTestSuite.RoundTripper
which will be used for the conformance tests. - Conformance tests pass
ConformanceTestSuite.RoundTripper
tohttp.MakeRequestAndExpectEventuallyConsistentResponse
, eghttp.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, tc)
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.
The user can just set ConformanceOption.RoundTripper
with whatever dial context they want, correct? The option RoundTripperDialContext is not used by anything other than RoundTripper.
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.
Hi @candita, the default round tripper sets the TLS client config which other RoundTripper implementations would need to duplicate. Ideally this wouldn't be necessary if it's feasible to inject a custom dialer for this purpose.
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.
I personally think this could be a very useful option. In general I'd like to see as many people as possible be able to use our default/built-in roundtripper, and I think these kinds of options should help.
Synced offline on this one and decided to move forward with a different approach that would pass this option to the RoundTripper instead, something like this:
Closing this one out. |
What type of PR is this?
/kind test
/area conformance
What this PR does / why we need it:
Allows configuring DialContext for default round tripper.
Which issue(s) this PR fixes:
Fixes #2962
Does this PR introduce a user-facing change?: