health

package
v0.0.0-...-288f078 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckCommand cmd.Handler = checkCommand{}

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	Cluster *arvados.Cluster

	// If non-nil, Log is called after handling each request.
	Log func(*http.Request, error)

	// If non-nil, report clock skew on each health-check.
	MetricClockSkew prometheus.Gauge
	// contains filtered or unexported fields
}

Aggregator implements service.Handler. It handles "GET /_health/all" by checking the health of all configured services on the cluster and responding 200 if everything is healthy.

func (*Aggregator) CheckHealth

func (agg *Aggregator) CheckHealth() error

func (*Aggregator) ClusterHealth

func (agg *Aggregator) ClusterHealth() ClusterHealthResponse

func (*Aggregator) Done

func (agg *Aggregator) Done() <-chan struct{}

func (*Aggregator) ServeHTTP

func (agg *Aggregator) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type CheckResult

type CheckResult struct {
	Health         string
	Error          string                 `json:",omitempty"`
	HTTPStatusCode int                    `json:",omitempty"`
	Response       map[string]interface{} `json:",omitempty"`
	ResponseTime   json.Number
	ClockTime      time.Time
	Server         string // "Server" header in http response
	Metrics
	// contains filtered or unexported fields
}

type ClusterHealthResponse

type ClusterHealthResponse struct {
	// "OK" if all needed services are OK, otherwise "ERROR".
	Health string

	// An entry for each known health check of each known instance
	// of each needed component: "instance of service S on node N
	// reports health-check C is OK."
	Checks map[string]CheckResult

	// An entry for each service type: "service S is OK." This
	// exposes problems that can't be expressed in Checks, like
	// "service S is needed, but isn't configured to run
	// anywhere."
	Services map[arvados.ServiceName]ServiceHealth

	// Difference between min/max timestamps in individual
	// health-check responses.
	ClockSkew arvados.Duration

	Errors []string
}

type Func

type Func func() error

Func is a health-check function: it returns nil when healthy, an error when not.

type Handler

type Handler struct {

	// Authentication token. If empty, all requests will return 404.
	Token string

	// Route prefix, typically "/_health/".
	Prefix string

	// Map of URI paths to health-check Func. The prefix is
	// omitted: Routes["foo"] is the health check invoked by a
	// request to "{Prefix}/foo".
	//
	// If "ping" is not listed here, it will be added
	// automatically and will always return a "healthy" response.
	Routes Routes

	// If non-nil, Log is called after handling each request. The
	// error argument is nil if the request was successfully
	// authenticated and served, even if the health check itself
	// failed.
	Log func(*http.Request, error)
	// contains filtered or unexported fields
}

Handler is an http.Handler that responds to authenticated health-check requests with JSON responses like {"health":"OK"} or {"health":"ERROR","error":"error text"}.

Fields of a Handler should not be changed after the Handler is first used.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type Metrics

type Metrics struct {
	ConfigSourceTimestamp time.Time
	ConfigSourceSHA256    string
	Version               string
}

type Routes

type Routes map[string]Func

Routes is a map of URI path to health-check function.

type ServiceHealth

type ServiceHealth struct {
	Health string // "OK", "ERROR", or "SKIP"
	N      int
}

Jump to

Keyboard shortcuts

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