controllers

package
v0.28.0-patch1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual

func DeepEqual(v1, v2 interface{}) bool

func MemslotIdxFromName added in v0.22.0

func MemslotIdxFromName(name string) (int, error)

MemslotIdxFromName takes "/objects/memslot3" or "memslot3 and returns 3

func QmpAddMemoryBackend added in v0.22.0

func QmpAddMemoryBackend(mon QMPRunner, idx int, sizeBytes int64) error

QmpAddMemoryBackend adds a single memory slot to the VM with the given size.

The memory slot does nothing until a corresponding "device" is added to the VM for the same memory slot. See QmpAddMemoryDevice for more. When unplugging, QmpDelMemoryDevice must be called before QmpDelMemoryBackend.

func QmpAddMemoryDevice added in v0.22.0

func QmpAddMemoryDevice(mon *qmp.SocketMonitor, idx int) error

func QmpAddr added in v0.17.3

func QmpAddr(vm *vmv1.VirtualMachine) (ip string, port int32)

func QmpCancelMigration added in v0.11.0

func QmpCancelMigration(ip string, port int32) error

func QmpConnect

func QmpConnect(ip string, port int32) (*qmp.SocketMonitor, error)

func QmpDelMemoryBackend added in v0.22.0

func QmpDelMemoryBackend(mon *qmp.SocketMonitor, idx int) error

func QmpDelMemoryDevice added in v0.22.0

func QmpDelMemoryDevice(mon *qmp.SocketMonitor, idx int) error

func QmpGetCpus

func QmpGetCpus(ip string, port int32) ([]QmpCpuSlot, []QmpCpuSlot, error)

func QmpGetMemorySize

func QmpGetMemorySize(ip string, port int32) (*resource.Quantity, error)

func QmpPlugCpu

func QmpPlugCpu(ip string, port int32) error

func QmpQueryMemoryBackendIds added in v0.22.0

func QmpQueryMemoryBackendIds(mon *qmp.SocketMonitor) (map[int]struct{}, error)

func QmpQuit

func QmpQuit(ip string, port int32) error

func QmpSetMemorySlots added in v0.22.0

func QmpSetMemorySlots(
	ctx context.Context,
	vm *vmv1.VirtualMachine,
	targetCnt int,
	recorder record.EventRecorder,
) (int, error)

QmpSetMemorySlots attempts to plug/unplug memory slots to match targetCnt.

Returns the number of slots, which the function managed to plug. Ideally, it matches targetCnt, but can be less or more if there are errors.

Returns -1 if failed to father current state of memory, otherwise, the return value is valid even if there are errors.

In order for the hotplug to occur, we have to do two things: 1. Plug memory backend (memslot<n>) - a QEMU object, which physically allocates the memory from host 2. Plug DIMM device (dimm<n>) - a device, which exposes the memory to the host. dimm<n> is always plugged into memslot<n> with the same n.

In order to do hotunplug, we need to make the same actions in the reversed order.

func QmpStartMigration

func QmpStartMigration(virtualmachine *vmv1.VirtualMachine, virtualmachinemigration *vmv1.VirtualMachineMigration) error

func QmpSyncCpuToTarget added in v0.11.0

func QmpSyncCpuToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error

func QmpSyncMemoryToTarget added in v0.11.0

func QmpSyncMemoryToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error

func QmpUnplugCpu

func QmpUnplugCpu(ip string, port int32) error

Types

type MigrationInfo

type MigrationInfo struct {
	Status      string `json:"status"`
	TotalTimeMs int64  `json:"total-time"`
	SetupTimeMs int64  `json:"setup-time"`
	DowntimeMs  int64  `json:"downtime"`
	Ram         struct {
		Transferred    int64 `json:"transferred"`
		Remaining      int64 `json:"remaining"`
		Total          int64 `json:"total"`
		Duplicate      int64 `json:"duplicate"`
		Normal         int64 `json:"normal"`
		NormalBytes    int64 `json:"normal-bytes"`
		DirtySyncCount int64 `json:"dirty-sync-count"`
	} `json:"ram"`
	Compression struct {
		CompressedSize  int64   `json:"compressed-size"`
		CompressionRate float64 `json:"compression-rate"`
	} `json:"compression"`
}

func QmpGetMigrationInfo

func QmpGetMigrationInfo(ip string, port int32) (*MigrationInfo, error)

type QMPRunner added in v0.22.0

type QMPRunner interface {
	Run([]byte) ([]byte, error)
}

type QmpCpuSlot

type QmpCpuSlot struct {
	Core int32  `json:"core"`
	QOM  string `json:"qom"`
	Type string `json:"type"`
}

type QmpCpus

type QmpCpus struct {
	Return []struct {
		Props struct {
			CoreId   int32 `json:"core-id"`
			ThreadId int32 `json:"thread-id"`
			SocketId int32 `json:"socket-id"`
		} `json:"props"`
		VcpusCount int32   `json:"vcpus-count"`
		QomPath    *string `json:"qom-path"`
		Type       string  `json:"type"`
	} `json:"return"`
}

type QmpMemoryDevice

type QmpMemoryDevice struct {
	Type string `json:"type"`
	Data struct {
		Memdev       string `json:"memdev"`
		Hotplugged   bool   `json:"hotplugged"`
		Addr         int64  `json:"addr"`
		Hotplugguble bool   `json:"hotpluggable"`
		Size         int64  `json:"size"`
		Slot         int64  `json:"slot"`
		Node         int64  `json:"node"`
		Id           string `json:"id"`
	} `json:"data"`
}

func QmpMonQueryMemoryDevices added in v0.22.0

func QmpMonQueryMemoryDevices(mon *qmp.SocketMonitor) ([]QmpMemoryDevice, error)

func QmpQueryMemoryDevices

func QmpQueryMemoryDevices(ip string, port int32) ([]QmpMemoryDevice, error)

type QmpMemoryDevices

type QmpMemoryDevices struct {
	Return []QmpMemoryDevice `json:"return"`
}

type QmpMemorySetter added in v0.22.0

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

func (*QmpMemorySetter) AddBackends added in v0.22.0

func (r *QmpMemorySetter) AddBackends()

func (*QmpMemorySetter) AddDevices added in v0.22.0

func (r *QmpMemorySetter) AddDevices()

func (*QmpMemorySetter) Disconnect added in v0.22.0

func (r *QmpMemorySetter) Disconnect()

func (*QmpMemorySetter) RemoveBackends added in v0.22.0

func (r *QmpMemorySetter) RemoveBackends()

func (*QmpMemorySetter) RemoveDevices added in v0.22.0

func (r *QmpMemorySetter) RemoveDevices()

type QmpMemorySize

type QmpMemorySize struct {
	Return struct {
		BaseMemory    int64 `json:"base-memory"`
		PluggedMemory int64 `json:"plugged-memory"`
	} `json:"return"`
}

type QmpMigrationInfo

type QmpMigrationInfo struct {
	Return MigrationInfo `json:"return"`
}

type QmpObject added in v0.22.0

type QmpObject struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type QmpObjects added in v0.22.0

type QmpObjects struct {
	Return []QmpObject `json:"return"`
}

type ReconcileSnapshot added in v0.25.0

type ReconcileSnapshot struct {
	// ControllerName is the name of the controller: virtualmachine or virtualmachinemigration.
	ControllerName string `json:"controllerName"`

	// Failing is the list of objects currently failing to reconcile
	Failing []string `json:"failing"`
}

ReconcileSnapshot provides a glimpse into the current state of ongoing reconciles

This type is (transitively) returned by the controller's "dump state" HTTP endpoint, and exists to allow us to get deeper information on the metrics - we can't expose information for every VirtualMachine into the metrics (it'd be too high cardinality), but we *can* make it available when requested.

type ReconcilerConfig added in v0.24.0

type ReconcilerConfig struct {
	// IsK3s is true iff the cluster is running k3s nodes.
	//
	// This is required because - unlike the other most common kubernetes distributions - k3s
	// changes the location of the containerd socket.
	// There unfortunately does not appear to be a way to disable this behavior.
	IsK3s bool

	// UseContainerMgr, if true, enables using container-mgr for new VM runner pods.
	//
	// This is defined as a config option so we can do a gradual rollout of this change.
	UseContainerMgr bool

	MaxConcurrentReconciles int

	// QEMUDiskCacheSettings sets the values of the 'cache.*' settings used for QEMU disks.
	//
	// This field is passed to neonvm-runner as the `-qemu-disk-cache-settings` arg, and is directly
	// used in setting up the VM disks via QEMU's `-drive` flag.
	QEMUDiskCacheSettings string
}

ReconcilerConfig stores shared configuration for VirtualMachineReconciler and VirtualMachineMigrationReconciler.

type ReconcilerMetrics added in v0.23.0

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

func MakeReconcilerMetrics added in v0.23.0

func MakeReconcilerMetrics() ReconcilerMetrics

type ReconcilerWithMetrics added in v0.25.0

type ReconcilerWithMetrics interface {
	reconcile.Reconciler

	Snapshot() ReconcileSnapshot
}

ReconcilerWithMetrics is a Reconciler produced by WithMetrics that can return a snapshot of the state backing the metrics.

func WithMetrics added in v0.23.0

func WithMetrics(reconciler reconcile.Reconciler, rm ReconcilerMetrics, cntrlName string) ReconcilerWithMetrics

WithMetrics wraps a given Reconciler with metrics capabilities.

The returned reconciler also provides a way to get a snapshot of the state of ongoing reconciles, to see the data backing the metrics.

type VirtualMachineMigrationReconciler

type VirtualMachineMigrationReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Config   *ReconcilerConfig

	Metrics ReconcilerMetrics
}

VirtualMachineMigrationReconciler reconciles a VirtualMachineMigration object

func (*VirtualMachineMigrationReconciler) Reconcile

It is essential for the controller's reconciliation loop to be idempotent. By following the Operator pattern you will create Controllers which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime. and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. For further info: - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile

func (*VirtualMachineMigrationReconciler) SetupWithManager

SetupWithManager sets up the controller with the Manager. Note that the Pods will be also watched in order to ensure its desirable state on the cluster

type VirtualMachineReconciler

type VirtualMachineReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Config   *ReconcilerConfig

	Metrics ReconcilerMetrics `exhaustruct:"optional"`
}

VirtualMachineReconciler reconciles a VirtualMachine object

func (*VirtualMachineReconciler) Reconcile

It is essential for the controller's reconciliation loop to be idempotent. By following the Operator pattern you will create Controllers which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime. and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. For further info: - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile

func (*VirtualMachineReconciler) SetupWithManager

func (r *VirtualMachineReconciler) SetupWithManager(mgr ctrl.Manager) (ReconcilerWithMetrics, error)

SetupWithManager sets up the controller with the Manager. Note that the Runner Pod will be also watched in order to ensure its desirable state on the cluster

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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