Browse Source

Merge pull request #29546 from cpuguy83/29505_fix_overay2_check_plugin

Ensure test graphdriver plugin runs on test host
Tõnis Tiigi 8 years ago
parent
commit
288e55c09b

+ 2 - 2
integration-cli/docker_cli_daemon_plugins_test.go

@@ -236,7 +236,7 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
 }
 }
 
 
 func (s *DockerDaemonSuite) TestGraphdriverPlugin(c *check.C) {
 func (s *DockerDaemonSuite) TestGraphdriverPlugin(c *check.C) {
-	testRequires(c, Network, IsAmd64, DaemonIsLinux, overlaySupported)
+	testRequires(c, Network, IsAmd64, DaemonIsLinux, overlay2Supported)
 
 
 	s.d.Start(c)
 	s.d.Start(c)
 
 
@@ -246,7 +246,7 @@ func (s *DockerDaemonSuite) TestGraphdriverPlugin(c *check.C) {
 	c.Assert(err, checker.IsNil, check.Commentf(out))
 	c.Assert(err, checker.IsNil, check.Commentf(out))
 
 
 	// restart the daemon with the plugin set as the storage driver
 	// restart the daemon with the plugin set as the storage driver
-	s.d.Restart(c, "-s", plugin)
+	s.d.Restart(c, "-s", plugin, "--storage-opt", "overlay2.override_kernel_check=1")
 
 
 	// run a container
 	// run a container
 	out, err = s.d.Cmd("run", "--rm", "busybox", "true") // this will pull busybox using the plugin
 	out, err = s.d.Cmd("run", "--rm", "busybox", "true") // this will pull busybox using the plugin

+ 4 - 0
integration-cli/docker_test_vars.go

@@ -66,6 +66,8 @@ var (
 
 
 	// daemonPid is the pid of the main test daemon
 	// daemonPid is the pid of the main test daemon
 	daemonPid int
 	daemonPid int
+
+	daemonKernelVersion string
 )
 )
 
 
 func init() {
 func init() {
@@ -111,6 +113,7 @@ func init() {
 	type Info struct {
 	type Info struct {
 		DockerRootDir     string
 		DockerRootDir     string
 		ExperimentalBuild bool
 		ExperimentalBuild bool
+		KernelVersion     string
 	}
 	}
 	var i Info
 	var i Info
 	status, b, err := sockRequest("GET", "/info", nil)
 	status, b, err := sockRequest("GET", "/info", nil)
@@ -118,6 +121,7 @@ func init() {
 		if err = json.Unmarshal(b, &i); err == nil {
 		if err = json.Unmarshal(b, &i); err == nil {
 			dockerBasePath = i.DockerRootDir
 			dockerBasePath = i.DockerRootDir
 			experimentalDaemon = i.ExperimentalBuild
 			experimentalDaemon = i.ExperimentalBuild
+			daemonKernelVersion = i.KernelVersion
 		}
 		}
 	}
 	}
 	volumesConfigPath = dockerBasePath + "/volumes"
 	volumesConfigPath = dockerBasePath + "/volumes"

+ 19 - 2
integration-cli/requirements_unix.go

@@ -8,6 +8,7 @@ import (
 	"os/exec"
 	"os/exec"
 	"strings"
 	"strings"
 
 
+	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/sysinfo"
 )
 )
 
 
@@ -124,7 +125,7 @@ var (
 		},
 		},
 		"Test cannot be run without a kernel (4.3+) supporting ambient capabilities",
 		"Test cannot be run without a kernel (4.3+) supporting ambient capabilities",
 	}
 	}
-	overlaySupported = testRequirement{
+	overlayFSSupported = testRequirement{
 		func() bool {
 		func() bool {
 			cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems")
 			cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems")
 			out, err := cmd.CombinedOutput()
 			out, err := cmd.CombinedOutput()
@@ -133,7 +134,23 @@ var (
 			}
 			}
 			return bytes.Contains(out, []byte("overlay\n"))
 			return bytes.Contains(out, []byte("overlay\n"))
 		},
 		},
-		"Test cannot be run wihtout suppport for ovelayfs",
+		"Test cannot be run without suppport for overlayfs",
+	}
+	overlay2Supported = testRequirement{
+		func() bool {
+			if !overlayFSSupported.Condition() {
+				return false
+			}
+
+			daemonV, err := kernel.ParseRelease(daemonKernelVersion)
+			if err != nil {
+				return false
+			}
+			requiredV := kernel.VersionInfo{Kernel: 4}
+			return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
+
+		},
+		"Test cannot be run without overlay2 support (kernel 4.0+)",
 	}
 	}
 )
 )