common

package
v1.16.0-pre.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClusterIDChanged    = errors.New("etcd cluster ID has changed")
	ErrEtcdInvalidResponse = errors.New("received an invalid etcd response")
)

Functions

func ConfigFiles added in v1.15.6

func ConfigFiles(cfgdir string) (configs map[string]string, err error)

ConfigFiles returns the list of configuration files in the given path. It shall be used by CLI tools only, as it doesn't handle subsequent updates.

func MetricsProvider

func MetricsProvider(subsystem string) func() Metrics

func NewSharedServicesObserver added in v1.16.0

func NewSharedServicesObserver(
	log logrus.FieldLogger, cache *GlobalServiceCache,
	onUpdate, onDelete func(*serviceStore.ClusterService),
) store.Observer

NewSharedServicesObserver returns an observer implementing the logic to convert and filter shared services notifications, update the global service cache and call the upstream handlers when appropriate.

Types

type ClusterMesh

type ClusterMesh interface {
	cell.HookInterface

	// ForEachRemoteCluster calls the provided function for each remote cluster
	// in the ClusterMesh.
	ForEachRemoteCluster(fn func(RemoteCluster) error) error
	// NumReadyClusters returns the number of remote clusters to which a connection
	// has been established
	NumReadyClusters() int
}

func NewClusterMesh

func NewClusterMesh(c Configuration) ClusterMesh

NewClusterMesh creates a new remote cluster cache based on the provided configuration

type Config

type Config struct {
	// ClusterMeshConfig is the path to the clustermesh configuration directory.
	ClusterMeshConfig string
}

func (Config) Flags

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

type Configuration

type Configuration struct {
	Config

	// ClusterInfo is the id/name of the local cluster. This is used for logging and metrics
	ClusterInfo types.ClusterInfo

	// NewRemoteCluster is a function returning a new implementation of the remote cluster business logic.
	NewRemoteCluster RemoteClusterCreatorFunc

	// nodeName is the name of the local node. This is used for logging and metrics
	NodeName string

	// ClusterSizeDependantInterval allows to calculate intervals based on cluster size.
	ClusterSizeDependantInterval kvstore.ClusterSizeDependantIntervalFunc

	// ServiceIPGetter, if not nil, is used to create a custom dialer for service resolution.
	ServiceIPGetter k8s.ServiceIPGetter

	// Metrics holds the different clustermesh metrics.
	Metrics Metrics
}

Configuration is the configuration that must be provided to NewClusterMesh()

type GlobalService added in v1.16.0

type GlobalService struct {
	ClusterServices map[string]*serviceStore.ClusterService
}

type GlobalServiceCache added in v1.16.0

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

func NewGlobalServiceCache added in v1.16.0

func NewGlobalServiceCache(metricTotalGlobalServices metric.Gauge) *GlobalServiceCache

func (*GlobalServiceCache) GetGlobalService added in v1.16.0

func (c *GlobalServiceCache) GetGlobalService(serviceNN types.NamespacedName) *GlobalService

GetGlobalService returns a global service object. This function returns a shallow copy of the GlobalService object, thus the ClusterService objects should not be mutated.

func (*GlobalServiceCache) GetService added in v1.16.0

func (c *GlobalServiceCache) GetService(serviceNN types.NamespacedName, clusterName string) *serviceStore.ClusterService

GetService returns the service for a specific cluster. This function does not make a copy of the cluster service object and should not be mutated.

func (*GlobalServiceCache) GetServices

func (c *GlobalServiceCache) GetServices(namespace string) []*serviceStore.ClusterService

GetServices returns the services for a specific namespace. This function does not make copy of the cluster services objects so those objects should not be mutated.

func (*GlobalServiceCache) Has added in v1.16.0

Has returns whether a given service is present in the cache.

func (*GlobalServiceCache) OnDelete added in v1.16.0

func (*GlobalServiceCache) OnUpdate added in v1.16.0

func (*GlobalServiceCache) Size added in v1.16.0

func (c *GlobalServiceCache) Size() (num int)

Size returns the number of global services in the cache

type Metrics

type Metrics struct {
	// TotalRemoteClusters tracks the total number of remote clusters.
	TotalRemoteClusters metric.Vec[metric.Gauge]
	// LastFailureTimestamp tracks the last failure timestamp.
	LastFailureTimestamp metric.Vec[metric.Gauge]
	// ReadinessStatus tracks the readiness status of remote clusters.
	ReadinessStatus metric.Vec[metric.Gauge]
	// TotalFailure tracks the number of failures when connecting to remote clusters.
	TotalFailures metric.Vec[metric.Gauge]
}

type RemoteCluster

type RemoteCluster interface {
	// Run implements the actual business logic once the connection to the remote cluster has been established.
	// The ready channel shall be closed when the initialization tasks completed, possibly returning an error.
	Run(ctx context.Context, backend kvstore.BackendOperations, config types.CiliumClusterConfig, ready chan<- error)

	Stop()
	Remove()
}

type RemoteClusterCreatorFunc

type RemoteClusterCreatorFunc func(name string, status StatusFunc) RemoteCluster

type StatusFunc

type StatusFunc func() *models.RemoteCluster

Jump to

Keyboard shortcuts

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