From 83e4f7d5538c9b83b6b022261f2e69724f988957 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 8 Apr 2025 14:06:28 +0100 Subject: [PATCH 1/5] chore(cli): TestSupportbundle: increase HealthcheckTimeout in tests --- cli/support_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/support_test.go b/cli/support_test.go index 1fb336142d4be..5e5a6c99ca0df 100644 --- a/cli/support_test.go +++ b/cli/support_test.go @@ -50,7 +50,8 @@ func TestSupportBundle(t *testing.T) { secretValue := uuid.NewString() seedSecretDeploymentOptions(t, &dc, secretValue) client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{ - DeploymentValues: dc.Values, + DeploymentValues: dc.Values, + HealthcheckTimeout: testutil.WaitLong, }) owner := coderdtest.CreateFirstUser(t, client) r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ @@ -113,7 +114,8 @@ func TestSupportBundle(t *testing.T) { secretValue := uuid.NewString() seedSecretDeploymentOptions(t, &dc, secretValue) client := coderdtest.New(t, &coderdtest.Options{ - DeploymentValues: dc.Values, + DeploymentValues: dc.Values, + HealthcheckTimeout: testutil.WaitLong, }) _ = coderdtest.CreateFirstUser(t, client) @@ -133,7 +135,8 @@ func TestSupportBundle(t *testing.T) { secretValue := uuid.NewString() seedSecretDeploymentOptions(t, &dc, secretValue) client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{ - DeploymentValues: dc.Values, + DeploymentValues: dc.Values, + HealthcheckTimeout: testutil.WaitLong, }) admin := coderdtest.CreateFirstUser(t, client) r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ From 0d5d06d2c6f6a16465eda9804ba7cf0fe3814853 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 8 Apr 2025 14:07:15 +0100 Subject: [PATCH 2/5] fix(coderd): debugDeploymentHealth: only cache non-nil health reports --- coderd/debug.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coderd/debug.go b/coderd/debug.go index 0ae62282a22d8..677a3e08a900e 100644 --- a/coderd/debug.go +++ b/coderd/debug.go @@ -84,7 +84,9 @@ 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 }) From bd3b1144b9061ee149d14090595505866af23cdc Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 8 Apr 2025 14:07:49 +0100 Subject: [PATCH 3/5] fix(coderd): debugDeploymentHealth: return 503 instead of 404 when health report unavailable --- coderd/debug.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/debug.go b/coderd/debug.go index 677a3e08a900e..64c7c9e632d0a 100644 --- a/coderd/debug.go +++ b/coderd/debug.go @@ -92,7 +92,7 @@ func (api *API) debugDeploymentHealth(rw http.ResponseWriter, r *http.Request) { 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 From a81e89b9ed21460d2af5463d6794997cb663c688 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 8 Apr 2025 14:19:47 +0100 Subject: [PATCH 4/5] fixup! fix(coderd): debugDeploymentHealth: return 503 instead of 404 when health report unavailable --- coderd/debug_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/debug_test.go b/coderd/debug_test.go index 0d5dfd1885f12..f7a0a180ec61d 100644 --- a/coderd/debug_test.go +++ b/coderd/debug_test.go @@ -117,7 +117,7 @@ func TestDebugHealth(t *testing.T) { require.NoError(t, err) defer res.Body.Close() _, _ = io.ReadAll(res.Body) - require.Equal(t, http.StatusNotFound, res.StatusCode) + require.Equal(t, http.StatusServiceUnavailable, res.StatusCode) }) t.Run("Refresh", func(t *testing.T) { From e754d28fe8166ac62bfae4b66b20f54c9a5c4944 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 8 Apr 2025 15:36:14 +0100 Subject: [PATCH 5/5] WaitLong -> WaitSuperLong --- cli/support_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/support_test.go b/cli/support_test.go index 5e5a6c99ca0df..e1ad7fca7b0a4 100644 --- a/cli/support_test.go +++ b/cli/support_test.go @@ -51,7 +51,7 @@ func TestSupportBundle(t *testing.T) { seedSecretDeploymentOptions(t, &dc, secretValue) client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{ DeploymentValues: dc.Values, - HealthcheckTimeout: testutil.WaitLong, + HealthcheckTimeout: testutil.WaitSuperLong, }) owner := coderdtest.CreateFirstUser(t, client) r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ @@ -115,7 +115,7 @@ func TestSupportBundle(t *testing.T) { seedSecretDeploymentOptions(t, &dc, secretValue) client := coderdtest.New(t, &coderdtest.Options{ DeploymentValues: dc.Values, - HealthcheckTimeout: testutil.WaitLong, + HealthcheckTimeout: testutil.WaitSuperLong, }) _ = coderdtest.CreateFirstUser(t, client) @@ -136,7 +136,7 @@ func TestSupportBundle(t *testing.T) { seedSecretDeploymentOptions(t, &dc, secretValue) client, db := coderdtest.NewWithDatabase(t, &coderdtest.Options{ DeploymentValues: dc.Values, - HealthcheckTimeout: testutil.WaitLong, + HealthcheckTimeout: testutil.WaitSuperLong, }) admin := coderdtest.CreateFirstUser(t, client) r := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{