-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate cpus according to actual number of node cpus #2057
Conversation
pkg/vm.go
Outdated
@@ -175,8 +176,16 @@ func (vm *VM) Validate() error { | |||
return fmt.Errorf("invalid memory must not be less than 250M") | |||
} | |||
|
|||
if vm.CPU == 0 || vm.CPU > 32 { | |||
return fmt.Errorf("invalid cpu must be between 1 and 32") | |||
n, err := cpu.Counts(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use runtime.NumCPU? https://pkg.go.dev/runtime#NumCPU, if so, let's not introduce a new dependency like gopsutil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n -> numCpus or ncpus or cpus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use runtime.NumCPU? https://pkg.go.dev/runtime#NumCPU, if so, let's not introduce a new dependency like gopsutil
this is not the same, according to the docs, the runtime.NumCPU is logical number of cpus that can be used by the current
process. this is a totally Go runtime thing, not related to the total number of CPUs available on the system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But should definitely rename the variable from n
to something else
pkg/vm.go
Outdated
@@ -175,8 +176,16 @@ func (vm *VM) Validate() error { | |||
return fmt.Errorf("invalid memory must not be less than 250M") | |||
} | |||
|
|||
if vm.CPU == 0 || vm.CPU > 32 { | |||
return fmt.Errorf("invalid cpu must be between 1 and 32") | |||
n, err := cpu.Counts(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use runtime.NumCPU? https://pkg.go.dev/runtime#NumCPU, if so, let's not introduce a new dependency like gopsutil
this is not the same, according to the docs, the runtime.NumCPU is logical number of cpus that can be used by the current
process. this is a totally Go runtime thing, not related to the total number of CPUs available on the system
pkg/vm.go
Outdated
@@ -175,8 +176,16 @@ func (vm *VM) Validate() error { | |||
return fmt.Errorf("invalid memory must not be less than 250M") | |||
} | |||
|
|||
if vm.CPU == 0 || vm.CPU > 32 { | |||
return fmt.Errorf("invalid cpu must be between 1 and 32") | |||
n, err := cpu.Counts(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But should definitely rename the variable from n
to something else
Issues