Skip to content

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

Merged
merged 17 commits into from
Apr 24, 2023
Merged

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Apr 20, 2023

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

@Emyrk Emyrk marked this pull request as ready for review April 21, 2023 12:49
@Emyrk Emyrk requested a review from deansheather April 21, 2023 12:54
Comment on lines +81 to +88
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)
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

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.

Copy link
Member Author

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.

@Emyrk Emyrk requested a review from deansheather April 24, 2023 14:16
}
// A switch statement felt easier to categorize the different cases than
// if else statements or nested if statements.
switch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool 😎

@Emyrk Emyrk merged commit 3129741 into main Apr 24, 2023
@Emyrk Emyrk deleted the stevenmasley/proxy_health branch April 24, 2023 15:25
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Moon health checks
2 participants