Documentation ¶
Index ¶
- Variables
- func FetchAllClusterResourceSnapshots(ctx context.Context, k8Client client.Client, crp string, ...) (map[string]*fleetv1beta1.ClusterResourceSnapshot, error)
- func NewAPIServerError(fromCache bool, err error) error
- func NewCreateIgnoreAlreadyExistError(err error) error
- func NewDeleteIgnoreNotFoundError(err error) error
- func NewExpectedBehaviorError(err error) error
- func NewUnexpectedBehaviorError(err error) error
- func NewUpdateIgnoreConflictError(err error) error
- func NewUserError(err error) error
- type Controller
- type KeyFunc
- type QueueKey
- type ReconcileFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpectedBehavior indicates the current situation is not expected. // There should be something wrong with the system and cannot be recovered by itself. ErrUnexpectedBehavior = errors.New("unexpected behavior which cannot be handled by the controller") // ErrExpectedBehavior indicates the current situation is expected, which can be recovered by itself after retries. ErrExpectedBehavior = errors.New("expected behavior which can be recovered by itself") // ErrAPIServerError indicates the error is returned by the API server. ErrAPIServerError = errors.New("error returned by the API server") // ErrUserError indicates the error is caused by the user and customer needs to take the action. ErrUserError = errors.New("failed to process the request due to a client error") )
Functions ¶
func FetchAllClusterResourceSnapshots ¶ added in v0.9.3
func FetchAllClusterResourceSnapshots(ctx context.Context, k8Client client.Client, crp string, masterResourceSnapshot *fleetv1beta1.ClusterResourceSnapshot) (map[string]*fleetv1beta1.ClusterResourceSnapshot, error)
FetchAllClusterResourceSnapshots fetches the group of clusterResourceSnapshots using master clusterResourceSnapshot.
func NewAPIServerError ¶ added in v0.6.4
NewAPIServerError returns error types when accessing data from cache or API server.
func NewCreateIgnoreAlreadyExistError ¶ added in v0.6.5
NewCreateIgnoreAlreadyExistError returns ErrExpectedBehavior type error if the error is already exist. Otherwise, returns ErrAPIServerError type error.
func NewDeleteIgnoreNotFoundError ¶ added in v0.9.2
NewDeleteIgnoreNotFoundError returns nil if the error is not found. Otherwise, returns ErrAPIServerError type error if err is not nil
func NewExpectedBehaviorError ¶ added in v0.6.4
NewExpectedBehaviorError returns ErrExpectedBehavior type error when err is not nil.
func NewUnexpectedBehaviorError ¶ added in v0.6.4
NewUnexpectedBehaviorError returns ErrUnexpectedBehavior type error when err is not nil.
func NewUpdateIgnoreConflictError ¶ added in v0.6.5
NewUpdateIgnoreConflictError returns ErrExpectedBehavior type error if the error is conflict. Otherwise, returns ErrAPIServerError type error.
func NewUserError ¶ added in v0.6.4
NewUserError returns ErrUserError type error when err is not nil.
Types ¶
type Controller ¶
type Controller interface { // Enqueue generates the key of 'obj' according to a 'KeyFunc' then adds the 'item' to queue immediately. Enqueue(obj interface{}) // Run starts a certain number of concurrent workers to reconcile the items and will never stop until // the context is closed or canceled Run(ctx context.Context, workerNumber int) error }
Controller maintains a rate limiting queue and the items in the queue will be reconciled by a "ReconcileFunc". The item will be re-queued if "ReconcileFunc" returns an error, maximum re-queue times defined by "maxRetries" above, after that the item will be discarded from the queue.
func NewController ¶
func NewController(Name string, KeyFunc KeyFunc, ReconcileFunc ReconcileFunc, rateLimiter workqueue.RateLimiter) Controller
NewController returns a controller which can process resource periodically. We create the queue during the creation of the controller which means it can only be run once. We can move that to the run if we need to run it multiple times
type KeyFunc ¶
KeyFunc knows how to make a key from an object. Implementations should be deterministic.
type QueueKey ¶
type QueueKey interface{}
QueueKey is the type of the item key that stores in queue. The key could be arbitrary types.
The most common full-qualified key is of type '<namespace>/<name>' which doesn't carry the `GVK` info of the resource the key points to. We need to support a key type that includes GVK(Group Version Kind) so that we can reconcile on any type of resources.
func ClusterWideKeyFunc ¶
ClusterWideKeyFunc generates a ClusterWideKey for object.
func NamespaceKeyFunc ¶
NamespaceKeyFunc generates a namespaced key for any objects.