profiles

package
v0.0.0-...-7801012 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

IsDevProfile is an alias for workflowproj.IsDevProfile

Functions

This section is empty.

Types

type ProfileReconciler

type ProfileReconciler interface {
	Reconcile(ctx context.Context, workflow *operatorapi.SonataFlow) (ctrl.Result, error)
	GetProfile() metadata.ProfileType
}

ProfileReconciler is the public interface to have access to this package and perform the actual reconciliation flow.

There are a few concepts in this package that you need to understand before attempting to maintain it:

1. ProfileReconciler: it's the main interface that internal structs implement via the baseReconciler. Every profile must embed the baseReconciler.

2. stateSupport: is a struct with a few support objects passed around the reconciliation states like the client and logger.

3. reconciliationStateMachine: is a struct within the ProfileReconciler that do the actual reconciliation. Each part of the reconciliation algorithm is a ReconciliationState that will be executed based on the ReconciliationState.CanReconcile call.

4. ReconciliationState: is where your business code should be focused on. Each state should react to a specific operatorapi.SonataFlowConditionType. The least conditions your state handles, the better. The ReconciliationState can provide specific code that will only be triggered if the workflow is in that specific condition.

5. objectCreator: are functions to create a specific Kubernetes object based on a given workflow instance. This function should return the desired default state.

6. mutateVisitor: is a function that states can pass to defaultObjectEnsurer that will be applied to a given live object during the reconciliation cycle. For example, if you wish to guarantee that an image in a specific container in the Deployment that you control and own won't change, make sure that your mutate function guarantees that.

7. defaultObjectEnsurer: is a struct for a given objectCreator to control the reconciliation and merge conditions to an object. A ReconciliationState may or may not have one or more ensurers. Depends on their role. There are states that just read objects, so no need to keep their desired state.

See the already implemented reconciliation profiles to have a better understanding.

While debugging, focus on the ReconciliationState(s), not in the profile implementation since the base algorithm is the same for every profile.

type ReconciliationState

type ReconciliationState interface {
	// CanReconcile checks if this state can perform its reconciliation task
	CanReconcile(workflow *operatorapi.SonataFlow) bool
	// Do perform the reconciliation task. It returns the controller result, the objects updated, and an error if any.
	// Objects can be nil if the reconciliation state doesn't perform any updates in any Kubernetes object.
	Do(ctx context.Context, workflow *operatorapi.SonataFlow) (ctrl.Result, []client.Object, error)
	// PostReconcile performs the actions to perform after the reconciliation that are not mandatory
	PostReconcile(ctx context.Context, workflow *operatorapi.SonataFlow) error
}

ReconciliationState is an interface implemented internally by different reconciliation algorithms to perform the adequate logic for a given workflow profile

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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