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.
This commit is contained in:
Kubernetes Submit Queue 2017-02-06 14:27:05 -08:00 committed by GitHub
commit d4bcf3ede5
2 changed files with 8 additions and 1 deletions

View File

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

View File

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