plan

package
v0.0.0-...-1d4c795 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 79 Imported by: 0

Documentation

Overview

The Plan CR represents a planned migration of VMs. The plan defines the source and destination providers; the resource mapping and a list of VMs to be migrated. The plan controller watches Migration CRs. Each Migration CR represents a separate and ordered execution of the plan. During plan execution, all validations are suspended. The plan Status.Migration contains a snapshot of the specification (except secrets) which is used during the execution.

Each plan execution:

1. Update the Status.Migration snapshot. 2. Ensure the plan CR namespace exists on the destination. 3. Ensure the CNV Secret exists and configured correctly on the destination. 4. Ensure the CNV ResourceMapping CR exists and configured correctly on the destination. 5. Create a CNV Import CR for each incomplete VM. 6. Requeue the reconcile until all of the VMs have either succeeded or failed. 7. A VM has completed successfully when it reaches the `Complete` phase without an error.

Each plan execution is idempotent. Subsequent migrations will only affect incomplete or failed VM migrations.

Index

Constants

View Source
const (
	// Name.
	Name = "plan"
	// Annotation for populator Labels set
	AnnPopulatorLabels = "populatorLabels"
)
View Source
const (
	// Legacy transfer network annotation (value=network-attachment-definition name)
	// FIXME: this should be phased out and replaced with the
	// k8s.v1.cni.cncf.io/networks annotation.
	AnnLegacyTransferNetwork = "v1.multus-cni.io/default-network"
	// Transfer network annotation (value=network-attachment-definition name)
	AnnTransferNetwork = "k8s.v1.cni.cncf.io/networks"
	// Annotation to specify the default route for the transfer network.
	// To be set on the transfer network NAD by the end user.
	AnnForkliftNetworkRoute = "forklift.konveyor.io/route"
	// Contains validations for a Kubevirt VM. Needs to be removed when
	// creating a VM from a template.
	AnnKubevirtValidations = "vm.kubevirt.io/validations"
	// PVC annotation containing the name of the importer pod.
	AnnImporterPodName = "cdi.kubevirt.io/storage.import.importPodName"
	// Openshift display name annotation (value=vmName)
	AnnDisplayName = "openshift.io/display-name"
	//  Original VM name on source (value=vmOriginalID)
	AnnOriginalID = "original-ID"
	// DV deletion on completion
	AnnDeleteAfterCompletion = "cdi.kubevirt.io/storage.deleteAfterCompletion"
	// Max Length for vm name
	NameMaxLength            = 63
	VddkVolumeName           = "vddk-vol-mount"
	DynamicScriptsVolumeName = "scripts-volume-mount"
	DynamicScriptsMountPath  = "/mnt/dynamic_scripts"
)

Annotations

View Source
const (
	OvaPVCLabel = "nfs-pvc"
	OvaPVLabel  = "nfs-pv"
)

Labels

View Source
const (
	ExtraV2vConf = "extra-v2v-conf"
	VddkConf     = "vddk-conf"

	VddkAioBufSizeDefault  = "16"
	VddkAioBufCountDefault = "4"
)

Vddk v2v conf

View Source
const (
	NoReQ   = time.Duration(0)
	PollReQ = time.Second * 3
)

Requeue

View Source
const (
	TransferCompleted              = "Transfer completed."
	PopulatorPodPrefix             = "populate-"
	DvStatusCheckRetriesAnnotation = "dvStatusCheckRetries"
	// TODO: ImageConversion and DiskTransferV2v step names remain here
	// until remaining cold/warm migration flow details can be
	// moved into base migrators.
	ImageConversion = "ImageConversion"
	DiskTransferV2v = "DiskTransferV2v"
)
View Source
const (
	WarmMigrationNotReady           = "WarmMigrationNotReady"
	MigrationTypeNotValid           = "MigrationTypeNotValid"
	NamespaceNotValid               = "NamespaceNotValid"
	TransferNetNotValid             = "TransferNetworkNotValid"
	NetRefNotValid                  = "NetworkMapRefNotValid"
	NetMapNotReady                  = "NetworkMapNotReady"
	NetMapPreservingIPsOnPodNetwork = "NetMapPreservingIPsOnPodNetwork"
	DsMapNotReady                   = "StorageMapNotReady"
	DsRefNotValid                   = "StorageRefNotValid"
	VMRefNotValid                   = "VMRefNotValid"
	VMNotFound                      = "VMNotFound"
	VMAlreadyExists                 = "VMAlreadyExists"
	VMNetworksNotMapped             = "VMNetworksNotMapped"
	VMStorageNotMapped              = "VMStorageNotMapped"
	VMStorageNotSupported           = "VMStorageNotSupported"
	VMMultiplePodNetworkMappings    = "VMMultiplePodNetworkMappings"
	VMMissingGuestIPs               = "VMMissingGuestIPs"
	VMIpNotMatchingUdnSubnet        = "VMIpNotMatchingUdnSubnet"
	VMMissingChangedBlockTracking   = "VMMissingChangedBlockTracking"
	VMHasSnapshots                  = "VMHasSnapshots"
	HostNotReady                    = "HostNotReady"
	DuplicateVM                     = "DuplicateVM"
	SharedDisks                     = "SharedDisks"
	SharedWarnDisks                 = "SharedWarnDisks"
	NameNotValid                    = "TargetNameNotValid"
	HookNotValid                    = "HookNotValid"
	HookNotReady                    = "HookNotReady"
	HookStepNotValid                = "HookStepNotValid"
	Executing                       = "Executing"
	Succeeded                       = "Succeeded"
	Failed                          = "Failed"
	Canceled                        = "Canceled"
	Deleted                         = "Deleted"
	Paused                          = "Paused"
	Archived                        = "Archived"
	UnsupportedDisks                = "UnsupportedDisks"
	InvalidDiskSizes                = "InvalidDiskSizes"
	MacConflicts                    = "MacConflicts"
	MissingPvcForOnlyConversion     = "MissingPvcForOnlyConversion"
	LuksAndClevisIncompatibility    = "LuksAndClevisIncompatibility"
	UnsupportedUdn                  = "UnsupportedUserDefinedNetwork"

	VDDKInvalid                = "VDDKInvalid"
	ValidatingVDDK             = "ValidatingVDDK"
	VDDKInitImageNotReady      = "VDDKInitImageNotReady"
	VDDKInitImageUnavailable   = "VDDKInitImageUnavailable"
	UnsupportedOvaSource       = "UnsupportedOvaSource"
	VMPowerStateUnsupported    = "VMPowerStateUnsupported"
	VMMigrationTypeUnsupported = "VMMigrationTypeUnsupported"
)

Types

View Source
const (
	Required = libcnd.Required
	Advisory = libcnd.Advisory
	Critical = libcnd.Critical
	Error    = libcnd.Error
	Warn     = libcnd.Warn
)

Categories

View Source
const (
	Pod     = "pod"
	Multus  = "multus"
	Ignored = "ignored"
)

Network types

View Source
const (
	Started                     = "Started"
	NotSet                      = "NotSet"
	NotFound                    = "NotFound"
	NotUnique                   = "NotUnique"
	NotSupported                = "NotSupported"
	Ambiguous                   = "Ambiguous"
	NotValid                    = "NotValid"
	Modified                    = "Modified"
	UserRequested               = "UserRequested"
	InMaintenanceMode           = "InMaintenanceMode"
	MissingGuestInfo            = "MissingGuestInformation"
	MissingChangedBlockTracking = "MissingChangedBlockTracking"
)

Reasons

View Source
const (
	True  = libcnd.True
	False = libcnd.False
)

Statuses

View Source
const (
	Shareable = "shareable"
)

Variables

View Source
var Settings = &settings.Settings

Application settings.

Functions

func Add

func Add(mgr manager.Manager) error

Creates a new Plan Controller and adds it to the Manager.

func GetOvaPvListNfs

func GetOvaPvListNfs(dClient client.Client, planID string) (pvs *core.PersistentVolumeList, found bool, err error)

func GetOvaPvcListNfs

func GetOvaPvcListNfs(dClient client.Client, planID string, planNamespace string) (pvcs *core.PersistentVolumeClaimList, found bool, err error)

func RequestForMigration

func RequestForMigration(ctx context.Context, a client.Object) (list []reconcile.Request)

Plan request for Migration.

Types

type DsMapPredicate

type DsMapPredicate struct {
	predicate.TypedFuncs[*api.StorageMap]
}

func (DsMapPredicate) Create

func (DsMapPredicate) Delete

func (DsMapPredicate) Generic

func (DsMapPredicate) Update

type ExtendedDataVolume

type ExtendedDataVolume struct {
	*cdi.DataVolume
	PVC *core.PersistentVolumeClaim
}

Represents a CDI DataVolume, its associated PVC, and added behavior.

func (*ExtendedDataVolume) Conditions

func (r *ExtendedDataVolume) Conditions() (cnd *libcnd.Conditions)

Get conditions.

func (*ExtendedDataVolume) PercentComplete

func (r *ExtendedDataVolume) PercentComplete() (pct float64)

Convert the Status.Progress into a percentage (float).

type HookPredicate

type HookPredicate struct {
	predicate.TypedFuncs[*api.Hook]
}

func (HookPredicate) Create

func (HookPredicate) Delete

func (HookPredicate) Generic

func (HookPredicate) Update

type HookRunner

type HookRunner struct {
	*plancontext.Context
	// contains filtered or unexported fields
}

Hook runner.

func (*HookRunner) Run

func (r *HookRunner) Run(vm *planapi.VMStatus) (err error)

Run.

type KubeVirt

type KubeVirt struct {
	*plancontext.Context
	// Builder
	Builder adapter.Builder
}

Represents kubevirt.

func (*KubeVirt) CreatePvForNfs

func (r *KubeVirt) CreatePvForNfs() (pvName string, err error)

func (*KubeVirt) CreatePvcForNfs

func (r *KubeVirt) CreatePvcForNfs(pvcNamePrefix, pvName, vmID string) (pvcName string, err error)

func (*KubeVirt) DataVolumes

func (r *KubeVirt) DataVolumes(vm *plan.VMStatus) (dataVolumes []cdi.DataVolume, err error)

func (*KubeVirt) DeleteConfigMap

func (r *KubeVirt) DeleteConfigMap(vm *plan.VMStatus) (err error)

Delete the ConfigMap that was created for this VM.

func (*KubeVirt) DeleteDataVolumes

func (r *KubeVirt) DeleteDataVolumes(vm *plan.VMStatus) (err error)

Delete the DataVolumes associated with the VM.

func (*KubeVirt) DeleteGuestConversionPod

func (r *KubeVirt) DeleteGuestConversionPod(vm *plan.VMStatus) (err error)

Delete the guest conversion pod on the destination cluster.

func (*KubeVirt) DeleteHookJobs

func (r *KubeVirt) DeleteHookJobs(vm *plan.VMStatus) (err error)

Delete any hook jobs that belong to a VM migration.

func (*KubeVirt) DeleteImporterPods

func (r *KubeVirt) DeleteImporterPods(pvc *core.PersistentVolumeClaim) (err error)

Delete the importer pods for a PersistentVolumeClaim.

func (*KubeVirt) DeleteJobs

func (r *KubeVirt) DeleteJobs(vm *plan.VMStatus) (err error)

func (*KubeVirt) DeleteObject

func (r *KubeVirt) DeleteObject(object client.Object, vm *plan.VMStatus, message, objType string, options ...client.DeleteOption) (err error)

Deletes an object from destination cluster associated with the VM.

func (*KubeVirt) DeletePVCConsumerPod

func (r *KubeVirt) DeletePVCConsumerPod(vm *plan.VMStatus) (err error)

Delete the PVC consumer pod on the destination cluster.

func (*KubeVirt) DeletePopulatedPVCs

func (r *KubeVirt) DeletePopulatedPVCs(vm *plan.VMStatus) error

Deletes PVCs that were populated using a volume populator, including prime PVCs

func (*KubeVirt) DeletePopulatorPods

func (r *KubeVirt) DeletePopulatorPods(vm *plan.VMStatus) (err error)

Delete any populator pods that belong to a VM's migration.

func (*KubeVirt) DeleteSecret

func (r *KubeVirt) DeleteSecret(vm *plan.VMStatus) (err error)

Delete the Secret that was created for this VM.

func (*KubeVirt) DeleteVM

func (r *KubeVirt) DeleteVM(vm *plan.VMStatus) (err error)

Delete the VirtualMachine CR on the destination cluster.

func (*KubeVirt) EnsureDataVolumes

func (r *KubeVirt) EnsureDataVolumes(vm *plan.VMStatus, dataVolumes []cdi.DataVolume) (err error)

Ensure the DataVolumes exist on the destination.

func (*KubeVirt) EnsureExtraV2vConfConfigMap

func (r *KubeVirt) EnsureExtraV2vConfConfigMap() error

Ensure the config map that contains extra configuration for virt-v2v exists on the destination.

func (*KubeVirt) EnsureGuestConversionPod

func (r *KubeVirt) EnsureGuestConversionPod(vm *plan.VMStatus, vmCr *VirtualMachine, pvcs []*core.PersistentVolumeClaim) (err error)

Ensure the guest conversion (virt-v2v) pod exists on the destination.

func (*KubeVirt) EnsureNamespace

func (r *KubeVirt) EnsureNamespace() error

Ensure the namespace exists on the destination.

func (*KubeVirt) EnsureOVAVirtV2VPVCStatus

func (r *KubeVirt) EnsureOVAVirtV2VPVCStatus(vmID string) (ready bool, err error)

func (*KubeVirt) EnsurePersistentVolume

func (r *KubeVirt) EnsurePersistentVolume(vmRef ref.Ref, persistentVolumes []core.PersistentVolume) (err error)

Ensure the PV exist on the destination.

func (*KubeVirt) EnsurePersistentVolumeClaim

func (r *KubeVirt) EnsurePersistentVolumeClaim(vmRef ref.Ref, persistentVolumeClaims []core.PersistentVolumeClaim) (err error)

Ensure the PV exist on the destination.

func (*KubeVirt) EnsurePopulatorVolumes

func (r *KubeVirt) EnsurePopulatorVolumes(vm *plan.VMStatus, pvcs []*core.PersistentVolumeClaim) (err error)

func (*KubeVirt) EnsureVM

func (r *KubeVirt) EnsureVM(vm *plan.VMStatus) error

Ensure the kubevirt VirtualMachine exists on the destination.

func (*KubeVirt) GetGuestConversionPod

func (r *KubeVirt) GetGuestConversionPod(vm *plan.VMStatus) (pod *core.Pod, err error)

Get the guest conversion pod for the VM.

func (*KubeVirt) GetImporterPod

func (r *KubeVirt) GetImporterPod(pvc core.PersistentVolumeClaim) (pod *core.Pod, found bool, err error)

Get the importer pod for a PersistentVolumeClaim.

func (*KubeVirt) GetPods

func (r *KubeVirt) GetPods(vm *plan.VMStatus) (pods *core.PodList, err error)

Gets pods associated with the VM.

func (*KubeVirt) GetPodsWithLabels

func (r *KubeVirt) GetPodsWithLabels(podLabels map[string]string) (pods *core.PodList, err error)

Gets pods associated with the VM.

func (*KubeVirt) IsCopyOffload

func (r *KubeVirt) IsCopyOffload(pvcs []*core.PersistentVolumeClaim) bool

IsCopyOffload is determined by PVC having the copy-offload label, which is set by the builder earlier in #PopulatorVolumes TODO rgolan - for now the check will be done if any PVC match in the migration - this is obviously coarse and should be per a disk's storage class, for example a disk from NFS or local doesn't support that (specifically referring to vmkfstools xcopy for RDM)

func (*KubeVirt) ListVMs

func (r *KubeVirt) ListVMs() ([]VirtualMachine, error)

List VirtualMachine CRs. Each VirtualMachine represents an imported kubevirt VM with associated DataVolumes.

func (*KubeVirt) PopulatorVolumes

func (r *KubeVirt) PopulatorVolumes(vmRef ref.Ref) (pvcs []*core.PersistentVolumeClaim, err error)

func (*KubeVirt) SetPopulatorPodOwnership

func (r *KubeVirt) SetPopulatorPodOwnership(vm *plan.VMStatus) (err error)

Set the Populator Pod Ownership.

func (*KubeVirt) UpdateVmByConvertedConfig

func (r *KubeVirt) UpdateVmByConvertedConfig(vm *plan.VMStatus, pod *core.Pod, step *plan.Step) error

func (*KubeVirt) VirtualMachineMap

func (r *KubeVirt) VirtualMachineMap() (mp VirtualMachineMap, err error)

Build a VirtualMachineMap.

type Migration

type Migration struct {
	*plancontext.Context
	// contains filtered or unexported fields
}

Migration.

func (*Migration) Archive

func (r *Migration) Archive()

Archive the plan. Best effort to remove any retained migration resources.

func (*Migration) Cancel

func (r *Migration) Cancel() error

Cancel the migration. Delete resources associated with VMs that have been marked canceled.

func (*Migration) NextPhase

func (r *Migration) NextPhase(vm *plan.VMStatus)

NextPhase transitions the VM to the next migration phase. If this was the last phase in the current pipeline step, the pipeline step is marked complete.

func (*Migration) Run

func (r *Migration) Run() (reQ time.Duration, err error)

Run the migration.

func (*Migration) SetPopulatorDataSourceLabels

func (r *Migration) SetPopulatorDataSourceLabels()

func (*Migration) Type

func (r *Migration) Type() string

Type of migration.

type MigrationPredicate

type MigrationPredicate struct {
	predicate.TypedFuncs[*api.Migration]
}

func (MigrationPredicate) Create

func (MigrationPredicate) Delete

func (MigrationPredicate) Generic

func (MigrationPredicate) Update

type NetMapPredicate

type NetMapPredicate struct {
	predicate.TypedFuncs[*api.NetworkMap]
}

func (NetMapPredicate) Create

func (NetMapPredicate) Delete

func (NetMapPredicate) Generic

func (NetMapPredicate) Update

type OpenPort

type OpenPort struct {
	// valid values are tcp, udp, sctp, icmp
	Protocol string `yaml:"protocol"`
	Port     int    `yaml:"port,omitempty"`
}

For the User Defined Networks we need to open some port so we can communicate with our metrics server inside the User Defined Network Namespace. Docs: https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/multiple_networks/primary-networks#opening-default-network-ports-udn_about-user-defined-networks

type PlanPredicate

type PlanPredicate struct {
	predicate.TypedFuncs[*api.Plan]
}

func (PlanPredicate) Create

func (PlanPredicate) Delete

func (PlanPredicate) Update

type ProviderPredicate

type ProviderPredicate struct {
	handler.WatchManager
	predicate.TypedFuncs[*api.Provider]
	// contains filtered or unexported fields
}

Provider watch predicate. Also ensures an inventory watch is created and associated with the channel source.

func (*ProviderPredicate) Create

Provider created event.

func (*ProviderPredicate) Delete

Provider deleted event.

func (*ProviderPredicate) Generic

Generic provider watch event.

func (*ProviderPredicate) Update

Provider updated event.

type Reconciler

type Reconciler struct {
	base.Reconciler
}

Reconciles a Plan object.

func (*Reconciler) IsValidNetworkNameTemplate

func (r *Reconciler) IsValidNetworkNameTemplate(networkNameTemplate string) error

func (*Reconciler) IsValidTargetName

func (r *Reconciler) IsValidTargetName(targetName string) error

func (*Reconciler) IsValidTemplate

func (r *Reconciler) IsValidTemplate(templateStr string, testData interface{}) (string, error)

func (*Reconciler) IsValidVolumeNameTemplate

func (r *Reconciler) IsValidVolumeNameTemplate(volumeNameTemplate string) error

func (Reconciler) Reconcile

func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (result reconcile.Result, err error)

Reconcile a Plan CR. Note: Must not a pointer receiver to ensure that the logger and other state is not shared.

type VirtualMachine

type VirtualMachine struct {
	*cnv.VirtualMachine
	DataVolumes []ExtendedDataVolume
}

Represents Kubevirt VirtualMachine with associated DataVolumes.

func (*VirtualMachine) Conditions

func (r *VirtualMachine) Conditions() (cnd *libcnd.Conditions)

Get conditions.

func (*VirtualMachine) Owner

func (r *VirtualMachine) Owner(dv *cdi.DataVolume) bool

Determine if `this` VirtualMachine is the owner of the CDI DataVolume.

type VirtualMachineMap

type VirtualMachineMap map[string]VirtualMachine

Map of VirtualMachines keyed by vmID.

Jump to

Keyboard shortcuts

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