finalizer

package
v1.17.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SingleObjectPredicate

func SingleObjectPredicate(key client.ObjectKey) predicate.Predicate

SingleObjectPredicate returns a Predicate which filters events by both name & namespace. The Predicate methods return true if the object matches.

Use this for client-side filtering when you can't use server-side fieldSelectors, like when an informer is shared between controllers.

Types

type Controller

type Controller struct {
	SyncScope declared.Scope
	SyncName  string
	Client    client.Client
	Mapper    meta.RESTMapper
	Scheme    *runtime.Scheme
	Finalizer Finalizer
}

Controller that watches a RootSync or RepoSync, injects a finalizer when deletion propagation is enabled via annotation, handles deletion propagation when the RSync is marked for deletion, and removes the finalizer when deletion propagation is complete.

Use `configsync.gke.io/deletion-propagation-policy: Foreground` to enable deletion propagation.

Use `configsync.gke.io/deletion-propagation-policy: Orphan` or remove the annotation to disable deletion propagation (default behavior).

The `configsync.gke.io/reconciler` finalizer is used to block deletion until all the managed objects can be deleted.

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)

Reconcile responds to changes in the RootSync/RepoSync being watched.

func (*Controller) SetupWithManager

func (c *Controller) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the finalizer Controller with reconciler-manager.

type Finalizer

type Finalizer interface {
	Finalize(ctx context.Context, syncObj client.Object) error
	AddFinalizer(ctx context.Context, syncObj client.Object) (bool, error)
	RemoveFinalizer(ctx context.Context, syncObj client.Object) (bool, error)
}

Finalizer handles finalizing a RootSync or RepoSync for the reconciler.

func New

func New(scope declared.Scope, destroyer applier.Destroyer, c client.Client, stopControllers context.CancelFunc, controllersStopped <-chan struct{}) Finalizer

New constructs a new RootSyncFinalizer or RepoSyncFinalizer, depending on the specified scope.

type RepoSyncFinalizer

type RepoSyncFinalizer struct {
	Destroyer applier.Destroyer
	Client    client.Client

	// StopControllers will be called by the Finalize() method to stop the Parser and Remediator.
	StopControllers context.CancelFunc

	// ControllersStopped will be closed by the caller when the parser and
	// remediator have fully stopped. This unblocks Finalize() to destroy
	// managed resource objects.
	ControllersStopped <-chan struct{}
}

RepoSyncFinalizer handles finalizing RepoSync objects, using the Destroyer to destroy all managed user objects previously applied from source. Implements the Finalizer interface.

func (*RepoSyncFinalizer) AddFinalizer

func (f *RepoSyncFinalizer) AddFinalizer(ctx context.Context, syncObj client.Object) (bool, error)

AddFinalizer adds the `configsync.gke.io/reconciler` finalizer to the specified object, and updates the server.

The specified syncObj must be of type `*v1beta1.RepoSync`.

func (*RepoSyncFinalizer) Finalize

func (f *RepoSyncFinalizer) Finalize(ctx context.Context, syncObj client.Object) error

Finalize performs the following actions on the syncObj (RepoSync): - Stop other controllers - Wait for other controllers to stop - Sets the Finalizing condition - Uses the Destroyer to delete managed objects - Removes the Finalizing condition - Removes the Finalizer (unblocking deletion)

The specified syncObj must be of type `*v1beta1.RepoSync`.

func (*RepoSyncFinalizer) RemoveFinalizer

func (f *RepoSyncFinalizer) RemoveFinalizer(ctx context.Context, syncObj client.Object) (bool, error)

RemoveFinalizer removes the `configsync.gke.io/reconciler` finalizer from the specified object, and updates the server.

The specified syncObj must be of type `*v1beta1.RepoSync`.

type RootSyncFinalizer

type RootSyncFinalizer struct {
	Destroyer applier.Destroyer
	Client    client.Client

	// StopControllers will be called by the Finalize() method to stop the Parser and Remediator.
	StopControllers context.CancelFunc

	// ControllersStopped will be closed by the caller when the parser and
	// remediator have fully stopped. This unblocks Finalize() to destroy
	// managed resource objects.
	ControllersStopped <-chan struct{}
}

RootSyncFinalizer handles finalizing RootSync objects, using the Destroyer to destroy all managed user objects previously applied from source. Implements the Finalizer interface.

func (*RootSyncFinalizer) AddFinalizer

func (f *RootSyncFinalizer) AddFinalizer(ctx context.Context, syncObj client.Object) (bool, error)

AddFinalizer adds the `configsync.gke.io/reconciler` finalizer to the specified object, and updates the server.

The specified syncObj must be of type `*v1beta1.RootSync`.

func (*RootSyncFinalizer) Finalize

func (f *RootSyncFinalizer) Finalize(ctx context.Context, syncObj client.Object) error

Finalize performs the following actions on the syncObj (RootSync): - Stop other controllers - Wait for other controllers to stop - Sets the Finalizing condition - Uses the Destroyer to delete managed objects - Removes the Finalizing condition - Removes the Finalizer (unblocking deletion)

The specified syncObj must be of type `*v1beta1.RootSync`.

func (*RootSyncFinalizer) RemoveFinalizer

func (f *RootSyncFinalizer) RemoveFinalizer(ctx context.Context, syncObj client.Object) (bool, error)

RemoveFinalizer removes the `configsync.gke.io/reconciler` finalizer from the specified object, and updates the server.

The specified syncObj must be of type `*v1beta1.RootSync`.

Jump to

Keyboard shortcuts

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