controllers

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Use this delay if you want to retry an invalid user configuration.
	// e.g.:
	// - referencing objects that don't exist.
	// - object collisions.
	// - missing permissions.
	DefaultGlobalMissConfigurationRetry = 30 * time.Second

	DefaultInitialBackoff = 10 * time.Second
	DefaultMaxBackoff     = 300 * time.Second
)
View Source
const (
	// This label is set on all dynamic objects to limit caches.
	DynamicCacheLabel = "package-operator.run/cache"
	// Common finalizer to free allocated caches when objects are deleted.
	CachedFinalizer = "package-operator.run/cached"
	// Records cause of change for history keeping.
	ChangeCauseAnnotation = "kubernetes.io/change-cause"
	// Causes PKO to skip ownership checks, used during self-bootstrap.
	ForceAdoptionEnvironmentVariable = "PKO_FORCE_ADOPTION"
	// Name of the PKO field manager for server-side apply.
	FieldOwner = "package-operator"
)

Variables

This section is empty.

Functions

func AddDynamicCacheLabel

func AddDynamicCacheLabel(
	ctx context.Context, w client.Writer, obj *unstructured.Unstructured,
) (*unstructured.Unstructured, error)

AddDynamicCacheLabel ensures that the given object is labeled for recognition by the dynamic cache.

func DeleteMappedConditions

func DeleteMappedConditions(_ context.Context, conditions *[]metav1.Condition)

func EnsureCachedFinalizer

func EnsureCachedFinalizer(
	ctx context.Context, c client.Client, obj client.Object,
) error

func EnsureFinalizer

func EnsureFinalizer(
	ctx context.Context, c client.Client,
	obj client.Object, finalizer string,
) error

Ensures the given finalizer is set and persisted on the given object.

func FreeCacheAndRemoveFinalizer

func FreeCacheAndRemoveFinalizer(
	ctx context.Context, c client.Client,
	obj client.Object, cache cacheFreer,
) error

Frees caches and removes the associated finalizer.

func GetControllerOf

func GetControllerOf(
	_ context.Context, scheme *runtime.Scheme, ownerStrategy isControllerChecker,
	owner client.Object, actualObjects []client.Object,
) ([]corev1alpha1.ControlledObjectReference, error)

Returns a list of ControlledObjectReferences controlled by this instance.

func IsAdoptionRefusedError

func IsAdoptionRefusedError(err error) bool

Returns true if the underlying error is because adoption has been refused.

func IsExternalResourceNotFound

func IsExternalResourceNotFound(err error) bool

func IsMappedCondition

func IsMappedCondition(cond metav1.Condition) bool

func MapConditions

func MapConditions(
	_ context.Context,
	srcGeneration int64, srcConditions []metav1.Condition,
	destGeneration int64, destConditions *[]metav1.Condition,
)

func RemoveFinalizer

func RemoveFinalizer(
	ctx context.Context, c client.Client,
	obj client.Object, finalizer string,
) error

Removes the given finalizer and persists the change.

func UpdateObjectSetOrPhaseStatusFromError

func UpdateObjectSetOrPhaseStatusFromError(
	ctx context.Context, objectSetOrPhase ObjectSetOrPhase,
	reconcileErr error, updateStatus func(ctx context.Context) error,
) (res ctrl.Result, err error)

Types

type BackoffConfig

type BackoffConfig struct {
	InitialBackoff *time.Duration
	MaxBackoff     *time.Duration
}

func (*BackoffConfig) Default

func (c *BackoffConfig) Default()

func (*BackoffConfig) GetBackoff

func (c *BackoffConfig) GetBackoff() *flowcontrol.Backoff

func (*BackoffConfig) Option

func (c *BackoffConfig) Option(opts ...BackoffOption)

type BackoffOption

type BackoffOption interface {
	ConfigureBackoff(*BackoffConfig)
}

type CommonObjectPhaseError

type CommonObjectPhaseError struct {
	OwnerKey, ObjectKey client.ObjectKey
	OwnerGVK, ObjectGVK schema.GroupVersionKind
}

type ControllerError

type ControllerError interface {
	CausedBy(reason ErrorReason) bool
}

type ErrorReason

type ErrorReason string
const (
	ErrorReasonExternalResourceNotFound ErrorReason = "external resource not found"
)

func (ErrorReason) String

func (r ErrorReason) String() string

type ObjectNotOwnedByPreviousRevisionError

type ObjectNotOwnedByPreviousRevisionError struct {
	CommonObjectPhaseError
}

This error is returned when a Phase contains objects that are not owned by a previous revision. Previous revisions of an Phase have to be declared in .spec.previousRevisions.

func (*ObjectNotOwnedByPreviousRevisionError) Error

type ObjectSetOrPhase

type ObjectSetOrPhase interface {
	ClientObject() client.Object
	GetConditions() *[]metav1.Condition
	UpdateStatusPhase()
}

type PhaseObjectOwner

type PhaseObjectOwner interface {
	ClientObject() client.Object
	GetRevision() int64
	GetConditions() *[]metav1.Condition
	IsPaused() bool
}

type PhaseReconciler

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

PhaseReconciler reconciles objects within a ObjectSet phase.

func NewPhaseReconciler

func NewPhaseReconciler(
	scheme *runtime.Scheme,
	writer client.Writer,
	dynamicCache dynamicCache,
	uncachedClient client.Reader,
	ownerStrategy ownerStrategy,
	preflightChecker preflightChecker,
) *PhaseReconciler

func (*PhaseReconciler) ReconcilePhase

func (r *PhaseReconciler) ReconcilePhase(
	ctx context.Context, owner PhaseObjectOwner,
	phase corev1alpha1.ObjectSetTemplatePhase,
	probe probing.Prober, previous []PreviousObjectSet,
) (actualObjects []client.Object, res ProbingResult, err error)

func (*PhaseReconciler) TeardownPhase

func (r *PhaseReconciler) TeardownPhase(
	ctx context.Context, owner PhaseObjectOwner,
	phase corev1alpha1.ObjectSetTemplatePhase,
) (cleanupDone bool, err error)

type PhaseReconcilerError

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

func NewExternalResourceNotFoundError

func NewExternalResourceNotFoundError(rsrc client.Object) *PhaseReconcilerError

func (*PhaseReconcilerError) CausedBy

func (e *PhaseReconcilerError) CausedBy(reason ErrorReason) bool

func (*PhaseReconcilerError) Error

func (e *PhaseReconcilerError) Error() string

type PreviousObjectSet

type PreviousObjectSet interface {
	ClientObject() client.Object
	GetRemotePhases() []corev1alpha1.RemotePhaseReference
}

type PreviousObjectSetFactory

type PreviousObjectSetFactory func(*runtime.Scheme) PreviousObjectSet

type PreviousOwner

type PreviousOwner interface {
	ClientObject() client.Object
	GetPrevious() []corev1alpha1.PreviousRevisionReference
}

type PreviousRevisionLookup

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

func NewPreviousRevisionLookup

func NewPreviousRevisionLookup(
	scheme *runtime.Scheme,
	newPreviousObjectSet PreviousObjectSetFactory,
	client client.Reader,
) *PreviousRevisionLookup

func (*PreviousRevisionLookup) Lookup

type ProbingResult

type ProbingResult struct {
	PhaseName    string
	FailedProbes []string
}

func (*ProbingResult) IsZero

func (e *ProbingResult) IsZero() bool

func (*ProbingResult) String

func (e *ProbingResult) String() string

func (*ProbingResult) StringWithoutPhase

func (e *ProbingResult) StringWithoutPhase() string

type RevisionCollisionError

type RevisionCollisionError struct {
	CommonObjectPhaseError
}

This error is returned when a Phase tries to adopt an object where the revision number is not increasing.

func (*RevisionCollisionError) Error

func (e *RevisionCollisionError) Error() string

type WithInitialBackoff

type WithInitialBackoff time.Duration

func (WithInitialBackoff) ConfigureBackoff

func (w WithInitialBackoff) ConfigureBackoff(c *BackoffConfig)

type WithMaxBackoff

type WithMaxBackoff time.Duration

func (WithMaxBackoff) ConfigureBackoff

func (w WithMaxBackoff) ConfigureBackoff(c *BackoffConfig)

Directories

Path Synopsis
hypershift/v1beta1
The package v1beta1 contains some API Schema definitions for the v1beta1 version of some Hypershift API group.
The package v1beta1 contains some API Schema definitions for the v1beta1 version of some Hypershift API group.

Jump to

Keyboard shortcuts

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