engines

package
v1.17.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

*

This file is intended to replace the reconciler engine file in `reconciler/engine/stepper.go`
For the moment the test does not pass since a weird behaviour of the Build() function that should be fixed quickly.

The Graph below is an example of LCGraph and Reconciliation states.

*

Index

Constants

View Source
const (
	//Initial oktsm.LCGState
	CRChecker = iota // The entry point of a reconciliation
	CRFinalizer
	ObjectsGetter
	Mutator
	Updater
	ErrorManager
	SuccessManager
	GiveupManager // This special state to deal with a not alarming error (i.e. no CR available,...) or with an alarming error (implementation problem,...)
	End           // Leaf node: End of reconciliation
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FreeStyle

type FreeStyle struct {
	logr.Logger
	okterr.Results
	// contains filtered or unexported fields
}

FreeStyle reconciler engine type. Let you manage your own reconciliation process as you want. Only the CR is fetched from Cluster before calling the Start() method

func NewFreeStyle

func NewFreeStyle(hook FreeStyleHook) *FreeStyle

NewFreeStyle creates a reconciler allowing a free reconciliation. However, the hook passed as argument, is called after CR is fetched (or not) from the cluster

func (*FreeStyle) Run

func (e *FreeStyle) Run()

Run starts a reconciliation loop All results (errors, operations, ...) have to be collected in Reconciler's results (Results)data

func (*FreeStyle) SetLogger

func (e *FreeStyle) SetLogger(logr logr.Logger)

SetLogger provides the logger to use

func (*FreeStyle) SetResults

func (e *FreeStyle) SetResults(results okterr.Results)

SetResults provides the operation results (success, errors, ...) generated during the reconciliation

type FreeStyleHook

type FreeStyleHook interface {
	ReconcileWithCR()
}

FreeStyleHook Defines the hook called by the engine at each reconciliation loop (after CR fetched on cluster)

type Stepper

type Stepper struct {
	logr.Logger
	okterr.Results
	// contains filtered or unexported fields
}

Stepper is an OKT reconciler engine which reates a Reconciliation state machine. It can be used to implement an idempotent Reconcile function for an Operator Controller

Reconciliation states :

     CRChecker           // Check the Custom Resource received by the Controller (from the queue)
     ObjectsGetter       // Create all OKT resources types manipulated by this Operator, register them to the OKT Reconciler
     Mutator			    // Mutates OKT resources to the desired state
     Updater				// Create or Updates OKT resources on Cluster
		SuccessManager		// Is reached after the Updater state in case of success

 Here are the debranching steps occuring on Finalization, Error, or Give-up events:
		CRFinalizer			// The CR is being deleted and has finalizer. This stage allows you to manage your own cleanup logic. The CR update is managed at the OKT reconciler level.
		ErrorManager		// Is reached after any step that raise an error different than GiveUpError. Just add an error in your Reconciler's results.

 Here is a special debranching step that is managed internaly by the Stepper, no need to handle it at your end
     GiveUpManager		// A Terminal state. Can be reached at any time/in any state (even in SuccessManager) when an unrecoverable error happen or simply when the reconciliation can't go further for the moment

Besides that, use the "Free style" engine if you want a full control on the reconiliation process.

func NewStepper

func NewStepper(hook StepperEngineHook) *Stepper

NewStepper Allocates a new reconciler Engine that will course several steps that maps a classical Reconciling process See Stepper type documentation

func (*Stepper) DisplayPathOfStates

func (smc *Stepper) DisplayPathOfStates(logs logr.Logger)

DisplayPathOfStates log the path of states

func (*Stepper) Enter

func (smc *Stepper) Enter(state oktsm.LCGState) error

func (*Stepper) GetState

func (smc *Stepper) GetState() string

GetState transition.Stater implementation

func (*Stepper) Run

func (smc *Stepper) Run()

Run starts from the first reconciliation step (CRChecker). At each an action hook is called with a context parameter which is the Stepper engine itself. It stops either if an error is returned or if the "End" state is reached All results (errors, operations, ...) have to be collected in Reconciler's results (Results)data Compute next state. The principle is to generate a list of events based on watched variable (error, giveup, finalizing) and build a list of events. To be sure to go to the next step, the normal course event "DefaultState" is always added to the list.

func (*Stepper) SetLogger

func (smc *Stepper) SetLogger(logs logr.Logger)

SetLogger xx

func (*Stepper) SetResults

func (smc *Stepper) SetResults(res okterr.Results)

SetResults xx

type StepperEngineHook

type StepperEngineHook interface {
	EnterInState(engine *Stepper)
}

StepperEngineHook Defines the callback used by this engine at each step of the reconciliation. Step name is the state name (CRChecker, ObjectGetter, Mutator, Update, ErrorManager, SuccessManager)

Jump to

Keyboard shortcuts

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