MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / checkServerStatus

Function checkServerStatus

controllers/workspace/status.go:201–230  ·  view source on GitHub ↗
(workspace *common.DevWorkspaceWithConfig)

Source from the content-addressed store, hash-verified

199}
200
201func checkServerStatus(workspace *common.DevWorkspaceWithConfig) (ok bool, responseCode *int, err error) {
202 mainUrl := workspace.Status.MainUrl
203 if mainUrl == "" {
204 // Support DevWorkspaces that do not specify an mainUrl
205 return true, nil, nil
206 }
207 healthz, err := url.Parse(mainUrl)
208 if err != nil {
209 return false, nil, err
210 }
211 healthz.Path = path.Join(healthz.Path, "healthz")
212
213 healthCheckHttpClient := httpClientsFactory.GetHealthCheckHttpClient()
214 resp, err := healthCheckHttpClient.Get(healthz.String())
215 if err != nil {
216 return false, nil, &dwerrors.RetryError{Err: err, Message: "Failed to check server status", RequeueAfter: 1 * time.Second}
217 }
218
219 defer func() {
220 _ = resp.Body.Close()
221 }()
222
223 if (resp.StatusCode / 100) == 4 {
224 // Assume endpoint is unimplemented and/or * is covered with authentication.
225 return true, &resp.StatusCode, nil
226 }
227
228 ok = (resp.StatusCode / 100) == 2
229 return ok, &resp.StatusCode, nil
230}
231
232func getMainUrl(exposedEndpoints map[string]v1alpha1.ExposedEndpointList) string {
233 for _, endpoints := range exposedEndpoints {

Callers 1

ReconcileMethod · 0.85

Calls 4

StringMethod · 0.80
CloseMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected