endpointmanager

package
v0.0.0-...-c34bea4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package endpointmanager manages the list of all local endpoints

Index

Constants

This section is empty.

Variables

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

Functions

func IsErrInvalidPrefix

func IsErrInvalidPrefix(err error) bool

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

func IsErrUnsupportedID

func IsErrUnsupportedID(err error) bool

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

Types

type EndpointCheckerFunc

type EndpointCheckerFunc func(*endpoint.Endpoint) error

EndpointCheckerFunc can verify whether an endpoint is currently healthy.

type EndpointManager

type EndpointManager struct {

	// EndpointSynchronizer updates external resources (e.g., Kubernetes) with
	// up-to-date information about endpoints managed by the endpoint manager.
	EndpointResourceSynchronizer
	// contains filtered or unexported fields
}

EndpointManager is a structure designed for containing state about the collection of locally running endpoints.

func NewEndpointManager

func NewEndpointManager(epSynchronizer EndpointResourceSynchronizer) *EndpointManager

NewEndpointManager creates a new EndpointManager.

func (*EndpointManager) AddEndpoint

func (mgr *EndpointManager) AddEndpoint(owner regeneration.Owner, ep *endpoint.Endpoint, reason string) (err error)

AddEndpoint takes the prepared endpoint object and starts managing it.

func (*EndpointManager) AddHostEndpoint

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

func (*EndpointManager) AddIPv6Address

func (mgr *EndpointManager) AddIPv6Address(ipv6 addressing.CiliumIPv6)

AddIPv6Address notifies an addition of an IPv6 address

func (*EndpointManager) AllocateID

func (mgr *EndpointManager) AllocateID(currID uint16) (uint16, error)

AllocateID checks if the ID can be reused. If it cannot, returns an error. If an ID of 0 is provided, a new ID is allocated. If a new ID cannot be allocated, returns an error.

func (*EndpointManager) CallbackForEndpointsAtPolicyRev

func (mgr *EndpointManager) CallbackForEndpointsAtPolicyRev(ctx context.Context, rev uint64, done func(time.Time)) error

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.

func (*EndpointManager) EndpointExists

func (mgr *EndpointManager) EndpointExists(id uint16) bool

EndpointExists returns whether the endpoint with id exists.

func (*EndpointManager) GetEndpoints

func (mgr *EndpointManager) GetEndpoints() []*endpoint.Endpoint

GetEndpoints returns a slice of all endpoints present in endpoint manager.

func (*EndpointManager) GetHostEndpoint

func (mgr *EndpointManager) GetHostEndpoint() *endpoint.Endpoint

GetHostEndpoint returns the host endpoint.

func (*EndpointManager) GetPolicyEndpoints

func (mgr *EndpointManager) GetPolicyEndpoints() map[policy.Endpoint]struct{}

GetPolicyEndpoints returns a map of all endpoints present in endpoint manager as policy.Endpoint interface set for the map key.

func (*EndpointManager) HasGlobalCT

func (mgr *EndpointManager) HasGlobalCT() bool

HasGlobalCT returns true if the endpoints have a global CT, false otherwise.

func (*EndpointManager) HostEndpointExists

func (mgr *EndpointManager) HostEndpointExists() bool

HostEndpointExists returns true if the host endpoint exists.

func (*EndpointManager) InitHostEndpointLabels

func (mgr *EndpointManager) InitHostEndpointLabels(ctx context.Context)

InitHostEndpointLabels initializes the host endpoint's labels with the node's known labels.

func (*EndpointManager) InitMetrics

func (mgr *EndpointManager) InitMetrics()

InitMetrics hooks the EndpointManager into the metrics subsystem. This can only be done once, globally, otherwise the metrics library will panic.

func (*EndpointManager) Lookup

func (mgr *EndpointManager) Lookup(id string) (*endpoint.Endpoint, error)

Lookup looks up the endpoint by prefix id

func (*EndpointManager) LookupCiliumID

func (mgr *EndpointManager) LookupCiliumID(id uint16) *endpoint.Endpoint

LookupCiliumID looks up endpoint by endpoint ID

func (*EndpointManager) LookupContainerID

func (mgr *EndpointManager) LookupContainerID(id string) *endpoint.Endpoint

LookupContainerID looks up endpoint by Docker ID

func (*EndpointManager) LookupIP

func (mgr *EndpointManager) LookupIP(ip net.IP) (ep *endpoint.Endpoint)

LookupIP looks up endpoint by IP address

func (*EndpointManager) LookupIPv4

func (mgr *EndpointManager) LookupIPv4(ipv4 string) *endpoint.Endpoint

LookupIPv4 looks up endpoint by IPv4 address

func (*EndpointManager) LookupIPv6

func (mgr *EndpointManager) LookupIPv6(ipv6 string) *endpoint.Endpoint

LookupIPv6 looks up endpoint by IPv6 address

func (*EndpointManager) LookupPodName

func (mgr *EndpointManager) LookupPodName(name string) *endpoint.Endpoint

LookupPodName looks up endpoint by namespace + pod name

func (*EndpointManager) OnAddNode

func (mgr *EndpointManager) OnAddNode(node *v1.Node,
	swg *lock.StoppableWaitGroup) error

OnAddNode implements the EndpointManager's logic for reacting to new nodes from K8s. It is currently not implemented as the EndpointManager has not need for it. This adheres to the subscriber.NodeHandler interface.

func (*EndpointManager) OnDeleteNode

func (mgr *EndpointManager) OnDeleteNode(node *v1.Node,
	swg *lock.StoppableWaitGroup) error

OnDeleteNode implements the EndpointManager's logic for reacting to node deletions from K8s. It is currently not implemented as the EndpointManager has not need for it. This adheres to the subscriber.NodeHandler interface.

func (*EndpointManager) OnUpdateNode

func (mgr *EndpointManager) OnUpdateNode(oldNode, newNode *v1.Node,
	swg *lock.StoppableWaitGroup) error

OnUpdateNode implements the EndpointManager's logic for reacting to updated nodes in K8s. It is currently not implemented as the EndpointManager has not need for it. This adheres to the subscriber.NodeHandler interface.

func (*EndpointManager) OverrideEndpointOpts

func (mgr *EndpointManager) OverrideEndpointOpts(om option.OptionMap)

OverrideEndpointOpts applies the given options to all endpoints.

func (*EndpointManager) RegenerateAllEndpoints

func (mgr *EndpointManager) RegenerateAllEndpoints(regenMetadata *regeneration.ExternalRegenerationMetadata) *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.

func (*EndpointManager) ReleaseID

func (mgr *EndpointManager) ReleaseID(ep *endpoint.Endpoint) error

ReleaseID releases the ID of the specified endpoint from the EndpointManager. Returns an error if the ID cannot be released.

func (*EndpointManager) RemoveAll

func (mgr *EndpointManager) RemoveAll()

RemoveAll removes all endpoints from the global maps.

func (*EndpointManager) RemoveEndpoint

func (mgr *EndpointManager) RemoveEndpoint(ep *endpoint.Endpoint, conf endpoint.DeleteConfig) []error

RemoveEndpoint stops the active handling of events by the specified endpoint, and prevents the endpoint from being globally acccessible via other packages.

func (*EndpointManager) RemoveID

func (mgr *EndpointManager) RemoveID(currID uint16)

RemoveID removes the id from the endpoints map in the EndpointManager.

func (*EndpointManager) RemoveIPv6Address

func (mgr *EndpointManager) RemoveIPv6Address(ipv6 addressing.CiliumIPv6)

RemoveAIPv6ddress notifies a removal of an IPv6 address

func (*EndpointManager) RestoreEndpoint

func (mgr *EndpointManager) RestoreEndpoint(ep *endpoint.Endpoint) error

RestoreEndpoint exposes the specified endpoint to other subsystems via the manager.

func (*EndpointManager) Subscribe

func (mgr *EndpointManager) Subscribe(s Subscriber)

func (*EndpointManager) Unsubscribe

func (mgr *EndpointManager) Unsubscribe(s Subscriber)

func (*EndpointManager) UpdatePolicyMaps

func (mgr *EndpointManager) UpdatePolicyMaps(ctx context.Context, notifyWg *sync.WaitGroup) *sync.WaitGroup

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.

func (*EndpointManager) UpdateReferences

func (mgr *EndpointManager) UpdateReferences(ep *endpoint.Endpoint) error

UpdateReferences updates maps the contents of mappings to the specified endpoint.

func (*EndpointManager) WaitForEndpointsAtPolicyRev

func (mgr *EndpointManager) WaitForEndpointsAtPolicyRev(ctx context.Context, rev uint64) error

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.

func (*EndpointManager) WithPeriodicEndpointGC

func (mgr *EndpointManager) WithPeriodicEndpointGC(ctx context.Context, checkHealth EndpointCheckerFunc, interval time.Duration) *EndpointManager

WithPeriodicEndpointGC runs a controller to periodically garbage collect endpoints that match the specified EndpointCheckerFunc.

type EndpointResourceSynchronizer

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 ErrInvalidPrefix

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

ErrInvalidPrefix represents the error of an invalid prefix.

func (ErrInvalidPrefix) Error

func (e ErrInvalidPrefix) Error() string

Error returns the string representation of the ErrInvalidPrefix.

type Subscriber

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