From 71cb0f7cecabd24a427f1a382d650ce364058e8e Mon Sep 17 00:00:00 2001 From: notpranavunsw <118208399+notpranavunsw@users.noreply.github.com> Date: Tue, 30 Apr 2024 19:07:41 -0500 Subject: [PATCH] return error if user requestes cpus exceeds hardware cpus Signed-off-by: notpranavunsw <118208399+notpranavunsw@users.noreply.github.com> ran linter Signed-off-by: notpranavunsw <118208399+notpranavunsw@users.noreply.github.com> --- pkg/limayaml/validate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go index d0a76ff1250..96232f0e825 100644 --- a/pkg/limayaml/validate.go +++ b/pkg/limayaml/validate.go @@ -108,6 +108,10 @@ func Validate(y LimaYAML, warn bool) error { return errors.New("field `cpus` must be set") } + if *y.CPUs > runtime.NumCPU() { + return fmt.Errorf("field `cpus` is set to %d, which is greater than the number of CPUs available (%d)", *y.CPUs, runtime.NumCPU()) + } + if _, err := units.RAMInBytes(*y.Memory); err != nil { return fmt.Errorf("field `memory` has an invalid value: %w", err) }