Skip to content

Commit

Permalink
neonvm-controller: make spec.cpuScalingMode immutable if already set
Browse files Browse the repository at this point in the history
Signed-off-by: Misha Sakhnov <[email protected]>
  • Loading branch information
mikhail-sakhnov committed Oct 31, 2024
1 parent 97ff1f7 commit 991ba87
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions neonvm/apis/neonvm/v1/virtualmachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit 991ba87

Please sign in to comment.