reconciler

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 29 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldTakeUpdatePath

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

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

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

CallbackDispatcher manages and executes resource callbacks

type ControllerConfigUpdater

type ControllerConfigUpdater func(cr client.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 client.Object) (bool, error)
	// Creates empty CR
	Create() client.Object
	// Status extracts status from the cr
	Status(cr client.Object) *sdkapi.Status
	// GetAllResources provides all resources managed by the cr
	GetAllResources(cr client.Object) ([]client.Object, error)
	// GetDependantResourcesListObjects returns resource list objects of dependant resources
	GetDependantResourcesListObjects() []client.ObjectList
}

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

type PerishablesSynchronizer

type PerishablesSynchronizer func(cr client.Object, logger logr.Logger) error

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

type PreCreateHook

type PreCreateHook func(cr client.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, getCache func() cache.Cache, createVersionLabel string, updateVersionLabel string, lastAppliedConfigAnnotation string, perishablesSyncInterval time.Duration, finalizerName string, subresourceEnabled bool, recorder record.EventRecorder) *Reconciler

NewReconciler creates new Reconciler instance configured with given parameters

func (*Reconciler) AddCallback

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

AddCallback registers a callback for given object type

func (*Reconciler) CheckDegraded

func (r *Reconciler) CheckDegraded(logger logr.Logger, cr client.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 client.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 client.Object, targetVersion string) error

CheckUpgrade checks whether an upgrade should be performed

func (*Reconciler) CleanupUnusedResources

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

CleanupUnusedResources removes unused resources

func (*Reconciler) CrError

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

CrError sets the CR's phase to "Error"

func (*Reconciler) CrInit

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

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

func (*Reconciler) CrSetVersion

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

CrSetVersion sets version and phase on the CR object

func (*Reconciler) CrUpdate

func (r *Reconciler) CrUpdate(cr client.Object) error

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

func (*Reconciler) CrUpdateStatus added in v0.2.3

func (r *Reconciler) CrUpdateStatus(phase sdkapi.Phase, cr client.Object) error

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

func (*Reconciler) GetAllDeployments

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

GetAllDeployments retrieves all deployments associated to the given CR object

func (*Reconciler) GetCr

func (r *Reconciler) GetCr(name types.NamespacedName) (client.Object, error)

GetCr retrieves the CR

func (*Reconciler) InvokeCallbacks

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

InvokeCallbacks executes callbacks registered

func (*Reconciler) InvokeDeleteCallbacks

func (r *Reconciler) InvokeDeleteCallbacks(logger logr.Logger, cr client.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 client.Object, finalizerName string) (reconcile.Result, error)

ReconcileDelete executes Delete operation

func (*Reconciler) ReconcileError

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

ReconcileError Marks CR as failed

func (*Reconciler) ReconcileUpdate

func (r *Reconciler) ReconcileUpdate(logger logr.Logger, cr client.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 client.Object) error

WatchDependantResources registers watches for dependant resource types

func (*Reconciler) WatchResourceTypes

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

WatchResourceTypes registers watches for given resources types

func (*Reconciler) WithController

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

WithController sets controller

func (*Reconciler) WithControllerConfigUpdater

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

WithControllerConfigUpdater sets ControllerConfigUpdater

func (*Reconciler) WithNamespacedCR added in v0.1.1

func (r *Reconciler) WithNamespacedCR() *Reconciler

WithNamespacedCR informs the Reconciler that the configuration CR is namespaced

func (*Reconciler) WithPerishablesSynchronizer

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

WithPerishablesSynchronizer sets PerishablesSynchronizer, which must not be nil

func (*Reconciler) WithPreCreateHook

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

WithPreCreateHook sets PreCreateHook

func (*Reconciler) WithSanityChecker

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

WithSanityChecker sets SanityChecker

func (*Reconciler) WithWatchRegistrator

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

WithWatchRegistrator sets WatchRegistrator

func (*Reconciler) WithWatching

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

WithWatching sets watching flag - for testing

type SanityChecker

type SanityChecker func(cr client.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