Documentation ¶
Overview ¶
Package util contains helpers for building controllers. It does not contain any controllers by itself.
Index ¶
- Constants
- func ClusterAvailableForReconciling(ctx context.Context, client ctrlruntimeclient.Client, ...) (bool, error)
- func ClusterReconcileWrapper(ctx context.Context, client ctrlruntimeclient.Client, workerName string, ...) (*reconcile.Result, error)
- func ConcurrencyLimitReached(ctx context.Context, client ctrlruntimeclient.Client, limit int) (bool, error)
- func EnqueueClusterForNamespacedObject(client ctrlruntimeclient.Client) handler.EventHandler
- func EnqueueClusterForNamespacedObjectWithSeedName(client ctrlruntimeclient.Client, seedName string, ...) handler.EventHandler
- func EnqueueClusterScopedObjectWithSeedName(seedName string) handler.EventHandler
- func EnqueueConst(queueKey string) handler.EventHandler
- func EnqueueObjectWithOperation() handler.EventHandler
Constants ¶
const ( CreateOperation = "create" UpdateOperation = "update" DeleteOperation = "delete" )
Variables ¶
This section is empty.
Functions ¶
func ClusterAvailableForReconciling ¶
func ClusterAvailableForReconciling(ctx context.Context, client ctrlruntimeclient.Client, cluster *kubermaticv1.Cluster, concurrencyLimit int) (bool, error)
ClusterAvailableForReconciling returns true if the given cluster can be reconciled. This is true if the cluster does not yet have the SeedResourcesUpToDate condition or if the concurrency limit of the controller is not yet reached. This ensures that not too many cluster updates are running at the same time, but also makes sure that un-UpToDate clusters will continue to be reconciled.
func ClusterReconcileWrapper ¶
func ClusterReconcileWrapper( ctx context.Context, client ctrlruntimeclient.Client, workerName string, cluster *kubermaticv1.Cluster, versions kubermatic.Versions, conditionType kubermaticv1.ClusterConditionType, reconcile func() (*reconcile.Result, error), ) (*reconcile.Result, error)
ClusterReconcileWrapper is a wrapper that should be used around any cluster reconciliaton. It:
- Checks if the cluster is paused
- Checks if the worker-name matches
- Sets the ReconcileSuccess condition for the controller by fetching the current Cluster object and patching its status.
func ConcurrencyLimitReached ¶
func ConcurrencyLimitReached(ctx context.Context, client ctrlruntimeclient.Client, limit int) (bool, error)
ConcurrencyLimitReached checks all the clusters inside the seed cluster and checks for the SeedResourcesUpToDate condition. Returns true if the number of clusters without this condition is equal or larger than the given limit.
func EnqueueClusterForNamespacedObject ¶
func EnqueueClusterForNamespacedObject(client ctrlruntimeclient.Client) handler.EventHandler
EnqueueClusterForNamespacedObject enqueues the cluster that owns a namespaced object, if any It is used by various controllers to react to changes in the resources in the cluster namespace.
func EnqueueClusterForNamespacedObjectWithSeedName ¶
func EnqueueClusterForNamespacedObjectWithSeedName(client ctrlruntimeclient.Client, seedName string, clusterSelector labels.Selector) handler.EventHandler
EnqueueClusterForNamespacedObjectWithSeedName enqueues the cluster that owns a namespaced object, if any. The seedName is put into the namespace field It is used by various controllers to react to changes in the resources in the cluster namespace.
func EnqueueClusterScopedObjectWithSeedName ¶
func EnqueueClusterScopedObjectWithSeedName(seedName string) handler.EventHandler
EnqueueClusterScopedObjectWithSeedName enqueues a cluster-scoped object with the seedName as namespace. If it gets an object with a non-empty name, it will log an error and not enqueue anything.
func EnqueueConst ¶
func EnqueueConst(queueKey string) handler.EventHandler
EnqueueConst enqueues a constant. It is meant for controllers that don't have a parent object they could enc and instead reconcile everything at once. The queueKey will be defaulted if empty.
func EnqueueObjectWithOperation ¶
func EnqueueObjectWithOperation() handler.EventHandler
EnqueueObjectWithOperation enqueues a the namespaced name for any resource. It puts the current operation (create, update, delete) as the namespace and "namespace/name" of the object into the name of the reconcile request.
Types ¶
This section is empty.