package reconciliation

import "github.com/oslokommune/okctl/pkg/controller/common/reconciliation"

Package reconciliation contains reconciliation resources necessary for both application and cluster reconciliation

Index

Constants

const (
	// ActionCreate indicates creation
	ActionCreate = "create"
	// ActionDelete indicates deletion
	ActionDelete = "delete"
	// ActionNoop indicates no necessary action
	ActionNoop = "noop"
	// ActionWait indicates the need to wait
	ActionWait = "wait"
)

Variables

var (
	// ErrMaximumReconciliationRequeues represents the reconciler trying a single reconciler too many times
	ErrMaximumReconciliationRequeues = errors.New("max reconciliation requeues reached")
	// ErrIndecisive represents the situation where the reconciler can't figure out what to do
	ErrIndecisive = errors.New("indecisive")
)

Functions

func AssertDependencyExistence

func AssertDependencyExistence(expectExistence bool, tests ...DependencyTestFn) (bool, error)

AssertDependencyExistence asserts that the existence of all the provided tests is as expected

func ClusterMetaAsID

func ClusterMetaAsID(meta v1alpha1.ClusterMeta) api.ID

ClusterMetaAsID knows how to convert cluster declaration metadata to an api.ID struct

func DefaultDelayFunction

func DefaultDelayFunction()

DefaultDelayFunction defines a sane default reconciliation loop delay function

Types

type Action

type Action string

Action represents actions a Reconciler can take

func DetermineUserIndication

func DetermineUserIndication(metadata Metadata, componentFlag bool) Action

DetermineUserIndication knows how to interpret what operation the user wants for the certain reconciler

type DependencyTestFn

type DependencyTestFn func() (bool, error)

DependencyTestFn defines a function which tests if a dependency is met

func GenerateClusterExistenceTest

func GenerateClusterExistenceTest(state *clientCore.StateHandlers, clusterName string) DependencyTestFn

GenerateClusterExistenceTest is a convenience function for creating a cluster existence test function

func GeneratePrimaryDomainDelegationTest

func GeneratePrimaryDomainDelegationTest(state *clientCore.StateHandlers) DependencyTestFn

GeneratePrimaryDomainDelegationTest is a convenience function for creating a dependency test checking for primary hosted zone delegation status

type Metadata

type Metadata struct {
	Out io.Writer

	ClusterDeclaration     *v1alpha1.Cluster
	ApplicationDeclaration v1alpha1.Application

	Purge bool
}

Metadata represents metadata required by most if not all operations on services

type Queue

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

Queue handles FIFO queue operations on Reconcilers

func NewQueue

func NewQueue(reconcilers []Reconciler) Queue

NewQueue creates a new queue from a list of Reconcilers

func (*Queue) Pop

func (q *Queue) Pop() Reconciler

Pop removes and returns the first element in the list

func (*Queue) Push

func (q *Queue) Push(reconciler Reconciler) error

Push adds a Reconciler to the back of the queue

type Reconciler

type Reconciler interface {
	// Reconcile knows how to do what is necessary to ensure the desired state is achieved
	Reconcile(ctx context.Context, meta Metadata, state *clientCore.StateHandlers) (Result, error)
	// String returns a name that describes the Reconciler
	String() string
}

Reconciler defines functions needed for the controller to use a reconciler

type Result

type Result struct {
	// Requeue indicates if this Reconciliation must be run again
	Requeue bool
	// RequeueAfter sets the amount of delay before the requeued reconciliation should be done
	RequeueAfter time.Duration
}

Result contains information about the result of a Reconcile() call

type Scheduler

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

Scheduler knows how to run reconcilers in a reasonable way

func NewScheduler

func NewScheduler(opts SchedulerOpts, reconcilers ...Reconciler) Scheduler

NewScheduler initializes a Scheduler

func (*Scheduler) Run

func (c *Scheduler) Run(ctx context.Context, state *clientCore.StateHandlers) (Result, error)

Run initiates scheduling of reconcilers

type SchedulerOpts

type SchedulerOpts struct {
	// Out provides reconcilers a way to express data
	Out io.Writer
	// Spinner provides the user some eye candy
	Spinner spinner.Spinner

	// Context of the scheduling. Signifies the intent of the user
	// PurgeFlag indicates if everything should be deleted
	PurgeFlag bool
	// ReconciliationLoopDelayFunction introduces delay to the reconciliation process
	ReconciliationLoopDelayFunction func()
	ClusterDeclaration              v1alpha1.Cluster
	ApplicationDeclaration          v1alpha1.Application
}

SchedulerOpts contains required data for scheduling reconciliations

Source Files

dependencies.go doc.go helpers.go queue.go scheduler.go types.go

Version
v0.0.106 (latest)
Published
Oct 21, 2022
Platform
linux/amd64
Imports
11 packages
Last checked
18 hours ago

Tools for package owners.