From 991ba87c63090fbc6e7992d059c09891067cdb9b Mon Sep 17 00:00:00 2001 From: Misha Sakhnov Date: Mon, 28 Oct 2024 12:49:22 +0100 Subject: [PATCH] neonvm-controller: make spec.cpuScalingMode immutable if already set Signed-off-by: Misha Sakhnov --- neonvm/apis/neonvm/v1/virtualmachine_webhook.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neonvm/apis/neonvm/v1/virtualmachine_webhook.go b/neonvm/apis/neonvm/v1/virtualmachine_webhook.go index 3d965a2fe..c129e7cdc 100644 --- a/neonvm/apis/neonvm/v1/virtualmachine_webhook.go +++ b/neonvm/apis/neonvm/v1/virtualmachine_webhook.go @@ -145,6 +145,11 @@ func (r *VirtualMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, } } + // allow to change CPU scaling mode only if it's not set + if r.Spec.CpuScalingMode != nil && before.Spec.CpuScalingMode != nil && *r.Spec.CpuScalingMode != *before.Spec.CpuScalingMode { + return nil, fmt.Errorf(".spec.cpuScalingMode is immutable") + } + // validate .spec.guest.cpu.use if r.Spec.Guest.CPUs.Use < r.Spec.Guest.CPUs.Min { return nil, fmt.Errorf(".cpus.use (%v) should be greater than or equal to the .cpus.min (%v)",