-
Notifications
You must be signed in to change notification settings - Fork 930
chore: Proxy health status checks + endpoint #7233
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
Conversation
At a given interval will check the reachability of workspace proxies.
healthCheckDuration := prometheus.NewHistogram(prometheus.HistogramOpts{ | ||
Namespace: "coderd", | ||
Subsystem: "proxyhealth", | ||
Name: "health_check_duration_seconds", | ||
Help: "Histogram for duration of proxy health collection in seconds.", | ||
Buckets: []float64{0.001, 0.005, 0.010, 0.025, 0.050, 0.100, 0.500, 1, 5, 10, 30}, | ||
}) | ||
opts.Prometheus.MustRegister(healthCheckDuration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have a labeled metric too with the proxy name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the total duration to check all proxies. I just wanted to make sure this routine doesn't end up taking forever
ProxyToken: fullToken, | ||
}) | ||
|
||
// Update the proxy health cache to include this new proxy. | ||
go api.forceWorkspaceProxyHealthUpdate(api.ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't do anything since it's not registered yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It adds the "Unregistered" to the cache. Before you call this, the proxy is not in the cache since the cache pulls it's list from the database.
So subsequent calls to proxy will now return this unregistered.
} | ||
// A switch statement felt easier to categorize the different cases than | ||
// if else statements or nested if statements. | ||
switch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool 😎
What this does
Workspace proxy feature (currently experimental) needs a health check to determine which workspace proxies are currently available. Without this, users could be directed to unreachable proxies.
This instantiates an in-memory cache that periodically checks the reach-ability of all workspace proxies and saves them. The endpoints that return workspace proxies now include health information.
Fixes #6909