From 7575235d64c8e24b42936cc396281087b631e1c0 Mon Sep 17 00:00:00 2001 From: Xinzhao Xu Date: Fri, 19 May 2023 11:26:55 +0800 Subject: [PATCH] apiserver: fix the issue that the /kapis/version API cannot be matched by routing (#5696) --- pkg/apiserver/runtime/runtime.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/apiserver/runtime/runtime.go b/pkg/apiserver/runtime/runtime.go index 3b4a51bc6..6e70973d9 100644 --- a/pkg/apiserver/runtime/runtime.go +++ b/pkg/apiserver/runtime/runtime.go @@ -17,6 +17,8 @@ limitations under the License. package runtime import ( + "strings" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -41,7 +43,8 @@ func init() { func NewWebService(gv schema.GroupVersion) *restful.WebService { webservice := restful.WebService{} - webservice.Path(ApiRootPath + "/" + gv.String()). + // the GroupVersion might be empty, we need to remove the final / + webservice.Path(strings.TrimRight(ApiRootPath+"/"+gv.String(), "/")). Produces(restful.MIME_JSON) return &webservice