controller

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 57 Imported by: 26

Documentation

Overview

* This file is part of the KubeVirt project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2019 Red Hat, Inc. *

Index

Constants

View Source
const (
	// FailedCreatePodReason is added in an event and in a vmi controller condition
	// when a pod for a vmi controller failed to be created.
	FailedCreatePodReason = "FailedCreate"
	// SuccessfulCreatePodReason is added in an event when a pod for a vmi controller
	// is successfully created.
	SuccessfulCreatePodReason = "SuccessfulCreate"
	// FailedDeletePodReason is added in an event and in a vmi controller condition
	// when a pod for a vmi controller failed to be deleted.
	FailedDeletePodReason = "FailedDelete"
	// SuccessfulDeletePodReason is added in an event when a pod for a vmi controller
	// is successfully deleted.
	SuccessfulDeletePodReason = "SuccessfulDelete"
	// FailedHandOverPodReason is added in an event and in a vmi controller condition
	// when transferring the pod ownership from the controller to virt-hander fails.
	FailedHandOverPodReason = "FailedHandOver"
	// FailedBackendStorageCreateReason is added when the creation of the backend storage PVC fails.
	FailedBackendStorageCreateReason = "FailedBackendStorageCreate"
	// FailedBackendStorageProbeReason is added when probing the backend storage PVC fails.
	FailedBackendStorageProbeReason = "FailedBackendStorageProbe"
	// BackendStorageNotReadyReason is added when the backend storage PVC is pending.
	BackendStorageNotReadyReason = "BackendStorageNotReady"
	// SuccessfulHandOverPodReason is added in an event
	// when the pod ownership transfer from the controller to virt-hander succeeds.
	SuccessfulHandOverPodReason = "SuccessfulHandOver"
	// FailedDataVolumeImportReason is added in an event when a dynamically generated
	// dataVolume reaches the failed status phase.
	FailedDataVolumeImportReason = "FailedDataVolumeImport"
	// FailedGuaranteePodResourcesReason is added in an event and in a vmi controller condition
	// when a pod has been created without a Guaranteed resources.
	FailedGuaranteePodResourcesReason = "FailedGuaranteeResources"
	// FailedGatherhingClusterTopologyHints is added if the cluster topology hints can't be collected for a VMI by virt-controller
	FailedGatherhingClusterTopologyHints = "FailedGatherhingClusterTopologyHints"
	// FailedPvcNotFoundReason is added in an event
	// when a PVC for a volume was not found.
	FailedPvcNotFoundReason = "FailedPvcNotFound"
	// SuccessfulMigrationReason is added when a migration attempt completes successfully
	SuccessfulMigrationReason = "SuccessfulMigration"
	// FailedMigrationReason is added when a migration attempt fails
	FailedMigrationReason = "FailedMigration"
	// SuccessfulAbortMigrationReason is added when an attempt to abort migration completes successfully
	SuccessfulAbortMigrationReason = "SuccessfulAbortMigration"
	// MigrationTargetPodUnschedulable is added a migration target pod enters Unschedulable phase
	MigrationTargetPodUnschedulable = "migrationTargetPodUnschedulable"
	// FailedAbortMigrationReason is added when an attempt to abort migration fails
	FailedAbortMigrationReason = "FailedAbortMigration"
	// MissingAttachmentPodReason is set when we have a hotplugged volume, but the attachment pod is missing
	MissingAttachmentPodReason = "MissingAttachmentPod"
	// PVCNotReadyReason is set when the PVC is not ready to be hot plugged.
	PVCNotReadyReason = "PVCNotReady"
	// FailedHotplugSyncReason is set when a hotplug specific failure occurs during sync
	FailedHotplugSyncReason = "FailedHotplugSync"
	// ErrImagePullReason is set when an error has occured while pulling an image for a containerDisk VM volume.
	ErrImagePullReason = "ErrImagePull"
	// ImagePullBackOffReason is set when an error has occured while pulling an image for a containerDisk VM volume,
	// and that kubelet is backing off before retrying.
	ImagePullBackOffReason = "ImagePullBackOff"
	// NoSuitableNodesForHostModelMigration is set when a VMI with host-model CPU mode tries to migrate but no node
	// is suitable for migration (since CPU model / required features are not supported)
	NoSuitableNodesForHostModelMigration = "NoSuitableNodesForHostModelMigration"
	// FailedPodPatchReason is set when a pod patch error occurs during sync
	FailedPodPatchReason = "FailedPodPatch"
	// MigrationBackoffReason is set when an error has occured while migrating
	// and virt-controller is backing off before retrying.
	MigrationBackoffReason = "MigrationBackoff"
)

Reasons for vmi events

View Source
const (
	/*
		TODO: replace the assignment to expression that accepts only kubev1.ManagedByLabelOperatorValue after few releases (after 0.47)
		The new assignment is to avoid error on update
		(operator can't recognize components with the old managed-by label's value)
	*/
	OperatorLabel    = kubev1.ManagedByLabel + " in (" + kubev1.ManagedByLabelOperatorValue + "," + kubev1.ManagedByLabelOperatorOldValue + " )"
	NotOperatorLabel = kubev1.ManagedByLabel + " notin (" + kubev1.ManagedByLabelOperatorValue + "," + kubev1.ManagedByLabelOperatorOldValue + " )"
)
View Source
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
)
View Source
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

View Source
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

View Source
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.

Functions

func AddFinalizer added in v0.31.0

func AddFinalizer(object metav1.Object, finalizer string)

func ApplyVolumeRequestOnVMISpec added in v0.36.0

func ApplyVolumeRequestOnVMISpec(vmiSpec *v1.VirtualMachineInstanceSpec, request *v1.VirtualMachineVolumeRequest) *v1.VirtualMachineInstanceSpec

func AttachmentPods added in v0.44.1

func AttachmentPods(ownerPod *k8sv1.Pod, podIndexer cache.Indexer) ([]*k8sv1.Pod, error)

func CurrentVMIPod added in v0.39.0

func CurrentVMIPod(vmi *v1.VirtualMachineInstance, podIndexer cache.Indexer) (*k8sv1.Pod, error)

func DataVolumeKey added in v0.8.0

func DataVolumeKey(dataVolume *cdiv1.DataVolume) string

func GeneratePatchBytes added in v0.42.0

func GeneratePatchBytes(ops []string) []byte

func GetControllerOf added in v0.1.0

func GetControllerOf(pod *k8sv1.Pod) *metav1.OwnerReference

GetControllerOf returns the controllerRef if controllee has a controller, otherwise returns nil.

func GetControllerRevisionInformerIndexers added in v0.49.1

func GetControllerRevisionInformerIndexers() cache.Indexers

func GetHotplugVolumes added in v1.3.0

func GetHotplugVolumes(vmi *v1.VirtualMachineInstance, virtlauncherPod *k8sv1.Pod) []*v1.Volume

func GetVMIInformerIndexers added in v0.49.1

func GetVMIInformerIndexers() cache.Indexers

func GetVirtualMachineCloneInformerIndexers added in v0.59.0

func GetVirtualMachineCloneInformerIndexers() cache.Indexers

func GetVirtualMachineExportInformerIndexers added in v0.57.0

func GetVirtualMachineExportInformerIndexers() cache.Indexers

func GetVirtualMachineInformerIndexers added in v0.49.1

func GetVirtualMachineInformerIndexers() cache.Indexers

func GetVirtualMachineRestoreInformerIndexers added in v0.49.1

func GetVirtualMachineRestoreInformerIndexers() cache.Indexers

func GetVirtualMachineSnapshotContentInformerIndexers added in v0.49.1

func GetVirtualMachineSnapshotContentInformerIndexers() cache.Indexers

func GetVirtualMachineSnapshotInformerIndexers added in v0.49.1

func GetVirtualMachineSnapshotInformerIndexers() cache.Indexers

func HandlePanic

func HandlePanic()

func HasFinalizer added in v0.1.0

func HasFinalizer(object metav1.Object, finalizer string) bool

func IsControlledBy added in v0.11.0

func IsControlledBy(pod *k8sv1.Pod, vmi *virtv1.VirtualMachineInstance) bool

func IsPodDownOrGoingDown added in v1.3.0

func IsPodDownOrGoingDown(pod *k8sv1.Pod) bool

func IsPodFailedOrGoingDown added in v1.3.0

func IsPodFailedOrGoingDown(pod *k8sv1.Pod) bool

func IsPodReady added in v1.3.0

func IsPodReady(pod *k8sv1.Pod) bool

IsPodReady treats the pod as ready to be handed over to virt-handler, as soon as all pods except the compute pod are ready.

func MigrationKey added in v0.9.2

func MigrationKey(migration *v1.VirtualMachineInstanceMigration) string

func NamespacedKey added in v0.47.0

func NamespacedKey(namespace, name string) string

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, kubevirtNamespace and field selector.

func ObservedLatestApiVersionAnnotation added in v0.20.0

func ObservedLatestApiVersionAnnotation(object metav1.Object) bool

func PodExists added in v1.3.0

func PodExists(pod *k8sv1.Pod) bool

func PodIsDown added in v1.3.0

func PodIsDown(pod *k8sv1.Pod) bool

func PodKey added in v0.5.0

func PodKey(pod *k8sv1.Pod) string

func RecheckDeletionTimestamp added in v0.1.0

func RecheckDeletionTimestamp(getObject func() (metav1.Object, error)) func() error

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 RemoveFinalizer(object metav1.Object, finalizer string)

func SetLatestApiVersionAnnotation added in v0.20.0

func SetLatestApiVersionAnnotation(object metav1.Object)

func SetSourcePod added in v1.2.1

func SetSourcePod(migration *v1.VirtualMachineInstanceMigration, vmi *v1.VirtualMachineInstance, podIndexer cache.Indexer)

func SetVMIMigrationPhaseTransitionTimestamp added in v0.55.0

func SetVMIMigrationPhaseTransitionTimestamp(oldVMIMigration *v1.VirtualMachineInstanceMigration, newVMIMigration *v1.VirtualMachineInstanceMigration)

func SetVMIPhaseTransitionTimestamp added in v0.43.0

func SetVMIPhaseTransitionTimestamp(oldVMI *v1.VirtualMachineInstance, newVMI *v1.VirtualMachineInstance)

func VMIActivePodsCount added in v0.36.3

func VMIActivePodsCount(vmi *v1.VirtualMachineInstance, vmiPodIndexer cache.Indexer) int

func VMIHasHotplugCPU added in v1.0.0

func VMIHasHotplugCPU(vmi *v1.VirtualMachineInstance) bool

func VMIHasHotplugMemory added in v1.1.0

func VMIHasHotplugMemory(vmi *v1.VirtualMachineInstance) bool

func VMIHasHotplugVolumes added in v0.44.1

func VMIHasHotplugVolumes(vmi *v1.VirtualMachineInstance) bool

func VirtualMachineInstanceKey added in v0.43.0

func VirtualMachineInstanceKey(vmi *v1.VirtualMachineInstance) string

func VirtualMachineInstanceKeys added in v0.43.0

func VirtualMachineInstanceKeys(vmis []*v1.VirtualMachineInstance) []string

func VirtualMachineKey

func VirtualMachineKey(vm *v1.VirtualMachine) string

func VirtualMachineKeys

func VirtualMachineKeys(vms []*v1.VirtualMachine) []string

func VolumeSnapshotClassInformer added in v0.31.0

func VolumeSnapshotClassInformer(clientSet kubecli.KubevirtClient, resyncPeriod time.Duration) cache.SharedIndexInformer

VolumeSnapshotClassInformer returns an informer for VolumeSnapshotClasses

func VolumeSnapshotInformer added in v0.31.0

func VolumeSnapshotInformer(clientSet kubecli.KubevirtClient, resyncPeriod time.Duration) cache.SharedIndexInformer

VolumeSnapshotInformer returns an informer for VolumeSnapshots

Types

type BaseControllerRefManager added in v0.1.0

type BaseControllerRefManager struct {
	Controller metav1.Object
	Selector   labels.Selector

	CanAdoptFunc func() error
	// contains filtered or unexported fields
}

func (*BaseControllerRefManager) CanAdopt added in v0.1.0

func (m *BaseControllerRefManager) CanAdopt() error

func (*BaseControllerRefManager) ClaimObject added in v0.1.0

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.

func (*BaseControllerRefManager) ReleaseDetachedObject added in v0.49.0

func (m *BaseControllerRefManager) ReleaseDetachedObject(obj metav1.Object, match func(metav1.Object) bool, release func(metav1.Object) error) (bool, error)

ReleaseDetachedObject tries to take release ownership of an object for this controller.

It will reconcile the following:

  • 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.

Returns True - if controller maintains ownership of object False - if controller releases or has no ownership of object err - if release fails.

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

type ControllerExpectations struct {
	cache.Store
	// contains filtered or unexported fields
}

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 NewControllerExpectationsWithName added in v0.12.0

func NewControllerExpectationsWithName(name string) *ControllerExpectations

func (*ControllerExpectations) AllPendingCreations added in v0.16.0

func (r *ControllerExpectations) AllPendingCreations() (sum int64)

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)

func (*ControllerExpectations) ExpectDeletions

func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int)

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)

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)
	ExpectCreations(controllerKey string, adds int)
	ExpectDeletions(controllerKey string, dels int)
	CreationObserved(controllerKey string)
	DeletionObserved(controllerKey string)
	RaiseExpectations(controllerKey string, add, del int)
	LowerExpectations(controllerKey string, add, del int)
	AllPendingCreations() (creations int64)
}

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{})

	// Waits for all informers to sync
	WaitForCacheSync(stopCh <-chan struct{})

	// Watches for vmi objects
	VMI() cache.SharedIndexInformer

	// Watches for vmi objects assigned to a specific host
	VMISourceHost(hostName string) cache.SharedIndexInformer

	// Watches for vmi objects assigned to a specific host
	// as a migration target
	VMITargetHost(hostName string) cache.SharedIndexInformer

	// Watches for VirtualMachineInstanceReplicaSet objects
	VMIReplicaSet() cache.SharedIndexInformer

	// Watches for VirtualMachinePool objects
	VMPool() cache.SharedIndexInformer

	// Watches for VirtualMachineInstancePreset objects
	VirtualMachinePreset() cache.SharedIndexInformer

	// Watches for pods related only to kubevirt
	KubeVirtPod() cache.SharedIndexInformer

	// Watches for nodes
	KubeVirtNode() cache.SharedIndexInformer

	// VirtualMachine handles the VMIs that are stopped or not running
	VirtualMachine() cache.SharedIndexInformer

	// Watches VirtualMachineInstanceMigration objects
	VirtualMachineInstanceMigration() cache.SharedIndexInformer

	// Watches VirtualMachineExport objects
	VirtualMachineExport() cache.SharedIndexInformer

	// Watches VirtualMachineSnapshot objects
	VirtualMachineSnapshot() cache.SharedIndexInformer

	// Watches VirtualMachineSnapshot objects
	VirtualMachineSnapshotContent() cache.SharedIndexInformer

	// Watches VirtualMachineRestore objects
	VirtualMachineRestore() cache.SharedIndexInformer

	// Watches MigrationPolicy objects
	MigrationPolicy() cache.SharedIndexInformer

	// Watches VirtualMachineClone objects
	VirtualMachineClone() cache.SharedIndexInformer

	// Watches VirtualMachineInstancetype objects
	VirtualMachineInstancetype() cache.SharedIndexInformer

	// Watches VirtualMachineClusterInstancetype objects
	VirtualMachineClusterInstancetype() cache.SharedIndexInformer

	// Watches VirtualMachinePreference objects
	VirtualMachinePreference() cache.SharedIndexInformer

	// Watches VirtualMachineClusterPreference objects
	VirtualMachineClusterPreference() cache.SharedIndexInformer

	// Watches for k8s extensions api configmap
	ApiAuthConfigMap() cache.SharedIndexInformer

	// Watches for the kubevirt CA config map
	KubeVirtCAConfigMap() cache.SharedIndexInformer

	// Watches for the kubevirt export CA config map
	KubeVirtExportCAConfigMap() cache.SharedIndexInformer

	// Watches for the export route config map
	ExportRouteConfigMap() cache.SharedIndexInformer

	// Watches for the kubevirt export service
	ExportService() cache.SharedIndexInformer

	// ConfigMaps which are managed by the operator
	OperatorConfigMap() cache.SharedIndexInformer

	// Watches for PersistentVolumeClaim objects
	PersistentVolumeClaim() cache.SharedIndexInformer

	// Watches for ControllerRevision objects
	ControllerRevision() cache.SharedIndexInformer

	// Watches for CDI DataVolume objects
	DataVolume() cache.SharedIndexInformer

	// Fake CDI DataVolume informer used when feature gate is disabled
	DummyDataVolume() cache.SharedIndexInformer

	// Watches for CDI DataSource objects
	DataSource() cache.SharedIndexInformer

	// Fake CDI DataSource informer used when feature gate is disabled
	DummyDataSource() cache.SharedIndexInformer

	// Watches for CDI StorageProfile objects
	StorageProfile() cache.SharedIndexInformer

	// Fake CDI StorageProfile informer used when feature gate is disabled
	DummyStorageProfile() cache.SharedIndexInformer

	// Watches for CDI objects
	CDI() cache.SharedIndexInformer

	// Fake CDI informer used when feature gate is disabled
	DummyCDI() cache.SharedIndexInformer

	// Watches for CDIConfig objects
	CDIConfig() cache.SharedIndexInformer

	// Fake CDIConfig informer used when feature gate is disabled
	DummyCDIConfig() cache.SharedIndexInformer

	// CRD
	CRD() cache.SharedIndexInformer

	// Watches for KubeVirt objects
	KubeVirt() cache.SharedIndexInformer

	// Service Accounts
	OperatorServiceAccount() cache.SharedIndexInformer

	// ClusterRole
	OperatorClusterRole() cache.SharedIndexInformer

	// ClusterRoleBinding
	OperatorClusterRoleBinding() cache.SharedIndexInformer

	// Roles
	OperatorRole() cache.SharedIndexInformer

	// RoleBinding
	OperatorRoleBinding() cache.SharedIndexInformer

	// CRD
	OperatorCRD() cache.SharedIndexInformer

	// Service
	OperatorService() cache.SharedIndexInformer

	// DaemonSet
	OperatorDaemonSet() cache.SharedIndexInformer

	// Deployment
	OperatorDeployment() cache.SharedIndexInformer

	// SecurityContextConstraints
	OperatorSCC() cache.SharedIndexInformer

	// Fake SecurityContextConstraints informer used when not on openshift
	DummyOperatorSCC() cache.SharedIndexInformer

	// Routes
	OperatorRoute() cache.SharedIndexInformer

	// Fake Routes informer used when not on openshift
	DummyOperatorRoute() cache.SharedIndexInformer

	// Ingress
	Ingress() cache.SharedIndexInformer

	// ConfigMaps for operator install strategies
	OperatorInstallStrategyConfigMaps() cache.SharedIndexInformer

	// Jobs for dumping operator install strategies
	OperatorInstallStrategyJob() cache.SharedIndexInformer

	// KubeVirt infrastructure pods
	OperatorPod() cache.SharedIndexInformer

	// Webhooks created/managed by virt operator
	OperatorValidationWebhook() cache.SharedIndexInformer

	// Webhooks created/managed by virt operator
	OperatorMutatingWebhook() cache.SharedIndexInformer

	// APIServices created/managed by virt operator
	OperatorAPIService() cache.SharedIndexInformer

	// PodDisruptionBudgets created/managed by virt operator
	OperatorPodDisruptionBudget() cache.SharedIndexInformer

	// ServiceMonitors created/managed by virt operator
	OperatorServiceMonitor() cache.SharedIndexInformer

	// Managed secrets which hold data like certificates
	Secrets() cache.SharedIndexInformer

	// Unmanaged secrets for things like Ingress TLS
	UnmanagedSecrets() cache.SharedIndexInformer

	// Fake ServiceMonitor informer used when Prometheus is not installed
	DummyOperatorServiceMonitor() cache.SharedIndexInformer

	// ValidatingAdmissionPolicyBinding created/managed by virt operator
	OperatorValidatingAdmissionPolicyBinding() cache.SharedIndexInformer

	// Fake OperatorValidatingAdmissionPolicyBinding informer used when ValidatingAdmissionPolicyBinding is not installed
	DummyOperatorValidatingAdmissionPolicyBinding() cache.SharedIndexInformer

	// ValidatingAdmissionPolicies created/managed by virt operator
	OperatorValidatingAdmissionPolicy() cache.SharedIndexInformer

	// Fake OperatorValidatingAdmissionPolicy informer used when ValidatingAdmissionPolicy is not installed
	DummyOperatorValidatingAdmissionPolicy() cache.SharedIndexInformer

	// The namespace where kubevirt is deployed in
	Namespace() cache.SharedIndexInformer

	// PrometheusRules created/managed by virt operator
	OperatorPrometheusRule() cache.SharedIndexInformer

	// Fake PrometheusRule informer used when Prometheus not installed
	DummyOperatorPrometheusRule() cache.SharedIndexInformer

	// PVC StorageClasses
	StorageClass() cache.SharedIndexInformer

	// Pod returns an informer for ALL Pods in the system
	Pod() cache.SharedIndexInformer

	ResourceQuota() cache.SharedIndexInformer

	K8SInformerFactory() informers.SharedInformerFactory
}

func NewKubeInformerFactory

func NewKubeInformerFactory(restClient *rest.RESTClient, clientSet kubecli.KubevirtClient, aggregatorClient aggregatorclient.Interface, kubevirtNamespace string) KubeInformerFactory

type PodConditionManager added in v0.48.0

type PodConditionManager struct {
}

func NewPodConditionManager added in v0.48.0

func NewPodConditionManager() *PodConditionManager

func (*PodConditionManager) ConditionsEqual added in v0.48.0

func (d *PodConditionManager) ConditionsEqual(pod1, pod2 *k8sv1.Pod) bool

func (*PodConditionManager) GetCondition added in v0.48.0

func (d *PodConditionManager) GetCondition(pod *k8sv1.Pod, cond k8sv1.PodConditionType) *k8sv1.PodCondition

func (*PodConditionManager) HasCondition added in v0.48.0

func (d *PodConditionManager) HasCondition(pod *k8sv1.Pod, cond k8sv1.PodConditionType) bool

func (*PodConditionManager) HasConditionWithStatus added in v0.48.0

func (d *PodConditionManager) HasConditionWithStatus(pod *k8sv1.Pod, cond k8sv1.PodConditionType, status k8sv1.ConditionStatus) bool

func (*PodConditionManager) HasConditionWithStatusAndReason added in v0.48.0

func (d *PodConditionManager) HasConditionWithStatusAndReason(pod *k8sv1.Pod, cond k8sv1.PodConditionType, status k8sv1.ConditionStatus, reason string) bool

func (*PodConditionManager) RemoveCondition added in v0.48.0

func (d *PodConditionManager) RemoveCondition(pod *k8sv1.Pod, cond k8sv1.PodConditionType)

func (*PodConditionManager) UpdateCondition added in v0.48.0

func (d *PodConditionManager) UpdateCondition(pod *k8sv1.Pod, cond *k8sv1.PodCondition)

UpdateCondition updates the given PodCondition, unless it is already set with the same status and reason.

type RealVirtualMachineControl added in v0.1.0

type RealVirtualMachineControl struct {
	Clientset kubecli.KubevirtClient
}

func (RealVirtualMachineControl) PatchDataVolume added in v0.8.0

func (r RealVirtualMachineControl) PatchDataVolume(namespace, name string, data []byte) error

func (RealVirtualMachineControl) PatchVirtualMachine added in v0.1.0

func (r RealVirtualMachineControl) PatchVirtualMachine(namespace, name string, data []byte) error

func (RealVirtualMachineControl) PatchVirtualMachineInstance added in v0.49.0

func (r RealVirtualMachineControl) PatchVirtualMachineInstance(namespace, name string, data []byte) error

type UIDSet

type UIDSet struct {
	sets.String
	// contains filtered or unexported fields
}

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) AddExpectedDeletion added in v0.12.0

func (u *UIDTrackingControllerExpectations) AddExpectedDeletion(rcKey string, deletedKey string)

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)

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) GetCondition added in v0.29.0

func (*VirtualMachineConditionManager) HasCondition added in v0.5.0

func (*VirtualMachineConditionManager) HasConditionWithStatus added in v0.12.0

func (*VirtualMachineConditionManager) RemoveCondition added in v0.5.0

func (*VirtualMachineConditionManager) UpdateCondition added in v0.44.1

UpdateCondition updates the given VirtualMachineCondition, unless it is already set with the same status and reason.

type VirtualMachineControlInterface added in v0.1.0

type VirtualMachineControlInterface interface {
	PatchVirtualMachine(namespace, name string, data []byte) error
	PatchVirtualMachineInstance(namespace, name string, data []byte) error
	PatchDataVolume(namespace, name string, data []byte) error
}

type VirtualMachineControllerRefManager added in v0.1.0

type VirtualMachineControllerRefManager struct {
	BaseControllerRefManager
	// contains filtered or unexported fields
}

func NewVirtualMachineControllerRefManager added in v0.1.0

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) AdoptDataVolume added in v0.8.0

func (m *VirtualMachineControllerRefManager) AdoptDataVolume(dataVolume *cdiv1.DataVolume) error

AdoptDataVolume sends a patch to take control of the dataVolume. It returns the error if the patching fails.

func (*VirtualMachineControllerRefManager) AdoptVirtualMachine added in v0.1.0

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) AdoptVirtualMachineInstance added in v0.47.0

func (m *VirtualMachineControllerRefManager) AdoptVirtualMachineInstance(vmi *virtv1.VirtualMachineInstance) error

AdoptVirtualMachineInstance sends a patch to take control of the vmi. It returns the error if the patching fails.

func (*VirtualMachineControllerRefManager) ClaimMatchedDataVolumes added in v0.8.0

func (m *VirtualMachineControllerRefManager) ClaimMatchedDataVolumes(dataVolumes []*cdiv1.DataVolume) ([]*cdiv1.DataVolume, error)

ClaimMatchedDataVolumes tries to take ownership of a list of DataVolumes.

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 DataVolume 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 DataVolumes that you now own is returned.

func (*VirtualMachineControllerRefManager) ClaimVirtualMachineInstanceByName added in v0.47.0

func (m *VirtualMachineControllerRefManager) ClaimVirtualMachineInstanceByName(vmi *virtv1.VirtualMachineInstance, filters ...func(machine *virtv1.VirtualMachineInstance) bool) (*virtv1.VirtualMachineInstance, error)

ClaimVirtualMachineInstanceByName tries to take ownership of a VirtualMachineInstance.

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 VirtualMachineInstance 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) ClaimVirtualMachineInstances added in v0.47.0

func (m *VirtualMachineControllerRefManager) ClaimVirtualMachineInstances(vmis []*virtv1.VirtualMachineInstance, filters ...func(machine *virtv1.VirtualMachineInstance) bool) ([]*virtv1.VirtualMachineInstance, error)

ClaimVirtualMachineInstances tries to take ownership of a list of VirtualMachineInstances.

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 VirtualMachineInstance 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) ReleaseDataVolume added in v0.8.0

func (m *VirtualMachineControllerRefManager) ReleaseDataVolume(dataVolume *cdiv1.DataVolume) error

ReleaseDataVolume sends a patch to free the dataVolume from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.

func (*VirtualMachineControllerRefManager) ReleaseDetachedVirtualMachines added in v0.49.0

func (m *VirtualMachineControllerRefManager) ReleaseDetachedVirtualMachines(vms []*virtv1.VirtualMachine, filters ...func(machine *virtv1.VirtualMachine) bool) ([]*virtv1.VirtualMachine, error)

ReleaseDetachedVirtualMachines removes ownership of detached VMs.

It will reconcile the following:

  • Release owned objects if the selector no longer matches.

List of Owned VMs is returned.

func (*VirtualMachineControllerRefManager) ReleaseVirtualMachine added in v0.1.0

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.

func (*VirtualMachineControllerRefManager) ReleaseVirtualMachineInstance added in v0.47.0

func (m *VirtualMachineControllerRefManager) ReleaseVirtualMachineInstance(vmi *virtv1.VirtualMachineInstance) error

ReleaseVirtualMachineInstance 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.

type VirtualMachineInstanceConditionManager added in v0.29.0

type VirtualMachineInstanceConditionManager struct {
}

func NewVirtualMachineInstanceConditionManager added in v0.6.1

func NewVirtualMachineInstanceConditionManager() *VirtualMachineInstanceConditionManager

func (*VirtualMachineInstanceConditionManager) AddPodCondition added in v0.29.0

AddPodCondition add pod condition to the VM.

func (*VirtualMachineInstanceConditionManager) CheckFailure added in v0.29.0

func (d *VirtualMachineInstanceConditionManager) CheckFailure(vmi *v1.VirtualMachineInstance, syncErr error, reason string) (changed bool)

func (*VirtualMachineInstanceConditionManager) ConditionsEqual added in v0.48.0

func (d *VirtualMachineInstanceConditionManager) ConditionsEqual(vmi1, vmi2 *v1.VirtualMachineInstance) bool

func (*VirtualMachineInstanceConditionManager) GetCondition added in v0.29.0

func (*VirtualMachineInstanceConditionManager) GetPodCondition added in v0.29.0

func (d *VirtualMachineInstanceConditionManager) GetPodCondition(pod *k8sv1.Pod, conditionType k8sv1.PodConditionType) *k8sv1.PodCondition

func (*VirtualMachineInstanceConditionManager) HasCondition added in v0.29.0

func (*VirtualMachineInstanceConditionManager) HasConditionWithStatus added in v0.29.0

func (*VirtualMachineInstanceConditionManager) HasConditionWithStatusAndReason added in v0.35.0

func (*VirtualMachineInstanceConditionManager) RemoveCondition added in v0.29.0

func (*VirtualMachineInstanceConditionManager) UpdateCondition added in v0.44.1

UpdateCondition updates the given VirtualMachineInstanceCondition, unless it is already set with the same status and reason.

type VirtualMachineInstanceMigrationConditionManager added in v0.16.0

type VirtualMachineInstanceMigrationConditionManager struct {
}

func NewVirtualMachineInstanceMigrationConditionManager added in v0.16.0

func NewVirtualMachineInstanceMigrationConditionManager() *VirtualMachineInstanceMigrationConditionManager

func (*VirtualMachineInstanceMigrationConditionManager) HasCondition added in v0.16.0

func (*VirtualMachineInstanceMigrationConditionManager) HasConditionWithStatus added in v0.16.0

func (*VirtualMachineInstanceMigrationConditionManager) RemoveCondition added in v0.16.0

func (*VirtualMachineInstanceMigrationConditionManager) UpdateCondition added in v1.3.0

UpdateCondition updates the given VirtualMachineMigrationCondition, unless it is already set with the same status and reason.

type VirtualMachinePoolConditionManager added in v0.49.0

type VirtualMachinePoolConditionManager struct {
}

func NewVirtualMachinePoolConditionManager added in v0.49.0

func NewVirtualMachinePoolConditionManager() *VirtualMachinePoolConditionManager

func (*VirtualMachinePoolConditionManager) GetCondition added in v0.49.0

func (*VirtualMachinePoolConditionManager) HasCondition added in v0.49.0

func (*VirtualMachinePoolConditionManager) RemoveCondition added in v0.49.0

func (*VirtualMachinePoolConditionManager) UpdateCondition added in v0.49.0

UpdateCondition updates the given VirtualMachinePoolCondition, unless it is already set with the same status and reason.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL