proxyhealth

package
v2.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Interval is the interval at which the proxy health is checked.
	Interval   time.Duration
	DB         database.Store
	Logger     slog.Logger
	Client     *http.Client
	Prometheus *prometheus.Registry
}

type ProxyHealth

type ProxyHealth struct {
	// contains filtered or unexported fields
}

ProxyHealth runs a go routine that periodically checks the health of all workspace proxies. This information is stored in memory, so each coderd replica has its own view of the health of the proxies. These views should be consistent, and if they are not, it indicates a problem.

func New

func New(opts *Options) (*ProxyHealth, error)

func (*ProxyHealth) ForceUpdate

func (p *ProxyHealth) ForceUpdate(ctx context.Context) error

ForceUpdate runs a single health check and updates the cache. If the health check fails, the cache is not updated and an error is returned. This is useful to trigger an update when a proxy is created or deleted.

func (*ProxyHealth) HealthStatus

func (p *ProxyHealth) HealthStatus() map[uuid.UUID]ProxyStatus

HealthStatus returns the current health status of all proxies stored in the cache.

func (*ProxyHealth) ProxyHosts

func (p *ProxyHealth) ProxyHosts() []string

ProxyHosts returns the host:port of all healthy proxies. This can be computed from HealthStatus, but is cached to avoid the caller needing to loop over all proxies to compute this on all static web requests.

func (*ProxyHealth) Run

func (p *ProxyHealth) Run(ctx context.Context)

Run will block until the context is canceled. It will periodically check the health of all proxies and store the results in the cache.

type ProxyStatus

type ProxyStatus struct {
	// ProxyStatus includes the value of the proxy at the time of checking. This is
	// useful to know as it helps determine if the proxy checked has different values
	// then the proxy in hand. AKA if the proxy was updated, and the status was for
	// an older proxy.
	Proxy database.WorkspaceProxy
	// ProxyHost is the host:port of the proxy url. This is included in the status
	// to make sure the proxy url is a valid URL. It also makes it easier to
	// escalate errors if the url.Parse errors (should never happen).
	ProxyHost string
	Status    Status
	Report    codersdk.ProxyHealthReport
	CheckedAt time.Time
}

type Status

type Status string
const (
	// Unknown should never be returned by the proxy health check.
	Unknown Status = "unknown"
	// Healthy means the proxy access url is reachable and returns a healthy
	// status code.
	Healthy Status = "ok"
	// Unreachable means the proxy access url is not responding.
	Unreachable Status = "unreachable"
	// Unhealthy means the proxy access url is responding, but there is some
	// problem with the proxy. This problem may or may not be preventing functionality.
	Unhealthy Status = "unhealthy"
	// Unregistered means the proxy has not registered a url yet. This means
	// the proxy was created with the cli, but has not yet been started.
	Unregistered Status = "unregistered"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL