controllerutils

package
v1.62.3 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 34 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

EnqueueOnce is a source.Source that simply triggers the reconciler once by directly enqueueing an empty reconcile.Request.

View Source
var HandleOnce = source.Func(func(_ context.Context, handler handler.EventHandler, queue workqueue.RateLimitingInterface, _ ...predicate.Predicate) error {
	handler.Create(event.CreateEvent{}, queue)
	return nil
})

HandleOnce is a source.Source that simply triggers the reconciler once by calling 'Create' at the event handler with an empty event.CreateEvent.

View Source
var (
	// RandomDuration is a function for returning a random duration.
	RandomDuration = utils.RandomDuration
)

Functions

func AddAllRunnables added in v1.57.0

func AddAllRunnables(mgr manager.Manager, runnables ...manager.Runnable) error

AddAllRunnables loops over the provided runnables and adds them to the manager. It returns an error immediately if adding fails.

func AddFinalizers added in v1.52.0

func AddFinalizers(ctx context.Context, writer client.Writer, obj client.Object, finalizers ...string) error

AddFinalizers ensures that the given finalizer is present in the given object and optimistic locking. If it is not set, it adds it and issues a patch. Note that this is done with a regular merge-patch since strategic merge-patches do not work with custom resources, see https://github.com/kubernetes/kubernetes/issues/105146.

func AddTasks

func AddTasks(annotations map[string]string, tasksToAdd ...string)

AddTasks adds tasks to the ShootTasks annotation of the passed map.

func CreateOrGetAndMergePatch added in v1.25.0

CreateOrGetAndMergePatch creates or gets and patches (using a merge patch) the given object in the Kubernetes cluster.

The MutateFn is called regardless of creating or patching an object.

It returns the executed operation and an error.

func CreateOrGetAndStrategicMergePatch added in v1.25.0

func CreateOrGetAndStrategicMergePatch(ctx context.Context, c client.Client, obj client.Object, f controllerutil.MutateFn, opts ...client.MergeFromOption) (controllerutil.OperationResult, error)

CreateOrGetAndStrategicMergePatch creates or gets and patches (using a strategic merge patch) the given object in the Kubernetes cluster.

The MutateFn is called regardless of creating or patching an object.

It returns the executed operation and an error.

func CreateWorker

func CreateWorker(ctx context.Context, queue workqueue.RateLimitingInterface, resourceType string, reconciler reconcile.Reconciler, waitGroup *sync.WaitGroup, workerCh chan<- int, opts ...WorkerOption)

CreateWorker creates and runs a worker goroutine that just processes items in the specified queue. The worker will run until ctx is cancelled. The worker will be added to the wait group when started and marked done when finished.

func DetermineBackupBucketAssociations

func DetermineBackupBucketAssociations(ctx context.Context, c client.Client, seedName string) ([]string, error)

DetermineBackupBucketAssociations determine the BackupBucket resources which are associated to seed with name <seedName>

func DetermineControllerInstallationAssociations

func DetermineControllerInstallationAssociations(ctx context.Context, c client.Client, seedName string) ([]string, error)

DetermineControllerInstallationAssociations determine the ControllerInstallation resources which are associated to seed with name <seedName>

func DetermineSecretBindingAssociations

func DetermineSecretBindingAssociations(ctx context.Context, c client.Client, quota *gardencorev1beta1.Quota) ([]string, error)

DetermineSecretBindingAssociations gets a <bindingLister> to determine the SecretBinding resources which are associated to given Quota <obj>.

func DetermineShootsAssociatedTo

func DetermineShootsAssociatedTo(ctx context.Context, gardenClient client.Reader, obj interface{}) ([]string, error)

DetermineShootsAssociatedTo gets a <shootLister> to determine the Shoots resources which are associated to given <obj> (either a CloudProfile, Seed, Secretbinding a or a ExposureClass object).

func EnqueueCreateEventsOncePer24hDuration added in v1.60.0

func EnqueueCreateEventsOncePer24hDuration(clock clock.Clock) handler.Funcs

EnqueueCreateEventsOncePer24hDuration returns handler.Funcs which enqueues the object for Create events only once per 24h. All other events are normally enqueued.

func GetAndCreateOrMergePatch added in v1.23.0

GetAndCreateOrMergePatch is similar to controllerutil.CreateOrPatch, but does not care about the object's status section. It reads the object from the client, reconciles the desired state with the existing state using the given MutateFn and creates or patches the object (using a merge patch) accordingly.

The MutateFn is called regardless of creating or updating an object.

It returns the executed operation and an error.

func GetAndCreateOrStrategicMergePatch added in v1.23.0

func GetAndCreateOrStrategicMergePatch(ctx context.Context, c client.Client, obj client.Object, f controllerutil.MutateFn, opts ...client.MergeFromOption) (controllerutil.OperationResult, error)

GetAndCreateOrStrategicMergePatch is similar to controllerutil.CreateOrPatch, but does not care about the object's status section. It reads the object from the client, reconciles the desired state with the existing state using the given MutateFn and creates or patches the object (using a strategic merge patch) accordingly.

The MutateFn is called regardless of creating or updating an object.

It returns the executed operation and an error.

func GetTasks added in v1.3.1

func GetTasks(annotations map[string]string) []string

GetTasks returns the list of tasks in the ShootTasks annotation.

func HasTask

func HasTask(annotations map[string]string, task string) bool

HasTask checks if the passed task is part of the ShootTasks annotation.

func ManagedSeedFilterFunc added in v1.18.0

func ManagedSeedFilterFunc(ctx context.Context, c client.Reader, seedName string) func(obj interface{}) bool

ManagedSeedFilterFunc returns a filtering func for ManagedSeeds that checks if the ManagedSeed references a Shoot scheduled on a Seed, for which the gardenlet is responsible..

func ReconcileOncePer24hDuration added in v1.10.2

func ReconcileOncePer24hDuration(clock clock.Clock, objectMeta metav1.ObjectMeta, observedGeneration int64, lastOperation *gardencorev1beta1.LastOperation) time.Duration

ReconcileOncePer24hDuration returns the duration until the next reconciliation should happen while respecting that only one reconciliation should happen per 24h. If the deletion timestamp is set or the generation has changed or the last operation does not indicate success or indicates that the last reconciliation happened more than 24h ago then 0 will be returned.

func RemoveAllFinalizers added in v1.27.0

func RemoveAllFinalizers(ctx context.Context, writer client.Writer, obj client.Object) error

RemoveAllFinalizers ensures that the given object has no finalizers with exponential backoff. If any finalizers are set, it removes them and issues a patch.

func RemoveAllTasks

func RemoveAllTasks(annotations map[string]string)

RemoveAllTasks removes the ShootTasks annotation from the passed map.

func RemoveFinalizers added in v1.52.0

func RemoveFinalizers(ctx context.Context, writer client.Writer, obj client.Object, finalizers ...string) error

RemoveFinalizers ensures that the given finalizer is not present anymore in the given object and optimistic locking. If it is set, it removes it and issues a patch. Note that this is done with a regular merge-patch since strategic merge-patches do not work with custom resources, see https://github.com/kubernetes/kubernetes/issues/105146.

func RemoveTasks added in v1.3.1

func RemoveTasks(annotations map[string]string, tasksToRemove ...string)

RemoveTasks removes tasks from the ShootTasks annotation of the passed map.

func SeedOfManagedSeedFilterFunc added in v1.25.0

func SeedOfManagedSeedFilterFunc(ctx context.Context, c client.Reader, seedName string) func(obj interface{}) bool

SeedOfManagedSeedFilterFunc returns a filtering func for Seeds that checks if the Seed is owned by a ManagedSeed that references a Shoot scheduled on a Seed, for which the gardenlet is responsible.

func ShootFilterFunc

func ShootFilterFunc(seedName string) func(obj interface{}) bool

ShootFilterFunc returns a filtering func for shoots.

func TypedCreateOrUpdate added in v1.34.0

func TypedCreateOrUpdate(ctx context.Context, c client.Client, scheme *runtime.Scheme, obj *unstructured.Unstructured, alwaysUpdate bool, mutate func() error) (controllerutil.OperationResult, error)

TypedCreateOrUpdate is like controllerutil.CreateOrUpdate, it retrieves the current state of the object from the API server, applies the given mutate func and creates or updates it afterwards. In contrast to controllerutil.CreateOrUpdate it tries to create a new typed object of obj's kind (using the provided scheme) to make typed Get requests in order to leverage the client's cache.

Types

type ControlledRunner added in v1.57.0

type ControlledRunner struct {
	// Manager is the controller-runtime manager.
	Manager manager.Manager
	// BootstrapRunnables are the runnables that are responsible for bootstrapping tasks. They will be started
	// sequentially in the provided order.
	BootstrapRunnables []manager.Runnable
	// ActualRunnables are the runnables that are responsible for the actual tasks of the controller. They will be added
	// sequentially in the provided order, however they will be started immediately if the manager is already started.
	ActualRunnables []manager.Runnable
}

ControlledRunner is a Runnable for the controller-runtime manager which can be used to control complex start-up sequences of controllers. It allows to first run a set of bootstrap runnables before adding the actual runnables to the manager. When the manager is started, this runner first runs all bootstrapping runnables before adding the actual runnables to the manager.

func (*ControlledRunner) Start added in v1.57.0

func (c *ControlledRunner) Start(ctx context.Context) error

Start starts the runner.

type WorkerOption added in v1.38.0

type WorkerOption func(*WorkerOptions)

WorkerOption is a func that mutates WorkerOptions.

func WithLogger added in v1.38.0

func WithLogger(logger logr.Logger) WorkerOption

WithLogger configures the logr.Logger to use for a controller worker. If set, a logger preconfigured with the name and namespace field will be injected into the context.Context on each Reconcile call. It can be retrieved via log.FromContext.

type WorkerOptions added in v1.38.0

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

WorkerOptions are options for a controller's worker.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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