From 6f4c14d1d358620d464f371df449b266ce2105c0 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 12:08:50 +0100 Subject: [PATCH 01/11] feat: show health warnings --- coderd/healthcheck/derphealth/derp.go | 18 ++++++++++++++---- coderd/healthcheck/healthcheck.go | 5 +++++ coderd/healthcheck/healthcheck_test.go | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/coderd/healthcheck/derphealth/derp.go b/coderd/healthcheck/derphealth/derp.go index 2570b9fcb10f0..2cbe90b330b77 100644 --- a/coderd/healthcheck/derphealth/derp.go +++ b/coderd/healthcheck/derphealth/derp.go @@ -27,6 +27,7 @@ import ( // @typescript-generate Report type Report struct { Healthy bool `json:"healthy"` + Warning bool `json:"warning"` Regions map[int]*RegionReport `json:"regions"` @@ -41,6 +42,7 @@ type Report struct { type RegionReport struct { mu sync.Mutex Healthy bool `json:"healthy"` + Warning bool `json:"warning"` Region *tailcfg.DERPRegion `json:"region"` NodeReports []*NodeReport `json:"node_reports"` @@ -53,6 +55,7 @@ type NodeReport struct { clientCounter int Healthy bool `json:"healthy"` + Warning bool `json:"warning"` Node *tailcfg.DERPNode `json:"node"` ServerInfo derp.ServerInfoMessage `json:"node_info"` @@ -108,6 +111,9 @@ func (r *Report) Run(ctx context.Context, opts *ReportOptions) { if !regionReport.Healthy { r.Healthy = false } + if regionReport.Warning { + r.Warning = true + } mu.Unlock() }() } @@ -159,6 +165,9 @@ func (r *RegionReport) Run(ctx context.Context) { if !nodeReport.Healthy { r.Healthy = false } + if nodeReport.Warning { + r.Warning = true + } r.mu.Unlock() }() } @@ -208,14 +217,15 @@ func (r *NodeReport) Run(ctx context.Context) { // We can't exchange messages with the node, if (!r.CanExchangeMessages && !r.Node.STUNOnly) || - // A node may use websockets because `Upgrade: DERP` may be blocked on - // the load balancer. This is unhealthy because websockets are slower - // than the regular DERP protocol. - r.UsesWebsocket || // The node was marked as STUN compatible but the STUN test failed. r.STUN.Error != nil { r.Healthy = false } + + // A node may use websockets because `Upgrade: DERP` may be blocked on + // the load balancer. This is unhealthy because websockets are slower + // than the regular DERP protocol. + r.Warning = r.UsesWebsocket } func (r *NodeReport) doExchangeMessage(ctx context.Context) { diff --git a/coderd/healthcheck/healthcheck.go b/coderd/healthcheck/healthcheck.go index 61c6e40c1e1be..d496e2546e64f 100644 --- a/coderd/healthcheck/healthcheck.go +++ b/coderd/healthcheck/healthcheck.go @@ -36,6 +36,8 @@ type Report struct { Time time.Time `json:"time"` // Healthy is true if the report returns no errors. Healthy bool `json:"healthy"` + // Warning is true when Coder is operational but its performance might be impacted. + Warning bool `json:"warning"` // FailingSections is a list of sections that have failed their healthcheck. FailingSections []string `json:"failing_sections"` @@ -156,6 +158,9 @@ func Run(ctx context.Context, opts *ReportOptions) *Report { if !report.DERP.Healthy { report.FailingSections = append(report.FailingSections, SectionDERP) } + if report.DERP.Warning { + report.Warning = true + } if !report.AccessURL.Healthy { report.FailingSections = append(report.FailingSections, SectionAccessURL) } diff --git a/coderd/healthcheck/healthcheck_test.go b/coderd/healthcheck/healthcheck_test.go index f89f12116dc88..207de0977a916 100644 --- a/coderd/healthcheck/healthcheck_test.go +++ b/coderd/healthcheck/healthcheck_test.go @@ -40,6 +40,7 @@ func TestHealthcheck(t *testing.T) { name string checker *testChecker healthy bool + warning bool failingSections []string }{{ name: "OK", @@ -77,6 +78,26 @@ func TestHealthcheck(t *testing.T) { }, healthy: false, failingSections: []string{healthcheck.SectionDERP}, + }, { + name: "DERPWarning", + checker: &testChecker{ + DERPReport: derphealth.Report{ + Healthy: true, + Warning: true, + }, + AccessURLReport: healthcheck.AccessURLReport{ + Healthy: true, + }, + WebsocketReport: healthcheck.WebsocketReport{ + Healthy: true, + }, + DatabaseReport: healthcheck.DatabaseReport{ + Healthy: true, + }, + }, + healthy: true, + warning: true, + failingSections: nil, }, { name: "AccessURLFail", checker: &testChecker{ @@ -151,8 +172,10 @@ func TestHealthcheck(t *testing.T) { }) assert.Equal(t, c.healthy, report.Healthy) + assert.Equal(t, c.warning, report.Warning) assert.Equal(t, c.failingSections, report.FailingSections) assert.Equal(t, c.checker.DERPReport.Healthy, report.DERP.Healthy) + assert.Equal(t, c.checker.DERPReport.Warning, report.DERP.Warning) assert.Equal(t, c.checker.AccessURLReport.Healthy, report.AccessURL.Healthy) assert.Equal(t, c.checker.WebsocketReport.Healthy, report.Websocket.Healthy) assert.NotZero(t, report.Time) From 059e9fa5cad62a1117f00afaec2ecab31ab11206 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 12:26:18 +0100 Subject: [PATCH 02/11] make gen --- coderd/apidoc/docs.go | 13 ++++++++ coderd/apidoc/swagger.json | 13 ++++++++ docs/api/debug.md | 16 +++++++--- docs/api/schemas.md | 64 ++++++++++++++++++++++++-------------- 4 files changed, 78 insertions(+), 28 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index b55e9d6d23225..0309e8eee1662 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -12071,6 +12071,9 @@ const docTemplate = `{ }, "uses_websocket": { "type": "boolean" + }, + "warning": { + "type": "boolean" } } }, @@ -12091,6 +12094,9 @@ const docTemplate = `{ }, "region": { "$ref": "#/definitions/tailcfg.DERPRegion" + }, + "warning": { + "type": "boolean" } } }, @@ -12120,6 +12126,9 @@ const docTemplate = `{ "additionalProperties": { "$ref": "#/definitions/derphealth.RegionReport" } + }, + "warning": { + "type": "boolean" } } }, @@ -12211,6 +12220,10 @@ const docTemplate = `{ "description": "Time is the time the report was generated at.", "type": "string" }, + "warning": { + "description": "Warning is true when Coder is operational but its performance might be impacted.", + "type": "boolean" + }, "websocket": { "$ref": "#/definitions/healthcheck.WebsocketReport" } diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 8b474ff8ecbee..23ffbde9c80ba 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -10996,6 +10996,9 @@ }, "uses_websocket": { "type": "boolean" + }, + "warning": { + "type": "boolean" } } }, @@ -11016,6 +11019,9 @@ }, "region": { "$ref": "#/definitions/tailcfg.DERPRegion" + }, + "warning": { + "type": "boolean" } } }, @@ -11045,6 +11051,9 @@ "additionalProperties": { "$ref": "#/definitions/derphealth.RegionReport" } + }, + "warning": { + "type": "boolean" } } }, @@ -11136,6 +11145,10 @@ "description": "Time is the time the report was generated at.", "type": "string" }, + "warning": { + "description": "Warning is true when Coder is operational but its performance might be impacted.", + "type": "boolean" + }, "websocket": { "$ref": "#/definitions/healthcheck.WebsocketReport" } diff --git a/docs/api/debug.md b/docs/api/debug.md index 5016f6a87b256..b4b9496bdbf5c 100644 --- a/docs/api/debug.md +++ b/docs/api/debug.md @@ -127,7 +127,8 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -153,7 +154,8 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true }, "property2": { "error": "string", @@ -191,7 +193,8 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -217,13 +220,16 @@ curl -X GET http://coder-server:8080/api/v2/debug/health \ "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true } - } + }, + "warning": true }, "failing_sections": ["string"], "healthy": true, "time": "string", + "warning": true, "websocket": { "body": "string", "code": 0, diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 517e76981c567..9a778602ef9b2 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -7113,7 +7113,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ``` @@ -7132,6 +7133,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `round_trip_ping_ms` | integer | false | | | | `stun` | [derphealth.StunReport](#derphealthstunreport) | false | | | | `uses_websocket` | boolean | false | | | +| `warning` | boolean | false | | | ## derphealth.RegionReport @@ -7172,7 +7174,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -7198,7 +7201,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true } ``` @@ -7210,6 +7214,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `healthy` | boolean | false | | | | `node_reports` | array of [derphealth.NodeReport](#derphealthnodereport) | false | | | | `region` | [tailcfg.DERPRegion](#tailcfgderpregion) | false | | | +| `warning` | boolean | false | | | ## derphealth.Report @@ -7286,7 +7291,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -7312,7 +7318,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true }, "property2": { "error": "string", @@ -7350,7 +7357,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -7376,9 +7384,11 @@ If the schedule is empty, the user will be updated to use the default schedule.| "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true } - } + }, + "warning": true } ``` @@ -7393,6 +7403,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `netcheck_logs` | array of string | false | | | | `regions` | object | false | | | | ยป `[any property]` | [derphealth.RegionReport](#derphealthregionreport) | false | | | +| `warning` | boolean | false | | | ## derphealth.StunReport @@ -7550,7 +7561,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -7576,7 +7588,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true }, "property2": { "error": "string", @@ -7614,7 +7627,8 @@ If the schedule is empty, the user will be updated to use the default schedule.| "enabled": true, "error": "string" }, - "uses_websocket": true + "uses_websocket": true, + "warning": true } ], "region": { @@ -7640,13 +7654,16 @@ If the schedule is empty, the user will be updated to use the default schedule.| "regionCode": "string", "regionID": 0, "regionName": "string" - } + }, + "warning": true } - } + }, + "warning": true }, "failing_sections": ["string"], "healthy": true, "time": "string", + "warning": true, "websocket": { "body": "string", "code": 0, @@ -7658,16 +7675,17 @@ If the schedule is empty, the user will be updated to use the default schedule.| ### Properties -| Name | Type | Required | Restrictions | Description | -| ------------------ | ---------------------------------------------------------- | -------- | ------------ | -------------------------------------------------------------------------- | -| `access_url` | [healthcheck.AccessURLReport](#healthcheckaccessurlreport) | false | | | -| `coder_version` | string | false | | The Coder version of the server that the report was generated on. | -| `database` | [healthcheck.DatabaseReport](#healthcheckdatabasereport) | false | | | -| `derp` | [derphealth.Report](#derphealthreport) | false | | | -| `failing_sections` | array of string | 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. | -| `time` | string | false | | Time is the time the report was generated at. | -| `websocket` | [healthcheck.WebsocketReport](#healthcheckwebsocketreport) | false | | | +| Name | Type | Required | Restrictions | Description | +| ------------------ | ---------------------------------------------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | +| `access_url` | [healthcheck.AccessURLReport](#healthcheckaccessurlreport) | false | | | +| `coder_version` | string | false | | The Coder version of the server that the report was generated on. | +| `database` | [healthcheck.DatabaseReport](#healthcheckdatabasereport) | false | | | +| `derp` | [derphealth.Report](#derphealthreport) | false | | | +| `failing_sections` | array of string | 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. | +| `time` | string | false | | Time is the time the report was generated at. | +| `warning` | boolean | false | | Warning is true when Coder is operational but its performance might be impacted. | +| `websocket` | [healthcheck.WebsocketReport](#healthcheckwebsocketreport) | false | | | ## healthcheck.WebsocketReport From ee8bd1b3c943342e83e748681c21b04d4ad33f2a Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 12:35:23 +0100 Subject: [PATCH 03/11] make site/src/api/typesGenerated.ts --- site/src/api/typesGenerated.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 920237160dfd1..94317b91bd3cc 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -2095,6 +2095,7 @@ export interface HealthcheckDatabaseReport { export interface HealthcheckReport { readonly time: string; readonly healthy: boolean; + readonly warning: boolean; readonly failing_sections: string[]; // Named type "github.com/coder/coder/v2/coderd/healthcheck/derphealth.Report" unknown, using "any" // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type @@ -2118,6 +2119,7 @@ export interface HealthcheckWebsocketReport { // From derphealth/derp.go export interface DerphealthNodeReport { readonly healthy: boolean; + readonly warning: boolean; // Named type "tailscale.com/tailcfg.DERPNode" unknown, using "any" // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type readonly node?: any; @@ -2137,6 +2139,7 @@ export interface DerphealthNodeReport { // From derphealth/derp.go export interface DerphealthRegionReport { readonly healthy: boolean; + readonly warning: boolean; // Named type "tailscale.com/tailcfg.DERPRegion" unknown, using "any" // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type readonly region?: any; @@ -2147,6 +2150,7 @@ export interface DerphealthRegionReport { // From derphealth/derp.go export interface DerphealthReport { readonly healthy: boolean; + readonly warning: boolean; readonly regions: Record; // Named type "tailscale.com/net/netcheck.Report" unknown, using "any" // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type From 99893ff5a6672cc3b32f20d27f3abf950df1c53a Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 14:06:10 +0100 Subject: [PATCH 04/11] WIP --- site/src/api/api.ts | 9 ++- site/src/api/typesGenerated.ts | 2 +- .../pages/HealthPage/HealthPage.stories.tsx | 13 ++++ site/src/pages/HealthPage/HealthPage.tsx | 31 +++++--- site/src/testHelpers/entities.ts | 76 +++++++++---------- 5 files changed, 77 insertions(+), 54 deletions(-) diff --git a/site/src/api/api.ts b/site/src/api/api.ts index ae26b8b0cbb80..4ea39109c9397 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -1557,12 +1557,13 @@ export const getInsightsTemplate = async ( export interface Health { healthy: boolean; + warning: boolean; time: string; coder_version: string; - access_url: { healthy: boolean }; - database: { healthy: boolean }; - derp: { healthy: boolean }; - websocket: { healthy: boolean }; + access_url: { healthy: boolean; warning: boolean }; + database: { healthy: boolean; warning: boolean }; + derp: { healthy: boolean; warning: boolean }; + websocket: { healthy: boolean; warning: boolean }; } export const getHealth = async () => { diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 94317b91bd3cc..16025c6798511 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -2099,7 +2099,7 @@ export interface HealthcheckReport { readonly failing_sections: string[]; // Named type "github.com/coder/coder/v2/coderd/healthcheck/derphealth.Report" unknown, using "any" // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type - readonly derp: any; + readonly derp: DerphealthReport; readonly access_url: HealthcheckAccessURLReport; readonly websocket: HealthcheckWebsocketReport; readonly database: HealthcheckDatabaseReport; diff --git a/site/src/pages/HealthPage/HealthPage.stories.tsx b/site/src/pages/HealthPage/HealthPage.stories.tsx index f0a88cc5b4518..5e2b2b2f0717e 100644 --- a/site/src/pages/HealthPage/HealthPage.stories.tsx +++ b/site/src/pages/HealthPage/HealthPage.stories.tsx @@ -31,3 +31,16 @@ export const UnhealthyDERP: Story = { }, }, }; + +export const HealthyDERPWithWarning: Story = { + args: { + healthStatus: { + ...MockHealth, + warning: true, + derp: { + ...MockHealth.derp, + warning: true, + }, + }, + }, +}; diff --git a/site/src/pages/HealthPage/HealthPage.tsx b/site/src/pages/HealthPage/HealthPage.tsx index 70ddd62185a72..e527a34eb2a68 100644 --- a/site/src/pages/HealthPage/HealthPage.tsx +++ b/site/src/pages/HealthPage/HealthPage.tsx @@ -85,7 +85,9 @@ export function HealthPageView({ {healthStatus.healthy - ? "All systems operational" + ? healthStatus.warning + ? "All systems operational, but performance might be degraded" + : "All systems operational" : "Some issues have been detected"} @@ -139,7 +141,8 @@ export function HealthPageView({ const isActive = tab.value === key; const isHealthy = healthStatus[key as keyof typeof sections].healthy; - + const isWarning = + healthStatus[key as keyof typeof sections].warning; return ( {isHealthy ? ( - theme.palette.success.light, - }} - /> + isWarning ? ( + theme.palette.warning.main, + }} + /> + ) : ( + theme.palette.success.light, + }} + /> + ) ) : ( Date: Fri, 10 Nov 2023 14:30:42 +0100 Subject: [PATCH 05/11] WIP --- site/src/api/api.ts | 15 ++-------- site/src/pages/HealthPage/HealthPage.tsx | 16 +++++++---- site/src/testHelpers/entities.ts | 35 +++++++++++++++++++----- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 4ea39109c9397..0f1d75b0bb9b9 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -1555,18 +1555,9 @@ export const getInsightsTemplate = async ( return response.data; }; -export interface Health { - healthy: boolean; - warning: boolean; - time: string; - coder_version: string; - access_url: { healthy: boolean; warning: boolean }; - database: { healthy: boolean; warning: boolean }; - derp: { healthy: boolean; warning: boolean }; - websocket: { healthy: boolean; warning: boolean }; -} - export const getHealth = async () => { - const response = await axios.get("/api/v2/debug/health"); + const response = await axios.get( + "/api/v2/debug/health", + ); return response.data; }; diff --git a/site/src/pages/HealthPage/HealthPage.tsx b/site/src/pages/HealthPage/HealthPage.tsx index e527a34eb2a68..d82cf014d025f 100644 --- a/site/src/pages/HealthPage/HealthPage.tsx +++ b/site/src/pages/HealthPage/HealthPage.tsx @@ -19,6 +19,7 @@ import { import { Stats, StatsItem } from "components/Stats/Stats"; import { createDayString } from "utils/createDayString"; import { DashboardFullPage } from "components/Dashboard/DashboardLayout"; +import { DerphealthReport } from "api/typesGenerated" const sections = { derp: "DERP", @@ -139,10 +140,12 @@ export function HealthPageView({ .map((key) => { const label = sections[key as keyof typeof sections]; const isActive = tab.value === key; - const isHealthy = - healthStatus[key as keyof typeof sections].healthy; - const isWarning = - healthStatus[key as keyof typeof sections].warning; + const healthSection = healthStatus[key as keyof typeof sections] + const isHealthy = healthSection.healthy; + if (healthSection instanceof DerphealthReport) { + + } + const isWarning = (healthSection as DerphealthReport).warning; return ( ); -} +}; + +export const getValidationErrorMessage = (error: unknown): string => { + const styles = { stats: (theme) => ({ diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index 52507ab06eaca..b3139b7523999 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -1,8 +1,7 @@ import { withDefaultFeatures, type GetLicensesResponse, - type DeploymentConfig, - type Health, + type DeploymentConfig } from "api/api"; import { FieldError } from "api/errors"; import * as TypesGen from "api/typesGenerated"; @@ -2809,12 +2808,34 @@ export const MockListeningPortsResponse: TypesGen.WorkspaceAgentListeningPortsRe ], }; -export const DeploymentHealthUnhealthy: Health = { +export const DeploymentHealthUnhealthy: TypesGen.HealthcheckReport = { healthy: false, + warning: false, + 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: { healthy: true }, - database: { healthy: false }, - derp: { healthy: false }, - websocket: { healthy: false }, + access_url: { + healthy: true, + access_url: "", + healthz_response: "", + reachable: true, + status_code: 0, + }, + database: { + healthy: false, + latency: "", + latency_ms: 0, + reachable: true, + }, + derp: { + healthy: false, + warning: false, + regions: [], + netcheck_logs: [], + }, + websocket: { + healthy: false, + body: "", + code: 0, + }, }; From b0dace2a0c1068e99d5b8338da8eb660782b59d1 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 14:34:46 +0100 Subject: [PATCH 06/11] WIP --- site/src/pages/HealthPage/HealthPage.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/site/src/pages/HealthPage/HealthPage.tsx b/site/src/pages/HealthPage/HealthPage.tsx index d82cf014d025f..f3ff72d8fa44f 100644 --- a/site/src/pages/HealthPage/HealthPage.tsx +++ b/site/src/pages/HealthPage/HealthPage.tsx @@ -226,9 +226,6 @@ export function HealthPageView({ ); }; -export const getValidationErrorMessage = (error: unknown): string => { - - const styles = { stats: (theme) => ({ padding: 0, From f97a35922e0e4de7a7a4eac0d61c30daf553dd13 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 15:17:55 +0100 Subject: [PATCH 07/11] fmt --- site/src/pages/HealthPage/HealthPage.tsx | 8 ++++---- site/src/testHelpers/entities.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/site/src/pages/HealthPage/HealthPage.tsx b/site/src/pages/HealthPage/HealthPage.tsx index f3ff72d8fa44f..65d01e439e1e5 100644 --- a/site/src/pages/HealthPage/HealthPage.tsx +++ b/site/src/pages/HealthPage/HealthPage.tsx @@ -19,7 +19,7 @@ import { import { Stats, StatsItem } from "components/Stats/Stats"; import { createDayString } from "utils/createDayString"; import { DashboardFullPage } from "components/Dashboard/DashboardLayout"; -import { DerphealthReport } from "api/typesGenerated" +import { DerphealthReport } from "api/typesGenerated"; const sections = { derp: "DERP", @@ -140,10 +140,10 @@ export function HealthPageView({ .map((key) => { const label = sections[key as keyof typeof sections]; const isActive = tab.value === key; - const healthSection = healthStatus[key as keyof typeof sections] + const healthSection = + healthStatus[key as keyof typeof sections]; const isHealthy = healthSection.healthy; if (healthSection instanceof DerphealthReport) { - } const isWarning = (healthSection as DerphealthReport).warning; return ( @@ -224,7 +224,7 @@ export function HealthPageView({ ); -}; +} const styles = { stats: (theme) => ({ diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index b3139b7523999..ad8e4623dcecb 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -1,7 +1,7 @@ import { withDefaultFeatures, type GetLicensesResponse, - type DeploymentConfig + type DeploymentConfig, } from "api/api"; import { FieldError } from "api/errors"; import * as TypesGen from "api/typesGenerated"; From 7f82c1ba4de547b0e87a637b8b7a1fa2b1e43481 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 15:57:10 +0100 Subject: [PATCH 08/11] Fix --- .../Dashboard/DeploymentBanner/DeploymentBannerView.tsx | 5 ++--- site/src/pages/HealthPage/HealthPage.tsx | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx b/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx index 61f68cc5b0f0b..1f27a9a38975d 100644 --- a/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx +++ b/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx @@ -1,5 +1,4 @@ -import type { Health } from "api/api"; -import type { DeploymentStats, WorkspaceStatus } from "api/typesGenerated"; +import type { DeploymentStats, HealthcheckReport, WorkspaceStatus } from "api/typesGenerated"; import { type FC, useMemo, @@ -67,7 +66,7 @@ const styles = { } satisfies Record>; export interface DeploymentBannerViewProps { - health?: Health; + health?: HealthcheckReport; stats?: DeploymentStats; fetchStats?: () => void; } diff --git a/site/src/pages/HealthPage/HealthPage.tsx b/site/src/pages/HealthPage/HealthPage.tsx index 65d01e439e1e5..e25430d2b9697 100644 --- a/site/src/pages/HealthPage/HealthPage.tsx +++ b/site/src/pages/HealthPage/HealthPage.tsx @@ -143,9 +143,7 @@ export function HealthPageView({ const healthSection = healthStatus[key as keyof typeof sections]; const isHealthy = healthSection.healthy; - if (healthSection instanceof DerphealthReport) { - } - const isWarning = (healthSection as DerphealthReport).warning; + const isWarning = (healthSection as DerphealthReport)?.warning; return ( Date: Fri, 10 Nov 2023 16:05:17 +0100 Subject: [PATCH 09/11] fix --- .../Dashboard/DeploymentBanner/DeploymentBannerView.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx b/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx index 1f27a9a38975d..3fea96bc4cc4f 100644 --- a/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx +++ b/site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx @@ -1,4 +1,8 @@ -import type { DeploymentStats, HealthcheckReport, WorkspaceStatus } from "api/typesGenerated"; +import type { + DeploymentStats, + HealthcheckReport, + WorkspaceStatus, +} from "api/typesGenerated"; import { type FC, useMemo, From e9497eece4bcab1fe21f1a43a0838896eefa74e1 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 16:14:03 +0100 Subject: [PATCH 10/11] Remove comment --- site/src/api/typesGenerated.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 16025c6798511..4226b57af11e3 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -2097,8 +2097,6 @@ export interface HealthcheckReport { readonly healthy: boolean; readonly warning: boolean; readonly failing_sections: string[]; - // Named type "github.com/coder/coder/v2/coderd/healthcheck/derphealth.Report" unknown, using "any" - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- External type readonly derp: DerphealthReport; readonly access_url: HealthcheckAccessURLReport; readonly websocket: HealthcheckWebsocketReport; From fa7224f4f1af1c501651d9e1717281a8a5062625 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 10 Nov 2023 16:22:01 +0100 Subject: [PATCH 11/11] Fix: test --- coderd/healthcheck/derphealth/derp_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/healthcheck/derphealth/derp_test.go b/coderd/healthcheck/derphealth/derp_test.go index 5b72007150ba4..80c7e8f72b321 100644 --- a/coderd/healthcheck/derphealth/derp_test.go +++ b/coderd/healthcheck/derphealth/derp_test.go @@ -174,7 +174,7 @@ func TestDERP(t *testing.T) { for _, region := range report.Regions { assert.False(t, region.Healthy) for _, node := range region.NodeReports { - assert.False(t, node.Healthy) + assert.True(t, node.Healthy) assert.True(t, node.CanExchangeMessages) assert.NotEmpty(t, node.RoundTripPing) assert.Len(t, node.ClientLogs, 2)