Skip to content

Commit 3cf35eb

Browse files
committed
WIP
1 parent f400d8a commit 3cf35eb

File tree

5 files changed

+42
-32
lines changed

5 files changed

+42
-32
lines changed

coderd/healthcheck/healthcheck.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Checker interface {
3030
Database(ctx context.Context, opts *DatabaseReportOptions) DatabaseReport
3131
}
3232

33-
// @typescript-generate Report
33+
// @typescript-generate DerphealthReport
3434
type Report struct {
3535
// Time is the time the report was generated at.
3636
Time time.Time `json:"time"`

scripts/apitypings/main_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ func TestGeneration(t *testing.T) {
4141
})
4242
}
4343
}
44+
45+
func TestFoo(t *testing.T) {
46+
output, err := Generate("/Users/mtojek/code/coder/coderd/healthcheck")
47+
require.NoError(t, err)
48+
require.Equal(t, "a", output)
49+
}

site/src/api/api.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -1555,17 +1555,7 @@ export const getInsightsTemplate = async (
15551555
return response.data;
15561556
};
15571557

1558-
export interface Health {
1559-
healthy: boolean;
1560-
time: string;
1561-
coder_version: string;
1562-
access_url: { healthy: boolean };
1563-
database: { healthy: boolean };
1564-
derp: { healthy: boolean };
1565-
websocket: { healthy: boolean };
1566-
}
1567-
15681558
export const getHealth = async () => {
1569-
const response = await axios.get<Health>("/api/v2/debug/health");
1559+
const response = await axios.get<TypesGen.HealthcheckReport>("/api/v2/debug/health");
15701560
return response.data;
15711561
};

site/src/components/Dashboard/DeploymentBanner/DeploymentBannerView.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Health } from "api/api";
2-
import type { DeploymentStats, WorkspaceStatus } from "api/typesGenerated";
1+
import type { DeploymentStats, HealthcheckReport, WorkspaceStatus } from "api/typesGenerated";
32
import {
43
type FC,
54
useMemo,
@@ -67,7 +66,7 @@ const styles = {
6766
} satisfies Record<string, Interpolation<Theme>>;
6867

6968
export interface DeploymentBannerViewProps {
70-
health?: Health;
69+
health?: HealthcheckReport;
7170
stats?: DeploymentStats;
7271
fetchStats?: () => void;
7372
}

site/src/testHelpers/entities.ts

+32-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import {
22
withDefaultFeatures,
33
type GetLicensesResponse,
4-
type DeploymentConfig,
5-
type Health,
4+
type DeploymentConfig
65
} from "api/api";
76
import { FieldError } from "api/errors";
87
import * as TypesGen from "api/typesGenerated";
@@ -2385,10 +2384,10 @@ export const MockLicenseResponse: GetLicensesResponse[] = [
23852384
},
23862385
];
23872386

2388-
export const MockHealth = {
2387+
export const MockHealth: TypesGen.HealthcheckReport = {
23892388
time: "2023-08-01T16:51:03.29792825Z",
23902389
healthy: true,
2391-
failing_sections: null,
2390+
failing_sections: [],
23922391
derp: {
23932392
healthy: true,
23942393
regions: {
@@ -2785,21 +2784,17 @@ export const MockHealth = {
27852784
reachable: true,
27862785
status_code: 200,
27872786
healthz_response: "OK",
2788-
error: null,
27892787
},
27902788
websocket: {
27912789
healthy: true,
2792-
response: {
2793-
body: "",
2794-
code: 101,
2795-
},
2796-
error: null,
2790+
body: "",
2791+
code: 101
27972792
},
27982793
database: {
27992794
healthy: true,
28002795
reachable: true,
2801-
latency: 92570,
2802-
error: null,
2796+
latency: "92570",
2797+
latency_ms: 92570,
28032798
},
28042799
coder_version: "v0.27.1-devel+c575292",
28052800
};
@@ -2813,12 +2808,32 @@ export const MockListeningPortsResponse: TypesGen.WorkspaceAgentListeningPortsRe
28132808
],
28142809
};
28152810

2816-
export const DeploymentHealthUnhealthy: Health = {
2811+
export const DeploymentHealthUnhealthy: TypesGen.HealthcheckReport = {
28172812
healthy: false,
2813+
failing_sections: [], // apparently this property is not used at all?
28182814
time: "2023-10-12T23:15:00.000000000Z",
28192815
coder_version: "v2.3.0-devel+8cca4915a",
2820-
access_url: { healthy: true },
2821-
database: { healthy: false },
2822-
derp: { healthy: false },
2823-
websocket: { healthy: false },
2816+
access_url: {
2817+
healthy: true,
2818+
access_url: "",
2819+
healthz_response: "",
2820+
reachable: true,
2821+
status_code: 0,
2822+
},
2823+
database: {
2824+
healthy: false,
2825+
latency: "",
2826+
latency_ms: 0,
2827+
reachable: true,
2828+
},
2829+
derp: {
2830+
healthy: false,
2831+
regions: [],
2832+
netcheck_logs: [],
2833+
},
2834+
websocket: {
2835+
healthy: false,
2836+
body: "",
2837+
code: 0,
2838+
},
28242839
};

0 commit comments

Comments
 (0)