-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add hyperkit version check whether user's hyperkit is newer #5833
Conversation
Can one of the admins verify this patch? |
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 Once the patch is verified, the new status will be reflected by the 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: govargo 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 |
/assign @tstromberg /cc @medyagh |
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 |
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.
I am not sure if this is the best place to store the mininum required hyperkit version
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.
I think a better place for this is in the package itself as a constant
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.
I moved this constant.
Makefile(& pkg/version/version.go) → pkg/minikube/registry/drvs/hyperkit.go
currentVersionDate, err := time.Parse(layout, currentVersion) | ||
if err != nil { | ||
glog.Warningf("Unable to parse to time.Date: %v", err) | ||
} |
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.
isNewerVersion
should probably return the error rather than silently dropping it, so that the caller can determine what the right course of action is.
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.
Thanks!
I changed that isNewerVersion
returns error if err != nil
.
pkg/version/version.go
Outdated
@@ -58,6 +61,11 @@ func GetISOPath() string { | |||
return isoPath | |||
} | |||
|
|||
// GetHyperKitVersion returns the specific hyperKit version | |||
func GetHyperKitVersion() string { | |||
return hyperKitVersion |
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.
Move the expected version into drvs/hyperkit
- as it's only consumed there.
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.
I moved this constant and getter method.
Makefile(& pkg/version/version.go) → pkg/minikube/registry/drvs/hyperkit.go
Thank you for review @tstromberg @medyagh! I'll retake these. |
I'm sorry for late. And FastFail(if vm-driver does not installed) will be implemented by #5840, so I removed FastFail from this PR. I also updated this PR title & description. Thank you. |
Updated code to resolve conflict(latest codebase edited the same file) |
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.
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 { |
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.
I think you can safely remove this public function. This variable is only apparently used by this file.
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.
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" |
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.
Instead of hyperkit.hyperkitSpecificVersion
- can this be renamed to minimumVersion
?
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.
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} |
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.
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.
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.
This way the hyperkit driver can still be automatically selected, but the error displayed.
Thanks. I added Healthy property.
The current text reads:
Could the first sentence be rephrased to be shorter? Perhaps:
|
@tstromberg I modified as you reviewed. |
// 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} |
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.
use %v for err, rather than %s. Don't ask me why, it's just a Go common practice. :)
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.
Thanks. I'll remember this manner.
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) |
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.
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")
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.
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 |
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.
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.
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.
Sorry, you are right.
I removed this getter func.
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.
Looks great, just minor idiomatic readability improvements to suggest.
Thank you for your quick feedback. |
@tstromberg Thanks for your suggestion. |
Some test failures:
|
/ok-to-test |
All Times minikube: [ 123.385700 121.444881 122.374470] Average minikube: 122.401684 Averages Time Per Log
|
Is this test executed by master branch? |
I close this PR because the minikube v1.6 do this, unless they specify --vm-driver=hyperkit. |
Re-opening because this PR is still quite valuable to us, for version checking. |
Travis still failing, but the tests run correctly when diff'd against master. Do you mind merging your PR against master (
|
@tstromberg
OK, I'll rebase against latest master branch. |
I updated |
/retest |
The test result doesn't change...
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. |
I don't get what is going on here. I'm just going to try to merge this and see if master works. |
PR seems to work just fine at master. ¯_(ツ)_/¯ |
Thank you very much!!! @tstromberg |
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 whenminikube 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 tominikube 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) **
After this PR, minikube fail fast
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.