reconciliation

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package reconciliation contains logic to configure resources for a single Anexia LBaaS LoadBalancer for a given set of external addresses, ports and servers. It also contains a helper to use multiple such "reconciliation"s as one.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResourcesNotDestroyable is returned when Reconcile tried to Destroy a resource but Engine returned an error
	ErrResourcesNotDestroyable = errors.New("failed to Destroy some resources")

	// ErrLBaaSResourceProgressing is returned by ReconcileCheck() when an existing resource was retrieved as not yet ready.
	ErrLBaaSResourceProgressing = errors.New("LBaaS resource still progressing")

	// ErrLBaaSResourceFailed is returned when a LBaaS resource is in a not-ok state.
	ErrLBaaSResourceFailed = errors.New("LBaaS resource in failure state")
)

Functions

This section is empty.

Types

type MultiReconciliation

type MultiReconciliation interface {
	// Add another Reconcilation to the collection of reconciliations to do.
	Add(Reconciliation)

	Reconciliation
}

MultiReconciliation is a collection of Reconcilation to do concurrently.

func Multi

func Multi(recon ...Reconciliation) MultiReconciliation

Multi creates a new MultiReconcilation from the given Reconcilation instances. Instead of giving them as attributes, they can also be added later via Add().

The ReconcileCheck, Reconcile and Status methods are called on all reconciliations in the collection concurrently and the results are aggregated into the returned values.

For Reconcile and ReconcileCheck this means, reconciliation is complete after all wrapped reconciliations are complete.

Status returns the set of addresses and ports given by all wrapped reconciliations, those only one some reconciliations are removed from the returned value.

This can be used to e.g. reconcile a given service for multiple different LBaaS LoadBalancers, removing the need for the LBaaS sync controller.

type Port

type Port struct {
	// External is the port from outside the cluster, as configured into the LBaaS Bind resource.
	External uint16

	// Internal is the port LBaaS connects to on the backend servers, in Kubernetes this is the NodePort.
	Internal uint16
}

Port describes a port for LBaaS reconciliation.

type Reconciliation

type Reconciliation interface {
	// ReconcileCheck runs every step once, collecting resources to be destroyed but stopping once any step needs
	// something to be created. It returns the resources to be created and destroyed. When both of the returned
	// arrays are empty no resources have to be created or destroyed anymore, meaning reconciliation is complete.
	//
	// Some resources need others to already exist, so creating all resources returned by ReconcileCheck
	// and then calling ReconcileCheck again will not always result in "nothing to change".
	ReconcileCheck() (toCreate []types.Object, toDestroy []types.Object, err error)

	// Reconcile calls ReconcileCheck in a loop, each time first destroying and then creating Objects until ReconcileCheck returns no operations to be done.
	// Once Reconcile returns without error, reconciliation is complete.
	Reconcile() error

	// Status returns a map with external IP address as key and array of ports as value, based on the current state in the Engine.
	Status() (map[string][]uint16, error)
}

Reconciliation wraps the current status and gives methods to operate on it, changing it into the desired state. Read the documentation for New for more info.

func New

func New(
	ctx context.Context,
	apiClient api.API,

	resourceNameSuffix string,
	loadBalancerIdentifier string,
	serviceUID string,

	externalAddresses []net.IP,
	ports map[string]Port,
	servers []Server,

	backoffSteps int,

	metrics metrics.ProviderMetrics,
) (Reconciliation, error)

New creates a new Reconcilation instance, usable to reconcile Anexia LBaaS resources for

  • a single LBaaS LoadBalancer
  • a single service UID (used for tagging the created resources and listing them)
  • a set of external IP addresses (translated into LBaaS Binds)
  • a set of ports (each having an internal (Kubernetes NodePort) and external (LBaaS Bind) port)
  • a set of nodes (each translated to a LBaaS Server)

Before doing anything, it will list all resources currently present in the Engine tagged with `anxccm-svc-ui=$serviceUID`.

Reconcilation is done in steps, in order Backends, Frontends, Binds, Servers. Each step returns a list of create and destroy operations to do, based on the current and desired state. The methods Reconcile, ReconcileCheck and Status use these steps and their results in different ways.

Final result is a LBaaS Frontend and Backend per port, for each Frontend one Bind per external IP and, also for each Frontend, a Backend per Port and Server.

type Server

type Server struct {
	// Name of the server, used for naming the LBaaS Server resources.
	Name string

	// IP address to configure in LBaaS Server resources.
	Address net.IP
}

Server describes a backend server for LBaaS reconciliation, in Kubernetes this is a Node.

Jump to

Keyboard shortcuts

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