Browse code

Skip KernelMemoryTCP if version is less than 1.40

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2018/10/28 02:44:52
Showing 2 changed files
... ...
@@ -475,6 +475,12 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
475 475
 		}
476 476
 	}
477 477
 
478
+	// When using API 1.39 and under, KernelMemoryTCP should be ignored because it
479
+	// was added in API 1.40.
480
+	if hostConfig != nil && versions.LessThan(version, "1.40") {
481
+		hostConfig.KernelMemoryTCP = 0
482
+	}
483
+
478 484
 	ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
479 485
 		Name:             name,
480 486
 		Config:           config,
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"time"
9 9
 
10 10
 	containertypes "github.com/docker/docker/api/types/container"
11
+	"github.com/docker/docker/api/types/versions"
11 12
 	"github.com/docker/docker/integration/internal/container"
12 13
 	"github.com/docker/docker/internal/test/request"
13 14
 	"gotest.tools/assert"
... ...
@@ -18,6 +19,7 @@ import (
18 18
 
19 19
 func TestKernelTCPMemory(t *testing.T) {
20 20
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
21
+	skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "skip test from new feature")
21 22
 	skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP)
22 23
 
23 24
 	defer setupTest(t)()