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

Minimum CPUs check #5086

Merged
merged 4 commits into from
Sep 5, 2019
Merged

Minimum CPUs check #5086

merged 4 commits into from
Sep 5, 2019

Conversation

MaxKam
Copy link
Contributor

@MaxKam MaxKam commented Aug 15, 2019

Closes #5010

Checks to make sure the number of cpus on host is not less than minimum required. Exits app and outputs error message if number is less than the minimum required.

@tstromberg

@k8s-ci-robot
Copy link
Contributor

Welcome @MaxKam!

It looks like this is your first PR to kubernetes/minikube 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/minikube has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 15, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @MaxKam. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MaxKam
To complete the pull request process, please assign afbjorklund
You can assign the PR to them by writing /assign @afbjorklund in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 15, 2019
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@RA489
Copy link

RA489 commented Aug 15, 2019

@minikube-bot OK to test

@@ -536,6 +536,11 @@ func validateConfig() {
out.V{"memory": memorySizeMB, "default_memorysize": pkgutil.CalculateSizeInMB(constants.DefaultMemorySize)})
}

cpuCount = viper.GetInt(cpus)
if cpuCount < constants.MinimumCPUS {
exit.UsageT("Requested cpu count {{.requested_cpus}} is less than the minimum allowed of {{.minimum_cpus}}", out.V{"requested_cpus": cpuCount, "minimum_cpus": constants.MinimumCPUS})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check looks great, but to fully resolve the issue, there is an additional complication: The none driver doesn't respect the value of --cpus, as it is not possible to programatically add a CPU to a physical machine.

This check will need an extra step, something like:

import "github.com/shirou/gopsutil/cpu"

if viper.GetString(vmDriver) == constants.DriverNone {
  ci, err := cpu.Info()
  if err == nil {
    glog.Warningf("Unable to get CPU info: %v", err)
  } else {
    cpuCount = ci.Cores
  }

For what it's worth, the memory check suffers the same issue, but I'm not sure what the appropriate API is to solve it, so I won't ask you to do so =)

Copy link
Collaborator

@afbjorklund afbjorklund Aug 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constants.MinimumCPUS

This should probably tie in with the Bootstrapper somehow ?

Since the requirement comes from kubeadm rather than k8s

https://github.com/kubernetes/kubernetes/blob/v1.15.2/cmd/kubeadm/app/constants/constants.go#L353

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstromberg Hows this? 1217054

@afbjorklund sorry I'm not quite sure what you want me to change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afbjorklund was remarking that our minimum memory and CPU core requirements may change in the future depending on the bootstrapper used. For instance, k3s won't require two cores.

I'm OK with deferring per-bootstrapper requirements until we have two with different requirements.

@RA489
Copy link

RA489 commented Aug 19, 2019

@minikube-bot OK to test

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 21, 2019
@tstromberg
Copy link
Contributor

make test appears to fail. Do you mind running it locally?

cmd/minikube/cmd/start.go:547:18: ci.Cores undefined (type []cpu.InfoStat has no field or method Cores) (typecheck)

			cpuCount = ci.Cores

@TravisBuddy
Copy link

Travis tests have failed

Hey @MaxKam,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

1st Build

View build log

make test
which go-bindata || GO111MODULE=off GOBIN=/home/travis/gopath/bin go get github.com/jteeuwen/go-bindata/...
PATH="/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.12.9.linux.amd64/bin:/home/travis/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.0/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin:/home/travis/gopath/bin" go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets deploy/addons/...
gofmt -s -w pkg/minikube/assets/assets.go
which go-bindata || GO111MODULE=off GOBIN=/home/travis/gopath/bin go get github.com/jteeuwen/go-bindata/...
/home/travis/gopath/bin/go-bindata
PATH="/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.12.9.linux.amd64/bin:/home/travis/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.0/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin:/home/travis/gopath/bin" go-bindata -nomemcopy -o pkg/minikube/translate/translations.go -pkg translate translations/...
gofmt -s -w pkg/minikube/translate/translations.go
./test.sh
= go mod ================================================================
ok
= make lint =============================================================
golangci/golangci-lint info checking GitHub for tag 'v1.17.1'
golangci/golangci-lint info found version: 1.17.1 for v1.17.1/linux/amd64
golangci/golangci-lint info installed out/linters/golangci-lint
cmd/minikube/cmd/start.go:39: File is not `goimports`-ed (goimports)
	"github.com/google/go-containerregistry/pkg/v1/remote"
test/integration/a_download_only_test.go:68:35: GetKubeadmCachedBinaries not declared by package constants (typecheck)
				for _, bin := range constants.GetKubeadmCachedBinaries() {
				                              ^
Makefile:323: recipe for target 'lint-ci' failed
make[1]: *** [lint-ci] Error 1
= boilerplate ===========================================================
ok
= schema_check ==========================================================
ok
= go test ===============================================================
ok  	k8s.io/minikube/cmd/minikube/cmd	0.059s	coverage: 15.6% of statements
ok  	k8s.io/minikube/cmd/minikube/cmd/config	0.042s	coverage: 18.9% of statements
ok  	k8s.io/minikube/pkg/drivers	0.012s	coverage: 19.6% of statements
ok  	k8s.io/minikube/pkg/drivers/kvm	0.028s	coverage: 2.3% of statements
ok  	k8s.io/minikube/pkg/minikube/assets	0.037s	coverage: 61.8% of statements
ok  	k8s.io/minikube/pkg/minikube/bootstrapper	2.781s	coverage: 72.9% of statements
ok  	k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm	0.073s	coverage: 29.5% of statements
ok  	k8s.io/minikube/pkg/minikube/cluster	0.290s	coverage: 54.2% of statements
ok  	k8s.io/minikube/pkg/minikube/config	0.028s	coverage: 76.0% of statements
ok  	k8s.io/minikube/pkg/minikube/cruntime	0.008s	coverage: 62.4% of statements
ok  	k8s.io/minikube/pkg/minikube/extract	0.007s	coverage: 56.7% of statements
ok  	k8s.io/minikube/pkg/minikube/kubeconfig	0.049s	coverage: 75.6% of statements
ok  	k8s.io/minikube/pkg/minikube/logs	0.031s	coverage: 1.5% of statements
ok  	k8s.io/minikube/pkg/minikube/machine	0.050s	coverage: 12.0% of statements
ok  	k8s.io/minikube/pkg/minikube/notify	0.025s	coverage: 77.8% of statements
ok  	k8s.io/minikube/pkg/minikube/out	0.010s	coverage: 70.3% of statements
ok  	k8s.io/minikube/pkg/minikube/problem	0.005s	coverage: 42.9% of statements
ok  	k8s.io/minikube/pkg/minikube/proxy	0.013s	coverage: 67.3% of statements
ok  	k8s.io/minikube/pkg/minikube/registry	0.013s	coverage: 81.8% of statements
ok  	k8s.io/minikube/pkg/minikube/service	0.042s	coverage: 35.9% of statements
ok  	k8s.io/minikube/pkg/minikube/sshutil	0.456s	coverage: 75.0% of statements
ok  	k8s.io/minikube/pkg/minikube/translate	0.005s	coverage: 8.4% of statements
ok  	k8s.io/minikube/pkg/minikube/tunnel	2.074s	coverage: 64.5% of statements
ok  	k8s.io/minikube/pkg/util	1.152s	coverage: 61.6% of statements
ok  	k8s.io/minikube/pkg/util/retry	0.002s	coverage: 0.0% of statements
ok
Makefile:229: recipe for target 'test' failed
make: *** [test] Error 4
TravisBuddy Request Identifier: 56b8c8d0-c510-11e9-8712-75d78f9b457f

Gopsutil packae doesn't automatically return a count of CPU cores, have to use
the Counts function.
@MaxKam
Copy link
Contributor Author

MaxKam commented Sep 2, 2019

@tstromberg make test is passing for me now.

@sharifelgamal sharifelgamal merged commit ba2f931 into kubernetes:master Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

none: the number of available CPUs 1 is less than the required 2
8 participants