lockedresourcecontroller

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnforcingReconciler

type EnforcingReconciler struct {
	util.ReconcilerBase
	// contains filtered or unexported fields
}

EnforcingReconciler is a reconciler designed to as a base type to extend for those operators that compute a set of resources that then need to be kept in place (i.e. enforced) the enforcing piece is taken care for, an implementor would just need to take care of the logic that computes the resources to be enforced.

func NewEnforcingReconciler

func NewEnforcingReconciler(client client.Client, scheme *runtime.Scheme, restConfig *rest.Config, apireader client.Reader, recorder record.EventRecorder, clusterWatchers bool) EnforcingReconciler

NewEnforcingReconciler creates a new EnforcingReconciler clusterWatcher determines whether the created watchers should be at the cluster level or namespace level. this affects the kind of permissions needed to run the controller also creating multiple namespace level permissions can create performance issue as one watch per object type per namespace is opened to the API server, if in doubt pass true here.

func NewFromManager

func NewFromManager(mgr manager.Manager, recorder record.EventRecorder, clusterWatchers bool) EnforcingReconciler

func (*EnforcingReconciler) GetLockedPatchStatuses

func (er *EnforcingReconciler) GetLockedPatchStatuses(instance client.Object) map[string]apis.Conditions

GetLockedPatchStatuses returns the status for all LockedPatches

func (*EnforcingReconciler) GetLockedResourceStatuses

func (er *EnforcingReconciler) GetLockedResourceStatuses(instance client.Object) map[string]apis.Conditions

GetLockedResourceStatuses returns the status for all LockedResources

func (*EnforcingReconciler) GetStatusChangeChannel

func (er *EnforcingReconciler) GetStatusChangeChannel() <-chan event.GenericEvent

GetStatusChangeChannel returns the channel through which status change events can be received

func (*EnforcingReconciler) ManageError

func (er *EnforcingReconciler) ManageError(context context.Context, instance client.Object, issue error) (reconcile.Result, error)

ManageError manage error sets an error status in the CR and fires an event, finally it returns the error so the operator can re-attempt

func (*EnforcingReconciler) ManageSuccess

func (er *EnforcingReconciler) ManageSuccess(context context.Context, instance client.Object) (reconcile.Result, error)

ManageSuccess will update the status of the CR and return a successful reconcile result

func (*EnforcingReconciler) Terminate

func (er *EnforcingReconciler) Terminate(instance client.Object, deleteResources bool) error

Terminate will stop the execution for the current instance. It will also optionally delete the locked resources.

func (*EnforcingReconciler) UpdateLockedResources

func (er *EnforcingReconciler) UpdateLockedResources(context context.Context, instance client.Object, lockedResources []lockedresource.LockedResource, lockedPatches []lockedpatch.LockedPatch) error

UpdateLockedResources will do the following:

  1. initialize or retrieve the LockedResourceManager related to the passed parent resource
  2. compare the currently enforced resources with the one passed as parameters and then a. return immediately if they are the same b. restart the LockedResourceManager if they don't match

func (*EnforcingReconciler) UpdateLockedResourcesWithRestConfig

func (er *EnforcingReconciler) UpdateLockedResourcesWithRestConfig(context context.Context, instance client.Object, lockedResources []lockedresource.LockedResource, lockedPatches []lockedpatch.LockedPatch, config *rest.Config) error

UpdateLockedResourcesWithRestConfig will do the following:

  1. initialize or retrieve the LockedResourceManager related to the passed parent resource
  2. compare the currently enforced resources with the one passed as parameters and then a. return immediately if they are the same b. restart the LockedResourceManager if they don't match

this variant allows passing a rest config

type LockedPatchReconciler

type LockedPatchReconciler struct {
	util.ReconcilerBase
	// contains filtered or unexported fields
}

LockedPatchReconciler is a reconciler that can enforce a LockedPatch

func NewLockedPatchReconciler

func NewLockedPatchReconciler(mgr manager.Manager, patch lockedpatch.LockedPatch, statusChange chan<- event.GenericEvent, parentObject client.Object) (*LockedPatchReconciler, error)

NewLockedPatchReconciler returns a new reconcile.Reconciler

func (*LockedPatchReconciler) GetKey

func (lpr *LockedPatchReconciler) GetKey() string

GetKey return the patch no so unique identifier

func (*LockedPatchReconciler) GetStatus

func (lpr *LockedPatchReconciler) GetStatus() []metav1.Condition

GetStatus returns the status for this reconciler

func (*LockedPatchReconciler) Reconcile

func (lpr *LockedPatchReconciler) Reconcile(context context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile method

type LockedResourceManager

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

LockedResourceManager is a manager designed to manage a set of LockedResourceReconciler. Each reconciler can handle a LockedResource. LockedResourceManager is designed to be sued within an operator to enforce a set of resources. It has methods to start and stop the enforcing and to detect whether a set of resources is equal to the currently enforce set.

func NewLockedResourceManager

func NewLockedResourceManager(config *rest.Config, options manager.Options, parent client.Object, statusChange chan<- event.GenericEvent, clusterWatchers bool) (LockedResourceManager, error)

NewLockedResourceManager build a new LockedResourceManager config: the rest config client to be used by the controllers options: the manager options parent: an object to which send notification when a recocilianton cicle completes for one of the reconcilers statusChange: a channel through which send the notifications

func (*LockedResourceManager) GetPatchReconcilers

func (lrm *LockedResourceManager) GetPatchReconcilers() []*LockedPatchReconciler

GetPatchReconcilers return the currently active patch reconcilers

func (*LockedResourceManager) GetPatches

func (lrm *LockedResourceManager) GetPatches() []lockedpatch.LockedPatch

GetPatches returns the currently enforced patches

func (*LockedResourceManager) GetResourceReconcilers

func (lrm *LockedResourceManager) GetResourceReconcilers() []*LockedResourceReconciler

GetResourceReconcilers return the currently active resource reconcilers

func (*LockedResourceManager) GetResources

func (lrm *LockedResourceManager) GetResources() []lockedresource.LockedResource

GetResources returns the currently enforced resources

func (*LockedResourceManager) IsSamePatches

func (lrm *LockedResourceManager) IsSamePatches(patches []lockedpatch.LockedPatch) (same bool, leftDifference []lockedpatch.LockedPatch, intersection []lockedpatch.LockedPatch, rightDifference []lockedpatch.LockedPatch)

IsSamePatches checks whether the currently enforced patches are the same as the ones passed as parameters same is true is current patches are the same as the patches passed as a parameter leftDifference contains the patches that are in the current patches but not in passed in the parameter intersection contains patches that are both in the current patches and the parameter, the patch definition may not be the same, the definitions of those in the parameter are returned rightDifference contains the patches that are in the parameter but not in the current patches

func (*LockedResourceManager) IsSameResources

func (lrm *LockedResourceManager) IsSameResources(resources []lockedresource.LockedResource) (same bool, leftDifference []lockedresource.LockedResource, intersection []lockedresource.LockedResource, rightDifference []lockedresource.LockedResource)

IsSameResources checks whether the currently enforced resources are the same as the ones passed as parameters same is true is current resources are the same as the resources passed as a parameter leftDifference contains the resources that are in the current resources but not in passed in the parameter intersection contains resources that are both in the current resources and the parameter rightDifference contains the resources that are in the parameter but not in the current resources

func (*LockedResourceManager) IsStarted

func (lrm *LockedResourceManager) IsStarted() bool

IsStarted returns whether the LockedResourceManager is started

func (*LockedResourceManager) Restart

func (lrm *LockedResourceManager) Restart(resources []lockedresource.LockedResource, patches []lockedpatch.LockedPatch, deleteResources bool, config *rest.Config) error

Restart restarts the manager with a different set of resources if deleteResources is set, resources that were enforced are deleted.

func (*LockedResourceManager) SetPatches

func (lrm *LockedResourceManager) SetPatches(patches []lockedpatch.LockedPatch) error

SetPatches set the patches to be enforced. Can be called only when the LockedResourceManager is stopped.

func (*LockedResourceManager) SetResources

func (lrm *LockedResourceManager) SetResources(resources []lockedresource.LockedResource) error

SetResources set the resources to be enforced. Can be called only when the LockedResourceManager is stopped.

func (*LockedResourceManager) Start

func (lrm *LockedResourceManager) Start(config *rest.Config) error

Start starts the LockedResourceManager

func (*LockedResourceManager) Stop

func (lrm *LockedResourceManager) Stop(deleteResources bool) error

Stop stops the LockedResourceManager. deleteResource controls whether the managed resources should be deleted or left in place notice that lrm will always succeed at stopping the manager, but it might fail at deleting resources

type LockedResourceReconciler

type LockedResourceReconciler struct {
	Resource     unstructured.Unstructured
	ExcludePaths []string
	util.ReconcilerBase
	// contains filtered or unexported fields
}

LockedResourceReconciler is a reconciler that will lock down a resource to prevent changes from external events. This reconciler can be configured to ignore a set of json path. Changed occurring on the ignored path will be ignored, and therefore allowed by the reconciler

func NewLockedObjectReconciler

func NewLockedObjectReconciler(mgr manager.Manager, object unstructured.Unstructured, excludePaths []string, statusChange chan<- event.GenericEvent, parentObject client.Object) (*LockedResourceReconciler, error)

NewLockedObjectReconciler returns a new reconcile.Reconciler

func (*LockedResourceReconciler) GetStatus

func (lor *LockedResourceReconciler) GetStatus() []metav1.Condition

GetStatus returns the latest reconcile status

func (*LockedResourceReconciler) Reconcile

func (lor *LockedResourceReconciler) Reconcile(context context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile contains the reconcile logic for LockedResourceReconciler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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