chore: remove failing_sections from healthcheck (#13426)

Closes #10854.
This commit is contained in:
Kyle Carberry
2024-06-21 13:49:02 -05:00
committed by GitHub
parent 5177f366f5
commit 54e8f30002
9 changed files with 32 additions and 74 deletions

7
coderd/apidoc/docs.go generated
View File

@ -13767,13 +13767,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"

View File

@ -12530,13 +12530,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"

View File

@ -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

View File

@ -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)