From 160ec8944ed445c89c6fefa8f50f456aa4e2773e Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 31 May 2024 10:43:39 -0400 Subject: [PATCH] chore: remove `failing_sections` from healthcheck Closes #10854. --- coderd/apidoc/docs.go | 7 --- coderd/apidoc/swagger.json | 7 --- coderd/healthcheck/healthcheck.go | 16 +++--- coderd/healthcheck/healthcheck_test.go | 68 +++++++++----------------- codersdk/healthsdk/healthsdk.go | 2 - docs/api/debug.md | 1 - docs/api/schemas.md | 2 - site/src/api/typesGenerated.ts | 1 - site/src/testHelpers/entities.ts | 2 - 9 files changed, 32 insertions(+), 74 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index f373e0079a780..2ce17fe3322dc 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -14060,13 +14060,6 @@ const docTemplate = `{ "derp": { "$ref": "#/definitions/healthsdk.DERPHealthReport" }, - "failing_sections": { - "description": "FailingSections is a list of sections that have failed their healthcheck.", - "type": "array", - "items": { - "$ref": "#/definitions/healthsdk.HealthSection" - } - }, "healthy": { "description": "Healthy is true if the report returns no errors.\nDeprecated: use ` + "`" + `Severity` + "`" + ` instead", "type": "boolean" diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 84bb41c44fcdd..667252c29c980 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -12792,13 +12792,6 @@ "derp": { "$ref": "#/definitions/healthsdk.DERPHealthReport" }, - "failing_sections": { - "description": "FailingSections is a list of sections that have failed their healthcheck.", - "type": "array", - "items": { - "$ref": "#/definitions/healthsdk.HealthSection" - } - }, "healthy": { "description": "Healthy is true if the report returns no errors.\nDeprecated: use `Severity` instead", "type": "boolean" diff --git a/coderd/healthcheck/healthcheck.go b/coderd/healthcheck/healthcheck.go index c724347721335..f33c318d332d2 100644 --- a/coderd/healthcheck/healthcheck.go +++ b/coderd/healthcheck/healthcheck.go @@ -156,27 +156,27 @@ func Run(ctx context.Context, opts *ReportOptions) *healthsdk.HealthcheckReport wg.Wait() report.Time = time.Now() - report.FailingSections = []healthsdk.HealthSection{} + failingSections := []healthsdk.HealthSection{} if report.DERP.Severity.Value() > health.SeverityWarning.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionDERP) + failingSections = append(failingSections, healthsdk.HealthSectionDERP) } if report.AccessURL.Severity.Value() > health.SeverityOK.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionAccessURL) + failingSections = append(failingSections, healthsdk.HealthSectionAccessURL) } if report.Websocket.Severity.Value() > health.SeverityWarning.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionWebsocket) + failingSections = append(failingSections, healthsdk.HealthSectionWebsocket) } if report.Database.Severity.Value() > health.SeverityWarning.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionDatabase) + failingSections = append(failingSections, healthsdk.HealthSectionDatabase) } if report.WorkspaceProxy.Severity.Value() > health.SeverityWarning.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionWorkspaceProxy) + failingSections = append(failingSections, healthsdk.HealthSectionWorkspaceProxy) } if report.ProvisionerDaemons.Severity.Value() > health.SeverityWarning.Value() { - report.FailingSections = append(report.FailingSections, healthsdk.HealthSectionProvisionerDaemons) + failingSections = append(failingSections, healthsdk.HealthSectionProvisionerDaemons) } - report.Healthy = len(report.FailingSections) == 0 + report.Healthy = len(failingSections) == 0 // Review healthcheck sub-reports. report.Severity = health.SeverityOK diff --git a/coderd/healthcheck/healthcheck_test.go b/coderd/healthcheck/healthcheck_test.go index 58fbe7305380d..9c744b42d1dca 100644 --- a/coderd/healthcheck/healthcheck_test.go +++ b/coderd/healthcheck/healthcheck_test.go @@ -49,11 +49,10 @@ func TestHealthcheck(t *testing.T) { t.Parallel() for _, c := range []struct { - name string - checker *testChecker - healthy bool - severity health.Severity - failingSections []healthsdk.HealthSection + name string + checker *testChecker + healthy bool + severity health.Severity }{{ name: "OK", checker: &testChecker{ @@ -93,9 +92,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: true, - severity: health.SeverityOK, - failingSections: []healthsdk.HealthSection{}, + healthy: true, + severity: health.SeverityOK, }, { name: "DERPFail", checker: &testChecker{ @@ -135,9 +133,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: false, - severity: health.SeverityError, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionDERP}, + healthy: false, + severity: health.SeverityError, }, { name: "DERPWarning", checker: &testChecker{ @@ -178,9 +175,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: true, - severity: health.SeverityWarning, - failingSections: []healthsdk.HealthSection{}, + healthy: true, + severity: health.SeverityWarning, }, { name: "AccessURLFail", checker: &testChecker{ @@ -220,9 +216,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: false, - severity: health.SeverityWarning, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionAccessURL}, + healthy: false, + severity: health.SeverityWarning, }, { name: "WebsocketFail", checker: &testChecker{ @@ -262,9 +257,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: false, - severity: health.SeverityError, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionWebsocket}, + healthy: false, + severity: health.SeverityError, }, { name: "DatabaseFail", checker: &testChecker{ @@ -304,9 +298,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - healthy: false, - severity: health.SeverityError, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionDatabase}, + healthy: false, + severity: health.SeverityError, }, { name: "ProxyFail", checker: &testChecker{ @@ -346,9 +339,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - severity: health.SeverityError, - healthy: false, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionWorkspaceProxy}, + severity: health.SeverityError, + healthy: false, }, { name: "ProxyWarn", checker: &testChecker{ @@ -389,9 +381,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - severity: health.SeverityWarning, - healthy: true, - failingSections: []healthsdk.HealthSection{}, + severity: health.SeverityWarning, + healthy: true, }, { name: "ProvisionerDaemonsFail", checker: &testChecker{ @@ -431,9 +422,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - severity: health.SeverityError, - healthy: false, - failingSections: []healthsdk.HealthSection{healthsdk.HealthSectionProvisionerDaemons}, + severity: health.SeverityError, + healthy: false, }, { name: "ProvisionerDaemonsWarn", checker: &testChecker{ @@ -474,9 +464,8 @@ func TestHealthcheck(t *testing.T) { }, }, }, - severity: health.SeverityWarning, - healthy: true, - failingSections: []healthsdk.HealthSection{}, + severity: health.SeverityWarning, + healthy: true, }, { name: "AllFail", healthy: false, @@ -518,14 +507,6 @@ func TestHealthcheck(t *testing.T) { }, }, severity: health.SeverityError, - failingSections: []healthsdk.HealthSection{ - healthsdk.HealthSectionDERP, - healthsdk.HealthSectionAccessURL, - healthsdk.HealthSectionWebsocket, - healthsdk.HealthSectionDatabase, - healthsdk.HealthSectionWorkspaceProxy, - healthsdk.HealthSectionProvisionerDaemons, - }, }} { c := c t.Run(c.name, func(t *testing.T) { @@ -537,7 +518,6 @@ func TestHealthcheck(t *testing.T) { assert.Equal(t, c.healthy, report.Healthy) assert.Equal(t, c.severity, report.Severity) - assert.Equal(t, c.failingSections, report.FailingSections) assert.Equal(t, c.checker.DERPReport.Healthy, report.DERP.Healthy) assert.Equal(t, c.checker.DERPReport.Severity, report.DERP.Severity) assert.Equal(t, c.checker.DERPReport.Warnings, report.DERP.Warnings) diff --git a/codersdk/healthsdk/healthsdk.go b/codersdk/healthsdk/healthsdk.go index 8a00a8a3d63a6..eb46073d4adf8 100644 --- a/codersdk/healthsdk/healthsdk.go +++ b/codersdk/healthsdk/healthsdk.go @@ -105,8 +105,6 @@ type HealthcheckReport struct { Healthy bool `json:"healthy"` // Severity indicates the status of Coder health. Severity health.Severity `json:"severity" enums:"ok,warning,error"` - // FailingSections is a list of sections that have failed their healthcheck. - FailingSections []HealthSection `json:"failing_sections"` DERP DERPHealthReport `json:"derp"` AccessURL AccessURLReport `json:"access_url"` diff --git a/docs/api/debug.md b/docs/api/debug.md index 0ae74b501210a..317efbd0c0650 100644 --- a/docs/api/debug.md +++ b/docs/api/debug.md @@ -280,7 +280,6 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ } ] }, - "failing_sections": ["DERP"], "healthy": true, "provisioner_daemons": { "dismissed": true, diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 978da35a58d02..4c3d2e77242e0 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -8246,7 +8246,6 @@ If the schedule is empty, the user will be updated to use the default schedule.| } ] }, - "failing_sections": ["DERP"], "healthy": true, "provisioner_daemons": { "dismissed": true, @@ -8348,7 +8347,6 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `coder_version` | string | false | | The Coder version of the server that the report was generated on. | | `database` | [healthsdk.DatabaseReport](#healthsdkdatabasereport) | false | | | | `derp` | [healthsdk.DERPHealthReport](#healthsdkderphealthreport) | false | | | -| `failing_sections` | array of [healthsdk.HealthSection](#healthsdkhealthsection) | false | | Failing sections is a list of sections that have failed their healthcheck. | | `healthy` | boolean | false | | Healthy is true if the report returns no errors. Deprecated: use `Severity` instead | | `provisioner_daemons` | [healthsdk.ProvisionerDaemonsReport](#healthsdkprovisionerdaemonsreport) | false | | | | `severity` | [health.Severity](#healthseverity) | false | | Severity indicates the status of Coder health. | diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 171f6744680cb..7c4642cde6045 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -2437,7 +2437,6 @@ export interface HealthcheckReport { readonly time: string; readonly healthy: boolean; readonly severity: HealthSeverity; - readonly failing_sections: readonly HealthSection[]; readonly derp: DERPHealthReport; readonly access_url: AccessURLReport; readonly websocket: WebsocketReport; diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index 5ff5fa6cd84c7..21b6243d7dba2 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -2528,7 +2528,6 @@ export const MockHealth: TypesGen.HealthcheckReport = { time: "2023-08-01T16:51:03.29792825Z", healthy: true, severity: "ok", - failing_sections: [], derp: { healthy: true, severity: "ok", @@ -3322,7 +3321,6 @@ export const MockSharedPortsResponse: TypesGen.WorkspaceAgentPortShares = { export const DeploymentHealthUnhealthy: TypesGen.HealthcheckReport = { healthy: false, severity: "ok", - failing_sections: [], // apparently this property is not used at all? time: "2023-10-12T23:15:00.000000000Z", coder_version: "v2.3.0-devel+8cca4915a", access_url: {