diff --git a/pkg/apiserver/dispatch/dispatch.go b/pkg/apiserver/dispatch/dispatch.go index 7241113e4ef366118d5951477de5d3041bff535c..643b3603699920db8c9298f8e9eea64c75120d45 100644 --- a/pkg/apiserver/dispatch/dispatch.go +++ b/pkg/apiserver/dispatch/dispatch.go @@ -18,18 +18,19 @@ package dispatch import ( "fmt" + "net/http" + "strings" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/httpstream" "k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" "k8s.io/klog" - "kubesphere.io/kubesphere/pkg/utils/clusterclient" - "net/http" - "strings" clusterv1alpha1 "kubesphere.io/kubesphere/pkg/apis/cluster/v1alpha1" "kubesphere.io/kubesphere/pkg/apiserver/request" clusterinformer "kubesphere.io/kubesphere/pkg/client/informers/externalversions/cluster/v1alpha1" + "kubesphere.io/kubesphere/pkg/utils/clusterclient" ) const proxyURLFormat = "/api/v1/namespaces/kubesphere-system/services/:ks-apiserver:/proxy%s" @@ -77,13 +78,13 @@ func (c *clusterDispatch) Dispatch(w http.ResponseWriter, req *http.Request, han } if !c.IsClusterReady(cluster) { - http.Error(w, fmt.Sprintf("cluster %s is not ready", cluster.Name), http.StatusInternalServerError) + http.Error(w, fmt.Sprintf("cluster %s is not ready", cluster.Name), http.StatusBadRequest) return } innCluster := c.GetInnerCluster(cluster.Name) if innCluster == nil { - http.Error(w, fmt.Sprintf("cluster %s is not ready", cluster.Name), http.StatusInternalServerError) + http.Error(w, fmt.Sprintf("cluster %s is not ready", cluster.Name), http.StatusBadRequest) return }