reconciler

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldTakeUpdatePath added in v0.0.3

func ShouldTakeUpdatePath(targetVersion, currentVersion string, deploying bool) (bool, error)

ShouldTakeUpdatePath checks whether upgrade-type reconciliation should be executed. Returns error in case of downgrade

Types

type CallbackDispatcher added in v0.0.3

type CallbackDispatcher interface {
	// AddCallback registers a callback for given object type
	AddCallback(runtime.Object, callbacks.ReconcileCallback)

	// InvokeCallbacks executes callbacks for desired/current object type
	InvokeCallbacks(l logr.Logger, cr interface{}, s callbacks.ReconcileState, desiredObj, currentObj runtime.Object) error
}

CallbackDispatcher manages and executes resource callbacks

type ControllerConfigUpdater added in v0.0.2

type ControllerConfigUpdater func(cr controllerutil.Object) error

ControllerConfigUpdater is expected to update controller configuration if required

type CrManager

type CrManager interface {
	// IsCreating checks whether creation of the managed resources will be executed
	IsCreating(cr controllerutil.Object) (bool, error)
	// Creates empty CR
	Create() controllerutil.Object
	// Status extracts status from the cr
	Status(cr runtime.Object) *sdkapi.Status
	// GetAllResources provides all resources managed by the cr
	GetAllResources(cr runtime.Object) ([]runtime.Object, error)
	// GetDependantResourcesListObjects returns resource list objects of dependant resources
	GetDependantResourcesListObjects() []runtime.Object
}

CrManager defines interface that needs to be provided for the reconciler to operate

type PerishablesSynchronizer

type PerishablesSynchronizer func() error

PerishablesSynchronizer is expected to execute perishable resources (i.e. certificates) synchronization if required

type PreCreateHook added in v0.0.2

type PreCreateHook func(cr controllerutil.Object) error

PreCreateHook is expected to perform custom actions before the creation of the managed resources is initiated

type Reconciler

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

Reconciler is responsible for performing deployment reconciliation

func NewReconciler

func NewReconciler(crManager CrManager, log logr.Logger, client client.Client, callbackDispatcher CallbackDispatcher, scheme *runtime.Scheme, createVersionLabel string, updateVersionLabel string, lastAppliedConfigAnnotation string, perishablesSyncInterval time.Duration, finalizerName string) *Reconciler

NewReconciler creates new Reconciler instance configured with given parameters

func (*Reconciler) AddCallback

func (r *Reconciler) AddCallback(obj runtime.Object, cb callbacks.ReconcileCallback)

AddCallback registers a callback for given object type

func (*Reconciler) CheckDegraded

func (r *Reconciler) CheckDegraded(logger logr.Logger, cr runtime.Object) (bool, error)

CheckDegraded checks whether the deployment is degraded and updates CR status conditions accordingly

func (*Reconciler) CheckForOrphans

func (r *Reconciler) CheckForOrphans(logger logr.Logger, cr runtime.Object) (bool, error)

CheckForOrphans checks whether there are any orphaned resources (ones that exist in the cluster but shouldn't)

func (*Reconciler) CheckUpgrade

func (r *Reconciler) CheckUpgrade(logger logr.Logger, cr runtime.Object, targetVersion string) error

CheckUpgrade checks whether an upgrade should be performed

func (*Reconciler) CleanupUnusedResources

func (r *Reconciler) CleanupUnusedResources(logger logr.Logger, cr controllerutil.Object) error

CleanupUnusedResources removes unused resources

func (*Reconciler) CrError

func (r *Reconciler) CrError(cr runtime.Object) error

CrError sets the CR's phase to "Error"

func (*Reconciler) CrInit

func (r *Reconciler) CrInit(cr controllerutil.Object, operatorVersion string) error

CrInit initializes the CR and moves it to CR to "Deploying" status

func (*Reconciler) CrSetVersion

func (r *Reconciler) CrSetVersion(cr runtime.Object, version string) error

CrSetVersion sets version and phase on the CR object

func (*Reconciler) CrUpdate

func (r *Reconciler) CrUpdate(phase sdkapi.Phase, cr runtime.Object) error

CrUpdate sets given phase on the CR and updates it in the cluster

func (*Reconciler) GetAllDeployments

func (r *Reconciler) GetAllDeployments(cr runtime.Object) ([]*appsv1.Deployment, error)

GetAllDeployments retrieves all deployments associated to the given CR object

func (*Reconciler) InvokeCallbacks

func (r *Reconciler) InvokeCallbacks(l logr.Logger, cr runtime.Object, s callbacks.ReconcileState, desiredObj, currentObj runtime.Object) error

InvokeCallbacks executes callbacks registered

func (*Reconciler) InvokeDeleteCallbacks

func (r *Reconciler) InvokeDeleteCallbacks(logger logr.Logger, cr runtime.Object) error

InvokeDeleteCallbacks executes operator deletion callbacks

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(request reconcile.Request, operatorVersion string, reqLogger logr.Logger) (reconcile.Result, error)

Reconcile performs request reconciliation

func (*Reconciler) ReconcileDelete

func (r *Reconciler) ReconcileDelete(logger logr.Logger, cr controllerutil.Object, finalizerName string) (reconcile.Result, error)

ReconcileDelete executes Delete operation

func (*Reconciler) ReconcileError

func (r *Reconciler) ReconcileError(cr runtime.Object, message string) (reconcile.Result, error)

ReconcileError Marks CR as failed

func (*Reconciler) ReconcileUpdate

func (r *Reconciler) ReconcileUpdate(logger logr.Logger, cr controllerutil.Object, operatorVersion string) (reconcile.Result, error)

ReconcileUpdate executes Update operation

func (*Reconciler) WatchCR

func (r *Reconciler) WatchCR() error

WatchCR registers watch for the managed CR

func (*Reconciler) WatchDependantResources

func (r *Reconciler) WatchDependantResources(cr runtime.Object) error

WatchDependantResources registers watches for dependant resource types

func (*Reconciler) WatchResourceTypes

func (r *Reconciler) WatchResourceTypes(resources ...runtime.Object) error

WatchResourceTypes registers watches for given resources types

func (*Reconciler) WithController added in v0.0.2

func (r *Reconciler) WithController(controller controller.Controller) *Reconciler

WithController sets controller

func (*Reconciler) WithControllerConfigUpdater added in v0.0.2

func (r *Reconciler) WithControllerConfigUpdater(updateConfig ControllerConfigUpdater) *Reconciler

WithControllerConfigUpdater sets ControllerConfigUpdater

func (*Reconciler) WithPerishablesSynchronizer added in v0.0.2

func (r *Reconciler) WithPerishablesSynchronizer(syncPerishables PerishablesSynchronizer) *Reconciler

WithPerishablesSynchronizer sets PerishablesSynchronizer, which must not be nil

func (*Reconciler) WithPreCreateHook added in v0.0.2

func (r *Reconciler) WithPreCreateHook(preCreate PreCreateHook) *Reconciler

WithPreCreateHook sets PreCreateHook

func (*Reconciler) WithSanityChecker added in v0.0.2

func (r *Reconciler) WithSanityChecker(checkSanity SanityChecker) *Reconciler

WithSanityChecker sets SanityChecker

func (*Reconciler) WithWatchRegistrator added in v0.0.2

func (r *Reconciler) WithWatchRegistrator(watch WatchRegistrator) *Reconciler

WithWatchRegistrator sets WatchRegistrator

func (*Reconciler) WithWatching added in v0.0.4

func (r *Reconciler) WithWatching(watching bool) *Reconciler

WithWatching sets watching flag - for testing

type SanityChecker added in v0.0.2

type SanityChecker func(cr controllerutil.Object, logger logr.Logger) (*reconcile.Result, error)

SanityChecker is expected to check if it makes sense to execute the reconciliation if required

type WatchRegistrator

type WatchRegistrator func() error

WatchRegistrator is expected to register additional resource watchers if required

Jump to

Keyboard shortcuts

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