xds

package
v0.0.0-...-4760111 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(log logr.Logger) envoy_log.Logger

func NewWatchdogCallbacks

func NewWatchdogCallbacks(newNodeWatchdog NewNodeWatchdogFunc) envoy_xds.Callbacks

func SanitizeMetric

func SanitizeMetric(metric string) string

We need to sanitize metrics in order to not break statsd and prometheus format. StatsD only allow [a-zA-Z_\-0-9.] characters, everything else is removed Extra dots breaks many regexes that converts statsd metric to prometheus one with tags

Types

type CallbacksChain

type CallbacksChain []envoy_xds.Callbacks

func (CallbacksChain) OnFetchRequest

func (chain CallbacksChain) OnFetchRequest(ctx context.Context, req *envoy.DiscoveryRequest) (errs error)

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error.

func (CallbacksChain) OnFetchResponse

func (chain CallbacksChain) OnFetchResponse(req *envoy.DiscoveryRequest, resp *envoy.DiscoveryResponse)

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error. OnFetchResponse is called immediately prior to sending a response.

func (CallbacksChain) OnStreamClosed

func (chain CallbacksChain) OnStreamClosed(streamID int64)

OnStreamClosed is called immediately prior to closing an xDS stream with a stream ID.

func (CallbacksChain) OnStreamOpen

func (chain CallbacksChain) OnStreamOpen(ctx context.Context, streamID int64, typ string) (errs error)

OnStreamOpen is called once an xDS stream is open with a stream ID and the type URL (or "" for ADS). Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (CallbacksChain) OnStreamRequest

func (chain CallbacksChain) OnStreamRequest(streamID int64, req *envoy.DiscoveryRequest) (errs error)

OnStreamRequest is called once a request is received on a stream. Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (CallbacksChain) OnStreamResponse

func (chain CallbacksChain) OnStreamResponse(streamID int64, req *envoy.DiscoveryRequest, resp *envoy.DiscoveryResponse)

OnStreamResponse is called immediately prior to sending a response on a stream.

type LoggingCallbacks

type LoggingCallbacks struct {
	Log logr.Logger
}

func (LoggingCallbacks) OnFetchRequest

func (cb LoggingCallbacks) OnFetchRequest(ctx context.Context, req *envoy.DiscoveryRequest) error

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error.

func (LoggingCallbacks) OnFetchResponse

func (cb LoggingCallbacks) OnFetchResponse(req *envoy.DiscoveryRequest, resp *envoy.DiscoveryResponse)

OnFetchRequest is called for each Fetch request. Returning an error will end processing of the request and respond with an error. OnFetchResponse is called immediately prior to sending a response.

func (LoggingCallbacks) OnStreamClosed

func (cb LoggingCallbacks) OnStreamClosed(streamID int64)

OnStreamClosed is called immediately prior to closing an xDS stream with a stream ID.

func (LoggingCallbacks) OnStreamOpen

func (cb LoggingCallbacks) OnStreamOpen(ctx context.Context, streamID int64, typ string) error

OnStreamOpen is called once an xDS stream is open with a stream ID and the type URL (or "" for ADS). Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (LoggingCallbacks) OnStreamRequest

func (cb LoggingCallbacks) OnStreamRequest(streamID int64, req *envoy.DiscoveryRequest) error

OnStreamRequest is called once a request is received on a stream. Returning an error will end processing and close the stream. OnStreamClosed will still be called.

func (LoggingCallbacks) OnStreamResponse

func (cb LoggingCallbacks) OnStreamResponse(streamID int64, req *envoy.DiscoveryRequest, resp *envoy.DiscoveryResponse)

OnStreamResponse is called immediately prior to sending a response on a stream.

type NewNodeWatchdogFunc

type NewNodeWatchdogFunc func(ctx context.Context, node *envoy_core.Node, streamId int64) (util_watchdog.Watchdog, error)

type Snapshot

type Snapshot interface {

	// GetSupportedTypes returns a list of xDS types supported by this snapshot.
	GetSupportedTypes() []string

	// Consistent check verifies that the dependent resources are exactly listed in the
	// snapshot:
	// - all EDS resources are listed by name in CDS resources
	// - all RDS resources are listed by name in LDS resources
	//
	// Note that clusters and listeners are requested without name references, so
	// Envoy will accept the snapshot list of clusters as-is even if it does not match
	// all references found in xDS.
	Consistent() error

	// GetResources selects snapshot resources by type.
	GetResources(typ string) map[string]envoy_types.Resource

	// GetVersion returns the version for a resource type.
	GetVersion(typ string) string

	// WithVersion creates a new snapshot with a different version for a given resource type.
	WithVersion(typ string, version string) Snapshot
}

Snapshot is an internally consistent snapshot of xDS resources. Consistency is important for the convergence as different resource types from the snapshot may be delivered to the proxy in arbitrary order.

Notice that unlike in the original github.com/envoyproxy/go-control-plane library, Snapshot is an interface which will allow to reuse SnapshotCache for arbitrary xDS resources rather than just core Envoy's ones.

type SnapshotAutoVersioner

type SnapshotAutoVersioner struct {
	UUID func() string
}

SnapshotAutoVersioner assigns versions to xDS resources in a new Snapshot by reusing if possible a version from the old snapshot and generating a new version (UUID) otherwise.

func (SnapshotAutoVersioner) Version

func (v SnapshotAutoVersioner) Version(new, old Snapshot) Snapshot

type SnapshotCache

type SnapshotCache interface {
	envoy_cache.Cache

	// SetSnapshot sets a response snapshot for a node. For ADS, the snapshots
	// should have distinct versions and be internally consistent (e.g. all
	// referenced resources must be included in the snapshot).
	//
	// This method will cause the server to respond to all open watches, for which
	// the version differs from the snapshot version.
	SetSnapshot(node string, snapshot Snapshot) error

	// GetSnapshots gets the snapshot for a node.
	GetSnapshot(node string) (Snapshot, error)

	// ClearSnapshot removes all status and snapshot information associated with a node.
	ClearSnapshot(node string)

	// GetStatusInfo retrieves status information for a node ID.
	GetStatusInfo(string) envoy_cache.StatusInfo

	// GetStatusKeys retrieves node IDs for all statuses.
	GetStatusKeys() []string
}

SnapshotCache is a snapshot-based cache that maintains a single versioned snapshot of responses per node. SnapshotCache consistently replies with the latest snapshot. For the protocol to work correctly in ADS mode, EDS/RDS requests are responded only when all resources in the snapshot xDS response are named as part of the request. It is expected that the CDS response names all EDS clusters, and the LDS response names all RDS routes in a snapshot, to ensure that Envoy makes the request for all EDS clusters or RDS routes eventually.

SnapshotCache can operate as a REST or regular xDS backend. The snapshot can be partial, e.g. only include RDS or EDS resources.

func NewSnapshotCache

func NewSnapshotCache(ads bool, hash envoy_cache.NodeHash, logger envoy_log.Logger) SnapshotCache

NewSnapshotCache initializes a simple cache.

ADS flag forces a delay in responding to streaming requests until all resources are explicitly named in the request. This avoids the problem of a partial request over a single stream for a subset of resources which would require generating a fresh version for acknowledgement. ADS flag requires snapshot consistency. For non-ADS case (and fetch), multiple partial requests are sent across multiple streams and re-using the snapshot version is OK.

Logger is optional.

type SnapshotVersioner

type SnapshotVersioner interface {
	Version(new, old Snapshot) Snapshot
}

SnapshotVersioner assigns versions to xDS resources in a new Snapshot.

Jump to

Keyboard shortcuts

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