Skip to content

Commit

Permalink
return error if user requestes cpus exceeds hardware cpus
Browse files Browse the repository at this point in the history
Signed-off-by: notpranavunsw <[email protected]>

ran linter

Signed-off-by: notpranavunsw <[email protected]>
  • Loading branch information
NotPranav0 committed May 1, 2024
1 parent 377d685 commit 71cb0f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/limayaml/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 71cb0f7

Please sign in to comment.