未验证 提交 5331ad8f 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #3319 from yuswift/remove_http1.1_support_code

remove http1.1 support code
......@@ -26,7 +26,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/httpstream"
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/proxy"
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
"k8s.io/client-go/rest"
......@@ -201,21 +200,6 @@ func (c *clusterDispatch) getInnerCluster(name string) *innerCluster {
return nil
}
// copy from https://github.com/kubernetes/apimachinery/blob/master/pkg/util/proxy/dial.go
func supportsHTTP11(nextProtos []string) bool {
if len(nextProtos) == 0 {
return true
}
for _, proto := range nextProtos {
if proto == "http/1.1" {
return true
}
}
return false
}
func (c *clusterDispatch) updateInnerClusters(obj interface{}) {
cluster := obj.(*clusterv1alpha1.Cluster)
......@@ -250,14 +234,6 @@ func (c *clusterDispatch) updateInnerClusters(obj interface{}) {
return
}
tlsConfig, err := net.TLSClientConfig(transport)
if err == nil {
// since http2 doesn't support websocket, we need to disable http2 when using websocket
if supportsHTTP11(tlsConfig.NextProtos) {
tlsConfig.NextProtos = []string{"http/1.1"}
}
}
c.mutex.Lock()
c.innerClusters[cluster.Name] = &innerCluster{
kubernetesURL: kubernetesEndpoint,
......
......@@ -17,15 +17,16 @@ limitations under the License.
package filters
import (
"k8s.io/apimachinery/pkg/util/net"
"net/http"
"net/url"
"k8s.io/apimachinery/pkg/util/proxy"
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
"k8s.io/client-go/rest"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/apiserver/request"
"kubesphere.io/kubesphere/pkg/server/errors"
"net/http"
"net/url"
)
// WithKubeAPIServer proxy request to kubernetes service if requests path starts with /api
......@@ -37,16 +38,6 @@ func WithKubeAPIServer(handler http.Handler, config *rest.Config, failed proxy.E
return handler
}
tlsConfig, err := net.TLSClientConfig(defaultTransport)
if err != nil {
klog.V(5).Infof("Unable to unwrap transport %T to get at TLS config: %v", defaultTransport, err)
}
// since http2 doesn't support websocket, we need to disable http2 when using websocket
if supportsHTTP11(tlsConfig.NextProtos) {
tlsConfig.NextProtos = []string{"http/1.1"}
}
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
info, ok := request.RequestInfoFrom(req.Context())
if !ok {
......@@ -71,18 +62,3 @@ func WithKubeAPIServer(handler http.Handler, config *rest.Config, failed proxy.E
handler.ServeHTTP(w, req)
})
}
// copy from https://github.com/kubernetes/apimachinery/blob/master/pkg/util/proxy/dial.go
func supportsHTTP11(nextProtos []string) bool {
if len(nextProtos) == 0 {
return true
}
for _, proto := range nextProtos {
if proto == "http/1.1" {
return true
}
}
return false
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册