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

add a DIalContext function to SpdyRoundTripper #112848

Closed

Conversation

tzneal
Copy link
Contributor

@tzneal tzneal commented Oct 4, 2022

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?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 4, 2022
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 4, 2022
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 4, 2022
@tzneal
Copy link
Contributor Author

tzneal commented Oct 4, 2022

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.

@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from 89f2a52 to 7131d36 Compare October 4, 2022 02:39
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Oct 4, 2022
@fedebongio
Copy link
Contributor

/assign @aojea
Antonio would you be able to take a look?
Thanks
/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 4, 2022
@aojea
Copy link
Member

aojea commented Oct 7, 2022

can you split the changes in 2 different commits?

  1. add the DialContext
  2. plumb the DialFunc from the constructor

@tzneal
Copy link
Contributor Author

tzneal commented Oct 7, 2022

Sure, two PRs or just two commits in the same PR?

@aojea
Copy link
Member

aojea commented Oct 7, 2022

2 commits is fine

/cc @enj

@k8s-ci-robot k8s-ci-robot requested a review from enj October 7, 2022 00:13
@aojea
Copy link
Member

aojea commented Oct 7, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 7, 2022
@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from 7131d36 to d83d7f2 Compare October 7, 2022 12:29
@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from 29a7242 to a62621e Compare October 8, 2022 13:24
@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from a62621e to 98f52bb Compare October 9, 2022 23:28
@aojea
Copy link
Member

aojea commented Oct 10, 2022

/lgtm
/assign @enj @liggitt

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2022
Comment on lines 310 to 335
// 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]
}
Copy link
Member

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?

Copy link
Contributor Author

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.

@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from 98f52bb to ec11d37 Compare October 13, 2022 00:10
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2022
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

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.
@tzneal tzneal force-pushed the add-dialcontext-func-support-to-spdy branch from ec11d37 to 36e5e1d Compare October 19, 2022 01:44
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tzneal
Once this PR has been reviewed and has the lgtm label, please ask for approval from liggitt by writing /assign @liggitt in a comment. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

@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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 10, 2022
@dims
Copy link
Member

dims commented Dec 12, 2022

If you still need this PR then please rebase, if not, please close the PR

@tzneal tzneal closed this Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remotecommand.NewSPDYExecutor ignores the rest.Config dial function
7 participants