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

feat: enable SPDY pings on connections #97083

Merged
merged 1 commit into from Jan 13, 2021

Conversation

knight42
Copy link
Member

@knight42 knight42 commented Dec 5, 2020

Signed-off-by: Jian Zeng zengjian.zj@bytedance.com

What type of PR is this?

/kind feature

What this PR does / why we need it:

Enable SPDY pings on connections and the period is set to 5s.

Which issue(s) this PR fixes:

xref #94301

Special notes for your reviewer:

Both kubectl exec and kubectl portforward invoke spdy.RoundTripperFor transitively:

Does this PR introduce a user-facing change?:

Enable SPDY pings to keep connections alive, so that `kubectl exec` and `kubectl portforward` won't be interrupted.

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


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 5, 2020
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Dec 5, 2020
@knight42
Copy link
Member Author

knight42 commented Dec 5, 2020

/cc @caesarxuchao @lavalamp

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 5, 2020
@nielsbasjes
Copy link

Question: Is the kubectl logs -f case also fixed with this?

@knight42
Copy link
Member Author

knight42 commented Dec 5, 2020

Question: Is the kubectl logs -f case also fixed with this?

@nielsbasjes I think this is a different problem, because kubectl logs -f is actually a simple HTTP request.

@aojea
Copy link
Member

aojea commented Dec 6, 2020

Why not enabling it by default as with http/2 #95981 ?

// NewRoundTripperWithProxy creates a new SpdyRoundTripper that will use the
// specified tlsConfig and proxy func.
func NewRoundTripperWithProxy(tlsConfig *tls.Config, followRedirects, requireSameHostRedirects bool, proxier func(*http.Request) (*url.URL, error)) *SpdyRoundTripper {
return NewRoundTripperWithConfig(RoundTripperConfig{
TLS: tlsConfig,
FollowRedirects: followRedirects,
RequireSameHostRedirects: requireSameHostRedirects,
Proxier: proxier,
})
}

/cc @caesarxuchao @lavalamp

@knight42
Copy link
Member Author

knight42 commented Dec 8, 2020

flake

--- FAIL: TestInitialSync (0.02s)
    api_test.go:171: Unexpected endpoints: []*v1.Endpoints{(*v1.Endpoints)(0xc00044b900)}, expected: []*v1.Endpoints{(*v1.Endpoints)(0xc0004ac280), (*v1.Endpoints)(0xc0004ac140)}

/test pull-kubernetes-bazel-test

@fedebongio
Copy link
Contributor

/assign @caesarxuchao
/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 Dec 8, 2020
@tiloso
Copy link
Contributor

tiloso commented Dec 8, 2020

Should NewRoundTripperWithProxy be removed from k8s.io/apimachinery/pkg/util/httpstream/spdy? I think it's not being used anywhere else.

@knight42
Copy link
Member Author

knight42 commented Dec 9, 2020

Should NewRoundTripperWithProxy be removed from k8s.io/apimachinery/pkg/util/httpstream/spdy? I think it's not being used anywhere else.

I guess we'd better not, as NewRoundTripperWithProxy is an exported function, we might break other users if we suddenly remove it.


"k8s.io/apimachinery/pkg/util/httpstream"
"k8s.io/apimachinery/pkg/util/httpstream/spdy"
restclient "k8s.io/client-go/rest"
)

// TODO: should we make the period configurable?
const pingPeriod = time.Second * 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 20 second is based on the bug report #94301. People might need a different pingPeriod to satisfy different load balancers.

I think we should expose this variable as a flag of kubectl exec and kubectl port-forward commands. That will need approvals from @kubernetes/sig-cli-api-reviews.

I'm ok with hard-code it to 20 seconds for now and make it configurable in a follow-up.

Can you remove the TODO?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the example config for a loadbalancer sets a timeout to 20 seconds having the ping every 20 seconds will most likely cause problems "in the wild". I see this simply as cutting it too close.

I would really prefer a ping interval of something like 5 or 10 seconds because of that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote let's hard code to 5s and not make it configurable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the ping period to 5s.

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jan 12, 2021
@fejta-bot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

Signed-off-by: Jian Zeng <zengjian.zj@bytedance.com>
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 13, 2021
@lavalamp
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 13, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knight42, lavalamp

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 13, 2021
@aojea
Copy link
Member

aojea commented Jan 13, 2021

awesome,
I think this was the last one without keepalive , right?
we should see less complains about hanging connections ... hopefully 🤞 ;)

@caesarxuchao
Copy link
Member

The unit test failure looks real:

1/1940 Tests Failed. | expand_less
-- | --
go_test: //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/go_default_test:run_1_of_2 expand_less0sexec ${PAGER:-/usr/bin/less} "$0" \|\| exit 1 Executing tests from //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy:go_default_test ----------------------------------------------------------------------------- --- FAIL: TestConnectionPings (0.04s)     connection_test.go:240: server: failed to send any pings (check logs) 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:33312: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:34410: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:52824: remote error: tls: bad certificate 2021/01/13 19:01:17 [001] WARN: Error copying to client: read tcp 127.0.0.1:37014->127.0.0.1:40645: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:47462: remote error: tls: bad certificate 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:60264: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:58088->127.0.0.1:42433: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:37486->127.0.0.1:36923: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:33462->127.0.0.1:42509: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:48890: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:32982->127.0.0.1:36415: read: connection reset by peer 2021/01/13 19:01:19 [001] WARN: Error copying to client: read tcp 127.0.0.1:45768->127.0.0.1:46097: read: connection reset by peer FAIL | go_test: //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/go_default_test:run_1_of_2 expand_less | 0s | exec ${PAGER:-/usr/bin/less} "$0" \|\| exit 1 Executing tests from //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy:go_default_test ----------------------------------------------------------------------------- --- FAIL: TestConnectionPings (0.04s)     connection_test.go:240: server: failed to send any pings (check logs) 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:33312: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:34410: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:52824: remote error: tls: bad certificate 2021/01/13 19:01:17 [001] WARN: Error copying to client: read tcp 127.0.0.1:37014->127.0.0.1:40645: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:47462: remote error: tls: bad certificate 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:60264: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:58088->127.0.0.1:42433: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:37486->127.0.0.1:36923: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:33462->127.0.0.1:42509: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:48890: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:32982->127.0.0.1:36415: read: connection reset by peer 2021/01/13 19:01:19 [001] WARN: Error copying to client: read tcp 127.0.0.1:45768->127.0.0.1:46097: read: connection reset by peer FAIL
go_test: //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy/go_default_test:run_1_of_2 expand_less | 0s
exec ${PAGER:-/usr/bin/less} "$0" \|\| exit 1 Executing tests from //staging/src/k8s.io/apimachinery/pkg/util/httpstream/spdy:go_default_test ----------------------------------------------------------------------------- --- FAIL: TestConnectionPings (0.04s)     connection_test.go:240: server: failed to send any pings (check logs) 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:33312: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:34410: remote error: tls: bad certificate 2021/01/13 19:01:17 http: TLS handshake error from 127.0.0.1:52824: remote error: tls: bad certificate 2021/01/13 19:01:17 [001] WARN: Error copying to client: read tcp 127.0.0.1:37014->127.0.0.1:40645: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:47462: remote error: tls: bad certificate 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:60264: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:58088->127.0.0.1:42433: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:37486->127.0.0.1:36923: read: connection reset by peer 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:33462->127.0.0.1:42509: read: connection reset by peer 2021/01/13 19:01:18 http: TLS handshake error from 127.0.0.1:48890: remote error: tls: bad certificate 2021/01/13 19:01:18 [001] WARN: Error copying to client: read tcp 127.0.0.1:32982->127.0.0.1:36415: read: connection reset by peer 2021/01/13 19:01:19 [001] WARN: Error copying to client: read tcp 127.0.0.1:45768->127.0.0.1:46097: read: connection reset by peer FAIL

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XS Denotes a PR that changes 0-9 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.

None yet

9 participants