reconciler

package
v0.0.0-...-fc29aca Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: UPL-1.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PatchIgnore - If the patch json is this we can skip the patch.
	PatchIgnore = "{\"metadata\":{\"creationTimestamp\":null},\"status\":{\"replicas\":0}}"

	// EventReasonCreated is the reason description for a created event.
	EventReasonCreated string = "Created"
	// EventReasonUpdated is the reason description for an updated event.
	EventReasonUpdated string = "Updated"
	// EventReasonFailed is the reason description for a failed event.
	EventReasonFailed string = "Failed"
	// EventReasonDeleted is the reason description for a deleted event.
	EventReasonDeleted string = "Deleted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseReconciler

type BaseReconciler interface {
	GetControllerName() string
	GetManager() manager.Manager
	GetClient() client.Client
	GetEventRecorder() record.EventRecorder
	GetLog() logr.Logger
	GetReconciler() reconcile.Reconciler
	SetPatchType(patchType types.PatchType)
}

type CommonReconciler

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

CommonReconciler is a base controller structure.

func (*CommonReconciler) ApplyThreeWayPatchWithCallback

func (in *CommonReconciler) ApplyThreeWayPatchWithCallback(ctx context.Context, name string, current client.Object, patch client.Patch, data []byte, callback func()) (bool, error)

ApplyThreeWayPatchWithCallback performs a three-way merge patch on the resource returning true if a patch was required otherwise false.

func (*CommonReconciler) BlankCoherenceContainerFields

func (in *CommonReconciler) BlankCoherenceContainerFields(template *corev1.PodTemplateSpec)

BlankCoherenceContainerFields blanks out any fields that may have been set by a previous Operator version. DO NOT blank out anything that the user has control over as they may have updated them, so we need to include them in the patch

func (*CommonReconciler) BlankContainerFields

func (in *CommonReconciler) BlankContainerFields(deployment coh.CoherenceResource, template *corev1.PodTemplateSpec)

BlankContainerFields blanks out any fields that we do not want to include in the patch Typically these are fields where we changed the default behaviour in the newer Operator versions

func (*CommonReconciler) BlankOperatorInitContainerFields

func (in *CommonReconciler) BlankOperatorInitContainerFields(template *corev1.PodTemplateSpec)

BlankOperatorInitContainerFields blanks out any fields that may have been set by a previous Operator version. DO NOT blank out anything that the user has control over as they may have updated them, so we need to include them in the patch

func (*CommonReconciler) CanCreate

func (in *CommonReconciler) CanCreate(ctx context.Context, deployment coh.CoherenceResource) (bool, string)

CanCreate determines whether any specified start quorum has been met.

func (*CommonReconciler) CreateThreeWayPatch

func (in *CommonReconciler) CreateThreeWayPatch(name string, original, desired, current runtime.Object, ignore ...string) (client.Patch, []byte, error)

CreateThreeWayPatch creates a three-way patch between the original state, the current state and the desired state of a k8s resource.

func (*CommonReconciler) CreateThreeWayPatchData

func (in *CommonReconciler) CreateThreeWayPatchData(original, desired, current runtime.Object) ([]byte, error)

CreateThreeWayPatchData creates a three-way patch between the original state, the current state and the desired state of a k8s resource.

func (*CommonReconciler) CreateTwoWayPatch

func (in *CommonReconciler) CreateTwoWayPatch(name string, desired, current runtime.Object, ignore ...string) (client.Patch, error)

CreateTwoWayPatch creates a two-way patch between the original state, the current state and the desired state of a k8s resource.

func (*CommonReconciler) CreateTwoWayPatchOfType

func (in *CommonReconciler) CreateTwoWayPatchOfType(patchType types.PatchType, name string, desired, current runtime.Object, ignore ...string) (client.Patch, error)

CreateTwoWayPatchOfType creates a two-way patch between the current state and the desired state of a k8s resource.

func (*CommonReconciler) Failed

func (in *CommonReconciler) Failed(ctx context.Context, err error, deployment coh.CoherenceResource, msg string, requeue bool, logger logr.Logger) (reconcile.Result, error)

Failed is a common error handler ToDo: we need to be able to add some form of back-off so that failures are re-queued with a growing back-off time

func (*CommonReconciler) FindCoherenceJob

func (in *CommonReconciler) FindCoherenceJob(ctx context.Context, namespace, name string) (*coh.CoherenceJob, error)

FindCoherenceJob finds the CoherenceJob resource.

func (*CommonReconciler) FindDeployment

func (in *CommonReconciler) FindDeployment(ctx context.Context, namespace, name string) (*coh.Coherence, error)

FindDeployment finds the Coherence resource.

func (*CommonReconciler) FindOwningCoherenceResource

func (in *CommonReconciler) FindOwningCoherenceResource(ctx context.Context, o client.Object) (coh.CoherenceResource, error)

FindOwningCoherenceResource finds the owning Coherence resource.

func (*CommonReconciler) GetClient

func (in *CommonReconciler) GetClient() client.Client

func (*CommonReconciler) GetCoherenceImage

func (in *CommonReconciler) GetCoherenceImage(template *corev1.PodTemplateSpec) string

GetCoherenceImage gets the Coherence image name from the coherence container.

func (*CommonReconciler) GetControllerName

func (in *CommonReconciler) GetControllerName() string

func (*CommonReconciler) GetEventRecorder

func (in *CommonReconciler) GetEventRecorder() record.EventRecorder

func (*CommonReconciler) GetLog

func (in *CommonReconciler) GetLog() logr.Logger

func (*CommonReconciler) GetManager

func (in *CommonReconciler) GetManager() manager.Manager

func (*CommonReconciler) GetMutex

func (in *CommonReconciler) GetMutex() *sync.Mutex

func (*CommonReconciler) GetOperatorImage

func (in *CommonReconciler) GetOperatorImage(template *corev1.PodTemplateSpec) string

GetOperatorImage gets the Operator image name from the init container.

func (*CommonReconciler) GetPatchType

func (in *CommonReconciler) GetPatchType() types.PatchType

func (*CommonReconciler) HandleErrAndFinish

func (in *CommonReconciler) HandleErrAndFinish(ctx context.Context, err error, deployment *coh.Coherence, msg string, logger logr.Logger) (reconcile.Result, error)

HandleErrAndFinish is the common error handler

func (*CommonReconciler) HandleErrAndRequeue

func (in *CommonReconciler) HandleErrAndRequeue(ctx context.Context, err error, deployment coh.CoherenceResource, msg string, logger logr.Logger) (reconcile.Result, error)

HandleErrAndRequeue is the common error handler

func (*CommonReconciler) Lock

func (in *CommonReconciler) Lock(request reconcile.Request) bool

Lock attempts to lock the requested resource.

func (*CommonReconciler) MaybeFindCoherenceJob

func (in *CommonReconciler) MaybeFindCoherenceJob(ctx context.Context, namespace, name string) (*coh.CoherenceJob, bool, error)

MaybeFindCoherenceJob possibly finds a CoherenceJob resource.

func (*CommonReconciler) MaybeFindDeployment

func (in *CommonReconciler) MaybeFindDeployment(ctx context.Context, namespace, name string) (*coh.Coherence, bool, error)

MaybeFindDeployment possibly finds a Coherence resource.

func (*CommonReconciler) MaybeFindJob

func (in *CommonReconciler) MaybeFindJob(ctx context.Context, namespace, name string) (*batchv1.Job, bool, error)

MaybeFindJob finds the required Job, returning the StatefulSet and a flag indicating whether it was found.

func (*CommonReconciler) MaybeFindStatefulSet

func (in *CommonReconciler) MaybeFindStatefulSet(ctx context.Context, namespace, name string) (*appsv1.StatefulSet, bool, error)

MaybeFindStatefulSet finds the required StatefulSet, returning the StatefulSet and a flag indicating whether it was found.

func (*CommonReconciler) SetCoherenceImage

func (in *CommonReconciler) SetCoherenceImage(template *corev1.PodTemplateSpec, image string)

SetCoherenceImage sets the Coherence image name in the coherence container.

func (*CommonReconciler) SetCommonReconciler

func (in *CommonReconciler) SetCommonReconciler(name string, mgr manager.Manager)

func (*CommonReconciler) SetOperatorImage

func (in *CommonReconciler) SetOperatorImage(template *corev1.PodTemplateSpec, image string)

SetOperatorImage sets the Operator image name in the init container.

func (*CommonReconciler) SetPatchType

func (in *CommonReconciler) SetPatchType(pt types.PatchType)

func (*CommonReconciler) SortEnvForAllContainers

func (in *CommonReconciler) SortEnvForAllContainers(template *corev1.PodTemplateSpec)

SortEnvForAllContainers sorts the environment variable slice for all containers.

func (*CommonReconciler) SortEnvForContainer

func (in *CommonReconciler) SortEnvForContainer(c *corev1.Container)

SortEnvForContainer sorts the environment variable slice for a container.

func (*CommonReconciler) ThreeWayPatch

func (in *CommonReconciler) ThreeWayPatch(ctx context.Context, name string, current, original, desired client.Object) (bool, error)

ThreeWayPatch performs a three-way merge patch on the resource returning true if a patch was required otherwise false.

func (*CommonReconciler) ThreeWayPatchWithCallback

func (in *CommonReconciler) ThreeWayPatchWithCallback(ctx context.Context, name string, current, original, desired client.Object, callback func()) (bool, error)

ThreeWayPatchWithCallback performs a three-way merge patch on the resource returning true if a patch was required otherwise false.

func (*CommonReconciler) TwoWayPatch

func (in *CommonReconciler) TwoWayPatch(ctx context.Context, name string, current, desired client.Object) (bool, error)

TwoWayPatch performs a two-way merge patch on the resource.

func (*CommonReconciler) Unlock

func (in *CommonReconciler) Unlock(request reconcile.Request)

Unlock unlocks the requested resource

func (*CommonReconciler) UpdateCoherenceJobStatusCondition

func (in *CommonReconciler) UpdateCoherenceJobStatusCondition(ctx context.Context, key types.NamespacedName, c coh.Condition) error

UpdateCoherenceJobStatusCondition updates the CoherenceJob resource's status.

func (*CommonReconciler) UpdateCoherenceJobStatusPhase

func (in *CommonReconciler) UpdateCoherenceJobStatusPhase(ctx context.Context, key types.NamespacedName, phase coh.ConditionType) error

UpdateCoherenceJobStatusPhase updates the CoherenceJob resource's status.

func (*CommonReconciler) UpdateCoherenceStatusCondition

func (in *CommonReconciler) UpdateCoherenceStatusCondition(ctx context.Context, key types.NamespacedName, c coh.Condition) error

UpdateCoherenceStatusCondition updates the Coherence resource's status.

func (*CommonReconciler) UpdateCoherenceStatusPhase

func (in *CommonReconciler) UpdateCoherenceStatusPhase(ctx context.Context, key types.NamespacedName, phase coh.ConditionType) error

UpdateCoherenceStatusPhase updates the Coherence resource's status.

func (*CommonReconciler) UpdateDeploymentStatusActionsState

func (in *CommonReconciler) UpdateDeploymentStatusActionsState(ctx context.Context, key types.NamespacedName, actionExecuted bool) error

UpdateDeploymentStatusActionsState updates the Coherence resource's status ActionsExecuted flag.

func (*CommonReconciler) UpdateDeploymentStatusHash

func (in *CommonReconciler) UpdateDeploymentStatusHash(ctx context.Context, key types.NamespacedName, hash string) error

UpdateDeploymentStatusHash updates the Coherence resource's status hash.

type ReconcileSecondaryResource

type ReconcileSecondaryResource struct {
	CommonReconciler
	Template  client.Object
	Kind      coh.ResourceType
	SkipWatch bool
}

ReconcileSecondaryResource reconciles secondary resources of a specific Kind for a specific Coherence resource

func (*ReconcileSecondaryResource) CanWatch

func (in *ReconcileSecondaryResource) CanWatch() bool

func (*ReconcileSecondaryResource) Create

func (in *ReconcileSecondaryResource) Create(ctx context.Context, name string, storage utils.Storage, logger logr.Logger) error

Create the specified resource

func (*ReconcileSecondaryResource) Delete

func (in *ReconcileSecondaryResource) Delete(ctx context.Context, namespace, name string, logger logr.Logger) error

Delete the resource

func (*ReconcileSecondaryResource) FindResource

func (in *ReconcileSecondaryResource) FindResource(ctx context.Context, namespace, name string) (client.Object, bool, error)

func (*ReconcileSecondaryResource) GetTemplate

func (in *ReconcileSecondaryResource) GetTemplate() client.Object

func (*ReconcileSecondaryResource) HashLabelsMatch

func (in *ReconcileSecondaryResource) HashLabelsMatch(o metav1.Object, storage utils.Storage) bool

HashLabelsMatch determines whether the Coherence Hash label on the specified Object matches the hash on the storage.

func (*ReconcileSecondaryResource) NewFromTemplate

func (in *ReconcileSecondaryResource) NewFromTemplate(namespace, name string) client.Object

NewFromTemplate creates a resource from a template resource.

func (*ReconcileSecondaryResource) ReconcileAllResourceOfKind

func (in *ReconcileSecondaryResource) ReconcileAllResourceOfKind(ctx context.Context, request reconcile.Request, deployment coh.CoherenceResource, storage utils.Storage) (reconcile.Result, error)

ReconcileAllResourceOfKind reconciles the state of all the desired resources of the specified Kind for the reconciler

func (*ReconcileSecondaryResource) ReconcileSingleResource

func (in *ReconcileSecondaryResource) ReconcileSingleResource(ctx context.Context, namespace, name string, owner coh.CoherenceResource, storage utils.Storage, logger logr.Logger) error

ReconcileSingleResource reconciles a specific resource.

func (*ReconcileSecondaryResource) Update

func (in *ReconcileSecondaryResource) Update(ctx context.Context, name string, current client.Object, storage utils.Storage, logger logr.Logger) error

Update possibly updates the resource if the current state differs from the desired state.

type SecondaryResourceReconciler

type SecondaryResourceReconciler interface {
	BaseReconciler
	GetTemplate() client.Object
	ReconcileAllResourceOfKind(context.Context, reconcile.Request, coh.CoherenceResource, utils.Storage) (reconcile.Result, error)
	CanWatch() bool
}

SecondaryResourceReconciler is a reconciler for sub-resources.

func NewConfigMapReconciler

func NewConfigMapReconciler(mgr manager.Manager) SecondaryResourceReconciler

func NewServiceReconciler

func NewServiceReconciler(mgr manager.Manager) SecondaryResourceReconciler

func NewSimpleReconciler

func NewSimpleReconciler(mgr manager.Manager, name string, kind coh.ResourceType, template client.Object) SecondaryResourceReconciler

NewSimpleReconciler returns a new SimpleReconciler.

type SimpleReconciler

type SimpleReconciler struct {
	ReconcileSecondaryResource
}

func (*SimpleReconciler) GetReconciler

func (in *SimpleReconciler) GetReconciler() reconcile.Reconciler

func (*SimpleReconciler) Reconcile

func (in *SimpleReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

Reconcile reads that state of the secondary resource for a deployment and makes changes based on the state read and the desired state based on the parent Coherence resource.

Jump to

Keyboard shortcuts

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