reconciler

package
v0.0.0-...-800520f Latest Latest
Warning

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

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

Documentation

Overview

Package reconciler reconciles the contents of two gRIBI RIBs -- the intended RIB is assumed to contain the desired RIB entries, whereas the 'target' RIB is to be programmed. The reconciler:

  • Uses the messages that are returned from the `Get` RPC to build the contents of an external RIB.
  • Calculates a diff between the two RIBs.
  • Sends gRIBI operations to the target RIB to make it consistent with the intended RIB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalRIB

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

LocalRIB wraps a RIB that is locally available on the system as a gRIBIgo RIB type.

func NewLocalRIB

func NewLocalRIB(r *rib.RIB) *LocalRIB

NewLocalRIB returns a new LocalRIB instance.

func (*LocalRIB) CleanUp

func (l *LocalRIB) CleanUp()

CleanUp implements the RIBTarget interface. No local cleanup is required.

func (*LocalRIB) Get

func (l *LocalRIB) Get(_ context.Context) (*rib.RIB, error)

Get returns the contents of the local RIB.

type Ops

type Ops struct {
	// NH stores the next-hop operations in the operation set.
	NH []*spb.AFTOperation
	// NHG stores the next-hop-group operations in the operation set.
	NHG []*spb.AFTOperation
	// TopLevel stores the IPv4, IPv6, and MPLS operations in the operation set.
	TopLevel []*spb.AFTOperation
}

Ops stores a set of operations with their corresponding types. Operations are stored as NH (nexthop), NHG (next-hop-group) and top-level (MPLS, IPv4, IPv6). This allows a gRIBI client to sequence the Ops suitably.

func (*Ops) DeepCopy

func (o *Ops) DeepCopy() *Ops

DeepCopy returns a deep copy (including cloning protobufs) of the specified operations.

func (*Ops) IsEmpty

func (o *Ops) IsEmpty() bool

IsEmpty determines whether the specified Ops contains any operations.

func (*Ops) Merge

func (o *Ops) Merge(in *Ops)

Merge adds the operations from the "in" operations to the receiver ops.

type R

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

func New

func New(intended, target RIBTarget) *R

New returns a new reconciler with the specified intended and target RIBs.

func (*R) Reconcile

func (r *R) Reconcile(ctx context.Context, id *atomic.Uint64) (*ReconcileOps, error)

Reconcile calculates the required gRIBI actions to institute a reconciliation operation between the intended and remote RIB. The specified ID is used as the base for the operation ID within gRIBI. Reconcile returns a set of operations in the form of a ReconcileOps struct.

Within the returned ReconcileOps:

  • The Add field indicates entries that are to be newly added to the remote RIB.
  • The Replace field indicates entries that are replacing entries within the remote RIB, the replaces will be implicit (i.e., expressed as gRIBI ADD operations) unless the ExplicitReplace option is provided.
  • The Delete field indicates entries that are to be deleted from the remote RIB.

Within each of these fields, entries are broken down into "top-level" entries which are from the IPv4, IPv6, or MPLS AFTs, and those that correspond to next-hop-group (NHG) or next-hop (NH) entries. This allows the client receiving these entries to enqueue them in the correct order to ensure that there are no forward references, and implement make-before-break.

type RIBTarget

type RIBTarget interface {
	// Get returns a RIB containing all network-instances and AFTs that are
	// supported by the RIB.
	Get(context.Context) (*rib.RIB, error)
	// CleanUp is called to indicate that the RIBTarget should remove any
	// state or external connections as it is no longer required.
	CleanUp()
}

RIBTarget is an interface that abstracts a local and remote RIB in the reconciler. It allows the RIB contents to be retrieved and programmed either via gRIBI or from a local RIB cache.

type ReconcileOps

type ReconcileOps struct {
	// Add stores the operations that are explicitly adding new entries.
	Add *Ops
	// Replace stores the operations that are implicit or explicit replaces of
	// existing entries.
	Replace *Ops
	// Delete stores the operations that are removing entries.
	Delete *Ops
}

ReconcileOps stores the operations that are required for a specific reconciliation run.

func NewReconcileOps

func NewReconcileOps() *ReconcileOps

NewReconcileOps returns a new reconcileOps struct with the fields initialised.

func (*ReconcileOps) DeepCopy

func (r *ReconcileOps) DeepCopy() *ReconcileOps

DeepCopy returns a copy of a reconcile ops struct, making a deep copy of all of the fields, including cloning protobufs.

func (*ReconcileOps) IsEmpty

func (r *ReconcileOps) IsEmpty() bool

IsEmpty determines whether the specified ReconcileOps contains any operations.

func (*ReconcileOps) Merge

func (r *ReconcileOps) Merge(in *ReconcileOps)

Merge adds the operations from the "in" operations to the receiver operations.

type RemoteRIB

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

RemoteRIB implements the RIBTarget interface and wraps a remote gRIBI RIB. The contents are accessed via the gRIBI gRPC API.

func NewRemoteRIB

func NewRemoteRIB(ctx context.Context, defName, addr string) (*RemoteRIB, error)

NewRemoteRIB returns a new remote gRIBI RIB. The context supplied is used to dial the remote gRIBI server at the address 'addr'. the 'defName' argument is used to identify the name of the default network instance on the server.

func NewRemoteRIBWithStub

func NewRemoteRIBWithStub(defName string, stub spb.GRIBIClient) (*RemoteRIB, error)

NewRemoteRIBWithStub creates a new remote RIB using the specified default network instance name, and the provided stub client. It returns an error if the client cannot be created.

func (*RemoteRIB) CleanUp

func (r *RemoteRIB) CleanUp()

CleanUp closes the remote connection to the gRIBI server.

func (*RemoteRIB) Get

func (r *RemoteRIB) Get(ctx context.Context) (*rib.RIB, error)

Get retrieves the contents of the remote gRIBI server's RIB and returns it as a gRIBIgo RIB struct. The context is used for a Get RPC call to the remote server.

Jump to

Keyboard shortcuts

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