Documentation
¶
Index ¶
- func ReconcileIDFromContext(ctx context.Context) types.UID
- type Controller
- func (c *Controller[request]) GetLogger() logr.Logger
- func (c *Controller[request]) NeedLeaderElection() bool
- func (c *Controller[request]) Reconcile(ctx context.Context, req request) (_ reconcile.Result, err error)
- func (c *Controller[request]) Start(ctx context.Context) error
- func (c *Controller[request]) Warmup(ctx context.Context) error
- func (c *Controller[request]) Watch(src source.TypedSource[request]) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Controller ¶
type Controller[request comparable] struct { // Name is used to uniquely identify a Controller in tracing, logging and monitoring. Name is required. Name string // MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1. MaxConcurrentReconciles int // Reconciler is a function that can be called at any time with the Name / Namespace of an object and // ensures that the state of the system matches the state specified in the object. // Defaults to the DefaultReconcileFunc. Do reconcile.TypedReconciler[request] // RateLimiter is used to limit how frequently requests may be queued into the work queue. RateLimiter workqueue.TypedRateLimiter[request] // NewQueue constructs the queue for this controller once the controller is ready to start. // This is a func because the standard Kubernetes work queues start themselves immediately, which // leads to goroutine leaks if something calls controller.New repeatedly. NewQueue func(controllerName string, rateLimiter workqueue.TypedRateLimiter[request]) workqueue.TypedRateLimitingInterface[request] // Queue is an listeningQueue that listens for events from Informers and adds object keys to // the Queue for processing Queue priorityqueue.PriorityQueue[request] // Started is true if the Controller has been Started Started bool // CacheSyncTimeout refers to the time limit set on waiting for cache to sync // Defaults to 2 minutes if not set. CacheSyncTimeout time.Duration // LogConstructor is used to construct a logger to then log messages to users during reconciliation, // or for example when a watch is started. // Note: LogConstructor has to be able to handle nil requests as we are also using it // outside the context of a reconciliation. LogConstructor func(request *request) logr.Logger // RecoverPanic indicates whether the panic caused by reconcile should be recovered. // Defaults to true. RecoverPanic *bool // LeaderElected indicates whether the controller is leader elected or always running. LeaderElected *bool // EnableWarmup specifies whether the controller should start its sources when the manager is not // the leader. This is useful for cases where sources take a long time to start, as it allows // for the controller to warm up its caches even before it is elected as the leader. This // improves leadership failover time, as the caches will be prepopulated before the controller // transitions to be leader. // // Setting EnableWarmup to true and NeedLeaderElection to true means the controller will start its // sources without waiting to become leader. // Setting EnableWarmup to true and NeedLeaderElection to false is a no-op as controllers without // leader election do not wait on leader election to start their sources. // Defaults to false. EnableWarmup *bool ReconciliationTimeout time.Duration // contains filtered or unexported fields }
Controller implements controller.Controller.
func New ¶ added in v0.22.0
func New[request comparable](options Options[request]) *Controller[request]
New returns a new Controller configured with the given options.
func (*Controller[request]) GetLogger ¶ added in v0.7.0
func (c *Controller[request]) GetLogger() logr.Logger
GetLogger returns this controller's logger.
func (*Controller[request]) NeedLeaderElection ¶ added in v0.15.0
func (c *Controller[request]) NeedLeaderElection() bool
NeedLeaderElection implements the manager.LeaderElectionRunnable interface.
func (*Controller[request]) Reconcile ¶
func (c *Controller[request]) Reconcile(ctx context.Context, req request) (_ reconcile.Result, err error)
Reconcile implements reconcile.Reconciler.
func (*Controller[request]) Start ¶
func (c *Controller[request]) Start(ctx context.Context) error
Start implements controller.Controller.
func (*Controller[request]) Warmup ¶ added in v0.22.0
func (c *Controller[request]) Warmup(ctx context.Context) error
Warmup implements the manager.WarmupRunnable interface.
func (*Controller[request]) Watch ¶
func (c *Controller[request]) Watch(src source.TypedSource[request]) error
Watch implements controller.Controller.
type Options ¶ added in v0.22.0
type Options[request comparable] struct { // Reconciler is a function that can be called at any time with the Name / Namespace of an object and // ensures that the state of the system matches the state specified in the object. // Defaults to the DefaultReconcileFunc. Do reconcile.TypedReconciler[request] // RateLimiter is used to limit how frequently requests may be queued into the work queue. RateLimiter workqueue.TypedRateLimiter[request] // NewQueue constructs the queue for this controller once the controller is ready to start. // This is a func because the standard Kubernetes work queues start themselves immediately, which // leads to goroutine leaks if something calls controller.New repeatedly. NewQueue func(controllerName string, rateLimiter workqueue.TypedRateLimiter[request]) workqueue.TypedRateLimitingInterface[request] // MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1. MaxConcurrentReconciles int // CacheSyncTimeout refers to the time limit set on waiting for cache to sync // Defaults to 2 minutes if not set. CacheSyncTimeout time.Duration // Name is used to uniquely identify a Controller in tracing, logging and monitoring. Name is required. Name string // LogConstructor is used to construct a logger to then log messages to users during reconciliation, // or for example when a watch is started. // Note: LogConstructor has to be able to handle nil requests as we are also using it // outside the context of a reconciliation. LogConstructor func(request *request) logr.Logger // RecoverPanic indicates whether the panic caused by reconcile should be recovered. // Defaults to true. RecoverPanic *bool // LeaderElected indicates whether the controller is leader elected or always running. LeaderElected *bool // EnableWarmup specifies whether the controller should start its sources // when the manager is not the leader. // Defaults to false, which means that the controller will wait for leader election to start // before starting sources. EnableWarmup *bool // ReconciliationTimeout is used as the timeout passed to the context of each Reconcile call. // By default, there is no timeout. ReconciliationTimeout time.Duration }
Options are the arguments for creating a new Controller.
Click to show internal directories.
Click to hide internal directories.