Documentation ¶
Index ¶
- Constants
- Variables
- func GetControllerOf(controllee metav1.Object) *metav1.OwnerReference
- func HandlePanic()
- func HasFinalizer(object metav1.Object, finalizer string) bool
- func NewListWatchFromClient(c cache.Getter, resource string, namespace string, ...) *cache.ListWatch
- func NewResourceEventHandlerFuncsForFunc(f func(interface{})) cache.ResourceEventHandlerFuncs
- func NewResourceEventHandlerFuncsForWorkqueue(queue workqueue.RateLimitingInterface) cache.ResourceEventHandlerFuncs
- func NoResyncPeriodFunc() time.Duration
- func PodKey(pod *k8sv1.Pod) string
- func PodKeys(pods []*k8sv1.Pod) []string
- func RecheckDeletionTimestamp(getObject func() (metav1.Object, error)) func() error
- func RemoveFinalizer(object metav1.Object, finalizer string)
- func VirtualMachineKey(vm *v1.VirtualMachine) string
- func VirtualMachineKeys(vms []*v1.VirtualMachine) []string
- type BaseControllerRefManager
- type ControlleeExpectations
- type ControllerExpectations
- func (r *ControllerExpectations) CreationObserved(controllerKey string)
- func (r *ControllerExpectations) DeleteExpectations(controllerKey string)
- func (r *ControllerExpectations) DeletionObserved(controllerKey string)
- func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error
- func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error
- func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
- func (r *ControllerExpectations) LowerExpectations(controllerKey string, add, del int)
- func (r *ControllerExpectations) RaiseExpectations(controllerKey string, add, del int)
- func (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool
- func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error
- type ControllerExpectationsInterface
- type Expectations
- type KubeInformerFactory
- type RealVirtualMachineControl
- type ResyncPeriodFunc
- type UIDSet
- type UIDTrackingControllerExpectations
- func (u *UIDTrackingControllerExpectations) DeleteExpectations(rcKey string)
- func (u *UIDTrackingControllerExpectations) DeletionObserved(rcKey, deleteKey string)
- func (u *UIDTrackingControllerExpectations) ExpectDeletions(rcKey string, deletedKeys []string) error
- func (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.String
- type VirtualMachineConditionManager
- func (d *VirtualMachineConditionManager) CheckFailure(vm *v1.VirtualMachine, syncErr error, reason string) (changed bool)
- func (d *VirtualMachineConditionManager) HasCondition(vm *v1.VirtualMachine, cond v1.VirtualMachineConditionType) bool
- func (d *VirtualMachineConditionManager) RemoveCondition(vm *v1.VirtualMachine, cond v1.VirtualMachineConditionType)
- type VirtualMachineControlInterface
- type VirtualMachineControllerRefManager
- func (m *VirtualMachineControllerRefManager) AdoptVirtualMachine(vm *virtv1.VirtualMachine) error
- func (m *VirtualMachineControllerRefManager) ClaimVirtualMachineByName(vm *virtv1.VirtualMachine, ...) (*virtv1.VirtualMachine, error)
- func (m *VirtualMachineControllerRefManager) ClaimVirtualMachines(vms []*virtv1.VirtualMachine, ...) ([]*virtv1.VirtualMachine, error)
- func (m *VirtualMachineControllerRefManager) ReleaseVirtualMachine(vm *virtv1.VirtualMachine) error
Constants ¶
const ( // BurstReplicas is the maximum amount of requests in a row for CRUD operations on resources by controllers, // to avoid unintentional DoS BurstReplicas uint = 250 )
const ( // If a watch drops a delete event for a pod, it'll take this long // before a dormant controller waiting for those packets is woken up anyway. It is // specifically targeted at the case where some problem prevents an update // of expectations, without it the controller could stay asleep forever. This should // be set based on the expected latency of watch events. // // Currently a controller can service (create *and* observe the watch events for said // creation) about 10 pods a second, so it takes about 1 min to service // 500 pods. Just creation is limited to 20qps, and watching happens with ~10-30s // latency/pod at the scale of 3000 pods over 100 nodes. ExpectationsTimeout = 5 * time.Minute )
Variables ¶
var ExpKeyFunc = func(obj interface{}) (string, error) { if e, ok := obj.(*ControlleeExpectations); ok { return e.key, nil } return "", fmt.Errorf("Could not find key for obj %#v", obj) }
ExpKeyFunc to parse out the key from a ControlleeExpectation
var (
KeyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc
)
var UIDSetKeyFunc = func(obj interface{}) (string, error) { if u, ok := obj.(*UIDSet); ok { return u.key, nil } return "", fmt.Errorf("Could not find key for obj %#v", obj) }
UIDSetKeyFunc to parse out the key from a UIDSet.
var UpdateTaintBackoff = wait.Backoff{ Steps: 5, Duration: 100 * time.Millisecond, Jitter: 1.0, }
Functions ¶
func GetControllerOf ¶
func GetControllerOf(controllee metav1.Object) *metav1.OwnerReference
GetControllerOf returns the controllerRef if controllee has a controller, otherwise returns nil.
func HandlePanic ¶
func HandlePanic()
func NewListWatchFromClient ¶
func NewListWatchFromClient(c cache.Getter, resource string, namespace string, fieldSelector fields.Selector, labelSelector labels.Selector) *cache.ListWatch
NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
func NewResourceEventHandlerFuncsForFunc ¶
func NewResourceEventHandlerFuncsForFunc(f func(interface{})) cache.ResourceEventHandlerFuncs
func NewResourceEventHandlerFuncsForWorkqueue ¶
func NewResourceEventHandlerFuncsForWorkqueue(queue workqueue.RateLimitingInterface) cache.ResourceEventHandlerFuncs
func NoResyncPeriodFunc ¶
Returns 0 for resyncPeriod in case resyncing is not needed.
func RecheckDeletionTimestamp ¶
RecheckDeletionTimestamp returns a CanAdopt() function to recheck deletion.
The CanAdopt() function calls getObject() to fetch the latest value, and denies adoption attempts if that object has a non-nil DeletionTimestamp.
func RemoveFinalizer ¶ added in v0.5.0
func VirtualMachineKey ¶
func VirtualMachineKey(vm *v1.VirtualMachine) string
func VirtualMachineKeys ¶
func VirtualMachineKeys(vms []*v1.VirtualMachine) []string
Types ¶
type BaseControllerRefManager ¶
type BaseControllerRefManager struct { Controller metav1.Object Selector labels.Selector CanAdoptFunc func() error // contains filtered or unexported fields }
func (*BaseControllerRefManager) CanAdopt ¶
func (m *BaseControllerRefManager) CanAdopt() error
func (*BaseControllerRefManager) ClaimObject ¶
func (m *BaseControllerRefManager) ClaimObject(obj metav1.Object, match func(metav1.Object) bool, adopt, release func(metav1.Object) error) (bool, error)
ClaimObject tries to take ownership of an object for this controller.
It will reconcile the following:
- Adopt orphans if the match function returns true.
- Release owned objects if the match function returns false.
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.
No reconciliation will be attempted if the controller is being deleted.
type ControlleeExpectations ¶
type ControlleeExpectations struct {
// contains filtered or unexported fields
}
ControlleeExpectations track controllee creates/deletes.
func (*ControlleeExpectations) Add ¶
func (e *ControlleeExpectations) Add(add, del int64)
Add increments the add and del counters.
func (*ControlleeExpectations) Fulfilled ¶
func (e *ControlleeExpectations) Fulfilled() bool
Fulfilled returns true if this expectation has been fulfilled.
func (*ControlleeExpectations) GetExpectations ¶
func (e *ControlleeExpectations) GetExpectations() (int64, int64)
GetExpectations returns the add and del expectations of the controllee.
type ControllerExpectations ¶
ControllerExpectations is a cache mapping controllers to what they expect to see before being woken up for a sync.
func NewControllerExpectations ¶
func NewControllerExpectations() *ControllerExpectations
NewControllerExpectations returns a store for ControllerExpectations.
func (*ControllerExpectations) CreationObserved ¶
func (r *ControllerExpectations) CreationObserved(controllerKey string)
CreationObserved atomically decrements the `add` expectation count of the given controller.
func (*ControllerExpectations) DeleteExpectations ¶
func (r *ControllerExpectations) DeleteExpectations(controllerKey string)
DeleteExpectations deletes the expectations of the given controller from the TTLStore.
func (*ControllerExpectations) DeletionObserved ¶
func (r *ControllerExpectations) DeletionObserved(controllerKey string)
DeletionObserved atomically decrements the `del` expectation count of the given controller.
func (*ControllerExpectations) ExpectCreations ¶
func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error
func (*ControllerExpectations) ExpectDeletions ¶
func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error
func (*ControllerExpectations) GetExpectations ¶
func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
GetExpectations returns the ControlleeExpectations of the given controller.
func (*ControllerExpectations) LowerExpectations ¶
func (r *ControllerExpectations) LowerExpectations(controllerKey string, add, del int)
Decrements the expectation counts of the given controller.
func (*ControllerExpectations) RaiseExpectations ¶
func (r *ControllerExpectations) RaiseExpectations(controllerKey string, add, del int)
Increments the expectation counts of the given controller.
func (*ControllerExpectations) SatisfiedExpectations ¶
func (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool
SatisfiedExpectations returns true if the required adds/dels for the given controller have been observed. Add/del counts are established by the controller at sync time, and updated as controllees are observed by the controller manager.
func (*ControllerExpectations) SetExpectations ¶
func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error
SetExpectations registers new expectations for the given controller. Forgets existing expectations.
type ControllerExpectationsInterface ¶
type ControllerExpectationsInterface interface { GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error) SatisfiedExpectations(controllerKey string) bool DeleteExpectations(controllerKey string) SetExpectations(controllerKey string, add, del int) error ExpectCreations(controllerKey string, adds int) error ExpectDeletions(controllerKey string, dels int) error CreationObserved(controllerKey string) DeletionObserved(controllerKey string) RaiseExpectations(controllerKey string, add, del int) LowerExpectations(controllerKey string, add, del int) }
ControllerExpectationsInterface is an interface that allows users to set and wait on expectations. Only abstracted out for testing. Warning: if using KeyFunc it is not safe to use a single ControllerExpectationsInterface with different types of controllers, because the keys might conflict across types.
type Expectations ¶
type Expectations interface {
Fulfilled() bool
}
Expectations are either fulfilled, or expire naturally.
type KubeInformerFactory ¶
type KubeInformerFactory interface { // Starts any informers that have not been started yet // This function is thread safe and idempotent Start(stopCh <-chan struct{}) // Watches for vm objects VM() cache.SharedIndexInformer // Watches for VirtualMachineReplicaSet objects VMReplicaSet() cache.SharedIndexInformer // Watches for VirtualMachinePreset objects VirtualMachinePreset() cache.SharedIndexInformer // Watches for pods related only to kubevirt KubeVirtPod() cache.SharedIndexInformer // Watches for nodes KubeVirtNode() cache.SharedIndexInformer // OfflineVirtualMachine handles the VMs that are stopped or not running OfflineVirtualMachine() cache.SharedIndexInformer // Watches for ConfigMap objects ConfigMap() cache.SharedIndexInformer }
func NewKubeInformerFactory ¶
func NewKubeInformerFactory(restClient *rest.RESTClient, clientSet kubecli.KubevirtClient) KubeInformerFactory
type RealVirtualMachineControl ¶
type RealVirtualMachineControl struct {
Clientset kubecli.KubevirtClient
}
func (RealVirtualMachineControl) PatchVirtualMachine ¶
func (r RealVirtualMachineControl) PatchVirtualMachine(namespace, name string, data []byte) error
type ResyncPeriodFunc ¶
func StaticResyncPeriodFunc ¶
func StaticResyncPeriodFunc(resyncPeriod time.Duration) ResyncPeriodFunc
StaticResyncPeriodFunc returns the resync period specified
type UIDSet ¶
UIDSet holds a key and a set of UIDs. Used by the UIDTrackingControllerExpectations to remember which UID it has seen/still waiting for.
type UIDTrackingControllerExpectations ¶
type UIDTrackingControllerExpectations struct { ControllerExpectationsInterface // contains filtered or unexported fields }
UIDTrackingControllerExpectations tracks the UID of the pods it deletes. This cache is needed over plain old expectations to safely handle graceful deletion. The desired behavior is to treat an update that sets the DeletionTimestamp on an object as a delete. To do so consistently, one needs to remember the expected deletes so they aren't double counted. TODO: RTCTimerTrack creates as well (#22599)
func NewUIDTrackingControllerExpectations ¶
func NewUIDTrackingControllerExpectations(ce ControllerExpectationsInterface) *UIDTrackingControllerExpectations
NewUIDTrackingControllerExpectations returns a wrapper around ControllerExpectations that is aware of deleteKeys.
func (*UIDTrackingControllerExpectations) DeleteExpectations ¶
func (u *UIDTrackingControllerExpectations) DeleteExpectations(rcKey string)
DeleteExpectations deletes the UID set and invokes DeleteExpectations on the underlying ControllerExpectationsInterface.
func (*UIDTrackingControllerExpectations) DeletionObserved ¶
func (u *UIDTrackingControllerExpectations) DeletionObserved(rcKey, deleteKey string)
DeletionObserved records the given deleteKey as a deletion, for the given rc.
func (*UIDTrackingControllerExpectations) ExpectDeletions ¶
func (u *UIDTrackingControllerExpectations) ExpectDeletions(rcKey string, deletedKeys []string) error
ExpectDeletions records expectations for the given deleteKeys, against the given controller.
func (*UIDTrackingControllerExpectations) GetUIDs ¶
func (u *UIDTrackingControllerExpectations) GetUIDs(controllerKey string) sets.String
GetUIDs is a convenience method to avoid exposing the set of expected uids. The returned set is not thread safe, all modifications must be made holding the uidStoreLock.
type VirtualMachineConditionManager ¶ added in v0.5.0
type VirtualMachineConditionManager struct { }
func NewVirtualMachineConditionManager ¶ added in v0.5.0
func NewVirtualMachineConditionManager() *VirtualMachineConditionManager
func (*VirtualMachineConditionManager) CheckFailure ¶ added in v0.5.0
func (d *VirtualMachineConditionManager) CheckFailure(vm *v1.VirtualMachine, syncErr error, reason string) (changed bool)
func (*VirtualMachineConditionManager) HasCondition ¶ added in v0.5.0
func (d *VirtualMachineConditionManager) HasCondition(vm *v1.VirtualMachine, cond v1.VirtualMachineConditionType) bool
func (*VirtualMachineConditionManager) RemoveCondition ¶ added in v0.5.0
func (d *VirtualMachineConditionManager) RemoveCondition(vm *v1.VirtualMachine, cond v1.VirtualMachineConditionType)
type VirtualMachineControllerRefManager ¶
type VirtualMachineControllerRefManager struct { BaseControllerRefManager // contains filtered or unexported fields }
func NewVirtualMachineControllerRefManager ¶
func NewVirtualMachineControllerRefManager( virtualMachineControl VirtualMachineControlInterface, controller metav1.Object, selector labels.Selector, controllerKind schema.GroupVersionKind, canAdopt func() error, ) *VirtualMachineControllerRefManager
NewVirtualMachineControllerRefManager returns a VirtualMachineControllerRefManager that exposes methods to manage the controllerRef of virtual machines.
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
VirtualMachineControllerRefManager instance. Create a new instance if it makes sense to check CanAdopt() again (e.g. in a different sync pass).
func (*VirtualMachineControllerRefManager) AdoptVirtualMachine ¶
func (m *VirtualMachineControllerRefManager) AdoptVirtualMachine(vm *virtv1.VirtualMachine) error
AdoptVirtualMachine sends a patch to take control of the vm. It returns the error if the patching fails.
func (*VirtualMachineControllerRefManager) ClaimVirtualMachineByName ¶
func (m *VirtualMachineControllerRefManager) ClaimVirtualMachineByName(vm *virtv1.VirtualMachine, filters ...func(machine *virtv1.VirtualMachine) bool) (*virtv1.VirtualMachine, error)
ClaimVirtualMachineByName tries to take ownership of a VirtualMachine.
It will reconcile the following:
- Adopt orphans if the selector matches.
- Release owned objects if the selector no longer matches.
Optional: If one or more filters are specified, a VirtualMachine will only be claimed if all filters return true.
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 VirtualMachines that you now own is returned.
func (*VirtualMachineControllerRefManager) ClaimVirtualMachines ¶
func (m *VirtualMachineControllerRefManager) ClaimVirtualMachines(vms []*virtv1.VirtualMachine, filters ...func(machine *virtv1.VirtualMachine) bool) ([]*virtv1.VirtualMachine, error)
ClaimVirtualMachines tries to take ownership of a list of VirtualMachines.
It will reconcile the following:
- Adopt orphans if the selector matches.
- Release owned objects if the selector no longer matches.
Optional: If one or more filters are specified, a VirtualMachine will only be claimed if all filters return true.
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 VirtualMachines that you now own is returned.
func (*VirtualMachineControllerRefManager) ReleaseVirtualMachine ¶
func (m *VirtualMachineControllerRefManager) ReleaseVirtualMachine(vm *virtv1.VirtualMachine) error
ReleaseVirtualMachine sends a patch to free the virtual machine from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.