Documentation ¶
Overview ¶
Package controller provides reusable support for controller implementations.
Index ¶
- func RetryAlways(obj interface{}, err error, retries Retry) bool
- func RetryNever(obj interface{}, err error, retries Retry) bool
- type InternalListWatch
- type Queue
- type QueueRetryManager
- type RCControlInterface
- type RCControllerRefManager
- func (m *RCControllerRefManager) AdoptReplicationController(rs *v1.ReplicationController) error
- func (m *RCControllerRefManager) ClaimReplicationController(rc *v1.ReplicationController) (bool, error)
- func (m *RCControllerRefManager) ClaimReplicationControllers(rcs []*v1.ReplicationController) ([]*v1.ReplicationController, error)
- func (m *RCControllerRefManager) ReleaseReplicationController(rc *v1.ReplicationController) error
- type ReQueue
- type RealRCControl
- type Retry
- type RetryController
- type RetryFunc
- type RetryManager
- type RunnableController
- type Scheduler
- func (s *Scheduler) Add(key, value interface{})
- func (s *Scheduler) Delay(key interface{})
- func (s *Scheduler) Len() int
- func (s *Scheduler) Map() map[interface{}]interface{}
- func (s *Scheduler) Remove(key, value interface{}) bool
- func (s *Scheduler) RunOnce()
- func (s *Scheduler) RunUntil(ch <-chan struct{})
- type StoppableController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RetryAlways ¶ added in v0.6.1
RetryNever is a RetryFunc implementation that will always retry
func RetryNever ¶ added in v0.6.1
RetryNever is a RetryFunc implementation that will never retry
Types ¶
type InternalListWatch ¶
type InternalListWatch struct { ListFunc func(options metainternal.ListOptions) (runtime.Object, error) WatchFunc func(options metainternal.ListOptions) (watch.Interface, error) }
func (*InternalListWatch) List ¶
func (lw *InternalListWatch) List(options metav1.ListOptions) (runtime.Object, error)
func (*InternalListWatch) Watch ¶
func (lw *InternalListWatch) Watch(options metav1.ListOptions) (watch.Interface, error)
type Queue ¶ added in v0.3.3
type Queue interface {
Pop(kcache.PopProcessFunc) (interface{}, error)
}
Queue is a narrow abstraction of a cache.FIFO.
type QueueRetryManager ¶ added in v0.3.3
type QueueRetryManager struct {
// contains filtered or unexported fields
}
QueueRetryManager retries a resource by re-queueing it into a ReQueue as long as retryFunc returns true.
func NewQueueRetryManager ¶ added in v0.3.3
func NewQueueRetryManager(queue ReQueue, keyFn kcache.KeyFunc, retryFn RetryFunc, limiter flowcontrol.RateLimiter) *QueueRetryManager
NewQueueRetryManager safely creates a new QueueRetryManager.
func (*QueueRetryManager) Forget ¶ added in v0.3.3
func (r *QueueRetryManager) Forget(resource interface{})
Forget resets the retry count for resource.
func (*QueueRetryManager) Retry ¶ added in v0.3.3
func (r *QueueRetryManager) Retry(resource interface{}, err error)
Retry will enqueue resource until retryFunc returns false for that resource has been exceeded, at which point resource will be forgotten and no longer retried. The current retry count will be passed to each invocation of retryFunc.
type RCControlInterface ¶
type RCControlInterface interface {
PatchReplicationController(namespace, name string, data []byte) error
}
RSControlInterface is an interface that knows how to add or delete ReplicationControllers, as well as increment or decrement them. It is used by the DeploymentConfig controller to ease testing of actions that it takes.
type RCControllerRefManager ¶
type RCControllerRefManager struct { kcontroller.BaseControllerRefManager // contains filtered or unexported fields }
func NewRCControllerRefManager ¶
func NewRCControllerRefManager( rcControl RCControlInterface, controller kmetav1.Object, selector klabels.Selector, controllerKind kschema.GroupVersionKind, canAdopt func() error, ) *RCControllerRefManager
NewRCControllerRefManager returns a RCControllerRefManager that exposes methods to manage the controllerRef of ReplicationControllers.
The CanAdopt() function can be used to perform a potentially expensive check (such as a live GET from the API server) prior to the first adoption. It will only be called (at most once) if an adoption is actually attempted. If CanAdopt() returns a non-nil error, all adoptions will fail.
NOTE: Once CanAdopt() is called, it will not be called again by the same
RCControllerRefManager instance. Create a new instance if it makes sense to check CanAdopt() again (e.g. in a different sync pass).
func (*RCControllerRefManager) AdoptReplicationController ¶
func (m *RCControllerRefManager) AdoptReplicationController(rs *v1.ReplicationController) error
AdoptReplicationController sends a patch to take control of the ReplicationController. It returns the error if the patching fails.
func (*RCControllerRefManager) ClaimReplicationController ¶
func (m *RCControllerRefManager) ClaimReplicationController(rc *v1.ReplicationController) (bool, error)
ClaimReplicationController tries to take ownership of a ReplicationController.
It will reconcile the following:
- Adopt the ReplicationController if it's an orphan.
- Release owned ReplicationController if the selector no longer matches.
A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.
If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The returned boolean indicates whether you now own the object.
func (*RCControllerRefManager) ClaimReplicationControllers ¶
func (m *RCControllerRefManager) ClaimReplicationControllers(rcs []*v1.ReplicationController) ([]*v1.ReplicationController, error)
ClaimReplicationControllers tries to take ownership of a list of ReplicationControllers.
It will reconcile the following:
- Adopt orphans if the selector matches.
- Release owned objects if the selector no longer matches.
A non-nil error is returned if some form of reconciliation was attempted and failed. Usually, controllers should try again later in case reconciliation is still needed.
If the error is nil, either the reconciliation succeeded, or no reconciliation was necessary. The list of ReplicationControllers that you now own is returned.
func (*RCControllerRefManager) ReleaseReplicationController ¶
func (m *RCControllerRefManager) ReleaseReplicationController(rc *v1.ReplicationController) error
ReleaseReplicationController sends a patch to free the ReplicationController from the control of the Deployment controller. It returns the error if the patching fails. 404 and 422 errors are ignored.
type RealRCControl ¶
type RealRCControl struct { KubeClient kclientset.Interface Recorder record.EventRecorder }
RealRCControl is the default implementation of RCControlInterface.
func (RealRCControl) PatchReplicationController ¶
func (r RealRCControl) PatchReplicationController(namespace, name string, data []byte) error
PatchReplicationController executes a strategic merge patch contained in 'data' on RC specified by 'namespace' and 'name'
type Retry ¶ added in v0.5.3
type Retry struct { // Count is the number of retries Count int // StartTimestamp is retry start timestamp StartTimestamp metav1.Time }
Retry describes provides additional information regarding retries.
type RetryController ¶ added in v0.3.3
type RetryController struct { // Queue is where work is retrieved for Handle. Queue // Handle is expected to process the next resource from the queue. Handle func(interface{}) error // RetryManager is fed the handled resource if Handle returns a Retryable // error. If Handle returns no error, the RetryManager is asked to forget // the resource. RetryManager }
RetryController is a RunnableController which delegates resource handling to a function and knows how to safely manage retries of a resource which failed to be successfully handled.
func (*RetryController) Run ¶ added in v0.3.3
func (c *RetryController) Run()
Run begins processing resources from Queue asynchronously.
func (*RetryController) RunUntil ¶ added in v0.4.2
func (c *RetryController) RunUntil(stopCh <-chan struct{})
RunUntil begins processing resources from Queue asynchronously until stopCh is closed.
type RetryFunc ¶ added in v0.4.2
RetryFunc should return true if the given object and error should be retried after the provided number of times.
type RetryManager ¶ added in v0.3.3
type RetryManager interface { // Retry will cause resource processing to be retried (for example, by // requeueing resource) Retry(resource interface{}, err error) // Forget will cause the manager to erase all prior knowledge of resource // and reclaim internal resources associated with state tracking of // resource. Forget(resource interface{}) }
RetryManager knows how to retry processing of a resource, and how to forget a resource it may be tracking the state of.
type RunnableController ¶ added in v0.3.3
type RunnableController interface {
// Run starts the asynchronous controller loop.
Run()
}
RunnableController is a controller which implements a Run loop.
type Scheduler ¶ added in v1.1.2
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a self-balancing, rate-limited, bucketed queue that can periodically invoke an action on all items in a bucket before moving to the next bucket. A ratelimiter sets an upper bound on the number of buckets processed per unit time. The queue has a key and a value, so both uniqueness and equality can be tested (key must be unique, value can carry info for the next processing). Items remain in the queue until removed by a call to Remove().
func NewScheduler ¶ added in v1.1.2
func NewScheduler(bucketCount int, bucketLimiter flowcontrol.RateLimiter, fn func(key, value interface{})) *Scheduler
NewScheduler creates a scheduler with bucketCount buckets, a rate limiter for restricting the rate at which buckets are processed, and a function to invoke when items are scanned in a bucket. TODO: remove DEBUG statements from this file once this logic has been adequately validated.
func (*Scheduler) Add ¶ added in v1.1.2
func (s *Scheduler) Add(key, value interface{})
Add places the key in the bucket with the least entries (except the current bucket). The key is used to determine uniqueness, while value can be used to associate additional data for later retrieval. An Add removes the previous key and value and will place the item in a new bucket. This allows callers to ensure that Add'ing a new item to the queue purges old versions of the item, while Remove can be conditional on removing only the known old version.
func (*Scheduler) Delay ¶ added in v1.1.2
func (s *Scheduler) Delay(key interface{})
Delay moves the key to the end of the chain if it exists.
func (*Scheduler) Map ¶ added in v1.1.2
func (s *Scheduler) Map() map[interface{}]interface{}
Map returns a copy of the scheduler contents, but does not copy the keys or values themselves. If values and keys are not immutable, changing the value will affect the value in the queue.
func (*Scheduler) Remove ¶ added in v1.1.2
Remove takes the key out of all buckets. If value is non-nil, the key will only be removed if it has the same value. Returns true if the key was removed.
type StoppableController ¶ added in v1.1.2
type StoppableController interface { // RunUntil starts the asynchronous controller loop, which runs until // ch is closed. RunUntil(ch <-chan struct{}) }
StoppableController is a controller which implements a Run loop.