Skip to content

Commit 3129741

Browse files
authored
chore: Proxy health status checks + endpoint (#7233)
* chore: Implement workspace proxy health check cron At a given interval will check the reachability of workspace proxies. * Proxyhealth is an enterprise feature * Start proxyhealth go routine on enterprise coder
1 parent 63e68c1 commit 3129741

File tree

13 files changed

+912
-60
lines changed

13 files changed

+912
-60
lines changed

coderd/apidoc/docs.go

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/workspaceproxy.go

+46-8
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,55 @@ import (
1212
"github.com/google/uuid"
1313
)
1414

15+
type ProxyHealthStatus string
16+
17+
const (
18+
// ProxyReachable means the proxy access url is reachable and returns a healthy
19+
// status code.
20+
ProxyReachable ProxyHealthStatus = "reachable"
21+
// ProxyUnreachable means the proxy access url is not responding.
22+
ProxyUnreachable ProxyHealthStatus = "unreachable"
23+
// ProxyUnhealthy means the proxy access url is responding, but there is some
24+
// problem with the proxy. This problem may or may not be preventing functionality.
25+
ProxyUnhealthy ProxyHealthStatus = "unhealthy"
26+
// ProxyUnregistered means the proxy has not registered a url yet. This means
27+
// the proxy was created with the cli, but has not yet been started.
28+
ProxyUnregistered ProxyHealthStatus = "unregistered"
29+
)
30+
31+
type WorkspaceProxyStatus struct {
32+
Status ProxyHealthStatus `json:"status" table:"status"`
33+
// Report provides more information about the health of the workspace proxy.
34+
Report ProxyHealthReport `json:"report,omitempty" table:"report"`
35+
CheckedAt time.Time `json:"checked_at" table:"checked_at" format:"date-time"`
36+
}
37+
38+
// ProxyHealthReport is a report of the health of the workspace proxy.
39+
// A healthy report will have no errors. Warnings are not fatal.
40+
type ProxyHealthReport struct {
41+
// Errors are problems that prevent the workspace proxy from being healthy
42+
Errors []string
43+
// Warnings do not prevent the workspace proxy from being healthy, but
44+
// should be addressed.
45+
Warnings []string
46+
}
47+
1548
type WorkspaceProxy struct {
16-
ID uuid.UUID `db:"id" json:"id" format:"uuid" table:"id"`
17-
Name string `db:"name" json:"name" table:"name,default_sort"`
18-
Icon string `db:"icon" json:"icon" table:"icon"`
49+
ID uuid.UUID `json:"id" format:"uuid" table:"id"`
50+
Name string `json:"name" table:"name,default_sort"`
51+
Icon string `json:"icon" table:"icon"`
1952
// Full url including scheme of the proxy api url: https://us.example.com
20-
URL string `db:"url" json:"url" table:"url"`
53+
URL string `json:"url" table:"url"`
2154
// WildcardHostname with the wildcard for subdomain based app hosting: *.us.example.com
22-
WildcardHostname string `db:"wildcard_hostname" json:"wildcard_hostname" table:"wildcard_hostname"`
23-
CreatedAt time.Time `db:"created_at" json:"created_at" format:"date-time" table:"created_at"`
24-
UpdatedAt time.Time `db:"updated_at" json:"updated_at" format:"date-time" table:"updated_at"`
25-
Deleted bool `db:"deleted" json:"deleted" table:"deleted"`
55+
WildcardHostname string `json:"wildcard_hostname" table:"wildcard_hostname"`
56+
CreatedAt time.Time `json:"created_at" format:"date-time" table:"created_at"`
57+
UpdatedAt time.Time `json:"updated_at" format:"date-time" table:"updated_at"`
58+
Deleted bool `json:"deleted" table:"deleted"`
59+
60+
// Status is the latest status check of the proxy. This will be empty for deleted
61+
// proxies. This value can be used to determine if a workspace proxy is healthy
62+
// and ready to use.
63+
Status WorkspaceProxyStatus `json:"status,omitempty" table:"status"`
2664
}
2765

2866
type CreateWorkspaceProxyRequest struct {

docs/api/enterprise.md

+42-11
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,14 @@ curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
11851185
"icon": "string",
11861186
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
11871187
"name": "string",
1188+
"status": {
1189+
"checked_at": "2019-08-24T14:15:22Z",
1190+
"report": {
1191+
"errors": ["string"],
1192+
"warnings": ["string"]
1193+
},
1194+
"status": "reachable"
1195+
},
11881196
"updated_at": "2019-08-24T14:15:22Z",
11891197
"url": "string",
11901198
"wildcard_hostname": "string"
@@ -1202,17 +1210,32 @@ curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
12021210

12031211
Status Code **200**
12041212

1205-
| Name | Type | Required | Restrictions | Description |
1206-
| --------------------- | ----------------- | -------- | ------------ | -------------------------------------------------------------------------------------- |
1207-
| `[array item]` | array | false | | |
1208-
| `» created_at` | string(date-time) | false | | |
1209-
| `» deleted` | boolean | false | | |
1210-
| `» icon` | string | false | | |
1211-
| `» id` | string(uuid) | false | | |
1212-
| `» name` | string | false | | |
1213-
| `» updated_at` | string(date-time) | false | | |
1214-
| `» url` | string | false | | Full URL including scheme of the proxy api url: https://us.example.com |
1215-
| `» wildcard_hostname` | string | false | | Wildcard hostname with the wildcard for subdomain based app hosting: \*.us.example.com |
1213+
| Name | Type | Required | Restrictions | Description |
1214+
| --------------------- | ------------------------------------------------------------------------ | -------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1215+
| `[array item]` | array | false | | |
1216+
| `» created_at` | string(date-time) | false | | |
1217+
| `» deleted` | boolean | false | | |
1218+
| `» icon` | string | false | | |
1219+
| `» id` | string(uuid) | false | | |
1220+
| `» name` | string | false | | |
1221+
| `» status` | [codersdk.WorkspaceProxyStatus](schemas.md#codersdkworkspaceproxystatus) | false | | Status is the latest status check of the proxy. This will be empty for deleted proxies. This value can be used to determine if a workspace proxy is healthy and ready to use. |
1222+
| `»» checked_at` | string(date-time) | false | | |
1223+
| `»» report` | [codersdk.ProxyHealthReport](schemas.md#codersdkproxyhealthreport) | false | | Report provides more information about the health of the workspace proxy. |
1224+
| `»»» errors` | array | false | | Errors are problems that prevent the workspace proxy from being healthy |
1225+
| `»»» warnings` | array | false | | Warnings do not prevent the workspace proxy from being healthy, but should be addressed. |
1226+
| `»» status` | [codersdk.ProxyHealthStatus](schemas.md#codersdkproxyhealthstatus) | false | | |
1227+
| `» updated_at` | string(date-time) | false | | |
1228+
| `» url` | string | false | | Full URL including scheme of the proxy api url: https://us.example.com |
1229+
| `» wildcard_hostname` | string | false | | Wildcard hostname with the wildcard for subdomain based app hosting: \*.us.example.com |
1230+
1231+
#### Enumerated Values
1232+
1233+
| Property | Value |
1234+
| -------- | -------------- |
1235+
| `status` | `reachable` |
1236+
| `status` | `unreachable` |
1237+
| `status` | `unhealthy` |
1238+
| `status` | `unregistered` |
12161239

12171240
To perform this operation, you must be authenticated. [Learn more](authentication.md).
12181241

@@ -1257,6 +1280,14 @@ curl -X POST http://coder-server:8080/api/v2/workspaceproxies \
12571280
"icon": "string",
12581281
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
12591282
"name": "string",
1283+
"status": {
1284+
"checked_at": "2019-08-24T14:15:22Z",
1285+
"report": {
1286+
"errors": ["string"],
1287+
"warnings": ["string"]
1288+
},
1289+
"status": "reachable"
1290+
},
12601291
"updated_at": "2019-08-24T14:15:22Z",
12611292
"url": "string",
12621293
"wildcard_hostname": "string"

0 commit comments

Comments
 (0)