xds

package
v0.0.0-...-4457478 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log = istiolog.RegisterScope("ads", "ads debugging")

	TotalXDSInternalErrors = monitoring.NewSum(
		"pilot_total_xds_internal_errors",
		"Total number of internal XDS errors in pilot.",
	)

	ExpiredNonce = monitoring.NewSum(
		"pilot_xds_expired_nonce",
		"Total number of XDS requests with an expired nonce.",
	)

	ResponseWriteTimeouts = monitoring.NewSum(
		"pilot_xds_write_timeout",
		"Pilot XDS response write timeouts.",
	)
)

Functions

func IncrementXDSRejects

func IncrementXDSRejects(xdsType string, node, errCode string)

func IsWildcardTypeURL

func IsWildcardTypeURL(typeURL string) bool

IsWildcardTypeURL checks whether a given type is a wildcard type https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#how-the-client-specifies-what-resources-to-return If the list of resource names becomes empty, that means that the client is no longer interested in any resources of the specified type. For Listener and Cluster resource types, there is also a “wildcard” mode, which is triggered when the initial request on the stream for that resource type contains no resource names.

func Receive

func Receive(ctx ConnectionContext)

func RecordSendTime

func RecordSendTime(duration time.Duration)

func Stream

func Stream(ctx ConnectionContext) error

Types

type Connection

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

Connection holds information about an xDS client connection. There may be more than one connection to the same client.

func NewConnection

func NewConnection(peerAddr string, stream DiscoveryStream) Connection

func (*Connection) ConnectedAt

func (conn *Connection) ConnectedAt() time.Time

func (*Connection) ErrorCh

func (conn *Connection) ErrorCh() chan error

func (*Connection) ID

func (conn *Connection) ID() string

func (*Connection) InitializedCh

func (conn *Connection) InitializedCh() chan struct{}

func (*Connection) MarkInitialized

func (conn *Connection) MarkInitialized()

func (*Connection) Peer

func (conn *Connection) Peer() string

func (*Connection) PushCh

func (conn *Connection) PushCh() chan any

func (*Connection) SetID

func (conn *Connection) SetID(id string)

func (*Connection) Stop

func (conn *Connection) Stop()

func (*Connection) StopCh

func (conn *Connection) StopCh() chan struct{}

func (*Connection) StreamDone

func (conn *Connection) StreamDone() <-chan struct{}

type ConnectionContext

type ConnectionContext interface {
	XdsConnection() *Connection
	Watcher() Watcher
	// Initialize checks the first request.
	Initialize(node *core.Node) error
	// Close discards the connection.
	Close()
	// Process responds to a discovery request.
	Process(req *discovery.DiscoveryRequest) error
	// Push responds to a push event queue
	Push(ev any) error
}

ConnectionContext is used by the RPC event loop to respond to requests and pushes.

type DiscoveryStream

DiscoveryStream is a server interface for XDS.

type ResourceDelta

type ResourceDelta struct {
	// Subscribed indicates the client requested these additional resources
	Subscribed sets.String
	// Unsubscribed indicates the client no longer requires these resources
	Unsubscribed sets.String
}

ResourceDelta records the difference in requested resources by an XDS client

func ShouldRespond

func ShouldRespond(w Watcher, id string, request *discovery.DiscoveryRequest) (bool, ResourceDelta)

ShouldRespond determines whether this request needs to be responded back. It applies the ack/nack rules as per xds protocol using WatchedResource for previous state and discovery request for the current state.

func (ResourceDelta) IsEmpty

func (rd ResourceDelta) IsEmpty() bool

type Resources

type Resources = []*discovery.Resource

type WatchedResource

type WatchedResource struct {
	// TypeUrl is copied from the DiscoveryRequest.TypeUrl that initiated watching this resource.
	// nolint
	TypeUrl string

	// ResourceNames tracks the list of resources that are actively watched.
	// For LDS and CDS, all resources of the TypeUrl type are watched if it is empty.
	// For endpoints the resource names will have list of clusters and for clusters it is empty.
	// For Delta Xds, all resources of the TypeUrl that a client has subscribed to.
	ResourceNames []string

	// Wildcard indicates the subscription is a wildcard subscription. This only applies to types that
	// allow both wildcard and non-wildcard subscriptions.
	Wildcard bool

	// NonceSent is the nonce sent in the last sent response. If it is equal with NonceAcked, the
	// last message has been processed. If empty: we never sent a message of this type.
	NonceSent string

	// NonceAcked is the last acked message.
	NonceAcked string

	// AlwaysRespond, if true, will ensure that even when a request would otherwise be treated as an
	// ACK, it will be responded to. This typically happens when a proxy reconnects to another instance of
	// Istiod. In that case, Envoy expects us to respond to EDS/RDS/SDS requests to finish warming of
	// clusters/listeners.
	// Typically, this should be set to 'false' after response; keeping it true would likely result in an endless loop.
	AlwaysRespond bool

	// LastResources tracks the contents of the last push.
	// This field is extremely expensive to maintain and is typically disabled
	LastResources Resources
}

WatchedResource tracks an active DiscoveryRequest subscription.

type Watcher

type Watcher interface {
	DeleteWatchedResource(url string)
	GetWatchedResource(url string) *WatchedResource
	NewWatchedResource(url string, names []string)
	UpdateWatchedResource(string, func(*WatchedResource) *WatchedResource)
	// GetID identifies an xDS client. This is different from a connection ID.
	GetID() string
}

Jump to

Keyboard shortcuts

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