Documentation ¶
Index ¶
- Constants
- func DeepEqual(v1, v2 interface{}) bool
- func MemslotIdxFromName(name string) (int, error)
- func QmpAddMemoryBackend(mon QMPRunner, idx int, sizeBytes int64) error
- func QmpAddMemoryDevice(mon *qmp.SocketMonitor, idx int) error
- func QmpAddr(vm *vmv1.VirtualMachine) (ip string, port int32)
- func QmpCancelMigration(ip string, port int32) error
- func QmpConnect(ip string, port int32) (*qmp.SocketMonitor, error)
- func QmpDelMemoryBackend(mon *qmp.SocketMonitor, idx int) error
- func QmpDelMemoryDevice(mon *qmp.SocketMonitor, idx int) error
- func QmpGetCpus(ip string, port int32) ([]QmpCpuSlot, []QmpCpuSlot, error)
- func QmpGetMemorySize(ip string, port int32) (*resource.Quantity, error)
- func QmpPlugCpu(ip string, port int32) error
- func QmpQueryMemoryBackendIds(mon *qmp.SocketMonitor) (map[int]struct{}, error)
- func QmpQuit(ip string, port int32) error
- func QmpSetMemorySlots(ctx context.Context, vm *vmv1.VirtualMachine, targetCnt int, ...) (int, error)
- func QmpSetVirtioMem(vm *vmv1.VirtualMachine, targetVirtioMemSize int64) (previous int64, _ error)
- func QmpStartMigration(virtualmachine *vmv1.VirtualMachine, ...) error
- func QmpSyncCpuToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error
- func QmpSyncMemoryToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error
- func QmpUnplugCpu(ip string, port int32) error
- type FailingRefresher
- type MigrationInfo
- type QMPRunner
- type QmpCpuSlot
- type QmpCpus
- type QmpMemoryDevice
- type QmpMemoryDevices
- type QmpMemorySetter
- type QmpMemorySize
- type QmpMigrationInfo
- type QmpObject
- type QmpObjects
- type ReconcileOutcome
- type ReconcileSnapshot
- type ReconcilerConfig
- type ReconcilerMetrics
- type ReconcilerWithMetrics
- type VMMigrationWebhook
- func (w *VMMigrationWebhook) Default(ctx context.Context, obj runtime.Object) error
- func (w *VMMigrationWebhook) SetupWithManager(mgr ctrl.Manager) error
- func (w *VMMigrationWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (w *VMMigrationWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (w *VMMigrationWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
- type VMReconciler
- type VMWebhook
- func (w *VMWebhook) Default(ctx context.Context, obj runtime.Object) error
- func (w *VMWebhook) SetupWithManager(mgr ctrl.Manager) error
- func (w *VMWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (w *VMWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
- func (w *VMWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
- type VirtualMachineMigrationReconciler
Constants ¶
const OutcomeLabel = "outcome"
Variables ¶
This section is empty.
Functions ¶
func MemslotIdxFromName ¶
MemslotIdxFromName takes "/objects/memslot3" or "memslot3 and returns 3
func QmpAddMemoryBackend ¶
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 ¶
func QmpAddMemoryDevice(mon *qmp.SocketMonitor, idx int) error
func QmpCancelMigration ¶
func QmpConnect ¶
func QmpConnect(ip string, port int32) (*qmp.SocketMonitor, error)
func QmpDelMemoryBackend ¶
func QmpDelMemoryBackend(mon *qmp.SocketMonitor, idx int) error
func QmpDelMemoryDevice ¶
func QmpDelMemoryDevice(mon *qmp.SocketMonitor, idx int) error
func QmpGetCpus ¶
func QmpGetCpus(ip string, port int32) ([]QmpCpuSlot, []QmpCpuSlot, error)
func QmpPlugCpu ¶
func QmpQueryMemoryBackendIds ¶
func QmpQueryMemoryBackendIds(mon *qmp.SocketMonitor) (map[int]struct{}, error)
func QmpSetMemorySlots ¶
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 QmpSetVirtioMem ¶
func QmpSetVirtioMem(vm *vmv1.VirtualMachine, targetVirtioMemSize int64) (previous int64, _ error)
QmpSetVirtioMem updates virtio-mem to the new target size, returning the previous target.
If the new target size is equal to the previous one, this function does nothing but query the target.
func QmpStartMigration ¶
func QmpStartMigration(virtualmachine *vmv1.VirtualMachine, virtualmachinemigration *vmv1.VirtualMachineMigration) error
func QmpSyncCpuToTarget ¶
func QmpSyncCpuToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error
func QmpSyncMemoryToTarget ¶
func QmpSyncMemoryToTarget(vm *vmv1.VirtualMachine, migration *vmv1.VirtualMachineMigration) error
func QmpUnplugCpu ¶
Types ¶
type FailingRefresher ¶
type FailingRefresher struct {
// contains filtered or unexported fields
}
FailingRefresher is a wrapper, which implements manager.Runnable
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 QmpCpuSlot ¶
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 ¶
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 ¶
type QmpMemorySetter struct {
// contains filtered or unexported fields
}
func (*QmpMemorySetter) AddBackends ¶
func (r *QmpMemorySetter) AddBackends()
func (*QmpMemorySetter) AddDevices ¶
func (r *QmpMemorySetter) AddDevices()
func (*QmpMemorySetter) Disconnect ¶
func (r *QmpMemorySetter) Disconnect()
func (*QmpMemorySetter) RemoveBackends ¶
func (r *QmpMemorySetter) RemoveBackends()
func (*QmpMemorySetter) RemoveDevices ¶
func (r *QmpMemorySetter) RemoveDevices()
type QmpMemorySize ¶
type QmpMigrationInfo ¶
type QmpMigrationInfo struct {
Return MigrationInfo `json:"return"`
}
type QmpObjects ¶
type QmpObjects struct {
Return []QmpObject `json:"return"`
}
type ReconcileOutcome ¶
type ReconcileOutcome string
const ( SuccessOutcome ReconcileOutcome = "success" FailureOutcome ReconcileOutcome = "failure" ConflictOutcome ReconcileOutcome = "conflict" )
type ReconcileSnapshot ¶
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"` // Conflicting is the list of objects currently failing to reconcile // due to a conflict Conflicting []string `json:"conflicting"` }
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 ¶
type ReconcilerConfig struct { // DisableRunnerCgroup, if true, disables running QEMU in a cgroup in new VM runner pods. // Fractional CPU scaling will continue to *pretend* to work, but it will not do anything in // practice. // // Under the hood, this results in passing -skip-cgroup-management and -enable-dummy-cpu-server // to neonvm-runner. DisableRunnerCgroup bool MaxConcurrentReconciles int // SkipUpdateValidationFor is the set of object names that we should ignore when doing webhook // update validation. SkipUpdateValidationFor map[types.NamespacedName]struct{} // 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 // DefaultMemoryProvider is the memory provider (dimm slots or virtio-mem) that will be used for // new VMs (or, when old ones restart) if nothing is explicitly set. DefaultMemoryProvider vmv1.MemoryProvider // MemhpAutoMovableRatio specifies the value that new neonvm-runners will set as the // kernel's 'memory_hotplug.auto_movable_ratio', iff the memory provider is virtio-mem. // // This value is passed directly to neonvm-runner as the '-memhp-auto-movable-ratio' flag. // We've confirmed sensible values are from 301 to 801 (i.e. 3.01:1 through 8.01:1). // The range of sensible values may extend further, but we have not tested that. MemhpAutoMovableRatio string // FailurePendingPeriod is the period for the propagation of // reconciliation failures to the observability instruments FailurePendingPeriod time.Duration // FailingRefreshInterval is the interval between consecutive // updates of metrics and logs, related to failing reconciliations FailingRefreshInterval time.Duration // AtMostOnePod is the flag that indicates whether we should only have one pod per VM. AtMostOnePod bool // DefaultCPUScalingMode is the default CPU scaling mode that will be used for VMs with empty spec.cpuScalingMode DefaultCPUScalingMode vmv1.CpuScalingMode }
ReconcilerConfig stores shared configuration for VirtualMachineReconciler and VirtualMachineMigrationReconciler.
type ReconcilerMetrics ¶
type ReconcilerMetrics struct {
// contains filtered or unexported fields
}
func MakeReconcilerMetrics ¶
func MakeReconcilerMetrics() ReconcilerMetrics
func (ReconcilerMetrics) ObserveReconcileDuration ¶
func (m ReconcilerMetrics) ObserveReconcileDuration( outcome ReconcileOutcome, duration time.Duration, )
type ReconcilerWithMetrics ¶
type ReconcilerWithMetrics interface { reconcile.Reconciler Snapshot() ReconcileSnapshot FailingRefresher() FailingRefresher }
ReconcilerWithMetrics is a Reconciler produced by WithMetrics that can return a snapshot of the state backing the metrics.
func WithMetrics ¶
func WithMetrics( reconciler reconcile.Reconciler, rm ReconcilerMetrics, cntrlName string, failurePendingPeriod time.Duration, refreshFailingInterval time.Duration, ) 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 VMMigrationWebhook ¶
type VMMigrationWebhook struct { Recorder record.EventRecorder Config *ReconcilerConfig }
func (*VMMigrationWebhook) SetupWithManager ¶
func (w *VMMigrationWebhook) SetupWithManager(mgr ctrl.Manager) error
func (*VMMigrationWebhook) ValidateCreate ¶
func (w *VMMigrationWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
ValidateCreate implements webhook.CustomValidator
func (*VMMigrationWebhook) ValidateDelete ¶
func (w *VMMigrationWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
ValidateDelete implements webhook.CustomValidator
func (*VMMigrationWebhook) ValidateUpdate ¶
func (w *VMMigrationWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error)
ValidateUpdate implements webhook.CustomValidator
type VMReconciler ¶
type VMReconciler struct { client.Client Scheme *runtime.Scheme Recorder record.EventRecorder Config *ReconcilerConfig Metrics ReconcilerMetrics `exhaustruct:"optional"` }
VMReconciler reconciles a VirtualMachine object
func (*VMReconciler) 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 (*VMReconciler) SetupWithManager ¶
func (r *VMReconciler) 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
type VMWebhook ¶
type VMWebhook struct { Recorder record.EventRecorder Config *ReconcilerConfig }
func (*VMWebhook) ValidateCreate ¶
func (w *VMWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error)
ValidateCreate implements webhook.CustomValidator
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 ¶
func (r *VirtualMachineMigrationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
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 ¶
func (r *VirtualMachineMigrationReconciler) SetupWithManager(mgr ctrl.Manager) (ReconcilerWithMetrics, error)
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