Skip to content

hyperkit driver should be happy with current minimum verison #9365

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

Merged
merged 27 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2423f81
Introduce minHyperkitVersion constant to keep the minimum compatible …
ilya-zuyev Sep 30, 2020
d124f29
Update comments
ilya-zuyev Sep 30, 2020
8ba7478
Add copyrights
ilya-zuyev Sep 30, 2020
334779c
Change required min hyperkit version to 1.11.0
ilya-zuyev Sep 30, 2020
11b8534
Fix unit tests error messages
ilya-zuyev Sep 30, 2020
c82e327
Do not panic if min version constant is invalid
ilya-zuyev Oct 1, 2020
6ca9402
Extract a function to download driver file, but don't change ownershi…
ilya-zuyev Oct 6, 2020
2641e3d
Add hyperkit driver v1.11.0 to testdata
ilya-zuyev Oct 6, 2020
7322fdd
Add an integration test for hyperkit driver upgrades
ilya-zuyev Oct 6, 2020
08da827
Rename minDriverVersion => minAcceptableDriverVersion. Add comments
ilya-zuyev Oct 9, 2020
9b70ec8
Update integration test:
ilya-zuyev Oct 13, 2020
786037e
Fix error message in int test
ilya-zuyev Oct 13, 2020
1381394
Fix comments
ilya-zuyev Oct 13, 2020
0a9cbbb
Use "--interactive=false" to avoid asking for sudo password
ilya-zuyev Oct 14, 2020
bfca3a6
Reorganize code - move tests related to hyperkit to driver_install_or…
ilya-zuyev Oct 15, 2020
489b59b
Integration tests: fix the default test driver perms
ilya-zuyev Oct 15, 2020
eef3fd8
Integration tests: add comments to internal functions
ilya-zuyev Oct 15, 2020
4eb6f9a
Integration tests: fix naming
ilya-zuyev Oct 15, 2020
3941018
Integration tests: update README in testsdata
ilya-zuyev Oct 15, 2020
2b32f6f
Integration tests: add copyright header
ilya-zuyev Oct 15, 2020
63ca225
Integration tests: fix driver permission
ilya-zuyev Oct 15, 2020
4c5ac5a
Integration tests: remove driver_install_or_update_darwin_test.go
ilya-zuyev Oct 15, 2020
a072e89
Merge branch 'master' into gh_7422-reuse_hyperkit_driver
ilya-zuyev Oct 15, 2020
8db8f55
replace glog -> klog
ilya-zuyev Oct 15, 2020
57a0e40
Reuse $MINIKUBE_HOME/cache files;
ilya-zuyev Oct 15, 2020
5fc73c7
Add a comment
ilya-zuyev Oct 15, 2020
6c65c5d
Log driver version when validating driver
ilya-zuyev Oct 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/minikube/driver/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func InstallOrUpdate(name string, directory string, v semver.Version, interactiv
defer releaser.Release()

exists := driverExists(executable)
path, err := validateDriver(executable, v)
path, err := validateDriver(executable, minDriverVersion(name, v))
if !exists || (err != nil && autoUpdate) {
glog.Warningf("%s: %v", executable, err)
path = filepath.Join(directory, executable)
Expand Down Expand Up @@ -133,6 +133,7 @@ func validateDriver(executable string, v semver.Version) (string, error) {
if err != nil {
return path, errors.Wrap(err, "can't parse driver version")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we allow version mismatches, could you please add a log sttatement declaring what driver version we are using? This will help for future debugging;

klog.Infof("%s version is %s", path, driverVersion)

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Done.

if driverVersion.LT(v) {
return path, fmt.Errorf("%s is version %s, want %s", executable, driverVersion, v)
}
Expand Down
31 changes: 31 additions & 0 deletions pkg/minikube/driver/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package driver

import (
"github.com/blang/semver"
"github.com/golang/glog"
)

// minHyperkitVersion is the minimum version of the minikube hyperkit driver compatible with the current minikube code
var minHyperkitVersion semver.Version

const minHyperkitVersionStr = "1.10.0"

func init() {
v, err := semver.New(minHyperkitVersionStr)
if err != nil {
glog.Fatalf("Failed to parse the hyperkit driver version: %v", err)
}
minHyperkitVersion = *v
}

func minDriverVersion(driver string, mkVer semver.Version) semver.Version {
Copy link
Member

Choose a reason for hiding this comment

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

add comment here, consider more descriptive name. maybe

minAcceptableVersion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

switch driver {
case HyperKit:
return minHyperkitVersion
case KVM2:
return mkVer
default:
glog.Warningf("Unexpected driver: %v", driver)
return mkVer
}
}
36 changes: 36 additions & 0 deletions pkg/minikube/driver/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package driver

import (
"testing"

"github.com/blang/semver"
)

func Test_minDriverVersion(t *testing.T) {

tests := []struct {
desc string
driver string
mkV string
want semver.Version
}{
{"Hyperkit", HyperKit, "1.1.1", minHyperkitVersion},
{"Invalid", "_invalid_", "1.1.1", v("1.1.1")},
{"KVM2", KVM2, "1.1.1", v("1.1.1")},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
if got := minDriverVersion(tt.driver, v(tt.mkV)); !got.EQ(tt.want) {
t.Errorf("minDriverVersion() = %v, want %v", got, tt.want)
}
})
}
}

func v(s string) semver.Version {
r, err := semver.New(s)
if err != nil {
panic(err)
}
return *r
}