plan

package
v0.0.0-...-e73b65a Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 58 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 (
	// Transfer network annotation (value=network-attachment-definition name)
	AnnDefaultNetwork = "v1.multus-cni.io/default-network"
	// Causes the importer pod to be retained after import.
	AnnRetainAfterCompletion = "cdi.kubevirt.io/storage.pod.retainAfterCompletion"
	// 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"
	// DV deletion on completion
	AnnDeleteAfterCompletion = "cdi.kubevirt.io/storage.deleteAfterCompletion"
)

Annotations

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

Requeue

View Source
const (
	Started                  = "Started"
	PreHook                  = "PreHook"
	StorePowerState          = "StorePowerState"
	PowerOffSource           = "PowerOffSource"
	WaitForPowerOff          = "WaitForPowerOff"
	CreateDataVolumes        = "CreateDataVolumes"
	CreateVM                 = "CreateVM"
	ScheduleVM               = "ScheduleVM"
	CopyDisks                = "CopyDisks"
	CopyingPaused            = "CopyingPaused"
	AddCheckpoint            = "AddCheckpoint"
	AddFinalCheckpoint       = "AddFinalCheckpoint"
	CreateSnapshot           = "CreateSnapshot"
	CreateInitialSnapshot    = "CreateInitialSnapshot"
	CreateFinalSnapshot      = "CreateFinalSnapshot"
	Finalize                 = "Finalize"
	CreateGuestConversionPod = "CreateGuestConversionPod"
	ConvertGuest             = "ConvertGuest"
	PostHook                 = "PostHook"
	Completed                = "Completed"
	WaitForSnapshot          = "WaitForSnapshot"
	WaitForInitialSnapshot   = "WaitForInitialSnapshot"
	WaitForFinalSnapshot     = "WaitForFinalSnapshot"
)

Phases.

View Source
const (
	Initialize      = "Initialize"
	Cutover         = "Cutover"
	DiskTransfer    = "DiskTransfer"
	ImageConversion = "ImageConversion"
	Unknown         = "Unknown"
)

Steps.

View Source
const (
	WarmMigrationNotReady        = "WarmMigrationNotReady"
	NamespaceNotValid            = "NamespaceNotValid"
	TransferNetNotValid          = "TransferNetworkNotValid"
	NetRefNotValid               = "NetworkMapRefNotValid"
	NetMapNotReady               = "NetworkMapNotReady"
	DsMapNotReady                = "StorageMapNotReady"
	DsRefNotValid                = "StorageRefNotValid"
	VMRefNotValid                = "VMRefNotValid"
	VMNotFound                   = "VMNotFound"
	VMAlreadyExists              = "VMAlreadyExists"
	VMNetworksNotMapped          = "VMNetworksNotMapped"
	VMStorageNotMapped           = "VMStorageNotMapped"
	VMMultiplePodNetworkMappings = "VMMultiplePodNetworkMappings"
	HostNotReady                 = "HostNotReady"
	DuplicateVM                  = "DuplicateVM"
	NameNotValid                 = "TargetNameNotValid"
	HookNotValid                 = "HookNotValid"
	HookNotReady                 = "HookNotReady"
	HookStepNotValid             = "HookStepNotValid"
	Executing                    = "Executing"
	Succeeded                    = "Succeeded"
	Failed                       = "Failed"
	Canceled                     = "Canceled"
	Deleted                      = "Deleted"
	Paused                       = "Paused"
	Pending                      = "Pending"
	Running                      = "Running"
	Blocked                      = "Blocked"
	Archived                     = "Archived"
)

Types

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

Categories

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

Reasons

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

Statuses

View Source
const (
	// Name.
	Name = "plan"
)
View Source
const (
	On = "On"
)

Power states.

Variables

View Source
var (
	HasPreHook         libitr.Flag = 0x01
	HasPostHook        libitr.Flag = 0x02
	RequiresConversion libitr.Flag = 0x04
)

Predicates.

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 RequestForMigration

func RequestForMigration(a k8shandler.MapObject) (list []reconcile.Request)

Plan request for Migration.

Types

type DataVolume

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

Represents a CDI DataVolume and add behavior.

func (*DataVolume) Conditions

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

Get conditions.

func (*DataVolume) PercentComplete

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

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

type DsMapPredicate

type DsMapPredicate struct {
	predicate.Funcs
}

func (DsMapPredicate) Create

func (r DsMapPredicate) Create(e event.CreateEvent) bool

func (DsMapPredicate) Delete

func (r DsMapPredicate) Delete(e event.DeleteEvent) bool

func (DsMapPredicate) Generic

func (r DsMapPredicate) Generic(e event.GenericEvent) bool

func (DsMapPredicate) Update

func (r DsMapPredicate) Update(e event.UpdateEvent) bool

type HookPredicate

type HookPredicate struct {
	predicate.Funcs
}

func (HookPredicate) Create

func (r HookPredicate) Create(e event.CreateEvent) bool

func (HookPredicate) Delete

func (r HookPredicate) Delete(e event.DeleteEvent) bool

func (HookPredicate) Generic

func (r HookPredicate) Generic(e event.GenericEvent) bool

func (HookPredicate) Update

func (r HookPredicate) Update(e event.UpdateEvent) bool

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) 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) 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) DeleteImporterPod

func (r *KubeVirt) DeleteImporterPod(dv DataVolume) (err error)

Delete the importer pod for a DataVolume.

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) EnsureGuestConversionPod

func (r *KubeVirt) EnsureGuestConversionPod(vm *plan.VMStatus, vmCr *VirtualMachine) (err error)

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

func (*KubeVirt) EnsureNamespace

func (r *KubeVirt) EnsureNamespace() (err error)

Ensure the namespace exists on the destination.

func (*KubeVirt) EnsureVM

func (r *KubeVirt) EnsureVM(vm *plan.VMStatus) (err 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(dv DataVolume) (pod *core.Pod, found bool, err error)

Get the importer pod for a DataVolume.

func (*KubeVirt) ListVMs

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

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

func (*KubeVirt) SetRunning

func (r *KubeVirt) SetRunning(vmCr *VirtualMachine, running bool) (err error)

Set the Running state on a Kubevirt VirtualMachine.

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() (err error)

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

func (*Migration) CleanUp

func (r *Migration) CleanUp(vm *plan.VMStatus) (err error)

Delete left over migration resources associated with a VM.

func (*Migration) Run

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

Run the migration.

func (*Migration) Type

func (r *Migration) Type() string

Type of migration.

type MigrationPredicate

type MigrationPredicate struct {
	predicate.Funcs
}

func (MigrationPredicate) Create

func (MigrationPredicate) Delete

func (MigrationPredicate) Generic

func (MigrationPredicate) Update

type NetMapPredicate

type NetMapPredicate struct {
	predicate.Funcs
}

func (NetMapPredicate) Create

func (r NetMapPredicate) Create(e event.CreateEvent) bool

func (NetMapPredicate) Delete

func (r NetMapPredicate) Delete(e event.DeleteEvent) bool

func (NetMapPredicate) Generic

func (r NetMapPredicate) Generic(e event.GenericEvent) bool

func (NetMapPredicate) Update

func (r NetMapPredicate) Update(e event.UpdateEvent) bool

type PlanPredicate

type PlanPredicate struct {
	predicate.Funcs
}

func (PlanPredicate) Create

func (r PlanPredicate) Create(e event.CreateEvent) bool

func (PlanPredicate) Delete

func (r PlanPredicate) Delete(e event.DeleteEvent) bool

func (PlanPredicate) Update

func (r PlanPredicate) Update(e event.UpdateEvent) bool

type Predicate

type Predicate struct {
	// contains filtered or unexported fields
}

Step predicate.

func (*Predicate) Evaluate

func (r *Predicate) Evaluate(flag libitr.Flag) (allowed bool, err error)

Evaluate predicate flags.

type ProviderPredicate

type ProviderPredicate struct {
	handler.WatchManager
	predicate.Funcs
	// contains filtered or unexported fields
}

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

func (*ProviderPredicate) Create

func (r *ProviderPredicate) Create(e event.CreateEvent) bool

Provider created event.

func (*ProviderPredicate) Delete

func (r *ProviderPredicate) Delete(e event.DeleteEvent) bool

Provider deleted event.

func (*ProviderPredicate) Generic

func (r *ProviderPredicate) Generic(e event.GenericEvent) bool

Generic provider watch event.

func (*ProviderPredicate) Update

func (r *ProviderPredicate) Update(e event.UpdateEvent) bool

Provider updated event.

type Reconciler

type Reconciler struct {
	base.Reconciler
}

Reconciles a Plan object.

func (Reconciler) Reconcile

func (r Reconciler) Reconcile(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 []DataVolume
}

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.

func (*VirtualMachine) PercentComplete

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

Convert the combined progress of all DataVolumes into a percentage (float).

type VirtualMachineMap

type VirtualMachineMap map[string]VirtualMachine

Map of VirtualMachines keyed by vmID.

Directories

Path Synopsis
ocp

Jump to

Keyboard shortcuts

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