Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop changing the root path of the root webservice #24474

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,22 @@ func (g *APIGroupVersion) newInstaller() *APIInstaller {

// TODO: document all handlers
// InstallSupport registers the APIServer support functions
func InstallSupport(mux Mux, ws *restful.WebService, checks ...healthz.HealthzChecker) {
func InstallSupport(mux Mux, checks ...healthz.HealthzChecker) []*restful.WebService {
// TODO: convert healthz and metrics to restful and remove container arg
healthz.InstallHandler(mux, checks...)

// Set up a service to return the git code version.
ws.Path("/version")
ws.Doc("git code version from which this is built")
ws.Route(
ws.GET("/").To(handleVersion).
versionWS := new(restful.WebService)
versionWS.Path("/version")
versionWS.Doc("git code version from which this is built")
versionWS.Route(
versionWS.GET("/").To(handleVersion).
Doc("get the code version").
Operation("getCodeVersion").
Produces(restful.MIME_JSON).
Consumes(restful.MIME_JSON))

return []*restful.WebService{versionWS}
}

// InstallLogsSupport registers the APIServer log support function into a mux.
Expand Down
14 changes: 8 additions & 6 deletions pkg/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,10 @@ func handleInternal(storage map[string]rest.Storage, admissionControl admission.
}
}

ws := new(restful.WebService)
InstallSupport(mux, ws)
container.Add(ws)
webservices := InstallSupport(mux)
for i := range webservices {
container.Add(webservices[i])
}
return &defaultAPIServer{mux, container}
}

Expand Down Expand Up @@ -3257,9 +3258,10 @@ func TestXGSubresource(t *testing.T) {
panic(fmt.Sprintf("unable to install container %s: %v", group.GroupVersion, err))
}

ws := new(restful.WebService)
InstallSupport(mux, ws)
container.Add(ws)
webservices := InstallSupport(mux)
for i := range webservices {
container.Add(webservices[i])
}

handler := defaultAPIServer{mux, container}
server := httptest.NewServer(handler)
Expand Down
7 changes: 4 additions & 3 deletions pkg/master/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,17 @@ func (m *Master) InstallAPIs(c *Config) {
}

// TODO(nikhiljindal): Refactor generic parts of support services (like /versions) to genericapiserver.
apiserver.InstallSupport(m.MuxHelper, m.RootWebService, healthzChecks...)
webservices := apiserver.InstallSupport(m.MuxHelper, healthzChecks...)

if c.EnableProfiling {
m.MuxHelper.HandleFunc("/metrics", MetricsWithReset)
} else {
m.MuxHelper.HandleFunc("/metrics", defaultMetricsHandler)
}

// Install root web services
m.HandlerContainer.Add(m.RootWebService)
for i := range webservices {
m.HandlerContainer.Add(webservices[i])
}

// allGroups records all supported groups at /apis
allGroups := []unversioned.APIGroup{}
Expand Down