Skip to content

fix!: remove failing_sections from healthcheck #13426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions coderd/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 24 additions & 44 deletions coderd/healthcheck/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions codersdk/healthsdk/healthsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 0 additions & 1 deletion docs/api/debug.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions docs/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: {
Expand Down
Loading