(workspace *common.DevWorkspaceWithConfig)
| 199 | } |
| 200 | |
| 201 | func 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 | |
| 232 | func getMainUrl(exposedEndpoints map[string]v1alpha1.ExposedEndpointList) string { |
| 233 | for _, endpoints := range exposedEndpoints { |
no test coverage detected