Merge pull request #130252 from fuweid/1.31-backport-130126

[release-1.31] proxy: should add PingPeriod for websocket translator
This commit is contained in:
Kubernetes Prow Robot 2025-02-19 07:16:28 -08:00 committed by GitHub
commit d74c758b7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import (
"net/http"
"net/url"
"strconv"
"time"
"github.com/mxk/go-flowrate/flowrate"
apierrors "k8s.io/apimachinery/pkg/api/errors"
@ -70,7 +71,7 @@ func (h *StreamTranslatorHandler) ServeHTTP(w http.ResponseWriter, req *http.Req
defer websocketStreams.conn.Close()
// Creating SPDY executor, ensuring redirects are not followed.
spdyRoundTripper, err := spdy.NewRoundTripperWithConfig(spdy.RoundTripperConfig{UpgradeTransport: h.Transport})
spdyRoundTripper, err := spdy.NewRoundTripperWithConfig(spdy.RoundTripperConfig{UpgradeTransport: h.Transport, PingPeriod: 5 * time.Second})
if err != nil {
websocketStreams.writeStatus(apierrors.NewInternalError(err)) //nolint:errcheck
metrics.IncStreamTranslatorRequest(req.Context(), strconv.Itoa(http.StatusInternalServerError))

View File

@ -500,6 +500,16 @@ var _ = SIGDescribe("Kubectl client", func() {
}
})
// https://issues.k8s.io/128314
f.It(f.WithSlow(), "should support exec idle connections", func(ctx context.Context) {
ginkgo.By("executing a command in the container")
execOutput := e2ekubectl.RunKubectlOrDie(ns, "exec", podRunningTimeoutArg, simplePodName, "--", "/bin/sh", "-c", "sleep 320 && echo running in container")
if expected, got := "running in container", strings.TrimSpace(execOutput); expected != got {
framework.Failf("Unexpected kubectl exec output. Wanted %q, got %q", expected, got)
}
})
ginkgo.It("should support exec through kubectl proxy", func(ctx context.Context) {
_ = getTestContextHost()