endpointmanager

package
v1.15.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 37 Imported by: 30

Documentation

Overview

Package endpointmanager manages the list of all local endpoints

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"endpoint-manager",
	"Manages the collection of local endpoints",

	cell.Config(defaultEndpointManagerConfig),
	cell.Provide(newDefaultEndpointManager),
)

Cell provides the EndpointManager which maintains the collection of locally running Cilium endpoints. Also exposed are EndpointsLookup and EndpointsModify APIs that EndpointManager implements. If possible, choose the minimal API as your dependency.

View Source
var (
	// ErrUnsupportedID represents an error of unsupported IP address format.
	ErrUnsupportedID = errors.New("unsupported IP address format")
)

Functions

func IsErrInvalidPrefix added in v0.15.7

func IsErrInvalidPrefix(err error) bool

IsErrInvalidPrefix returns true if the given error is the type of ErrInvalidPrefix.

func IsErrUnsupportedID added in v0.15.7

func IsErrUnsupportedID(err error) bool

IsErrUnsupportedID returns true if the given error is the type of ErrUnsupportedID.

func New added in v0.15.7

func New(epSynchronizer EndpointResourceSynchronizer) *endpointManager

New creates a new endpointManager.

Types

type EndpointCheckerFunc added in v0.15.7

type EndpointCheckerFunc func(*endpoint.Endpoint) error

EndpointCheckerFunc can verify whether an endpoint is currently healthy.

type EndpointManager added in v0.15.7

type EndpointManager interface {
	EndpointsLookup
	EndpointsModify
	subscriber.Node
	EndpointResourceSynchronizer

	// Subscribe to endpoint events.
	Subscribe(s Subscriber)

	// Unsubscribe from endpoint events.
	Unsubscribe(s Subscriber)

	// UpdatePolicyMaps returns a WaitGroup which is signaled upon once all endpoints
	// have had their PolicyMaps updated against the Endpoint's desired policy state.
	//
	// Endpoints will wait on the 'notifyWg' parameter before updating policy maps.
	UpdatePolicyMaps(ctx context.Context, notifyWg *sync.WaitGroup) *sync.WaitGroup

	// RegenerateAllEndpoints calls a setState for each endpoint and
	// regenerates if state transaction is valid. During this process, the endpoint
	// list is locked and cannot be modified.
	// Returns a waiting group that can be used to know when all the endpoints are
	// regenerated.
	RegenerateAllEndpoints(regenMetadata *regeneration.ExternalRegenerationMetadata) *sync.WaitGroup

	// WaitForEndpointsAtPolicyRev waits for all endpoints which existed at the time
	// this function is called to be at a given policy revision.
	// New endpoints appearing while waiting are ignored.
	WaitForEndpointsAtPolicyRev(ctx context.Context, rev uint64) error

	// OverrideEndpointOpts applies the given options to all endpoints.
	OverrideEndpointOpts(om option.OptionMap)

	// InitHostEndpointLabels initializes the host endpoint's labels with the
	// node's known labels.
	InitHostEndpointLabels(ctx context.Context)

	// GetPolicyEndpoints returns a map of all endpoints present in endpoint
	// manager as policy.Endpoint interface set for the map key.
	GetPolicyEndpoints() map[policy.Endpoint]struct{}

	// HasGlobalCT returns true if the endpoints have a global CT, false otherwise.
	HasGlobalCT() bool

	// CallbackForEndpointsAtPolicyRev registers a callback on all endpoints that
	// exist when invoked. It is similar to WaitForEndpointsAtPolicyRevision but
	// each endpoint that reaches the desired revision calls 'done' independently.
	// The provided callback should not block and generally be lightweight.
	CallbackForEndpointsAtPolicyRev(ctx context.Context, rev uint64, done func(time.Time)) error
}

type EndpointManagerConfig added in v0.15.7

type EndpointManagerConfig struct {
	// EndpointGCInterval is interval to attempt garbage collection of
	// endpoints that are no longer alive and healthy.
	EndpointGCInterval time.Duration
}

func (EndpointManagerConfig) Flags added in v0.15.7

func (def EndpointManagerConfig) Flags(flags *pflag.FlagSet)

type EndpointResourceSynchronizer added in v0.15.7

type EndpointResourceSynchronizer interface {
	RunK8sCiliumEndpointSync(ep *endpoint.Endpoint, conf endpoint.EndpointStatusConfiguration)
	DeleteK8sCiliumEndpointSync(e *endpoint.Endpoint)
}

EndpointResourceSynchronizer is an interface which synchronizes CiliumEndpoint resources with Kubernetes.

type EndpointsLookup added in v0.15.7

type EndpointsLookup interface {
	// Lookup looks up endpoint by prefix ID
	Lookup(id string) (*endpoint.Endpoint, error)

	// LookupCiliumID looks up endpoint by endpoint ID
	LookupCiliumID(id uint16) *endpoint.Endpoint

	// LookupCNIAttachmentID looks up endpoint by CNI attachment ID
	LookupCNIAttachmentID(id string) *endpoint.Endpoint

	// LookupIPv4 looks up endpoint by IPv4 address
	LookupIPv4(ipv4 string) *endpoint.Endpoint

	// LookupIPv6 looks up endpoint by IPv6 address
	LookupIPv6(ipv6 string) *endpoint.Endpoint

	// LookupIP looks up endpoint by IP address
	LookupIP(ip netip.Addr) (ep *endpoint.Endpoint)

	// LookupCEPName looks up endpoints by namespace + cep name, e.g. "prod/cep-0"
	LookupCEPName(name string) (ep *endpoint.Endpoint)

	// GetEndpointsByPodName looks up endpoints by namespace + pod name, e.g. "prod/pod-0"
	GetEndpointsByPodName(name string) []*endpoint.Endpoint

	// GetEndpointsByContainerID looks up endpoints by container ID
	GetEndpointsByContainerID(containerID string) []*endpoint.Endpoint

	// GetEndpoints returns a slice of all endpoints present in endpoint manager.
	GetEndpoints() []*endpoint.Endpoint

	// EndpointExists returns whether the endpoint with id exists.
	EndpointExists(id uint16) bool

	// GetHostEndpoint returns the host endpoint.
	GetHostEndpoint() *endpoint.Endpoint

	// HostEndpointExists returns true if the host endpoint exists.
	HostEndpointExists() bool
}

type EndpointsModify added in v0.15.7

type EndpointsModify interface {
	// AddEndpoint takes the prepared endpoint object and starts managing it.
	AddEndpoint(owner regeneration.Owner, ep *endpoint.Endpoint, reason string) (err error)

	AddHostEndpoint(
		ctx context.Context,
		owner regeneration.Owner,
		policyGetter policyRepoGetter,
		ipcache *ipcache.IPCache,
		proxy endpoint.EndpointProxy,
		allocator cache.IdentityAllocator,
		reason, nodeName string,
	) error

	// RestoreEndpoint exposes the specified endpoint to other subsystems via the
	// manager.
	RestoreEndpoint(ep *endpoint.Endpoint) error

	// UpdateReferences updates maps the contents of mappings to the specified endpoint.
	UpdateReferences(ep *endpoint.Endpoint) error

	// RemoveEndpoint stops the active handling of events by the specified endpoint,
	// and prevents the endpoint from being globally acccessible via other packages.
	RemoveEndpoint(ep *endpoint.Endpoint, conf endpoint.DeleteConfig) []error

	// RemoveAll removes all endpoints from the global maps.
	RemoveAll()
}

type ErrInvalidPrefix added in v0.15.7

type ErrInvalidPrefix struct {
	// InvalidPrefix contains the invalid prefix.
	InvalidPrefix string
}

ErrInvalidPrefix represents the error of an invalid prefix.

func (ErrInvalidPrefix) Error added in v0.15.7

func (e ErrInvalidPrefix) Error() string

Error returns the string representation of the ErrInvalidPrefix.

type Subscriber added in v0.15.7

type Subscriber interface {
	// EndpointCreated is called at the end of endpoint creation.
	// Implementations must not attempt write operations on the
	// EndpointManager from this callback.
	EndpointCreated(ep *endpoint.Endpoint)

	// EndpointDeleted is called at the end of endpoint deletion.
	// Implementations must not attempt write operations on the
	// EndpointManager from this callback.
	EndpointDeleted(ep *endpoint.Endpoint, conf endpoint.DeleteConfig)
}

Subscribers may register via Subscribe() to be notified when events occur.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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