Skip to content

Commit

Permalink
Merge pull request kubernetes#130126 from fuweid/fix-128314
Browse files Browse the repository at this point in the history
proxy: should add PingPeriod for websocket translator
  • Loading branch information
k8s-ci-robot authored Feb 18, 2025
2 parents 931ad2a + dc59c02 commit fc87678
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"net/url"
"strconv"
"time"

"github.com/mxk/go-flowrate/flowrate"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -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))
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,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()

Expand Down

0 comments on commit fc87678

Please sign in to comment.