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

Add hyperkit version check whether user's hyperkit is newer #5833

Merged
merged 4 commits into from
Dec 19, 2019
Merged

Add hyperkit version check whether user's hyperkit is newer #5833

merged 4 commits into from
Dec 19, 2019

Conversation

govargo
Copy link
Contributor

@govargo govargo commented Nov 5, 2019

What type of PR is this?

/kind bug

What this PR does / why we need it:

(Updated 2019/11/11)
I removed point1 of the PR due to duplication of #5840.

#### 1. FastFail if driver error occurres.

So far, even if driver error occurres(like not installed) minikube keeps to starting VM when minikube start.
Of course this finish with failure.
This PR fix this behaviour.
If driver error occurres, minikube stop starting VM(minikube exits).

2. Add version check of hyperkit which inspect user's hyperkit is newer than specific version

If hyperkit's version is older than expected, minikube start(hyperkit) will fail due to version.
Related Issue #5594, #5780

This PR add suggestion about hyperkit upgrade information, if user's hyperkit version is older than expected.

Which issue(s) this PR fixes:

Fixes #5478, #5821

Does this PR introduce a user-facing change?

Yes. This PR add hyperkit version check to minikube start command and FastFail if driver error occurres.
Yes. This PR add hyperkit version check to minikube start command.

(Removed FastFail due to duplication of #5840)


**Before this PR, minikube keeps to starting VM(but keep tp failing) **

$ minikube start --vm-driver=hyperkit
😄  minikube v1.5.1 on Darwin 10.14.5

⚠️  'hyperkit' driver reported a possible issue: exec: "hyperkit": executable file not found in $PATH
💡  Suggestion: Run 'brew install hyperkit'
📘  Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/

💾  Downloading driver docker-machine-driver-hyperkit:
    > docker-machine-driver-hyperkit.sha256: 65 B / 65 B [---] 100.00% ? p/s 0s
    > docker-machine-driver-hyperkit: 10.79 MiB / 10.79 MiB  100.00% 4.57 MiB p
🔑  The 'hyperkit' driver requires elevated permissions. The following commands will be executed:

    $ sudo chown root:wheel /Users/k-iso/.minikube/bin/docker-machine-driver-hyperkit
    $ sudo chmod u+s /Users/k-iso/.minikube/bin/docker-machine-driver-hyperkit


Password:
💿  Downloading VM boot image ...
    > minikube-v1.5.1.iso.sha256: 65 B / 65 B [--------------] 100.00% ? p/s 0s
    > minikube-v1.5.1.iso: 143.76 MiB / 143.76 MiB [-] 100.00% 64.66 MiB p/s 3s
🔥  Creating hyperkit VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🔄  Retriable failure: create: Error creating machine: Error in driver during machine creation: new-ing Hyperkit: Could not find hyperkit executable
🔥  Deleting "minikube" in hyperkit ...
🔥  Creating hyperkit VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🔄  Retriable failure: create: Error creating machine: Error in driver during machine creation: new-ing Hyperkit: Could not find hyperkit executable
🔥  Deleting "minikube" in hyperkit ...
🔥  Creating hyperkit VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🔄  Retriable failure: create: Error creating machine: Error in driver during machine creation: new-ing Hyperkit: Could not find hyperkit executable
🔥  Deleting "minikube" in hyperkit ...
🔥  Creating hyperkit VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🔄  Retriable failure: create: Error creating machine: Error in driver during machine creation: new-ing Hyperkit: Could not find hyperkit executable
🔥  Deleting "minikube" in hyperkit ...

💣  Unable to start VM: create: Error creating machine: Error in driver during machine creation: new-ing Hyperkit: Could not find hyperkit executable

😿  Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
👉  https://github.com/kubernetes/minikube/issues/new/choose

After this PR, minikube fail fast

$ minikube start --vm-driver=hyperkit
😄  minikube v1.5.1 on Darwin 10.14.5

⚠️  'hyperkit' driver reported a possible issue: exec: "hyperkit": executable file not found in $PATH
💡  Suggestion: Run 'brew install hyperkit'
📘  Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/

After this PR, minikube checks user's hyperkit version

If user's hyperkit current version is 0.20180621 and specific version is 0.20190201, minikube suggests hyperkit upgrade information.

$ minikube start --vm-driver=hyperkit
😄  minikube v1.5.2 on Darwin 10.14.5

⚠️   'hyperkit' driver reported a possible issue: the installed hyperkit version (0.20180621) is older than the minimum recommended version (0.20191201)
💡  Suggestion: Run 'brew upgrade hyperkit'
📘  Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/

💾  Downloading driver docker-machine-driver-hyperkit:
    > docker-machine-driver-hyperkit.sha256: 65 B / 65 B [---] 100.00% ? p/s 0s
    > docker-machine-driver-hyperkit: 10.79 MiB / 10.79 MiB  100.00% 6.34 MiB p
🔑  The 'hyperkit' driver requires elevated permissions. The following commands will be executed:

    $ sudo chown root:wheel /Users/k-iso/.minikube/bin/docker-machine-driver-hyperkit
    $ sudo chmod u+s /Users/k-iso/.minikube/bin/docker-machine-driver-hyperkit


Password:
💿  Downloading VM boot image ...
    > minikube-v1.5.1.iso.sha256: 65 B / 65 B [--------------] 100.00% ? p/s 0s
    > minikube-v1.5.1.iso: 143.76 MiB / 143.76 MiB [-] 100.00% 17.73 MiB p/s 8s
🔥  Creating hyperkit VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...
💾  Downloading kubeadm v1.16.2
💾  Downloading kubelet v1.16.2
🚜  Pulling images ...
🚀  Launching Kubernetes ...
⌛  Waiting for: apiserver
🏄  Done! kubectl is now configured to use "minikube"

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 5, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @govargo. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 5, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: govargo
To complete the pull request process, please assign tstromberg
You can assign the PR to them by writing /assign @tstromberg 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

@govargo
Copy link
Contributor Author

govargo commented Nov 5, 2019

/assign @tstromberg

/cc @medyagh

@govargo govargo changed the title Fix without hyperkit errormsg Fix FastFail if driver error occured & Add hyperkit version check Nov 5, 2019
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 5, 2019
Makefile Outdated
@@ -24,6 +24,8 @@ ISO_VERSION ?= v$(VERSION_MAJOR).$(VERSION_MINOR).1
# Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta
DEB_VERSION ?= $(subst -,~,$(RAW_VERSION))
RPM_VERSION ?= $(DEB_VERSION)
# used by hyperkit versionCheck(whether user's hyperkit is older than this)
HYPERKIT_VERSION ?= 0.20190201
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this is the best place to store the mininum required hyperkit version

Copy link
Member

Choose a reason for hiding this comment

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

I think a better place for this is in the package itself as a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this constant.
Makefile(& pkg/version/version.go) → pkg/minikube/registry/drvs/hyperkit.go

cmd/minikube/cmd/start.go Outdated Show resolved Hide resolved
pkg/minikube/registry/drvs/hyperkit/hyperkit.go Outdated Show resolved Hide resolved
cmd/minikube/cmd/start.go Outdated Show resolved Hide resolved
currentVersionDate, err := time.Parse(layout, currentVersion)
if err != nil {
glog.Warningf("Unable to parse to time.Date: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

isNewerVersion should probably return the error rather than silently dropping it, so that the caller can determine what the right course of action is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!
I changed that isNewerVersion returns error if err != nil.

pkg/minikube/registry/drvs/hyperkit/hyperkit.go Outdated Show resolved Hide resolved
@@ -58,6 +61,11 @@ func GetISOPath() string {
return isoPath
}

// GetHyperKitVersion returns the specific hyperKit version
func GetHyperKitVersion() string {
return hyperKitVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the expected version into drvs/hyperkit - as it's only consumed there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this constant and getter method.
Makefile(& pkg/version/version.go) → pkg/minikube/registry/drvs/hyperkit.go

@govargo
Copy link
Contributor Author

govargo commented Nov 6, 2019

Thank you for review @tstromberg @medyagh!

I'll retake these.
And when that is done, I will return comments.

@govargo govargo changed the title Fix FastFail if driver error occured & Add hyperkit version check Add hyperkit version check whether user's hyperkit is newer Nov 11, 2019
@govargo
Copy link
Contributor Author

govargo commented Nov 11, 2019

@tstromberg @medyagh

I'm sorry for late.
I updated my code as you reviewed.

And FastFail(if vm-driver does not installed) will be implemented by #5840, so I removed FastFail from this PR.
I just only left hyperkit version check.

I also updated this PR title & description.

Thank you.

@govargo
Copy link
Contributor Author

govargo commented Nov 12, 2019

Updated code to resolve conflict(latest codebase edited the same file)

Copy link
Contributor

@tstromberg tstromberg left a comment

Choose a reason for hiding this comment

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

Some minor feedback from testing this PR locally. This will definitely save some users from grief.

}

// GetHyperKitVersion returns the specific hyperKit version
func GetHyperKitVersion() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can safely remove this public function. This variable is only apparently used by this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right.
I modified this to private function.

@@ -37,6 +39,11 @@ const (
docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/"
)

var (
// hyperkitSpecificVersion is used by hyperkit versionCheck(whether user's hyperkit is older than this)
hyperkitSpecificVersion = "0.20190201"
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hyperkit.hyperkitSpecificVersion - can this be renamed to minimumVersion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks nice naming!
I renamed.

return registry.State{Installed: true, Error: fmt.Errorf("hyperkit version check failed:\n%s", err), Doc: docURL}
}
if !isNew {
return registry.State{Installed: true, Error: fmt.Errorf("the mininum recommended hyperkit version is %s. your hyperkit version is 0.%s. please consider upgrading your hyperkit", GetHyperKitVersion(), currentVersion), Fix: "Run 'brew upgrade hyperkit'", Doc: docURL}
Copy link
Contributor

Choose a reason for hiding this comment

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

set Healthy: true, as we don't really know yet if the hyperkit driver is healthy or not even if the version is old.

This way the hyperkit driver can still be automatically selected, but the error displayed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way the hyperkit driver can still be automatically selected, but the error displayed.

Thanks. I added Healthy property.

@tstromberg
Copy link
Contributor

tstromberg commented Nov 13, 2019

The current text reads:

⚠️  'hyperkit' driver reported an issue: the mininum recommended hyperkit version is
0.20191201. your hyperkit version is 0.20190802. please consider upgrading you
hyperkit
💡  Suggestion: Run 'brew upgrade hyperkit'

Could the first sentence be rephrased to be shorter? Perhaps:

⚠️  'hyperkit' driver reported an issue: the installed hyperkit version (0.20191201) is
older than the minimum recommended version (0.20191201)
💡  Suggestion: Run 'brew upgrade hyperkit'

@govargo
Copy link
Contributor Author

govargo commented Nov 14, 2019

@tstromberg
Thank you for your good feedback!!

I modified as you reviewed.
And I changed warning message as you proposed.

// If current hyperkit is not newer than minimumVersion, suggest upgrade information
isNew, err := isNewerVersion(currentVersion, specificVersion)
if err != nil {
return registry.State{Installed: true, Healthy: true, Error: fmt.Errorf("hyperkit version check failed:\n%s", err), Doc: docURL}
Copy link
Contributor

Choose a reason for hiding this comment

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

use %v for err, rather than %s. Don't ask me why, it's just a Go common practice. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I'll remember this manner.

@govargo
Copy link
Contributor Author

govargo commented Nov 14, 2019

I updated PR description.

layout := "20060102"
currentVersionDate, err := time.Parse(layout, currentVersion)
if err != nil {
glog.Warningf("Unable to parse to time.Date: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

In general we either: return errors, or log them. We almost never do both, as it often causes duplicate errors to be logged.

In order to get the same basic effect here, use:

return false, errors.Wrap(err, "parse date")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general we either: return errors, or log them. We almost never do both, as it often causes duplicate errors to be logged.

Thanks.
I'll remember this!

return version
}

// getHyperKitVersion returns the minimum hyperKit version
Copy link
Contributor

Choose a reason for hiding this comment

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

Get is implied for Go function names. This would normally just be called hyperkit.hyperKitVersion. I would rather just see this method removed, since it does not add anything over referring to minimumVersion directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, you are right.
I removed this getter func.

Copy link
Contributor

@tstromberg tstromberg left a comment

Choose a reason for hiding this comment

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

Looks great, just minor idiomatic readability improvements to suggest.

@govargo
Copy link
Contributor Author

govargo commented Nov 14, 2019

Thank you for your quick feedback.
I will work on immediately

@govargo
Copy link
Contributor Author

govargo commented Nov 14, 2019

@tstromberg
I updated.

Thanks for your suggestion.
I'll remember those.

@tstromberg
Copy link
Contributor

Some test failures:

# k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit [k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit.test]
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:55:15: undefined: splitHyperKitVersion
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:85:15: undefined: convertVersionToDate
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:119:18: undefined: isNewerVersion

@tstromberg
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 14, 2019
@minikube-bot
Copy link
Collaborator

All Times minikube: [ 123.385700 121.444881 122.374470]
All Times Minikube (PR 5833): [ 119.401989 122.342768 123.808334]

Average minikube: 122.401684
Average Minikube (PR 5833): 121.851030

Averages Time Per Log

+----------------------+-----------+--------------------+
|         LOG          | MINIKUBE  | MINIKUBE (PR 5833) |
+----------------------+-----------+--------------------+
| minikube v           |  0.317921 |           0.310180 |
| Creating kvm2        | 38.406732 |          38.240960 |
| Preparing Kubernetes | 53.295196 |          52.552395 |
| Pulling images       |  2.903170 |           2.668731 |
| Launching Kubernetes | 19.884803 |          19.479054 |
| Waiting for cluster  |  7.547330 |           8.556659 |
+----------------------+-----------+--------------------+

@govargo
Copy link
Contributor Author

govargo commented Nov 15, 2019

Some test failures:

# k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit [k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit.test]
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:55:15: undefined: splitHyperKitVersion
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:85:15: undefined: convertVersionToDate
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:119:18: undefined: isNewerVersion

Is this test executed by master branch?
If so, the test will fail because these method don't exist yet.

https://travis-ci.org/kubernetes/minikube/jobs/611933306?utm_medium=notification&utm_source=github_status

@govargo
Copy link
Contributor Author

govargo commented Dec 17, 2019

I close this PR because the minikube v1.6 do this, unless they specify --vm-driver=hyperkit.

@govargo govargo closed this Dec 17, 2019
@tstromberg tstromberg reopened this Dec 17, 2019
@tstromberg
Copy link
Contributor

Re-opening because this PR is still quite valuable to us, for version checking.

@tstromberg
Copy link
Contributor

Travis still failing, but the tests run correctly when diff'd against master. Do you mind merging your PR against master (git merge master) to see if it fixes the test?

# k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit [k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit.test]
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:55:15: undefined: splitHyperKitVersion
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:85:15: undefined: convertVersionToDate
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:119:18: undefined: isNewerVersion

@govargo
Copy link
Contributor Author

govargo commented Dec 18, 2019

@tstromberg
Thanks for reopening this PR.

Travis still failing, but the tests run correctly when diff'd against master. Do you mind merging your PR against master (git merge master) to see if it fixes the test?

OK, I'll rebase against latest master branch.

@govargo
Copy link
Contributor Author

govargo commented Dec 18, 2019

I updated

@govargo
Copy link
Contributor Author

govargo commented Dec 18, 2019

/retest

@govargo
Copy link
Contributor Author

govargo commented Dec 18, 2019

The test result doesn't change...

# k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit [k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit.test]
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:55:15: undefined: splitHyperKitVersion
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:85:15: undefined: convertVersionToDate
pkg/minikube/registry/drvs/hyperkit/hyperkit_test.go:119:18: undefined: isNewerVersion
ok  	k8s.io/minikube/pkg/minikube/registry	0.026s	coverage: 95.1% of statements
FAIL	k8s.io/minikube/pkg/minikube/registry/drvs/hyperkit [build failed]

I doubt this test fails due to git or go mod, but I have no conviction. I have no idea...

If someone noticed this cause, would you tell me please.

@tstromberg
Copy link
Contributor

I don't get what is going on here. I'm just going to try to merge this and see if master works.

@tstromberg tstromberg merged commit 28c4c82 into kubernetes:master Dec 19, 2019
@tstromberg
Copy link
Contributor

PR seems to work just fine at master. ¯_(ツ)_/¯

@govargo
Copy link
Contributor Author

govargo commented Dec 20, 2019

Thank you very much!!! @tstromberg

@govargo govargo deleted the fix-without-hyperkit-errormsg branch January 23, 2020 06:25
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. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FailFast if hyperkit is not installed.
5 participants