mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat(coderd/healthcheck): add health check for proxy (#10846)
Adds a health check for workspace proxies: - Healthy iff all proxies are healthy and the same version, - Warning if some proxies are unhealthy, - Error if all proxies are unhealthy, or do not all have the same version.
This commit is contained in:
@ -960,3 +960,20 @@ func convertProxy(p database.WorkspaceProxy, status proxyhealth.ProxyStatus) cod
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// workspaceProxiesFetchUpdater implements healthcheck.WorkspaceProxyFetchUpdater
|
||||
// in an actually useful and meaningful way.
|
||||
type workspaceProxiesFetchUpdater struct {
|
||||
fetchFunc func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error)
|
||||
updateFunc func(context.Context) error
|
||||
}
|
||||
|
||||
func (w *workspaceProxiesFetchUpdater) Fetch(ctx context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error) {
|
||||
//nolint:gocritic // Need perms to read all workspace proxies.
|
||||
authCtx := dbauthz.AsSystemRestricted(ctx)
|
||||
return w.fetchFunc(authCtx)
|
||||
}
|
||||
|
||||
func (w *workspaceProxiesFetchUpdater) Update(ctx context.Context) error {
|
||||
return w.updateFunc(ctx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user