summarize

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorActionHandler added in v0.25.0

func ErrorActionHandler(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, _ reconcile.Result, err error)

ErrorActionHandler is a ResultProcessor that handles all the actions configured in the given error. Logging and event recording are the handled actions at present. As more configurations are added to serror.Config, more action handlers can be added here.

func RecordReconcileReq

func RecordReconcileReq(ctx context.Context, recorder kuberecorder.EventRecorder, obj client.Object, _ reconcile.Result, _ error)

RecordReconcileReq is a ResultProcessor that checks the reconcile annotation value and sets it in the object status as status.lastHandledReconcileAt.

Types

type Conditions

type Conditions struct {
	// Target is the target condition, e.g.: Ready.
	Target string
	// Owned conditions are the conditions owned by the reconciler for this
	// target condition.
	Owned []string
	// Summarize conditions are the conditions that the target condition depends
	// on.
	Summarize []string
	// NegativePolarity conditions are the conditions in Summarize with negative
	// polarity.
	NegativePolarity []string
}

Conditions contains all the conditions information needed to summarize the target condition.

type Helper

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

Helper is SummarizeAndPatch helper.

func NewHelper

func NewHelper(recorder kuberecorder.EventRecorder, serialPatcher *patch.SerialPatcher) *Helper

NewHelper returns an initialized Helper.

func (*Helper) SummarizeAndPatch

func (h *Helper) SummarizeAndPatch(ctx context.Context, obj conditions.Setter, options ...Option) (ctrl.Result, error)

SummarizeAndPatch summarizes and patches the result to the target object. When used at the very end of a reconciliation, the result builder must be specified using the Option WithResultBuilder(). The returned result and error can be returned as the return values of the reconciliation. When used in the middle of a reconciliation, no result builder should be set and the result can be ignored.

type HelperOptions

type HelperOptions struct {
	// Conditions are conditions that needs to be summarized and persisted on
	// the object.
	Conditions []Conditions
	// Processors are chain of ResultProcessors for processing the results. This
	// can be used to analyze and modify the results. This enables injecting
	// custom middlewares in the SummarizeAndPatch operation.
	Processors []ResultProcessor
	// IgnoreNotFound can be used to ignores any resource not found error during
	// patching.
	IgnoreNotFound bool
	// ReconcileResult is the abstracted result of reconciliation.
	ReconcileResult reconcile.Result
	// ReconcileError is the reconciliation error.
	ReconcileError error
	// ResultBuilder defines how the reconciliation result is computed.
	ResultBuilder reconcile.RuntimeResultBuilder
	// PatchFieldOwner defines the field owner configuration for the Kubernetes
	// patch operation.
	PatchFieldOwner string
	// BiPolarityConditionTypes is a list of bipolar conditions in the order
	// of priority.
	BiPolarityConditionTypes []string
}

HelperOptions contains options for SummarizeAndPatch. Summarizing and patching at the very end of a reconciliation involves computing the result of the reconciler. This requires providing the ReconcileResult, ReconcileError and a ResultBuilder in the context of the reconciliation. For using this to perform intermediate patching in the middle of a reconciliation, no ReconcileResult, ReconcileError or ResultBuilder should be provided. Only Conditions summary would be calculated and patched.

type Option

type Option func(*HelperOptions)

Option is configuration that modifies SummarizeAndPatch.

func WithBiPolarityConditionTypes added in v0.30.0

func WithBiPolarityConditionTypes(types ...string) Option

WithBiPolarityConditionTypes sets the BiPolarityConditionTypes used to calculate the value of Ready condition in SummarizeAndPatch.

func WithConditions

func WithConditions(condns ...Conditions) Option

WithConditions sets the Conditions for which summary is calculated in SummarizeAndPatch.

func WithIgnoreNotFound

func WithIgnoreNotFound() Option

WithIgnoreNotFound skips any resource not found error during patching.

func WithPatchFieldOwner

func WithPatchFieldOwner(fieldOwner string) Option

WithPatchFieldOwner sets the FieldOwner in the patch helper.

func WithProcessors

func WithProcessors(rps ...ResultProcessor) Option

WithProcessors can be used to inject middlewares in the SummarizeAndPatch process, to be executed before the result calculation and patching.

func WithReconcileError

func WithReconcileError(re error) Option

WithReconcileError sets the value of input error used to calculate the results reconciliation in SummarizeAndPatch.

func WithReconcileResult

func WithReconcileResult(rr reconcile.Result) Option

WithReconcileResult sets the value of input result used to calculate the results of reconciliation in SummarizeAndPatch.

func WithResultBuilder

func WithResultBuilder(rb reconcile.RuntimeResultBuilder) Option

WithResultBuilder sets the strategy for result computation in SummarizeAndPatch.

type ResultProcessor

ResultProcessor processes the results of reconciliation (the object, result and error). Any errors during processing need not result in the reconciliation failure. The errors can be recorded as logs and events.

Jump to

Keyboard shortcuts

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