docker driver: relax version constraint
When Docker (Moby) was installed from the source code, the version string is typically set to "dev", or "library-import". Previously, minikube could not start with these versions. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>pull/11309/head
parent
95e81551c9
commit
2cae14829d
|
@ -166,6 +166,9 @@ func checkDockerVersion(o string) registry.State {
|
|||
}
|
||||
}
|
||||
|
||||
hintInstallOfficial := fmt.Sprintf("Install the official release of %s (Minimum recommended version is %2d.%02d.%d, current version is %s)",
|
||||
driver.FullName(driver.Docker), minDockerVersion[0], minDockerVersion[1], minDockerVersion[2], parts[1])
|
||||
|
||||
p := strings.SplitN(parts[1], ".", 3)
|
||||
switch l := len(p); l {
|
||||
case 2:
|
||||
|
@ -174,12 +177,13 @@ func checkDockerVersion(o string) registry.State {
|
|||
// remove postfix string for unstable(test/nightly) channel. https://docs.docker.com/engine/install/
|
||||
p[2] = strings.SplitN(p[2], "-", 2)[0]
|
||||
default:
|
||||
// When Docker (Moby) was installed from the source code, the version string is typically set to "dev", or "library-import".
|
||||
return registry.State{
|
||||
Reason: "PROVIDER_DOCKER_VERSION_PARSING_FAILED",
|
||||
Error: errors.Errorf("expected version format is \"<year>.<month>.{patch}\". but got %s", parts[1]),
|
||||
Installed: true,
|
||||
Healthy: false,
|
||||
Doc: docURL,
|
||||
Installed: true,
|
||||
Healthy: true,
|
||||
NeedsImprovement: true,
|
||||
Fix: hintInstallOfficial,
|
||||
Doc: docURL,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,11 +191,11 @@ func checkDockerVersion(o string) registry.State {
|
|||
k, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return registry.State{
|
||||
Reason: "PROVIDER_DOCKER_VERSION_PARSING_FAILED",
|
||||
Error: errors.Wrap(err, "docker version"),
|
||||
Installed: true,
|
||||
Healthy: false,
|
||||
Doc: docURL,
|
||||
Installed: true,
|
||||
Healthy: true,
|
||||
NeedsImprovement: true,
|
||||
Fix: hintInstallOfficial,
|
||||
Doc: docURL,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,13 @@ package docker
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testCase struct {
|
||||
version, expect string
|
||||
version, expect string
|
||||
expectFixContains string
|
||||
}
|
||||
|
||||
func appendVersionVariations(tc []testCase, v []int, reason string) []testCase {
|
||||
|
@ -81,6 +83,30 @@ func TestCheckDockerVersion(t *testing.T) {
|
|||
tc = appendVersionVariations(tc, v, "PROVIDER_DOCKER_VERSION_LOW")
|
||||
}
|
||||
|
||||
tc = append(tc, []testCase{
|
||||
{
|
||||
// "dev" is set when Docker (Moby) was installed with `make binary && make install`
|
||||
version: "linux-dev",
|
||||
expect: "",
|
||||
expectFixContains: fmt.Sprintf("Install the official release of Docker (Minimum recommended version is %02d.%02d.%d, current version is dev)",
|
||||
minDockerVersion[0], minDockerVersion[1], minDockerVersion[2]),
|
||||
},
|
||||
{
|
||||
// "library-import" is set when Docker (Moby) was installed with `go build github.com/docker/docker/cmd/dockerd` (unrecommended, but valid)
|
||||
version: "linux-library-import",
|
||||
expect: "",
|
||||
expectFixContains: fmt.Sprintf("Install the official release of Docker (Minimum recommended version is %02d.%02d.%d, current version is library-import)",
|
||||
minDockerVersion[0], minDockerVersion[1], minDockerVersion[2]),
|
||||
},
|
||||
{
|
||||
// "foo.bar.baz" is a triplet that cannot be parsed as "%02d.%02d.%d"
|
||||
version: "linux-foo.bar.baz",
|
||||
expect: "",
|
||||
expectFixContains: fmt.Sprintf("Install the official release of Docker (Minimum recommended version is %02d.%02d.%d, current version is foo.bar.baz)",
|
||||
minDockerVersion[0], minDockerVersion[1], minDockerVersion[2]),
|
||||
},
|
||||
}...)
|
||||
|
||||
for _, c := range tc {
|
||||
t.Run("checkDockerVersion test", func(t *testing.T) {
|
||||
s := checkDockerVersion(c.version)
|
||||
|
@ -89,6 +115,11 @@ func TestCheckDockerVersion(t *testing.T) {
|
|||
t.Errorf("Error %v expected. but got %q. (version string : %s)", c.expect, s.Reason, c.version)
|
||||
}
|
||||
}
|
||||
if c.expectFixContains != "" {
|
||||
if !strings.Contains(s.Fix, c.expectFixContains) {
|
||||
t.Errorf("Error expected Fix to contain %q, but got %q", c.expectFixContains, s.Fix)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue