-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Changes from 26 commits
2423f81
d124f29
8ba7478
334779c
11b8534
c82e327
6ca9402
2641e3d
7322fdd
08da827
9b70ec8
786037e
1381394
0a9cbbb
bfca3a6
489b59b
eef3fd8
4eb6f9a
3941018
2b32f6f
63ca225
4c5ac5a
a072e89
8db8f55
57a0e40
5fc73c7
6c65c5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,13 +55,12 @@ 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, minAcceptableDriverVersion(name, v)) | ||
if !exists || (err != nil && autoUpdate) { | ||
klog.Warningf("%s: %v", executable, err) | ||
path = filepath.Join(directory, executable) | ||
derr := download.Driver(executable, path, v) | ||
if derr != nil { | ||
return derr | ||
if err := download.Driver(executable, path, v); err != nil { | ||
return err | ||
} | ||
} | ||
return fixDriverPermissions(name, path, interactive) | ||
|
@@ -133,6 +132,7 @@ func validateDriver(executable string, v semver.Version) (string, error) { | |
if err != nil { | ||
return path, errors.Wrap(err, "can't parse driver version") | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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;
Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package driver | ||
|
||
import ( | ||
"github.com/blang/semver" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
// minHyperkitVersion is the minimum version of the minikube hyperkit driver compatible with the current minikube code | ||
var minHyperkitVersion *semver.Version | ||
|
||
const minHyperkitVersionStr = "1.11.0" | ||
|
||
func init() { | ||
v, err := semver.New(minHyperkitVersionStr) | ||
if err != nil { | ||
klog.Errorf("Failed to parse the hyperkit driver version: %v", err) | ||
} else { | ||
minHyperkitVersion = v | ||
} | ||
} | ||
|
||
// minAcceptableDriverVersion is the minimum version of driver supported by current version of minikube | ||
func minAcceptableDriverVersion(driver string, mkVer semver.Version) semver.Version { | ||
switch driver { | ||
case HyperKit: | ||
if minHyperkitVersion != nil { | ||
return *minHyperkitVersion | ||
} | ||
return mkVer | ||
case KVM2: | ||
return mkVer | ||
default: | ||
klog.Warningf("Unexpected driver: %v", driver) | ||
return mkVer | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
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 := minAcceptableDriverVersion(tt.driver, v(tt.mkV)); !got.EQ(tt.want) { | ||
t.Errorf("Invalid min supported version, got: %v, want: %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func v(s string) semver.Version { | ||
r, err := semver.New(s) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return *r | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Starting minikube version 1.14 we do not update the installed hyperkit driver if its version is 1.11.0 or higher. | ||
Have the hyperkit driver v1.11.0 here to test this behaviour. |
Uh oh!
There was an error while loading. Please reload this page.