chore(cli): increase healthcheck timeout in TestSupportbundle (#17291)

Fixes https://github.com/coder/internal/issues/272

* Increases healthcheck timeout in tests. This seems to be the most
usual cause of test failures.
* Adds a non-nilness check before caching a healthcheck report.
* Modifies the HTTP response code to 503 (was 404) when no healthcheck
report is available. 503 seems to be a better indicator of the server
state in this case, whereas 404 could be misinterpreted as a typo in the
healthcheck URL.
This commit is contained in:
Cian Johnston
2025-04-09 09:21:17 +01:00
committed by GitHub
parent 8d122aa4ab
commit a8fbe71a22
3 changed files with 11 additions and 6 deletions

View File

@ -84,13 +84,15 @@ func (api *API) debugDeploymentHealth(rw http.ResponseWriter, r *http.Request) {
defer cancel()
report := api.HealthcheckFunc(ctx, apiKey)
api.healthCheckCache.Store(report)
if report != nil { // Only store non-nil reports.
api.healthCheckCache.Store(report)
}
return report, nil
})
select {
case <-ctx.Done():
httpapi.Write(ctx, rw, http.StatusNotFound, codersdk.Response{
httpapi.Write(ctx, rw, http.StatusServiceUnavailable, codersdk.Response{
Message: "Healthcheck is in progress and did not complete in time. Try again in a few seconds.",
})
return