Commit d4bcf3ed authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #40951 from yujuhong/fix_cri_portforward

Automatic merge from submit-queue (batch tested with PRs 40930, 40951) Fix CRI port forwarding Websocket support was introduced #33684, which broke the CRI implementation. This change fixes it.
parents 44a3cd12 bb0eb3c3
......@@ -45,6 +45,8 @@ const (
// options contains details about which streams are required for
// port forwarding.
// All fields incldued in V4Options need to be expressed explicilty in the
// CRI (pkg/kubelet/api/{version}/runtime/api.proto) PortForwardRequest.
type V4Options struct {
Ports []int32
}
......@@ -82,6 +84,11 @@ func NewV4Options(req *http.Request) (*V4Options, error) {
}, nil
}
// BuildV4Options returns a V4Options based on the given information.
func BuildV4Options(ports []int32) (*V4Options, error) {
return &V4Options{Ports: ports}, nil
}
// handleWebSocketStreams handles requests to forward ports to a pod via
// a PortForwarder. A pair of streams are created per port (DATA n,
// ERROR n+1). The associated port is written to each stream as a unsigned 16
......
......@@ -302,7 +302,7 @@ func (s *server) servePortForward(req *restful.Request, resp *restful.Response)
return
}
portForwardOptions, err := portforward.NewV4Options(req.Request)
portForwardOptions, err := portforward.BuildV4Options(pf.Port)
if err != nil {
resp.WriteError(http.StatusBadRequest, err)
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment