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

Fix --memory flag parsing in minikube start #9033

Merged
merged 1 commit into from
Aug 20, 2020
Merged

Fix --memory flag parsing in minikube start #9033

merged 1 commit into from
Aug 20, 2020

Conversation

vixus0
Copy link
Contributor

@vixus0 vixus0 commented Aug 19, 2020

Fixes #9017. Due to the way Go handles variable scope, mem was being redeclared inside the conditional. Outside, we were stuck with the value provided by suggestMemoryAllocation, therefore ignoring the value passed through the --memory flag.

Output of minikube start with the fix:

# minikube start --memory=2g --driver=kvm2
😄  minikube v1.12.3 on Ubuntu 18.04
✨  Using the kvm2 driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🔥  Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...

# minikube start --memory=8g --driver=kvm2
😄  minikube v1.12.3 on Ubuntu 18.04
✨  Using the kvm2 driver based on user configuration
👍  Starting control plane node minikube in cluster minikube
🔥  Creating kvm2 VM (CPUs=2, Memory=8192MB, Disk=20000MB) ...

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. 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 19, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @vixus0. 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 k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 19, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vixus0
To complete the pull request process, please assign priyawadhwa
You can assign the PR to them by writing /assign @priyawadhwa 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 removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Aug 19, 2020
@TravisBuddy
Copy link

Travis tests have failed

Hey @vixus0,
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.14.6.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.3/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.14.6.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.3/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
MINIKUBE_LDFLAGS="-X k8s.io/minikube/pkg/version.version=v1.12.3 -X k8s.io/minikube/pkg/version.isoVersion=v1.12.2 -X k8s.io/minikube/pkg/version.isoPath=minikube/iso -X k8s.io/minikube/pkg/version.gitCommitID="25a29054da4f96f92115d662c0872edff1691c15" -X k8s.io/minikube/pkg/version.storageProvisionerVersion=v2" ./test.sh
= make lint =============================================================
golangci/golangci-lint info checking GitHub for tag 'v1.29.0'
golangci/golangci-lint info found version: 1.29.0 for v1.29.0/linux/amd64
golangci/golangci-lint info installed out/linters/golangci-lint
cmd/minikube/cmd/start_flags.go:230: File is not `goimports`-ed (goimports)
      var err error
Makefile:408: recipe for target 'lint-ci' failed
make[1]: *** [lint-ci] Error 1
= go mod ================================================================
unused golang.org/x/exp
ok
= boilerplate ===========================================================
ok
Makefile:292: recipe for target 'test' failed
make: *** [test] Error 4
TravisBuddy Request Identifier: 0ed2c5b0-e21b-11ea-81c3-ef1e647c3fbd

@TravisBuddy
Copy link

Travis tests have failed

Hey @vixus0,
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.14.6.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.3/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.14.6.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.3/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
MINIKUBE_LDFLAGS="-X k8s.io/minikube/pkg/version.version=v1.12.3 -X k8s.io/minikube/pkg/version.isoVersion=v1.12.2 -X k8s.io/minikube/pkg/version.isoPath=minikube/iso -X k8s.io/minikube/pkg/version.gitCommitID="bbcf0aa9b03e11f0ceed9203f171791ad6104e6d" -X k8s.io/minikube/pkg/version.storageProvisionerVersion=v2" ./test.sh
= make lint =============================================================
golangci/golangci-lint info checking GitHub for tag 'v1.29.0'
golangci/golangci-lint info found version: 1.29.0 for v1.29.0/linux/amd64
golangci/golangci-lint info installed out/linters/golangci-lint
cmd/minikube/cmd/start_flags.go:230: File is not `goimports`-ed (goimports)
      var err error
Makefile:408: recipe for target 'lint-ci' failed
make[1]: *** [lint-ci] Error 1
= go mod ================================================================
unused golang.org/x/exp
ok
= boilerplate ===========================================================
ok
Makefile:292: recipe for target 'test' failed
make: *** [test] Error 4
TravisBuddy Request Identifier: 3e821bd0-e21b-11ea-81c3-ef1e647c3fbd

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

thank you very much @vixus0 for fixing this bug, do you mind sharing the output of After this PR in the description?

also would u please run "make lint" and address the lint issue?

@vixus0
Copy link
Contributor Author

vixus0 commented Aug 19, 2020

@medyagh I've updated the description, I hope that works. When I tried make lint I get the following:

./out/linters/golangci-lint-v1.29.0 run --timeout 7m --build-tags "integration container_image_ostree_stub containers_image_openpgp go_getter_nos3 go_getter_nogcs" --enable goimports,gocritic,golint,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled --exclude 'variable on range scope.*in function literal|ifElseChain' --skip-files "pkg/minikube/translate/translations.go|pkg/minikube/assets/assets.go" ./...
ERRO Running error: context loading failed: no go files to analyze
make: *** [Makefile:402: lint] Error 5

@tstromberg
Copy link
Contributor

@vixus0 - You should be able to fix the lint error by running goimports -w cmd/minikube/cmd/start_flags.go

@tstromberg
Copy link
Contributor

Odd that make lint fails on your machine. I cut & paste the same command you output on my own and it functioned properly.

We do have an alternative linter in the Makefile, but it does raise a few other issues that would not be related to your PR: make golint

@medyagh
Copy link
Member

medyagh commented Aug 19, 2020

@medyagh I've updated the description, I hope that works. When I tried make lint I get the following:

= make lint =============================================================
golangci/golangci-lint info checking GitHub for tag 'v1.29.0'
golangci/golangci-lint info found version: 1.29.0 for v1.29.0/linux/amd64
golangci/golangci-lint info installed out/linters/golangci-lint
cmd/minikube/cmd/start_flags.go:230: File is not `goimports`-ed (goimports)
      var err error
Makefile:408: recipe for target 'lint-ci' failed
make[1]: *** [lint-ci] Error 1

you can fix that by

goimports -w cmd/minikube/cmd/start_flags.go

Due to the way Go handles variable scope, `mem` was being
redeclared inside the conditional. Outside, we were stuck with the value
provided by `suggestMemoryAllocation`, therefore ignoring the value
passed through the `--memory` flag.
@vixus0
Copy link
Contributor Author

vixus0 commented Aug 20, 2020

@medyagh lint issue should be fixed. Still couldn't get make lint to work, but the goimports -w sorted the indentation.

@ThisGuyCodes
Copy link

any timeline on another point release to get this fix out?

@tstromberg
Copy link
Contributor

tstromberg commented Aug 31, 2020

@ThisGuyCodes v1.13.0 will be released this week.

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

minikube start --memory flag is broken in v1.12.3
7 participants