Skip to content
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

Merged
merged 3 commits into from
Sep 25, 2023

Conversation

rawdaGastan
Copy link
Contributor

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)
Copy link
Collaborator

@xmonader xmonader Sep 17, 2023

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

Copy link
Collaborator

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

Copy link
Member

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

Copy link
Member

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 Show resolved Hide resolved
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)
Copy link
Member

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)
Copy link
Member

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

@muhamadazmy muhamadazmy merged commit aa6efe6 into main Sep 25, 2023
2 checks passed
@muhamadazmy muhamadazmy deleted the main_max_available_cpus branch September 25, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants