envoy

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitReasonExit        = "exit"
	ExitReasonSignal      = "signal"
	ExitReasonOOMKill     = "oom_kill"
	ExitReasonStartFailed = "start_failed"
)

Exit reasons the runtime records. The code is the decimal exit status for ExitReasonExit, the signal name for ExitReasonSignal and ExitReasonOOMKill, and empty for ExitReasonStartFailed.

View Source
const (

	// DefaultVersion is the Envoy release that backplane images bake in and
	// that the runtime downloads. The Envoy version must not float, because a
	// new minor release can break the Go filter. Bump it only after a soak
	// test of the new release.
	DefaultVersion = "v1.35.13"
)

Variables

This section is empty.

Functions

func NewReadyChecker

func NewReadyChecker(adminHost string, listeners ...*Listener) *readyChecker

NewReadyChecker creates a new readyChecker.

Types

type ChecksumDownloader added in v0.23.0

type ChecksumDownloader interface {
	// DownloadChecksum returns the published SHA-256 digest of the binary in
	// lowercase hex. It returns an empty digest when no checksum is published.
	DownloadChecksum(ctx context.Context) (string, error)
}

ChecksumDownloader is implemented by releases that can publish a ".sha256" sidecar next to the binary.

type ExitInfo added in v0.23.0

type ExitInfo struct {
	// At is the time the exit was recorded.
	At time.Time
	// ProcState is the state of the exited process. It is nil if the process
	// never started.
	ProcState *os.ProcessState
	// Err is the error returned by the wait on the process, if any.
	Err error
	// Reason is one of exit, signal, oom_kill and start_failed.
	Reason string
	// Code is the decimal exit status for an exit, the signal name for a
	// signal and an OOM kill, and empty for a failed start.
	Code string
	// Uptime is how long the process ran.
	Uptime time.Duration
	// RequestsInFlight is the last sampled number of active downstream
	// requests. It is nil when no sample was taken.
	RequestsInFlight *int64
	// Connections is the last sampled number of active downstream connections.
	// It is nil when no sample was taken.
	Connections *int64
	// SampleAge is how old the sample was when the process exited.
	SampleAge time.Duration
	// ConnectionsAborted counts the established connections the kernel tore
	// down when the process died. The value at the exit is a floor, because
	// the kernel resets the sockets after the parent reaps the process. It
	// becomes final when the next process starts.
	ConnectionsAborted int64
	// ConnectionsRefused counts the connection attempts the kernel answered
	// with a reset while Envoy was gone. It becomes final when the next
	// process starts.
	ConnectionsRefused int64
}

ExitInfo records the last exit of the Envoy process.

type ExitKey added in v0.23.1

type ExitKey struct {
	// Reason is one of exit, signal, oom_kill and start_failed.
	Reason string
	// Code is the exit status or the signal name.
	Code string
}

ExitKey names one kind of exit. The set of keys is bounded by the reason vocabulary and the exit status range.

type FatalError

type FatalError struct {
	Err error
}

FatalError is an error that should cause the runtime to exit.

func (FatalError) Error

func (e FatalError) Error() string

Error implements the error interface.

type GitHubRelease

type GitHubRelease struct {
	Version string
	Sha     string
	Contrib bool
}

GitHubRelease represents a release from GitHub.

func (*GitHubRelease) DownloadBinary

func (r *GitHubRelease) DownloadBinary(ctx context.Context) (io.ReadCloser, error)

func (*GitHubRelease) DownloadChecksum added in v0.23.0

func (r *GitHubRelease) DownloadChecksum(ctx context.Context) (string, error)

DownloadChecksum returns the digest published next to the release binary.

func (*GitHubRelease) String

func (r *GitHubRelease) String() string

type Identity added in v0.23.1

type Identity struct {
	// Proxy is the name of the Proxy object.
	Proxy string
	// Replica is the name of the replica.
	Replica string
	// ProjectID is the Apoxy project. It is empty outside the hosted platform.
	ProjectID string
}

Identity names the Proxy and the replica the Envoy process belongs to.

type LatestCachedRelease

type LatestCachedRelease struct {
	Path string
	// contains filtered or unexported fields
}

func (*LatestCachedRelease) DownloadBinary

func (r *LatestCachedRelease) DownloadBinary(ctx context.Context) (io.ReadCloser, error)

func (*LatestCachedRelease) String

func (r *LatestCachedRelease) String() string

type Limits added in v0.23.1

type Limits struct {
	// MaxActiveDownstreamConnections is the connection cap of the overload
	// manager.
	MaxActiveDownstreamConnections *uint64
	// MaxHeapBytes is the fixed heap size of the overload manager.
	MaxHeapBytes *uint64
}

Limits are the configured ceilings of the Envoy process. Dashboards draw the ceiling next to the value Envoy reports.

type Listener

type Listener struct {
	Name    string
	Address corev3.Address
}

type Metrics added in v0.23.1

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

Metrics exports the state of the Envoy runtime to Prometheus and, when a sink is configured, to an OpenTelemetry collector.

func NewMetrics added in v0.23.1

func NewMetrics(src metricsSource, id Identity, otlpAddr string) (*Metrics, error)

NewMetrics defines the runtime metrics and registers the exporters. An empty otlpAddr leaves the OTLP export off, which is the default outside the hosted platform.

func (*Metrics) Gatherer added in v0.23.1

func (m *Metrics) Gatherer() prometheus.Gatherer

Gatherer returns the Prometheus gatherer of the runtime metrics.

func (*Metrics) Registry added in v0.23.1

func (m *Metrics) Registry() *prometheus.Registry

Registry returns the Prometheus registry the metrics are registered on.

func (*Metrics) Shutdown added in v0.23.1

func (m *Metrics) Shutdown(ctx context.Context) error

Shutdown flushes and stops the exporters.

type Option

type Option func(*Runtime)

Option configures a Runtime.

func WithAdminHost

func WithAdminHost(host string) Option

WithAdminHost sets the host for the Envoy admin interface.

func WithArgs

func WithArgs(args ...string) Option

WithArgs sets additional arguments to pass to Envoy. The arguments are appended to the default arguments.

func WithBootstrapConfigYAML

func WithBootstrapConfigYAML(yaml string) Option

WithBootstrapConfigYAML sets the Envoy bootstrap config YAML.

func WithCluster

func WithCluster(cluster string) Option

WithCluster sets the Envoy cluster name. If this is not set, a random cluster name is used. The cluster name is used in the Envoy bootstrap config.

func WithDrainTimeout

func WithDrainTimeout(timeout *time.Duration) Option

If this is not set, the default timeout is used (30 seconds).

func WithGoPluginDir

func WithGoPluginDir(dir string) Option

WithGoPluginDir sets the directory to load Go plugins from.

func WithIdentity added in v0.23.1

func WithIdentity(proxy, replica, projectID string) Option

WithIdentity names the Proxy and the replica this runtime belongs to. Every metric datapoint carries the names as attributes. The project ID is empty outside the hosted platform.

func WithLimits added in v0.23.1

func WithLimits(l Limits) Option

WithLimits sets the configured ceilings of the Envoy process. The runtime publishes them as gauges next to the values Envoy reports.

func WithLogsCollector

func WithLogsCollector(c logs.LogsCollector) Option

WithLogsCollector sets the logs collector.

func WithMinDrainTime

func WithMinDrainTime(timeout *time.Duration) Option

If this is not set, the default timeout is used (30 seconds).

func WithNodeMetadata

func WithNodeMetadata(metadata *xdstypes.NodeMetadata) Option

WithNodeMetadata sets the metadata for the Envoy node in XDS discovery requests. The metadata will be included in the node configuration and sent to the control plane.

func WithOTLPMetricSink added in v0.23.1

func WithOTLPMetricSink(addr string) Option

WithOTLPMetricSink sends the runtime metrics to the OpenTelemetry collector at addr ("host:port"). An empty address leaves the OTLP export off.

func WithOtelCollector

func WithOtelCollector(c *otel.Collector) Option

WithOtelCollector sets the OpenTelemetry collector.

func WithRelease

func WithRelease(release ReleaseDownloader) Option

WithRelease sets the Envoy release to use. If this is not set, the latest release is used.

type ReleaseDownloader

type ReleaseDownloader interface {
	// String returns the release version.
	String() string

	// DownloadBinary downloads the release binary.
	DownloadBinary(ctx context.Context) (io.ReadCloser, error)
}

type Runtime

type Runtime struct {
	EnvoyPath           string
	BootstrapConfigYAML string
	Release             ReleaseDownloader
	Cluster             string
	// Args are additional arguments to pass to Envoy.
	Args []string
	// contains filtered or unexported fields
}

func (*Runtime) Configure added in v0.23.1

func (r *Runtime) Configure(opts ...Option)

Configure applies options to the runtime before it starts. Metrics read the values at collection time, so the caller sets identity and limits once.

func (*Runtime) Gatherer added in v0.23.1

func (r *Runtime) Gatherer() prometheus.Gatherer

Gatherer returns the Prometheus gatherer of the runtime metrics. The metrics server appends the families to the Envoy stats.

func (*Runtime) Metrics added in v0.23.1

func (r *Runtime) Metrics() *Metrics

Metrics returns the runtime metrics and defines them on first use.

func (*Runtime) RuntimeStatus

func (r *Runtime) RuntimeStatus() RuntimeStatus

RuntimeStatus returns the status of the Envoy process.

func (*Runtime) Shutdown

func (r *Runtime) Shutdown(ctx context.Context) error

Shutdown gracefully drains connections and shuts down the Envoy process.

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context, opts ...Option) error

Start starts the Envoy binary.

type RuntimeStatus

type RuntimeStatus struct {
	StartedAt time.Time
	Starting  bool
	Running   bool
	ProcState *os.ProcessState
	// LastExit is the last recorded exit of the Envoy process. It is nil until
	// the process exits for the first time.
	LastExit *ExitInfo
	// Restarts counts how many times the runtime started Envoy again after an
	// exit.
	Restarts int
	// ExitCounts counts the exits of each reason and code.
	ExitCounts map[ExitKey]int64
}

type URLRelease

type URLRelease struct {
	URL string
}

func (*URLRelease) DownloadBinary

func (r *URLRelease) DownloadBinary(ctx context.Context) (io.ReadCloser, error)

func (*URLRelease) DownloadChecksum added in v0.23.0

func (r *URLRelease) DownloadChecksum(ctx context.Context) (string, error)

DownloadChecksum returns the digest published next to the release binary.

func (*URLRelease) String

func (r *URLRelease) String() string

Jump to

Keyboard shortcuts

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