-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9365 from ilya-zuyev/gh_7422-reuse_hyperkit_driver
hyperkit driver should be happy with current minimum verison
- Loading branch information
Showing
8 changed files
with
239 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/integration/testdata/hyperkit-driver-version-1.11.0/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Binary file added
BIN
+12.9 MB
test/integration/testdata/hyperkit-driver-version-1.11.0/docker-machine-driver-hyperkit
Binary file not shown.