mirror of https://github.com/k3s-io/k3s
Fix CRI port forwarding
Websocket support was introduced #33684, which broke the CRI implementation. This change fixes it.pull/6/head
parent
ab794c6128
commit
bb0eb3c33e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue